4
我在獲取GCM推送通知消息後創建通知。這一切都已完成。但是當我點擊通知時,有時它不會啓動(PendingIntent)。大部分問題出現在我收到通知後馬上點擊。待定的意圖實際上是我的第一個登錄頁自我。這是源代碼..PendingIntent並非總是在Android中啓動
public void createNotification(Context context, String message) {
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon,
"My notification", System.currentTimeMillis());
// Hide the notification after its selected
notification.flags |= Notification.FLAG_AUTO_CANCEL ;
Intent intent;
intent = new Intent(context, Login.class);
intent.putExtra("pushNoti", "pushNoti");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(context, "my Alert",
message, pendingIntent);
notification.defaults = Notification.DEFAULT_SOUND;
notificationManager.notify(0, notification);
}
這裏的上下文從GCM的onMessage(上下文的背景下,意圖意圖)..越來越
誰能幫助我?
張貼一些代碼將有所幫助。 – 2012-08-09 09:31:53
另外我的應用程序在後臺,當我這樣做.. – hacker 2012-08-09 10:09:24