收到 GCM 推送通知消息后,我正在创建通知。这一切都完成了。但是当我点击通知时,有时它没有启动(PendingIntent)。大多数情况下,当我收到通知后立即点击时,问题就出现了。待定意图实际上是我的第一个登录页面本身。这是源代码。。
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(Context context, Intent intent)..
谁能帮我 ?