【发布时间】:2014-07-15 18:56:58
【问题描述】:
我已经实现了 GCMIntentService,每当我收到推送通知时,我都需要显示 通知菜单中的通知,并在 意图。 我可以在通知菜单中看到通知,但单击它什么也没做。以下是我正在使用的代码:-
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
Intent i = new Intent(this, ChatDetail.class);
Bundle b = new Bundle();
b.putString("my_id", "5356b178b130a74a57019fe9");
b.putString("you_id", youId);
i.putExtras(b);
// PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
// new Intent(this, MainActivity.class), 0);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
i,PendingIntent.FLAG_CANCEL_CURRENT );
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.pool_my_ride_icon)
.setContentTitle("GCM Notification")
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(text))
.setContentText(text);
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
我可以看到通知,但是当我单击它时,通知菜单会向上滑动并且没有 做任何事情都不会打开任何活动。 如果我没有在附加内容中发送任何捆绑包,那么我可以打开活动,但是当我发送时 捆绑值然后我无法打开活动。
提前致谢
【问题讨论】:
-
你有日志吗?活动是否完全开放?在 Activity 中放置一些日志语句以确保它根本不会启动,并且不会在视图显示之前的某个其他点崩溃。也许还可以发布您的
onReceive()代码。 -
没有,活动根本打不开
-
嘿 abhishek 显示您的堆栈跟踪,因为当我尝试单击通知时它会打开活动..
标签: android android-intent notifications google-cloud-messaging