I have a large number of activities in my app that I transition between using intents.I would like the app to start every time as if it had been cleared from the background. I can't find anywhere how to do this. Thanks.
Asked
Active
Viewed 377 times
0
-
What do you mean by "I would like the app to start every time as if it had been cleared from the background."? – Emmanuel May 26 '14 at 23:10
-
Do you mean that you want your app to start at the same main activity every time? – Code-Apprentice May 26 '14 at 23:11
-
I mean that the app always starts from the same activity and can't be put in the background and then re entered in the middle of the app. – user3478306 May 27 '14 at 00:04
2 Answers
0
i suppose you want to start the app with the actvivities stack cleared.
Intent intent_activity=new Intent(MainActivity.this, Activity2.class);
intent_activity.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent_activity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent_activity);
use flags to make you shure the stack is cleared and declare the states of the life cycle of the activities
@Override
protected void onCreate() {
super.onCreate();
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onDestroy() {
super.onDestroy();
}

UrielUVD
- 482
- 1
- 9
- 27
0
try this
Intent intent = new Intent(ProfileActivity.this,
LoginActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);

user3398827
- 1
- 1