I have created a notification in my "onCreate" activity method.
Everything runs smoothly, only that you can close it by pressing the "delete all" button.
How do I make this notification perma? as in it should just be more of an info rather than a notification..
This is my current code:
private void showNotification() {
// TODO Auto-generated method stub
nMN = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification n = new Notification.Builder(this)
.setContentTitle("Whip And Weep")
.setContentText("Whip is On!")
.setSmallIcon(R.drawable.ic_launcher)
.build();
nMN.notify(NOTIFICATION_ID, n);
}
A permanent notification is a (usually silent) alert displayed by certain apps on your Android smartphone or tablet at all times to let you know they're running in the background.
When an app needs to be absolutely sure it won't be cleared from RAM by Android's memory management system, it posts a persistent, ongoing notification. Another time you'll encounter non-removable alerts is when your phone or carrier really wants you to do something, like apply an update.
On your notification builder use .setOngoing(true)
. This will prevent the user from removing your notification.
See the Notification Builder Documentation for more info: http://developer.android.com/reference/android/app/Notification.Builder.html#setOngoing%28boolean%29
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With