当使用pendingIntent启动活动并且该活动已经在后台处于活动状态时,我无法获取新的intent额外信息。 getIntent将返回启动活动的intent。但在这种情况下,Android只会将其带回到前台并调用onResume方法。 我想要能够获取新的额外信息以便更新该活动。
我该如何做呢?
当使用pendingIntent启动活动并且该活动已经在后台处于活动状态时,我无法获取新的intent额外信息。 getIntent将返回启动活动的intent。但在这种情况下,Android只会将其带回到前台并调用onResume方法。 我想要能够获取新的额外信息以便更新该活动。
我该如何做呢?
尝试
@Override
protected void onNewIntent(Intent intent) {
// TODO Auto-generated method stub
super.onNewIntent(intent);
}
编辑:当将活动启动模式设置为singleTask时,它可以正常工作。
在onCreate和onNewIntent中,Intent的含义是不同的。 如果Activity的启动模式为singleTask或singleInstance,则需要分别处理两种情况的Intent。 请仔细阅读:http://developer.android.com/reference/android/app/Activity.html#onNewIntent(android.content.Intent)
通过onNewIntent接收到的Intent和通过getIntent获取的Intent在onCreate中获取的Intent是不同的。
FLAG_UPDATE_CURRENT
标志? - nullpotent