为什么 splash activity 崩溃了?

Why splash activity crashed?

我尝试在我的应用程序中实现启动。 Splash activity 运行 但在执行 ondestroy 方法后应用程序崩溃了。

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_splash);
           getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
           TimerTask splash = new TimerTask(){
                public void run() {
                    onDestroy();
                    startActivity(new Intent(getApplicationContext(), Collection_List_Activity.class));
                }
            };

            Timer splashScreenTimer = new Timer();
            // Timer set to 4.5 seconds
            splashScreenTimer.schedule(splash, 1000);

    }

您不应该手动呼叫 onDestroy。这是一个 activity 生命周期方法,生命周期方法不应该被手动调用。您应该改用 finish()