blank screen comes before splash

Really! the below link work for me!!!!

https://cyrilmottier.com/2013/01/23/android-app-launching-made-gorgeous/

write the separate style in style.xml for your splash screen so that you can co-relate both the screen.

Herein the style:

<style name="AppTheme.Splash" parent="AppTheme.NoActionBar">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowBackground">@drawable/splash_final</item>
    </style>

The problem you are facing here is called 'cold start' and it's the time mostly spent in your Application.onCreate method, which usually does some initialisations and it might take longer than you wish. You can read here the official documentation: https://developer.android.com/topic/performance/launch-time.html

If this is the case than setting the theme to translucent or disabling preview as others suggested will only apparently solve the issue, because in reality you will try to launch the app and you won't receive any feedback about the fact the you tapped the app icon. You will see your app starting with a delay, which is not a desired UX.

Blank, black or white screen, it really depends on the android:windowBackground attribute specified in your main activity theme. The best you can do, apart from moving some of the initialisations that you probably are doing in your Application.onCreate method, is to brand your preview window with a logo as suggested in this post:

https://plus.google.com/+AndroidDevelopers/posts/Z1Wwainpjhd

You can go further and improve the user experience by animating your logo image in a splash screen, if it's the case, or by designing the preview window in a way that can be smooth transitioned to your main activity content, like described here:

http://saulmm.github.io/avoding-android-cold-starts

Same question is answered correctly here: https://stackoverflow.com/a/40482549/7094200 and described in this blog post: https://www.bignerdranch.com/blog/splash-screens-the-right-way/


It's better to use a Themed background for your starting activity but if you don't want the blank screen appears before launching main activity you can define your activity like this:

Add android:windowDisablePreview to your AppTheme in res/values/styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <style name="AppTheme" parent="android:Theme">
        <item name="android:windowDisablePreview">true</item>
  </style>
</resources>

Then set your activity theme in your manifest:

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

P.S: Setting android:windowDisablePreview has no effect on your activity background, so you have nothing to worry.


Generally speaking, splash screens are not recommended for an app but if you really must.

Android will load a blank layout before it loads an activity layout based on the theme you have set for it. The solution is to set the theme of the splash activity to a transparent one.

Create a transparent theme in res/values/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
   <style name="Theme.Transparent" parent="android:Theme">
      <item name="android:windowIsTranslucent">true</item>
      <item name="android:windowBackground">@android:color/transparent</item>
      <item name="android:windowContentOverlay">@null</item>
      <item name="android:windowNoTitle">true</item>
      <item name="android:windowIsFloating">true</item>
     <item name="android:backgroundDimEnabled">false</item>
  </style>
</resources>

Then set the theme in your manifest

<activity android:name=".SplashActivity" android:theme="@style/Theme.Transparent">
...
</activity>