Reputation: 1272
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);
}
Upvotes: 11
Views: 19465
Reputation: 875
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
Upvotes: 27