开发者

clearTaskOnLaunch but considering this

开发者 https://www.devze.com 2023-03-12 15:49 出处:网络
Sorry for my english. My \"Root\" activity (let\'s call it Activity A) is an activity that asks for a password. If the password is correct it should start another activity (B) with subactivities ands

Sorry for my english.

My "Root" activity (let's call it Activity A) is an activity that asks for a password. If the password is correct it should start another activity (B) with subactivities and so (B, C, D, etc).

When the user presses "back" in the Activity B, the app must exit (and not back to Activity A). To achieve this, I simply "finish()" Activity A after I call Activity B. This process works OK.

The problem is when the user presses "home" and then starts the app again, the app resumes from the last point an开发者_如何学Pythond not from the Activity A.

I use 'android:clearTaskOnLaunch="true"', but it is not working because the "Root" activity is killed when the password is correct.

What is the best solution for this situation?

Thanks!


There are some tricks I can think of, but people will still be able to get to it through Recent Tasks. You should perhaps rethink your logic of when the user needs to re-enter a password.


You can try merging Activity A with Activity B. At the first, make the Log In controls visible. After you had validated the user, make the login controls invisible, and make all the other controls visible.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号