Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: How to create an "Ongoing" notification?

enter image description here

Hello, How do i create the permanent notification like the first one for Battery Indicator?

like image 783
Rohith Nandakumar Avatar asked Apr 17 '11 14:04

Rohith Nandakumar


2 Answers

In case you are using NotificationCompat.Builder , you can use :

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) mBuilder.setOngoing(true); //this will make ongoing notification 
like image 84
Mahmoud Farahat Avatar answered Sep 28 '22 21:09

Mahmoud Farahat


Assign Notification.FLAG_ONGOING_EVENT flag to your Notification.

Sample code:

yourNotification.flags = Notification.FLAG_ONGOING_EVENT; // Notify... 

If you aren't familiar with the Notification API, read Creating Status Bar Notifications on Android developers website.

like image 27
Wroclai Avatar answered Sep 28 '22 21:09

Wroclai