How to create a splash screen in android ?

In your first splash screen put the belwo code :

public class HomeActivity extends AppCompatActivity {

    private static int SPLASH_TIME_OUT=3000;
    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);

        new Handler().postDelayed(new Runnable() {
            @Override            public void run() {
                Intent homeIntent = new Intent(HomeActivity.this,MainActivity.class);
                startActivity(homeIntent);
                finish();
            }
        },SPLASH_TIME_OUT);
    }
}


In the manifest file you have to make the below update : 


<application    android:allowBackup="true"    android:icon="@mipmap/ic_launcher"    android:label="@string/app_name"    android:roundIcon="@mipmap/ic_launcher"    android:supportsRtl="true"    android:theme="@style/AppTheme">

    <activity android:name=".HomeActivity" android:theme="@style/AppTheme.NoActionBar">

        <intent-filter >
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

<activity    android:name=".MainActivity"    android:label="@string/app_name"    android:theme="@style/AppTheme.NoActionBar">
   
</activity>

No comments:

Post a Comment

How to set  interstitial  ads to be show for each n seconds ? ScheduledExecutorService schedul = Executors. newSingleThreadScheduledExec...