根据Google Developers Guide,我正在实施this代码。显示接收的推送通知
一切都好,我可以成功接收通知数据。
如果检查GCMIntentService.java文件第70行,它呼应这一行的logcat:
I/GCM Demo(6653): Working... 1/5 @ 8656981
I/GCM Demo(6653): Working... 2/5 @ 8657982
I/GCM Demo(6653): Working... 3/5 @ 8658983
I/GCM Demo(6653): Working... 4/5 @ 8659983
I/GCM Demo(6653): Working... 5/5 @ 8660984
I/GCM Demo(6653): Completed work @ 8661985
I/GCM Demo(6653): Received: Bundle[{msg=messagehere, from=SENDERIDHERE, android.support.content.wakelockid=3, collapse_key=do_not_collapse}]
所以我的设备接收通知数据,但在设备的状态栏中没有看到通知。什么也没发生
你能告诉我为什么这些推送通知不会显示在我的设备上,只有在LogCat中?
最新通报
- Manifest file
这是我的sendNotification的()方法:
private void sendNotification(String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setContentTitle("GCM Notification") .setStyle(new NotificationCompat.BigTextStyle() .bigText(msg)) .setContentText(msg); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
将您的代码发布到创建通知(您链接的代码中的'sendNotification')的地方。 – ianhanniballake 2014-10-27 19:20:47
尝试在第106行使用'(int)(System.currentTimeMillis()&0xfffffff);'代替NOTIFICATION_ID'。只是疯狂的猜测。还要在清单文件中尝试使用完整路径作为意图服务类。 – Rohit5k2 2014-10-27 19:22:54
@ianhanniballake发布。谢谢。 – Eray 2014-10-27 19:23:01