Reputation: 670
I have an android application where there are 3 activities:
MA – MainActivity (Launched when the application is started) AC1 – Activity1 – declared as androidLaunchMode=”singleInstance” AC2- Activity2- declared as androidLaunchMode=”singleInstance”
Initial flow of activities is MA -> AC1 Go back to MA MA -> AC2
So the total flow is like MA -> AC1 -> MA -> AC2 Now when I press back I want the flow to be AC2 -> MA to close application.
So, on back press of MA I want to clear the back stack of activities. So, how to I handle this in onKeyDown() of MA?
Upvotes: 1
Views: 891
Reputation: 15269
While you are calling MA from AC1 put below flag as intent
FLAG_ACTIVITY_REORDER_TO_FRONT
and
FLAG_ACTIVITY_CLEAR_TOP
Upvotes: 2
Reputation: 1253
Try startActivityForResult()
Go through the following links
http://micropilot.tistory.com/1577 http://rahulonblog.blogspot.com/2010/05/android-startactivityforresult-example.html
Upvotes: 0