michael
michael

Reputation: 110550

What is the recommend way to get the main Activity from child Activity

My android application has 1 main activity. And it launches some sub-activity (which I wrote) and that also launches some sub-activity (which I wrote). I do this:

 Intent i = new Intent("my intent1");
 startActivity(i);

My question is how can each of my sub-activity and sub-sub-activity get back to the Parent activity?

Thank you.

Upvotes: 1

Views: 2328

Answers (2)

michael
michael

Reputation: 110550

I think there is a method getParent() which returns the parent Activity of a child activity.

Upvotes: 1

synic
synic

Reputation: 26668

You should start your sub Activities via [startActivityForResult()][1], and when you're done in your sub-activity, call finish(). This will close the sub-activity and return to the Activity that called startActivityForResult.

[1]: http://developer.android.com/intl/de/reference/android/app/Activity.html#startActivityForResult(android.content.Intent, int)

Upvotes: 5

Related Questions