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?
Asked
Active
Viewed 3,024 times
1

Roger RV
- 132
- 3
- 15
-
1May be this can help , not sure though . Try : `onResume() { // Start SplashActivty here }` add this in HomeActivity . – Vikrant Apr 22 '17 at 09:30
-
@Vikrant The problem is that I only want to start the Splash when the activity HomeActivity pass for onDestroy. Is it clear to use a boolean to check if this happend? I need to do is to prevent GPU problems – Roger RV Apr 22 '17 at 09:31
3 Answers
2
If you want to remove old activity from activity stack, start new activity using these intent flags
Intent intent = new Intent(this, Activity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
It will clear activity stack and you new activity will be the only activity in the stack.

mallaudin
- 4,744
- 3
- 36
- 68
0
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))
}

devmike01
- 1,971
- 1
- 20
- 30