I have an Android app containing two Activities
.
Activity A
has a button that launches Activity B
using Context.startActivity(Intent intent)
.
There is also Notification
, which opens an Activity in the same way.
If I run B
from this notification and press the "Back" button, it just closes B
and does not show A
how I go there with a normal case.
Is it possible to get B
to return to A
if it started with a notification without a history stack?
Decision
As stefan and Paul Lammertsma, the best way is to start A
from the notification and in A
create a new intent using B
- but not in onCreate()
!
I dig a bit and find that if I set a new property for activity A
in AndroidManifest
:
android:launchMode="singleTask"
in A
will be an activity called
onNewIntent(Intent intent)
And there we have to checl, if the Intent
contains an additional value passed from the notification, and if so, then we invoke the new intent B
Thank you both and good luck with it for the following developers :-)
source share