I have a notification that needs to start a activity B
. However, I want to be able to let the user "go back" to the Dasboard A
.
I am wondering how this could be done? Will I need to use a intent extra to start A and process that intent in onCreate
and then start B
manually? Or is it possible to manually specify a backstack?
You can use the startActivities method to launch a complete backstack of activities in one go.
startActivities(
new Intent[]
{
new Intent("my.intent.FOO_INTENT"),
new Intent("my.intent.BAR_INTENT"),
new Intent("my.intent.BAZ_INTENT")
});
In this example an instance of Baz is created and made the current Activity.
If Baz finishes then an instance of Bar is created and is made the current Activity.
If Bar finishes then an instance of Foo is created and is made the current Activity.
This method was introduced in API level 16 but is available in the v4 support library via the ContextCompat class:
ContextCompat.startActivities(context,
new Intent[]
{
new Intent("my.intent.FOO_INTENT"),
new Intent("my.intent.BAR_INTENT"),
new Intent("my.intent.BAZ_INTENT")
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With