我已經實現了GCMIntentService,並且每當我得到推送通知時,我都需要在通知菜單中顯示 通知,並使用 意圖中的某些包值打開活動。 我可以在通知菜單中看到通知,但點擊它只是不會做任何事情。以下是我使用的代碼: -PendingIntent在意圖添加附加內容時不起作用
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());
我可以看到該通知,但是當我點擊它通知菜單向上滑動,不 做任何事情,不打開任何活動。 如果我不發送任何捆綁的額外產品,那麼我可以打開該活動,但是當我發送 捆綁包價值時,我無法打開該活動。
在此先感謝
你有沒有記錄?活動是否開放?在活動中放入一些日誌語句,以確保它根本不會啓動,並且在可以顯示視圖之前不會在其他某個點崩潰。也許還會發布你的'onReceive()'代碼。 –
沒有活動根本沒有打開 – abhishek
嘿abhishek顯示你的stacktrace,因爲當我試圖打開活動時點擊通知.. – goonerDroid