Curious, if I can invoke some 3rd party activity, and then in onActivityResult read my original intent data.
views:
27answers:
1
+1
A:
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");
}
Cristian
2010-06-20 02:22:39
I know, you can say that this is rare, but the process hosting my activity can be killed before the 3rd party completed and onActivityResult called. If this happens, the intentForThat3rdPartyActivity would be null.
alex2k8
2010-06-20 02:48:44
Probably I should save information into savedInstanceState, but would be nice to get original intent without extra code :-)
alex2k8
2010-06-20 02:52:14
Yup... if that's the case you have no choice but saving the that data in the `savedInstanceState`.
Cristian
2010-06-20 02:59:27
Or if you control both sides, the calling and receiving activity, you can just pass the data in the intent back as the data of the result.
Moncader
2010-06-20 16:14:04
There is no way to get original intent extras, until the called activity will send the intent back by doing something like this setResult(RESULT_OK, getIntent()).
alex2k8
2010-06-21 20:52:21