문제

Some apps have notifications which can´t be dismissed by swiping them away.

How can I manage such behaviour?

도움이 되었습니까?

해결책

In addition to Andro Selvas answer:

If you are using the NotificationCompat.Builder, just use

builder.setOngoing(true);

다른 팁

Use the flag,FLAG_ONGOING_EVENT to make it persistent.

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

Also you can check, FLAG_NO_CLEAR

I used the below code to make my notification persistent:

startForeground(yourNotificationId,notificationObject);

To make it dismissable, just do the below:

stopForeground(true);

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top