在不创建 Thread 和 运行() 的情况下应用 SplashScreen

Apply SplashScreen without making Thread and run()

这是我的代码..我想制作没有线程计时器的启动画面.. 我该怎么做?

public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Thread timer = new Thread() {
        public void run() {
            try {
                sleep(2000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } finally {
                // myCode();

                }
            }
        }
    };
    timer.start();
} }

您可以使用以下代码,我认为这对您有好处。

   public class SplashActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
     new Handler().postDelayed(new Runnable(){
        @Override
        public void run() {
            Intent mainIntent = new 
            Intent(SplashActivity.this,AnotherActivity.class);
            startActivity(mainIntent);
            finish();
        }
    },3000);
   }
 }