Search code examples
androidandroid-fragmentsandroid-intentonactivityresult

Get the result of startActivityForResult method in another activity?


I am using a Google place picker API as follow:

PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult( builder.build((Activity) context), PLACE_PICKER_REQUEST );

Now, I am getting the expected result in onActivityResult() method:

protected void onActivityResult( int requestCode, int resultCode, Intent data ) {
  if( requestCode == PLACE_PICKER_REQUEST && resultCode == RESULT_OK ) {
        displayPlace( PlacePicker.getPlace( data, this ) );
    }
}

Process of the activity and intent is

MapActvity -> Place picker intent -> MapActivity 

Instead of getting back to MapActivity after calling startActivityForResult can I directly move to another activity and collect the result in onActivityResult() of another activity?


Solution

  • No, sorry, this is not possible. The startActivityForResult() and onActivityResult() methods are paired; the call to startActivityForResult() always delivers its results to the same activity (or fragment) that made the call.