Android - Disable dummy starting window of application

urSus picture urSus · Jun 4, 2013 · Viewed 13.5k times · Source

I want to know how to achieve this effect.

My app (default everything), when launcher icon is clicked, right away display some kind of a empty dummy window, where nothing is happening and then loads layout into it.

"Heavier" apps like YouTube, Drive, Dropbox etc. when started, seem to wait after launch, without showing that dummy window and load right into ready layout.

Any idea how to do this or where should I look into?

Thanks

//EDIT: this has nothing to do with something like loading database, where I should display progressBar, imho this has to do with stuff before activity exists.

Answer

JDCoder picture JDCoder · May 23, 2014

I suggest you don't disable the dummy loading window using:

<style name="Theme.MyTheme" parent="android:style/Theme" >
    ....
    <item name="android:windowDisablePreview">true</item>
    ....
</style>

because you could run into several problems. For example, if you try to animate an AlertDialog, enter animation will not work (personal experience).

The right solution is to set the theme of your application like to your main activity screen (same ActionBar style, same background color). In my application after severals experiments i found the right solution for my needs. (I have a main activity with blank background, no ActionBar, just full screen personal layout)

1 - styles.xml: add new style like this (remove ActionBar and set the same background color of my main activity)

<style name="LoadingTheme" parent="@android:style/Theme.Light.NoTitleBar.Fullscreen">
    <item name="android:windowBackground">@color/white_smoke</item>
</style>

2 - AndroidManifest.xml: set my theme for main activity to "LoadingTheme"

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
        <activity
            android:name="com.company.appname.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/LoadingTheme">
        <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
    </activity>
    ....
</application>

And finally i have full blank dummy loading window without ActionBar with soft MainActivity load and working animations.

Hope to be helpful.