年纪大了额外的意图在startActivity后onResume()(newIntent) [英] Getting old intent extras in onResume() after startActivity(newIntent)

查看:109
本文介绍了年纪大了额外的意图在startActivity后onResume()(newIntent)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调用的活动中,我有以下的code:

In the calling activity, I have the following code:

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(意向)被称为

后,控制进到CalledActivity的onResume()

After the startActivity(intent) is called, the control goes to onResume() of the CalledActivity.

然而,在CalledActivity的onResume(),getIntent()给我的旧的意图,而不是设置由CallingActivity新的意图。

However, in the onResume() of the CalledActivity, getIntent() gives me the old intent and not the new intent as set by the CallingActivity.

我怎样才能在onResume新的意图()的CalledActivity ??的

How can I get the new intent in onResume() of the CalledActivity??

推荐答案

您应该尝试重写活动的 onNewIntent(意向意图)方法,并使用 setIntent(意向)更新的意图。

You should try to override the onNewIntent (Intent intent) method of Activity, and use setIntent(Intent) to update the intent.

这篇关于年纪大了额外的意图在startActivity后onResume()(newIntent)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆