White screen before splashscreen

前端 未结 3 484
北恋
北恋 2021-01-14 03:42

I have an issue with my SplashScreenActivity, when I start my application on my phone it shows a white screen for about 0,5 seconds. The MainActitivy

相关标签:
3条回答
  • 2021-01-14 04:30
     Thread splashscreen = new Thread() {
    
            public void run() {
                try {
                    Thread.sleep(1000);
                    Intent mainScreen = new Intent("com.rm.jkrm.MAINACTIVITY");
                    startActivity(mainScreen);
                } catch (InterruptedException e) {
    
                } finally {
                    finish();
                }
            }
        };
        splashscreen.start();
    

    this is your problem UI thread to sleep not a very good idea use handler instead and I think it may cause an exception too.

    Handler h=new Handler();
            h.postDelayed(new Runnable() {
    
                public void run() {
                    // TODO Auto-generated method stub
                    startActivity(new Intent(Splash_Activity.this,Main_Activity.class));
                    finish();
                }
            }, 2000);
        }
    
    0 讨论(0)
  • 2021-01-14 04:33

    Change SplashActivity theme in the AndroidManifest.xml file to this.

    android:theme="@android:style/Theme.Translucent.NoTitleBar"
    
    0 讨论(0)
  • 2021-01-14 04:39

    You need to run this two actions in an AsyncTask:

    setContentView(R.layout.splashscreen);
    randomSplash();
    

    put the setContentView in the doInBackground-method and in the postExecute method you run randomSplash.

    0 讨论(0)
提交回复
热议问题