Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 通知兼容性生成器_Android_Xml_Notifications - Fatal编程技术网

Android 通知兼容性生成器

Android 通知兼容性生成器,android,xml,notifications,Android,Xml,Notifications,我发送了不扩展任何内容的类的构造函数context int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); myNotification = new NotificationCompat.Builder(context) .setSmallIcon(icon) .setContentTitle(context

我发送了不扩展任何内容的类的构造函数context

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);
然后我通过RemoteView发送一些数据,最后

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());
但是我需要设置这个通知,它将不可能通过侧击来删除。现在每次我都可以通过刷卡来删除它。如何禁用它


谢谢

通知生成器有一个方法。将其设置为true,以使通知成为用户无法解除的持续通知

设置这是否为“正在进行的”通知。持续通知 用户无法拒绝,因此您的应用程序或服务必须 注意取消它们。它们通常用于表示 用户积极参与的后台任务(例如,播放 音乐)或以某种方式挂起,因此占用了设备 (例如,文件下载、同步操作、活动网络连接)


通知生成器有一个方法setContinuous。将其设置为true,以使通知成为用户无法解除的持续通知

设置这是否为“正在进行的”通知。持续通知 用户无法拒绝,因此您的应用程序或服务必须 注意取消它们。它们通常用于表示 用户积极参与的后台任务(例如,播放 音乐)或以某种方式挂起,因此占用了设备 (例如,文件下载、同步操作、活动网络连接)

您只需要使用setContinuous(true)。删除setAutoCancel(错误)行

同时使用setContinuous()和setAutoCancel()方法对我不起作用(未显示通知)。

您只需要使用setContinuous(true)。删除setAutoCancel(错误)行


同时使用SetContinuous()和setAutoCancel()方法对我不起作用(未显示通知)。

是否尝试将Continuous设置为
true
?是否尝试将Continuous设置为
true