0

I need a proper way to implement Splash Screen in android. As i referred some examples but they are deprecated

new Handler().postDelayed(new Runnable() {
  @Override
     public void run() {
       Intent i = new Intent(MainSplashScreen.this, FirstScreen.class);
       startActivity(i);
       finish();
     }

}, 5*1000);
Android
  • 1,420
  • 4
  • 13
  • 23

1 Answers1

1

This is a bad practice IMHO. You should run your app as fast as possible. Users don't want to wait.

Instead of wait just create an activity and assign a windowBackground to it through style file.

<style name="AppTheme.Launcher">
    <item name="android:windowBackground">@drawable/splash_background</item>
</style>

splash_background.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@color/green" />

    <item android:gravity="center">
        <bitmap android:src="@drawable/brand" android:gravity="center" />
    </item>
</layer-list>
appersiano
  • 2,670
  • 22
  • 42