Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

closing a parent activity from within a child activity

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

 @Override
    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) {
                this.finish();

            }
        }
    }



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

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

Please help.
thanks
ASKER CERTIFIED SOLUTION
Avatar of Rafael I
Rafael I
Flag of Japan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial