Sam
Sam

Reputation: 6405

How to clear the activity stack in Android

I have the following application flow in my Android app,

Login->Home->screen1->screen2->screen3->screen4-> logout

In the screen4 I have a log out button, which allows the user to logout from the application and re-login. When I re-login to the app, the previous data is still shown. Is there a way to start the application fresh when the user logs out from the app?

NOTE: all the above activities launch mode set to "single task",

Upvotes: 3

Views: 910

Answers (4)

Shardul
Shardul

Reputation: 27980

Well I dont know it its that what you want but can finishing activity before starting another and storing login in Application Context can help?

Upvotes: 0

Falmarri
Falmarri

Reputation: 48615

You could set a static flag when the user clicks logout and in each activity check that flag in onResume() and if it's set call finish(). That's kind of hacky though.

Upvotes: 2

jacknad
jacknad

Reputation: 13739

Configure this for your activity in AndroidManifest.xml. The attribute is android:clearTaskOnLaunch.

Upvotes: -1

Kiril Kirilov
Kiril Kirilov

Reputation: 11257

See if that helps - http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP (This and other flags)

Upvotes: 6

Related Questions