Right now, what is happening is when I press home-key, last active activity is displayed. But what I want is to start the application as new every time the user presses home key and start the app from launcher. Please help
Asked
Active
Viewed 381 times
0
-
Similar approach to http://stackoverflow.com/questions/3473168/clear-the-entire-history-stack-and-start-a-new-activity-on-android – karllindmark Jan 03 '13 at 14:08
-
1Why? What does the user gain by your proposed behavior? – CommonsWare Jan 03 '13 at 14:30
-
Security .. Consider this case - the user presses the home key and forgets to log out of the app and later, when the app is relaunched, instead of asking for user-credentials, app's data is shown directly. – Rookie Jan 03 '13 at 14:38
-
3Implement a configurable timeout mechanism for user credentials, rather than blindly wiping them out simply because something else took over the foreground. – CommonsWare Jan 03 '13 at 14:55
2 Answers
0
I think you can override onPause() event when you pressing home button and in there you can implement finishing your activity. with setting intent flag as FLAG_ACTIVITY_CLEAR_TOP on starting your Activity your back stack would be clear so with finishing the last activity there is no activity on the task and stack

Arash GM
- 10,316
- 6
- 58
- 76
0
While creating intent you can set the flag. for example
Intent intent = new Intent();
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

Ruchit Mittal
- 312
- 1
- 9