通过点击系统通知栏移除 通知只需要一个方法
Notification notification = new Notification();
notification.setAutoCancel(true);
下面是整个系统弹窗的方法已做了6.0设配
/**
* 头部系统消息提示
* 状态栏提示消息
*/
private void setNotificationDemoForAndroidO(int progress, String content, Context context) {
//ID
String id = “testNotification”;
//名称
String name = “notification”;
NotificationManager notificationManager = (NotificationManager) context.getSystemService
(NOTIFICATION_SERVICE);
Notification.Builder mBuilder = new Notification.Builder(context);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.layout_notification);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(id, name, NotificationManager
.IMPORTANCE_DEFAULT);//FLAG_AUTO_CANCEL
mBuilder.setChannelId(id);