androidondestroyandroid-ondestroy

Android start another Activity when onDestroy();


I need to destroy the activity HomeActivity onDestroy(); and then when enter to the app start the activity SplashActivity like a new Intent. Any idea to do it clear?


Solution

  • onDestroy() is only called when you call finish() on your activity or the system is temporary destroying the system. So since you're not calling finish() on your activity, the onDestroy() will not be invoked. The workaround for this is, launching the splashscreen activity in your onstop() method. Like this

    @Override
    public void onStop(){
        super.onStop();
        startActivity(new Intent(this, SplashScreen.class))
    
    }