简体   繁体   中英

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",

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.

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM