0

When my application loads a white screen is shown quickly. I changed some things so it is shorter now but I don't seem to be able to make it completely disappear.

I see almost all most apps have this sometimes (longer if phone has been turned off and so short it is not noticed if app has been started once alredy and then is started again). After the app has been run once it does not happen (is the app somehow still in memory maybe?).

So there is no way to get around that?

I do my initializing on a background thread so I am not blocking the UI.

I use one activity and many fragments.

I have tried not using a bitmap as background but instead just a color background but still it is slow so it is not the decoding.

@Override
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);

    setContentView( R.layout.loading_layout );

    final FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragment_content);

    if (fragment == null)
    {
        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.fragment_content, new LoadingFragment());
        ft.commit();
    }
}
jww
  • 97,681
  • 90
  • 411
  • 885
  • possible duplicate of [How to remove the white screen while my app loads?](http://stackoverflow.com/questions/18940392/how-to-remove-the-white-screen-while-my-app-loads) – Vitaliy A Sep 07 '14 at 15:26

2 Answers2

1

Make your launch screen Translucent.

<activity
        android:name="com.your.package"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"
        android:windowSoftInputMode="stateAlwaysHidden" />

Duplicate of question

P.S. Also make sure that all heavy operations and initialization on splash screen done on background thread (use AsyncTask).

Community
  • 1
  • 1
Vitaliy A
  • 3,651
  • 1
  • 32
  • 34
  • No title bar does not sound like what I want.And the app crashes on startup if I add it. Because I use the titlebar which is now null. –  Sep 07 '14 at 16:06
  • 1
    In that case, use ```android:theme="@android:style/Theme.Translucent"``` instead – Sean O'Toole Sep 07 '14 at 16:10
  • 1
    You allways can remove .NoTitleBar from theme declaration.Are you really need title bar on Splash? Explain what you need it for, and we will find solution together. – Vitaliy A Sep 07 '14 at 16:13
  • I guess I dont need the title bar on splash, how do I reattach it? I need it once the application is running. Using only Theme.Translucent makes the app crash with no error msg. –  Sep 07 '14 at 16:24
  • So use other theme with title bar for activity next to Splash. – Vitaliy A Sep 07 '14 at 16:45
  • well it is the same activity, just diffferent fragments. –  Sep 07 '14 at 16:57
0

That Sounds normal to me. Espeacially when there´s a lot of Content in your app, it takes a while until the app is ready to use. If that´s the case should try this :

If you don´t want the White Screen you should use a splash-screen.

Here is an example.

How do I make a splash screen?

Community
  • 1
  • 1
  • But I have a splash screen. But it launches after the white part. So before I had a longer "white time", now some of it is replaced byt he loading/splash screen but I still have 0.5 seconds of white screen. –  Sep 07 '14 at 15:05
  • Do it like Vitaly A told you, "make your launch screen Translucent." –  Sep 07 '14 at 15:28
  • Add this to your manifest: android:theme="@android:style/Theme.Translucent.NoTitleBar" –  Sep 07 '14 at 15:29