Android application sets aside some opportunity to fire up, particularly the first run through the application is keep running on a gadget (here and there this is alluded to as a chilly begin). The sprinkle screen may show start up advance to the client, or it might show marking data to distinguish and advance the application.
And few steps to know what in splash screen,
1) we have to create one image file (i.e jpg file) resources --> drawable--> splash.jpg(upload or paste).
2) We should create one java class and xml files in the project as shown in code.
3) And Android mainfest.xml we should write the as shown below example,
And few steps to know what in splash screen,
1) we have to create one image file (i.e jpg file) resources --> drawable--> splash.jpg(upload or paste).
2) We should create one java class and xml files in the project as shown in code.
3) And Android mainfest.xml we should write the as shown below example,
<activity
android:name=".SplashScreen"
android:label="@string/app_name" > <intent-filter>
<action
android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity
android:name=".MainActivity"
android:label="@string/app_name" > <intent-filter> <action android:name="com.coderefer.androidsplashscreenexample.MAINACTIVITY" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity>
code for android splash screen as shown below.
activity_main.xml :-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"> </LinearLayout>
splash.xml :-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/splash"> </LinearLayout>
MainActivity.java :-
package com.kiranapp; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { @Override
public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.activity_main); } }
SpalshScreen.java :-
package com.kiranapp; /** * Created by Dell on 11/16/2016. */
import android.app.Activity; import android.content.Intent; import android.os.Bundle; public class SplashScreen extends Activity { @Override
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.splash); Thread timerThread = new Thread(){ public void run(){ try{ sleep(3000); }
catch(InterruptedException e){
e.printStackTrace();
}
finally{ Intent intent = new Intent(SplashScreen.this,MainActivity.class); startActivity(intent); } } }; timerThread.start(); } @Override
protected void onPause() { super.onPause(); finish(); } }
AndroidMainfest.xml :-
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kiranapp"> <application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" > <activity
android:name=".SplashScreen"
android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity
android:name=".MainActivity"
android:label="@string/app_name" > <intent-filter> <action
android:name="com.coderefer.androidsplashscreenexample.MAINACTIVITY" /> <category
android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> </application> </manifest>
Output :-
SplashScreen figure |
No comments:
Post a Comment