Android notification swipe delete disabling

Is it possible to disable the swipe delete feature of an android notification from the notifications list in android. Please help me.

Thanks in advance.


Try this code

builder.setOngoing(true); // Cant cancel your notification (except notificationManager.cancel(); )

Above code in Notifcation Builder.

public void DisplayNotification() {

// Use NotificationCompat.Builder to set up our notification.
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);

//icon appears in device notification bar and right hand corner of notification

// This intent is fired when notification is clicked
Intent tapIntent = new Intent(CurrentActivity.this, SecondActivity.class);

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, tapIntent, 0);

// Set the intent that will fire when the user taps the notification.

builder.setOngoing(true); // Cant cancel your notification (except NotificationManger.cancel(); )

// Content title, which appears in large type at the top of the notification
builder.setContentTitle("Notifications Title");

// Content text, which appears in smaller text below the title
builder.setContentText("Your notification content here.");

NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

// Will display the notification in the notification bar

Cancel Notification

public void cancelNotification() {
        mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        mNotificationManager.cancel(NOTIFICATION_ID); // Notification ID to cancel

Happy Coding :)

you can mark your Notification as an 'ongoing' notification.

--> Notification.Builder setOngoing


not allow to cancel notification by swipe.

Need Your Help

Turn off automatic pagination of Django Rest Framework ModelViewSet

django pagination django-rest-framework

I am using Django Rest Framework's ModelViewSet for one of my views. ModelViewSet uses the ListModelMixin which automatically paginates the results but I do not want the results paginated. In my AP...