intentForThat3rdPartyActivity

intentForThat3rdPartyActivity

很好奇,如果我可以调用某些第三方 Activity ,然后在onActivityResult中读取我的原始 Intent 数据。

最佳答案

真的,我对我没有任何意义...无论如何,因为onActivityResult始终是启动第三方 Activity 的同一Activity的一部分,所以您只需将数据保存在 Activity 中的某个位置即可。例如:

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

关于android - 我可以在onActivityResult回调中获取原始请求数据(额外 Intent )吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3077977/

10-12 04:23