Reputation: 1290
Is it possible to allow a user to dismiss a notification by swiping it, but not allow it to be dismissed using the "Clear All" button?
I've searched SO and the web for a solution, but almost every question and answer seems to be related to either using the setOngoing(
) method or setting the FLAG_NO_CLEAR
. These solutions prevent the user from dismissing the notification using the swipe gesture.
The closest answer I found was this one.
I cannot use the "touch" or "click" event (which would fire the ContentIntent
) because that intent does something different in my app than the DeleteIntent
.
I would prefer a clean API call (i.e. something like setNoClearAll(true)
or somesuch), but I would be satisfied if there were some way to distinguish whether my notification was dismissed using a swipe gesture or a clear all button. Is such a thing possible?
Upvotes: 2
Views: 1718
Reputation: 38223
Is it possible to allow a user to dismiss a notification by swiping it, but not allow it to be dismissed using the "Clear All" button?
I'm afraid that's not possible.
I suggest using a custom notification layout with an [X] button in corner and setOngoing(true)
. You can assign custom pending intent to the button. The notification won't be cleared by clear all button and it can't be swiped away but the user still has means to dismiss the notification.
Take inspiration from media style notification on Android 4:
Upvotes: 2