Android 当应用程序在onNewIntent和onResume中打开时,意图向应用程序传递空内容
我有一个应用程序,它使用ccs获得云消息传递 我使用下面的代码创建了通知Android 当应用程序在onNewIntent和onResume中打开时,意图向应用程序传递空内容,android,android-intent,broadcastreceiver,android-pendingintent,Android,Android Intent,Broadcastreceiver,Android Pendingintent,我有一个应用程序,它使用ccs获得云消息传递 我使用下面的代码创建了通知 Intent intent = new Intent(this, GcmActivity.class).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra("title",messagetype); intent.putExtra("message", msg); intent.putExtra("additional", additionalInfo);
Intent intent = new Intent(this, GcmActivity.class).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra("title",messagetype);
intent.putExtra("message", msg);
intent.putExtra("additional", additionalInfo);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_stat_cloud)
.setContentTitle(messagetype)
.setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
.setContentText(msg)
.setTicker(msg)
.setAutoCancel(true)
.setSound(Settings.System.DEFAULT_NOTIFICATION_URI);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(randInt(1, 1000), mBuilder.build());
现在,当我在应用程序未打开时单击通知时,它传递了意图,我将它们显示在列表中
但是,当应用程序打开时单击时,它们都为空。实际上,为什么我希望在应用程序打开时发送此消息,因为我有一个broadcastreceiver,它更新listview,但在屏幕处于睡眠状态时不会更新。我在这个代码之前发送了广播
我知道这和旗帜有关,所以我试着加入我的意图
Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP
没有结果。当应用程序打开时,使用下面的标志:
setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
就这样…等待的意图?如果是,那么如何检查应用程序是否打开。请帮助我。你不需要检查应用是否打开或关闭,只需将此标志设置为你的意图。不@Jay…它不起作用,….它在onnewintent和onnewresume中的相同空值检索我真的很抱歉值传递得很好,但是我尝试使用空变量获取它们…thanx用于帮助@Jay