gpt4 book ai didi

android - 在 startActivity(newIntent) 之后在 onResume() 中获取旧的 intent extras

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

在调用 Activity 中,我有以下代码:

Intent intent = new Intent();
intent.setClass(CallingActivity.this, CalledActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(key, new_value);
startActivity(intent);

调用 startActivity(intent) 后,控制转到 CalledActivity 的 onResume()。

但是,在 CalledActivity 的 onResume() 中,getIntent() 给我的是旧 Intent ,而不是 CallingActivity 设置的新 Intent 。

如何在 CalledActivity 的 onResume() 中获取新 Intent ?

最佳答案

你应该尝试覆盖Activity的onNewIntent(Intent intent)方法,并使用setIntent(Intent)来更新intent。

关于android - 在 startActivity(newIntent) 之后在 onResume() 中获取旧的 intent extras,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9925963/

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