I have foreground service on an app targeting SDK 26 and therefore there will be a persistent notification as long as the service is up. I know that I can customise this notification using Service.AutomaticForegroundNotification. What I am trying to do is to hide the notification icon in such a way that it will only be visible if the user pulls down the notification bar from top. Other times the icon should not be visible at the status bar on top.
On Android 8.0 and 8.1, I could achieve this by setting notification priority. I set the importance as IMPORTANCE_MIN and it works great, even though it is specifically mentioned not to use it in foreground services. Any idea why there is no error?
But when I tried the same app on an emulator running Android 7.0, the icon still showed up on status bar (unfortunately all my live devices are on 8.0). What could be the way to achieve this on Android 7 and below?
BTW here is the code I used to set notification with no status bar icon for a foreground service:
On Android 8.0 and 8.1, I could achieve this by setting notification priority. I set the importance as IMPORTANCE_MIN and it works great, even though it is specifically mentioned not to use it in foreground services. Any idea why there is no error?
But when I tried the same app on an emulator running Android 7.0, the icon still showed up on status bar (unfortunately all my live devices are on 8.0). What could be the way to achieve this on Android 7 and below?
BTW here is the code I used to set notification with no status bar icon for a foreground service:
B4X:
Sub Service_Create
Dim nb As Notification
nb.Initialize2(nb.IMPORTANCE_MIN)
nb.Vibrate=False
nb.Sound=False
nb.Light=False
nb.Icon="icon"
nb.SetInfo("Test","Testing","")
Service.AutomaticForegroundNotification=nb
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS
End Sub