Do you know which method I am supposed to use to create a permanent Notification using NotificationChannel in Android Pie? More precisely, a notification that the user cant remove.
Asked
Active
Viewed 731 times
-1
-
What do you mean "permanent Notification" ? what did you tried? – Vadim Eksler Mar 14 '19 at 07:51
-
A notification that the user cant remove (I edited the question) – Bazouk55555 Mar 14 '19 at 07:53
-
You make notification in service? – Vadim Eksler Mar 14 '19 at 07:57
-
start a foreground service – Samuel Robert Mar 14 '19 at 07:58
-
Yes it has been created in a service. – Bazouk55555 Mar 14 '19 at 07:58
-
imho there is no option like you want https://developer.android.com/reference/android/app/NotificationChannel.html you can make it via NotificationCompat.Builder or via notification.flags from Notification class – Vadim Eksler Mar 14 '19 at 08:08
-
1Also when you call notification via `startForeground(SERVICE_ID, notification);` user cant remove it if you don't call `stopForeground(true);` and not changed `FLAG_AUTO_CANCEL` of notification. – Vadim Eksler Mar 14 '19 at 08:19
-
Ha ok! THank you for your answers – Bazouk55555 Mar 14 '19 at 08:20
1 Answers
2
If I understand correctly your question than your permanent notification is called ongoing notification.
You can use
setOngoing(true)
for your
NotificationCompat.Builder
However this question seems to be duplicated: please see more here:

Krisztián Vizsy
- 31
- 4
-
1No because I am talking about NotificationCHannel which is not the case in the question you show – Bazouk55555 Mar 14 '19 at 07:59
-
1Notification Channels are created before you send notifications via that channel, for that sending you probably still would use NotificationCompat where you can use setOngoing. Or you mean you would like all notifications of a channel to be ongoing? I am not sure if that is possible with Android SDK As far as I know you have to set it individually for each notifications. – Krisztián Vizsy Mar 14 '19 at 08:06
-