Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

White background when Android app start up

Every when my app starts up, there's a white background displays in a short time. Despite of using splash screen, the problem is still exists. I would like to set the start up screen to black instead of white as default!

This is my splash's screen activity:

public class SplashActivity extends Activity {

private static String TAG = SplashActivity.class.getName();
private static long SLEEP_TIME = 1;    // Sleep for some time

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);    // Removes title bar
    setContentView(R.layout.splash);

    // Start timer and launch main activity
    IntentLauncher launcher = new IntentLauncher();
    launcher.start();
}

private class IntentLauncher extends Thread {

    /**
      * Sleep for some time and than start new activity.
      */ 
    @Override
    public void run() {
        try {
            // Sleeping
            Thread.sleep(SLEEP_TIME*1000);
        } catch (Exception e) {
            Log.e(TAG, e.getMessage());
        }

        // Start main activity
        Intent intent = new Intent(SplashActivity.this, MainActivity.class);
        SplashActivity.this.startActivity(intent);
        SplashActivity.this.finish();
    }

}

@Override
protected void onPause() {
    super.onPause();
    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
}
}
like image 564
cxphong Avatar asked Nov 02 '13 04:11

cxphong


People also ask

How do I get rid of the white screen on my Android?

One of the reliable ways to fix the white screen of death on Android Phones or Tablets is to reboot your phone. First, press down the Power Button and Volume Down together, then tap on reboot. Once your phone reboot, it might result from a virus causing the Phone IOS not to load on time.


2 Answers

in styles.xml, in the theme specified in your AndroidManifest.xml, add the following line:

<item name="android:windowBackground">@android:color/black</item>
like image 146
djunod Avatar answered Sep 17 '22 13:09

djunod


Use this tag in your manifest:

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

instead of :

this.requestWindowFeature(Window.FEATURE_NO_TITLE);
like image 38
SweetWisher ツ Avatar answered Sep 20 '22 13:09

SweetWisher ツ