2

I have an Android app with multiple activities. The main activity communicates over a network and can launch or dismiss various other activities depending on commands it receives over the network. When an Activity is dismissed I don't want to finish() it, just move it down the stack so it's no longer the top activity. What I really need is a FLAG_ACTIVITY_REORDER_TO_BOTTOM but there is no such thing.

There's an intent flag called FLAG_ACTIVITY_PREVIOUS_IS_TOP and the name implies something like that but I don't understand the description:

"If set and this intent is being used to launch a new activity from an existing one, the current activity will not be counted as the top activity for deciding whether the new intent should be delivered to the top instead of starting a new one. The previous activity will be used as the top, with the assumption being that the current activity will finish itself immediately"

Could someone please decode that for me, and if it's not what I want IS there some way to tell an activity to submerge itself below the previous one?

3
  • This may cause issues as android can finish/stop your launched but paused apps if it needs resources. Oct 18, 2013 at 16:43
  • That wouldn't be a problem. But let's turn it around - what's a good way to have the main activity FORCE the other activity to close itself?
    – user316117
    Oct 18, 2013 at 16:51
  • look up the call hierarchy for both finish() and finalize(). Without knowing more about your app, I'd probably say just wrapper them with a clean up / close call, make it public and have your main app's dispatch table call it to shut it down. If you have synchronization between the apps, that will have to be dealt with accordingly. Just curious, why do you have to do separate apps like this? (Or are they other peoples' apps you'd like to launch/stop?) Oct 18, 2013 at 17:09

2 Answers 2

0

This isn't possible. The activities are stacked and you cant put one back under the other. It sounds like you may want to create a class that extends Android’s android.app.Application.

I found this tutorial online and it looks good. Good luck.

Extending Android's android.app.Application tutorial

0

You cannot move an activity below a certain activity into the android back Stack. The only way to move a activity in back stack is to open another activity on top of it. You can move an activity on top by creating a single instance of activity using FLAG 'singleTop' in this way your activity will be moved to the top of another activity and only a single instance of activity will be there in stack.

More information about activity back stack and Flags is available here.

Go through this information and all your doubts will get cleared about back stack.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.