user782104
user782104

Reputation: 13555

Control the finish of activities in android

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:

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

Answers (2)

mmlooloo
mmlooloo

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);

read FLAG_ACTIVITY_CLEAR_TOP

Upvotes: 2

Fahim
Fahim

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

Related Questions