我正在尝试通过下面的代码发出提醒通知,并希望它一直存在,直到用户决定关闭它。但它会在几秒钟后自动关闭(大约 10 秒)。有没有办法让它持久化并留给用户解雇它。
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Notification")
.setContentText("Hello !!!")
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.addAction(R.drawable.ic_launcher,
"View Call", null)
.addAction(R.drawable.ic_launcher,
"Call Back", null);
// Gets an instance of the NotificationManager service
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());