I ‘m calling getParent().setResult(0) in TabActivity. This is called when the user hits previous button. I want the current activity to close and get deleted from the stack.
getparent() returns null. Can someone tell me why does that happen??
getParent().setResult(0);
finish();
Thanks
UPDATE: This is the definition of getParent()…What does embedded child mean. And secondly is the TabActivity an embedded child if it is called from another Activity??
public final Activity getParent ()
Return the parent activity if this view is an embedded child.
You haven’t clearly stated you’re question. You want to understand how to pass a result back from an Activity to the Activity which called it. You must first understand that Activities aren’t hierarchical even though they are kept on a back stack. Later activities do not belong to the Activity they are called from.
However, here is the answer the question you meant to ask:
You are using
startActivityForResult(Intent, int)(Which you can read up on here)When
Activity AcallsstartActivityForResult()methodActivity Bis started, this should do whatever processing is required and then when it exits either call:when a yes/no is required or
where intent is an
Intentwhich contains bundled information you want to use inActivity Ato act upon.After
Activity BexitsActivity Awill resume and call the method:This is where you will process the result.
You can read all about this here:
http://developer.android.com/reference/android/app/Activity.html#StartingActivities