How to get started with populated back stack?

I have a notice that should begin action B However, I want the user to be able to return to Dasboard A

I am wondering how can this be done? Should I use additional intentions to start A and process this intent in onCreate and then start B manually? Or can I manually specify a backstack?

+4
source share
2 answers

I would go with your own decision and create an intention for activity A and somehow tell about activity A in this intention that it should start Activity B.

This behavior is not standard Android behavior. The user must be used to go to the last screen using the back button. I would not try to capture this feature of the operating system.

If in your case the user, for example, is sent to a detailed presentation of the message through a notification, he must close your application and return to the previous screen. If you want to give your user the ability to "return" from a message to a shared message inbox, use the up navigation structure that can be used with the ICS action bar. It sounds complicated, but essentially it means that you need to add a button that leads the user to the inbox. Since the introduction of the Actionbar (summer 2010, I think) there is a standard position for this button. It is located in the upper left corner of the screen. (exactly the same as the iOS back button;))

0
source

You can use the startActivities method to start a full backup of actions 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, a Baz instance is created and the current operation is performed.

If Baz ends, a Bar instance is created and the current operation is performed.

If Bar ends, an instance of Foo is created and the current activity is executed.

This method was introduced at API level 16, but is available in the v4 support library through 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") }); 
+14
source

Source: https://habr.com/ru/post/1393751/


All Articles