我正在尝试s4模型,所以在运行但是在棒棒糖版本中,它不起作用。
我的代码:
Intent myIntent = new Intent(CheckinService1.this,
Main1.class);
myIntent.putExtra("check", "check");
sp.putCheckin(CheckinService1.this, "check");
PendingIntent pendingIntent = PendingIntent
.getActivity(CheckinService1.this, 0, myIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
myNotification.defaults |= Notification.DEFAULT_SOUND;
myNotification.defaults |= Notification.DEFAULT_VIBRATE;
myNotification.flags |= Notification.FLAG_AUTO_CANCEL;
myNotification.setLatestEventInfo(context,
notificationTitle, notificationText,
pendingIntent);
notificationManager.notify(MY_NOTIFICATION_ID,
myNotification);
答案 0 :(得分:2)
更正后的代码
Intent myIntent = new Intent(CheckinService1.this,
Main1.class);
myIntent.putExtra("check", "check");
myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_SINGLE_TOP);
sp.putCheckin(CheckinService1.this, "check");
PendingIntent pendingIntent = PendingIntent
.getActivity(CheckinService1.this, 0, myIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
myNotification.defaults |= Notification.DEFAULT_SOUND;
myNotification.defaults |= Notification.DEFAULT_VIBRATE;
myNotification.flags |= Notification.FLAG_AUTO_CANCEL;
myNotification.setLatestEventInfo(context,
notificationTitle, notificationText,
pendingIntent);
notificationManager.notify(MY_NOTIFICATION_ID,
myNotification);
答案 1 :(得分:1)
尝试添加:
myNotification.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
| Intent.FLAG_ACTIVITY_SINGLE_TOP);