I had Activity
A(launchMode
is singleTask
) and B. In onCreate()
of A, I triggered an alarm, which will activate a BroadcastReceiver
after some time. Then I pressed home button to hide A.
In that BroadcastReceiver
's onReceive()
, following code will be executed:
Intent intent = new Intent(context, B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
And then I found B was launched normally, but A will also be resumed. I don't know why and don't like that behavior.
Let's imagine: user opened you app's Activity
A, pressed home button and opened another app's Activity
B, then a BroadcastReceiver
is activated and Activity
C of your app is opened, user did some stuff there and then he pressed back button. He should see B instead of A, right?
How can I forbid this behavior? Thanks in advance.