我已创建通知栏
通知通知=新通知(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);
如果设备强制重启通知仍然在启动后出现。
如果设备重启,我需要关闭通知栏。
答案 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);