Fragment Activity Backstack - android

I am having problems with my backstack. I have a main activity that launches a FragmentActivity A which then starts an Activity B. When i call finish() on B it goes back to the main activity not A. I debugged it and A is not being destroyed until finish() is called on B but A is being skipped over.

Related

Resume Parent Activity

I have 2 Activity A and B, A calls B so, I want to Resume parent Activity (A) when B calls finish() on its Activity. Any advice will be useful.
UPDATE:
Maybe I should mention that I use fragments, each Activity has its own fragment, I call finish() from fragment hosted inside B activity and I expect to receive Resume on fragment belongs to A.
When you call Activity B, Activity A will go to background. Unless you finish Activity A while starting Activity B, it will automatically resume when Activity B finishes.
If you are calling this,
startActivity(ActivityB.class, this);
finish();
Just remove the finish(). It should work as expected.

How to skip and call an activity in the back stack

Assume I have 2 activities A and B. A is the main activity and set as singleTask so only one instance will be created.
Activity B can be instantiated many times. In onPause() in Activity B, I am calling activity A.
If I have 2 instances of activity B, then the first instance will call its onPause(), so the second instance will close quickly, because the first instance of activity B will call the instance of A and it will clear all activities and come to front.
I want to avoid that flow, instead the last instance of activity B should call instance of activity A.
How to do that?

How can i deny activity to be destroyed

I'm starting the activity "B" from the activity "A". When I'm closing the activity B using the back button or method finish(), the activity A is recreating. How can i deny activity to be destroyed?
Activities in android are stored in a Stack called activity-stack, when you go to next Activity it's added to the stack, when you go back you pop last element from stack and nothing points at it any more, so not destroying is just waste of space!
Even if you override the back button to launch previous activity with noHistory or clearTop flag, current activity would be destroyed.
I suggest that you read more on activity lifecycle

Android activity navigation issue

I have a problem with navigating through activities. I am navigating from HomeActivity to Activity A. When I move from Home to Activity A, I finish the HomeActivity and starts another activity Activity B. When I start Activity B, I am not finishing Activity A. So when I finish Activity B normally it should go to Activity A. But In my case it is not working. When I call finish() in Activity B, both Activity B and Activity A is getting finished.
Can anybody suggest a way to accomplish this?

How to finish "Activity A" since "Activity B"? (Finish an Activity since other)

I'm trying to finish the Activity A since Activity B when it will finish too. The Activity B was launches since Actvity A.
So I've paused the Activity A. How can I do it?
You may try using startActivityForResult() on the Activity A to invoke the Activity B.
And then, before calling finish() on the Activity B, you should call setResult() and call finish() on the Activity A in onActivityResult()
Example here

Categories

Resources