How to finish work and return to another place?

My application implements an action that stretches for 3-4 actions. The entry point to this process can be various actions in the application. (HomeActivity, various displayActivities). I want to return to the starting action after the successful completion of the last action.

Is there a better way to do this? thank you very much.

+2
source share
2 answers

You can use a global static boolean value to help you with this (in the SomeClass.IsClosingFlow example). In addition, you must define each action for a “mark” if it is in a “stream” (stream = means its part of the action package, to be closed). I recommend using this label as an abstract method if all your actions extend some abstract actions (i.e. isActivityInFlow() ).

The following code demonstrates this. This should be a place in the onResume() each action in the application:

  // Check to see if we are in the process of closing activities if (SomeClass.IsClosingFlow){ if (isActivityInFlow()){ this.finish(); } else{ // If we got here, and we're not in the flow anymore SomeClass.IsClosingFlow = false; } } 
+1
source

There are many ways to control the flow of applications. One way that might work for you, and quite simply, is to simply use startActivityForResult() when called from one action to another. Then, when you are finally done, you simply set the result and call finish() . In each exercise, you can implement onActivityResult() so that it sets the result and calls finish() on its own. This way you can direct several actions and then attach yourself to those who started the chain.

0
source

All Articles