Skip to content Skip to sidebar Skip to footer

Android Can You Get An Activity Result From A Chained Startactivityforresult

I have the following activity screens Activity A - contains a button that links to Activity B Activity B - contains a confirmation of order and then a Next button that opens up a A

Solution 1:

If you would like to get the result from Activity C passed back to Activity A:

Start Activity B from Activity A:

IntentshowB=newIntent(ActivityA, ActivityB); 
startActivityForResult(showB, RequestCode); 

In Activity B call C:

IntentshowC=newIntent(ActivityC);
showC.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(showC); 
finish(); //Close Activity B

In C:

//set the result code andclose the activity
Intent result=new Intent();
setResult(resultCode, result);//like RESULT_OK
finish();

In A:

publicvoidonActivityResult(int requestCode, int resultCode, Intent data){

  ...... handle RequestCode here
}

Solution 2:

Could it possibly be to do with calling finish() from Activity B when it is returned from Activity C?

Yes. You need to set the result to OK in Activity B at

case GET_SIGNATURE:
if ( resultCode == RESULT_OK )
{
    // here you need set it to OK before calling finishfinish();
}

as well.

Post a Comment for "Android Can You Get An Activity Result From A Chained Startactivityforresult"