Addev
Addev

Reputation: 32221

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

Upvotes: 1

Views: 62

Answers (1)

Kirill Kulakov
Kirill Kulakov

Reputation: 10245

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.

Upvotes: 1

Related Questions