我发送了没有扩展上下文的类的构造函数
int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
myNotification = new NotificationCompat.Builder(context)
.setSmallIcon(icon)
.setContentTitle(context.getResources().getString(R.string.app_name))
.setContentText(context.getResources().getString(R.string.app_name))
.setWhen(when)
.setTicker(context.getResources().getString(R.string.app_name))
.setDefaults(Notification.FLAG_NO_CLEAR);
然后我通过 RemoteViews 发送一些数据,最后
Intent notificationIntent = new Intent(context, Menu_Activity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
contentView.setOnClickPendingIntent(R.id.layoutNotification, contentIntent);
myNotification.setContent(remoteView);
myNotification.setOngoing(false);
myNotification.setAutoCancel(false);
myNotification.setPriority(Notification.PRIORITY_HIGH);
myNotification.setContentIntent(contentIntent);
myNotificationManager.notify(NOTIFICATION_ID, myNotification.build());
但我需要设置此通知,无法通过将其滑动到一侧来删除。现在每次我都可以通过滑动删除它。如何禁用它?
谢谢