当前位置: 代码迷 >> 综合 >> 通知栏通知不被清除通知所取消
  详细解决方案

通知栏通知不被清除通知所取消

热度:8   发布时间:2024-01-26 03:53:08.0
Android 实现点击清理通知而不清理通知栏的通知解决办法
NotificationCompat.Builder builder=new NotificationCompat.Builder(appContext, CHANNEL_ID).setSmallIcon(appContext.getApplicationInfo().icon).setContentTitle(title).setTicker(content).setContentText(content)
//                .setOngoing(true)//通知不会被清除通知所清理.setWhen(System.currentTimeMillis()).setAutoCancel(true).setContentIntent(pendingIntent);

设置setOngoing(true)即可

  相关解决方案