我正在使用 GCMIntentService 在我的应用程序中处理推送通知。我正在创建状态栏通知并使用待处理的 Intent 导航到活动。
我创建通知的代码是:
private static void generateNotification(Context context, String message, String title1, String desc, String soln, String date, String time) {
int icon = R.drawable.notification_icon;
long when = System.currentTimeMillis();
Log.i("","@@##@@ notificatin"+title1+desc+soln+message);
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context,AppLog.class);
notificationIntent.putExtra(Description.REQUEST_FROM, "notification");
notificationIntent.putExtra(Description.INFO_TITLE, title1);
notificationIntent.putExtra(Description.INFO_DESC, desc);
notificationIntent.putExtra(Description.INFO_SOLUTION, soln);
notificationIntent.putExtra(Description.INFO_DATE, date);
notificationIntent.putExtra(Description.INFO_TIME, time);
PendingIntent pIntent = PendingIntent.getActivity(context, 0,notificationIntent, 0);
notification.setLatestEventInfo(context, title, message, pIntent);
Uri uri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
notification.sound=uri;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);
}
在我的 AppLog.class 中,我正在处理它:
if(bundle!=null && bundle.containsKey(Description.REQUEST_FROM)){
Log.i("","@@##@@ applog"+bundle);
}
当第一个通知发送到设备时,我的 AppLog Activity 类中将正确填充数据。但是对于所有通知,它总是向我显示旧包。
我尝试了一切,但问题仍然存在。从服务创建的待处理意图或通知是否有任何问题?