Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 236
Sujith Thankachan Avatar asked Feb 15 '14 08:02

Sujith Thankachan


People also ask

How do I get rid of swipe notifications?

To find your notifications, from the top of your phone screen, swipe down. Touch and hold the notification, and then tap Settings . Choose your settings: To turn off all notifications, turn off All notifications.

How do I stop Android notifications from popping up?

1 Solution. You might have to go to each app individually and disable the pop up notification for each. See screenshot, this is the Phone app under notification catagory> missed calls disable pop-up. Hope this helps.

What happens when you swipe left on notifications?

Left: Swipe left to dismiss, right for actions. Right: Swipe right to dismiss, left for actions. Still, this is a solution to a problem that shouldn't have existed.


3 Answers

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
builder.setSmallIcon(R.drawable.ic_stat_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.setContentIntent(pendingIntent);

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
notificationManager.notify(NOTIFICATION_ID, builder.build());
}

Cancel Notification

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

Happy Coding :)

like image 127
Venkatesh Selvam Avatar answered Oct 01 '22 00:10

Venkatesh Selvam


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

--> Notification.Builder setOngoing

like image 28
cania Avatar answered Sep 30 '22 22:09

cania


notificationBuilder.setOngoing(true);

not allow to cancel notification by swipe.

like image 5
Abdurahman Popal Avatar answered Oct 01 '22 00:10

Abdurahman Popal