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)即可
本文介绍了一种在Android中实现点击清理通知而不清理通知栏中所有通知的方法。通过使用NotificationCompat.Builder设置setOngoing(true),可以使通知在点击时不会被清除,从而实现更精细的通知管理。
3403





