Disable clearing notification for my application

You might want to look into making a notification in the "running" section of the notifications. These notifications aren't cleared when the user clears them.

Use the Notification.FLAG_NO_CLEAR AND Notification.FLAG_ONGOING_EVENT. This should give you the effect you want


Here's a notification that won't allow the user to clear it.

Notification notification = new NotificationCompat.Builder(this)
        .setTicker(r.getString(R.string.app_name))
        .setSmallIcon(R.drawable.ic_launcher)
        .setContentTitle(r.getString(R.string.app_name))
        .setAutoCancel(false)
        .setOngoing(true)
        .build();

The setOngoing(true) call achieves this, and setAutoCancel(false) stops the notification from going away when the user taps the notification.

The notification will be cleared if the application is uninstalled or by calling Cancel or CancelAll: http://developer.android.com/reference/android/app/NotificationManager.html#cancel(int)