Android Question Notification.sound=false but plays sounds

When using the code below in a forground service the sound does gets played.
However when the GPS data does change then the notification sound get played a lot. But it is set to false...

Tested this on a Samsung A8.
Using B4A 10.70 , targetSdkVersion=26

B4X:
'this is in the Starter module
Sub CreateNotification2 As Notification
    Dim notification As Notification
  
    Globaal.CancelNotification(nid)
      
    notification.Initialize2(notification.IMPORTANCE_LOW)
    notification.Vibrate=False
    notification.Sound=False 'sound is false but get played?!
    notification.Icon = "icon"
    notification.SetInfo("mobile","bv", Main)
    Return notification
End Sub

I'm using a sort of the tracker example.

B4X:
'in Tracker module
Sub TimeTracker_tick 'to keep the app alive we send every 60 seconds an update of the notification when there hasn't been any GPS changes
    If Main.FinishOnResume=False Then
        Dim n As Notification = Starter.CreateNotification2
        n.Notify(Starter.nid)
    End If
End Sub

Sub GPS_LocationChanged (Location1 As Location)
  
    Dim lTime As Long
    TimeTracker.Enabled=False 'stop timer
    'do stuff with GPS data
  
    'notification
    Dim n As Notification = Starter.CreateNotification2
    n.Notify(Starter.nid)
  
    TimeTracker.Enabled=True 'start timer
End Sub
 
Looks like it gets overruled by the settings under "App info" and then "Notifications".
There it is possible to allow sound per notification. Is it possible to block or overrule this?
 
Upvote 0
I've changed the notification to NB6. Works like a charm.
But if I go too "App info" and then "App settings - Notifications" you'll get an overview of notifications and their categories. There I can change the "Notification style" from "Silent" to "Sound" (or worse "Sound and pop-up").

When I do so the notification plays a sound even if I set my notification to "False" for sounds.

Can I overrule/prevent this?

Changed the code to

B4X:
Sub CreateNotification2 As Notification
    Dim notification As NB6
'   ToastMessageShow("Createnoti",True)

    notification.Initialize(nid , Application.LabelName, "LOW") 'opletten met het wijzigen van de channel(s)
    notification.SmallIcon(LoadBitmapResize(File.DirAssets, "smartphonelm2.png", 24dip, 24dip, False))
    notification.SetDefaults(False,False,False)
    Return notification.Build("App name","Company name", "", Main)
End Sub

Sub GPS_LocationChanged (Location1 As Location)
   
    Dim lTime As Long
    TimeTracker.Enabled=False
'do GPS stuff

    Dim n As Notification = Starter.CreateNotification2
    n.Notify(Starter.nid)
TimeTracker.Enabled=true
End Sub

gets called by
B4X:
'Tracker service module
Service.StartForeground(Starter.nid, Starter.CreateNotification2) 'Starter.nid is a fixed number 99
 
Upvote 0
Top