closing a parent activity from within a child activity

I am starting a new activity from my existing one like this -
 Intent intent = new Intent(tring, NumberActivity.class);

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
Log.d("Tring","Inside onActivityResult of Tring");
        if (requestCode == 1) {
            if (resultCode == RESULT_OK) {


Now in i have the following piece of code :
setResult(RESULT_OK, null);

According to what i have read this should close out my current Activity (ie. NumberActivity) and call onActivityResult method of inside which i have made a call to finish. so the parent activity gets finished.
But this is not happening.

Please help.
Rohit BajajAsked:
Who is Participating?
Rafael IConnect With a Mentor Solutions EngineerCommented:
one way to approach this is to kill your parent activity when you start the child activity.  that way when you finish with the child activity, you can exit without worrying about the parent activity.  if you need the parent activity, just have the child activity call the parent activity.  then you just have to worry about storing the information of the parent (if any) in order to call it again.

to kill the parent activity after calling the child, override the onPause function and tell it to finish there.  for example:

protected void onPause() {

Open in new window

good luck!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.