Reputation: 13555
There are two activities in my app
Activity A: Select Country
Activity B: Select Region
First I enter Activity A, select a country, then will jump to Activity B, and I would like to keep the case like this:
requirement 1 : if in Activity B press back, then go back Activity A and select country again,
requirement 2 : if in Activity B select region, then finish the Activity A
The problem is, if I startActivity()
to open B, then finish Activity A , it can not meet the requirement 1, but otherwise I can not fit requirement 2.
Is there simpler way besides using onActivityResult
in Activity A? Can I directly finish A in Activity B?
Thanks a lot.
Upvotes: 0
Views: 170
Reputation: 18977
When user select a region call the activity C (the one before activity A) with below code:
Intent intent = new Intent(this, activityC.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Upvotes: 2
Reputation: 12358
Use have to use startActivityForResult for starting the activity
Refer the documentation on it http://developer.android.com/training/basics/intents/result.html
Upvotes: 0