Programing

사용자가 알림을 닫지 못하도록 방지

lottogame 2020. 12. 7. 07:41
반응형

사용자가 알림을 닫지 못하도록 방지


일부 앱에는 스 와이프하여 닫을 수없는 알림이 있습니다.

그러한 행동을 어떻게 관리 할 수 ​​있습니까?


Andro Selvas 답변 외에도 :

당신이 사용하는 경우 NotificationCompat.Builder을 , 다만 사용

builder.setOngoing(true);

플래그를 사용하여 FLAG_ONGOING_EVENT지속적으로 만드십시오.

Notification notification = new Notification(icon, tickerText, when);
    notification.flags = Notification.FLAG_ONGOING_EVENT;

또한 FLAG_NO_CLEAR을 확인할 수 있습니다.


알림을 영구적으로 만들기 위해 아래 코드를 사용했습니다.

startForeground (yourNotificationId, notificationObject);

해제하려면 다음을 수행하십시오.

stopForeground (true);

참고 URL : https://stackoverflow.com/questions/18464810/prevent-user-from-dismissing-notification

반응형