White screen before splashscreen

前端 未结 3 486
北恋
北恋 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);
        }
    

提交回复
热议问题