Can I get original request data (intent extras) in onActivityResult callback?
Curious, if I can invoke some 3rd party activity, and then in onActivityResult read my original intent data.
I does not make any sence for me, really... Anyway, as the onActivityResult
will be always part of the same Activity
that launched the 3rd party activity you just have to save that data somewhere on your activity. For instance:
private Intent intentForThat3rdPartyActivity = null; // long name, huh?
public void hereYouLaunchThings(){
if( intentForThat3rdPartyActivity == null ){
intentForThat3rdPartyActivity = new Intent(YourActitity.this, The3rdPartyActivity.class);
intentForThat3rdPartyActivity.putExtra("weird", "data");
}
startActivityForResult(intentForThat3rdPartyActivity, 9999);
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
// this should have the same data you passed
String foo = intentForThat3rdPartyActivity.getStringExtra("weird");
}
精彩评论