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 Inte开发者_运维问答nt("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.
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)
I think there is a method getParent() which returns the parent Activity of a child activity.
精彩评论