开发者

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");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜