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

use*_*756 7 android

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

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

在调用startActivity(intent)之后,控件转到CalledActivity的onResume().

但是,在CalledActivity的onResume()中,getIntent()为我提供了旧的意图,而不是CallingActivity设置的新意图.

如何在CalledActivity的onResume()中获得新的意图?

dre*_*ale 13

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