简体   繁体   中英

Start a new activity clearing the activity stack

In order to block the application when it detects that is not a licensed version I'd like to start a new activity clearing the current stack, thats is: if the stack have the activities [A,B,C,D] i want to start the activity E leaving the stack with only [E].

I'm playing with the intent extras FLAG_ACTIVITY_CLEAR_TOP, FLAG_ACTIVITY_CLEAR_TASK and FLAG_ACTIVITY_NEW_TASK with no success

You could create a parent activity which is overriding the OnNewIntent , when receving an intent with EXIT extra finishes itself.note that you have to call it with the SINGLE_TOP flag, so the OnNewIntent will be called.

then create a static method which broadcast an exit intent to all of your activities that inharnace this parent activity.

This should work even if you have move than one tasks.

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