设备重启后通知栏不会解除

时间:2013-10-01 09:23:57

标签: android android-notifications

我已创建通知栏

  

通知通知=新通知(logoId,“ABC”,系统           .currentTimeMillis());

Intent intent = new Intent(context, NewActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
notification.setLatestEventInfo(context, "PQR", "", pendingIntent);
notification.flags |= Notification.FLAG_NO_CLEAR;
((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(
    Constants.NOTIFICATION_ID, notification);

如果设备强制重启通知仍然在启动后出现。

如果设备重启,我需要关闭通知栏。

1 个答案:

答案 0 :(得分:0)

试试这个

Notification notification = new Notification(logoId, "ABC", System .currentTimeMillis());

Intent intent = new Intent(context, NewActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
notification.setLatestEventInfo(context, "PQR", "", pendingIntent);
notification.flags |= Notification.FLAG_AUTO_CANCEL
((NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE)).notify(
    Constants.NOTIFICATION_ID, notification);