gpt4 book ai didi

android - 我可以在 onActivityResult 回调中获取原始请求数据(intent extras)吗?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:13:41 26 4
gpt4 key购买 nike

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

最佳答案

我对我来说没有任何意义,真的......无论如何,因为 onActivityResult 将始终是启动第 3 方 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 extras)吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3077977/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com