0% found this document useful (0 votes)
15 views7 pages

Android App Setup Guide with Splash Screen

android app code

Uploaded by

lkpbusiness518
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views7 pages

Android App Setup Guide with Splash Screen

android app code

Uploaded by

lkpbusiness518
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

<**************IMPORTANT STEPS****************>

1. Open (activity_main.xml) & ([Link]) & >manifest >


([Link])
2. Change App Icon : res>new>image asset key
3. Splash Screen : java > new > Activity > Empty Activity
Activity name: SplashActivity
4. Upload Splash Screen: drawable (open and right click & paste the image file
named 'logo') >

<------------- activity_main.xml (paste full code) --------------->

<?xml version="1.0" encoding="utf-8"?>


<[Link]
xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<[Link]
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">

<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
tools:ignore="MissingConstraints" />

</[Link]>
</[Link]>

*************************END CODE ABOVE********************************

<----------- [Link] (paste full code)--------------------->

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="[Link]
package="[Link].techno1online">

<uses-permission android:name="[Link]" />


<uses-permission android:name="[Link].ACCESS_NETWORK_STATE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Techno1Online">
<activity android:name=".MainActivity"></activity>
<activity
android:name=".SplashActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="[Link]" />

<category android:name="[Link]" />


</intent-filter>
</activity>
</application>

</manifest>

********************************END CODE ABOVE*******************************

<---------------- [Link] (Leave Package name)(Paste Full code)


--------------->

import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];

import [Link];
import [Link];

public class MainActivity extends AppCompatActivity {

String websiteURL = "[Link] // sets web url


private WebView webview;
SwipeRefreshLayout mySwipeRefreshLayout;

@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);

if( ! [Link](this)) //returns true if internet


available
{
//if there is no internet do this
setContentView([Link].activity_main);
//[Link](this,"No Internet Connection,
Chris",Toast.LENGTH_LONG).show();

new [Link](this) //alert the person knowing they are about


to close
.setTitle("No internet connection available")
.setMessage("Please Check you're Mobile data or Wifi network.")
.setPositiveButton("Ok", new [Link]()
{
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
//.setNegativeButton("No", null)
.show();

}
else
{
//Webview stuff
webview = findViewById([Link]);
[Link]().setJavaScriptEnabled(true);
[Link]().setDomStorageEnabled(true);
[Link](WebView.OVER_SCROLL_NEVER);
[Link](websiteURL);
[Link](new WebViewClientDemo());

//Swipe to refresh functionality


mySwipeRefreshLayout =
(SwipeRefreshLayout)[Link]([Link]);

[Link](
new [Link]() {
@Override
public void onRefresh() {
[Link]();
}
}
);
}

private class WebViewClientDemo extends WebViewClient {


@Override
//Keep webview in app when clicking links
public boolean shouldOverrideUrlLoading(WebView view, String url) {
[Link](url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
[Link](view, url);
[Link](false);
}
}

//set back button functionality


@Override
public void onBackPressed() { //if user presses the back button do this
if ([Link]() && [Link]()) { //check if in webview and
the user can go back
[Link](); //go back in webview
} else { //do this if the webview cannot go back any further
new [Link](this) //alert the person knowing they are about
to close
.setTitle("EXIT")
.setMessage("Are you sure. You want to close this app?")
.setPositiveButton("Yes", new [Link]()
{
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.setNegativeButton("No", null)
.show();
}
}

class CheckNetwork {

private static final String TAG = [Link]();

public static boolean isInternetAvailable(Context context)


{
NetworkInfo info = (NetworkInfo) ((ConnectivityManager)

[Link](Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo();

if (info == null)
{
Log.d(TAG,"no internet connection");
return false;
}
else
{
if([Link]())
{
Log.d(TAG," internet connection available...");
return true;
}
else
{
Log.d(TAG," internet connection");
return true;
}

}
}
}

**************************END CODE ABOVE*************************

<---------------- [Link] (leave package name)


--------------------->
import [Link];

import [Link];

import [Link];

import [Link];

import [Link];

public class SplashActivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

[Link](savedInstanceState);

Window window = getWindow() ;

[Link]([Link].FLAG_FULLSCREEN);

setContentView([Link].activity_splash);

Thread splashTread = new Thread(){

@Override

public void run() {

try {

sleep(3000);

startActivity(new
Intent(getApplicationContext(),[Link]));

finish();

} catch (InterruptedException e) {

[Link]();

[Link]();

}
};

[Link]();

**************************END CODE ABOVE*****************

<--------------------------- activity_splash.xml ----------------------->

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="[Link]

xmlns:app="[Link]

xmlns:tools="[Link]

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical"

tools:context=".SplashActivity">

<ImageView

android:layout_width="match_parent"

android:layout_height="300dp"

android:src="@drawable/logo"

android:scaleType="centerCrop"

android:padding="50dp"

android:layout_marginTop="220dp"/>

<ProgressBar

android:layout_width="220dp"

android:layout_height="10dp"
android:layout_gravity="center_horizontal"

style="?android:attr/progressBarStyleHorizontal"

android:max="100"

android:indeterminate="true"

android:progress="0"

android:layout_marginTop="100dp"

/>

</LinearLayout>

You might also like