getIntent().getExtras()在android 4.1.1 JellyBean上运行的Galaxy Nexus上返回null

getIntent().getExtras()在android 4.1.1 JellyBean上运行的Galaxy Nexus上返回null,android,Android,我正在使用bug sense进行bug报告。在对我的应用程序进行最新更新后,我的应用程序上出现了空指针 这个问题只发生在Android 4.1.1上。在几乎所有的活动中,这些空指针都有25次出现,并且只出现在Android 4.1.1中 有人知道为什么会这样吗 Intent i= new Intent(context, MyActivity.class); i.putExtra("id", id); context.startActivity(i); 获取额外服务: Bun

我正在使用bug sense进行bug报告。在对我的应用程序进行最新更新后,我的应用程序上出现了空指针

这个问题只发生在Android 4.1.1上。在几乎所有的活动中,这些空指针都有25次出现,并且只出现在Android 4.1.1中

有人知道为什么会这样吗

Intent i= new Intent(context, MyActivity.class);
i.putExtra("id", id);
context.startActivity(i);
获取额外服务:

Bundle extras = getIntent().getExtras();
String id = extras.getString("id"); //null pointer

看起来非常类似,即使与安卓4.1.1无关

你在用标签吗?
我认为您需要提供更多的上下文和代码才能得到一个有效的答案。

我只在android 4.1上使用
singleTask
启动模式时遇到了同样的问题。 如果我在其实例之前已启动的情况下启动此活动,则会重新生成此活动。

似乎
getIntent()
返回的是第一个意图而不是当前意图。 说:

getIntent():返回启动此活动的意图

我发现在
onCreate
中,我获得了第一个意图(activity launcher),但在
onNewIntent中,我获得了额外的适当意图。所以我重写了onNewIntent,如下所示:

@Override
public void onNewIntent(Intent intent) {
  super.onNewIntent(intent);
  setIntent(intent);
}
获取由
onCreate
中的
getIntent
返回的正确意图

您可以在此处找到有关此覆盖的一些讨论:

Android 4.1.1中的所有崩溃?什么设备?如何设置附加功能?@blackbelt大约80%的Galaxy Nesus和20%的“Crespo4G上的Android”谢谢。我没有使用标签。该代码适用于其他设备,但不适用于某些设备