As update and completion of https://www.b4x.com/android/forum/threads/background-location-tracking.50246/page-4#post-684135
I'll like to play a custom sound on notification so i made a little change based on https://www.b4x.com/android/forum/t...e-for-local-or-scheduled-notifications.54940/
Unfortunately i hear only the default notification sound. In post 54940 i can read

Furthermore when i install the app on the phone the first time appears correctly a request to use gps location, but for notification the request for allow or not the request appears only first time that there is a notification, but if the smartphone it's not at hand i don't receive any notification except the one 'do you want to allow notifications'?
So it's possible to request directly at installation 'do you want to allow notifications'? changing/adding a row somewhere, my be in Project Attributes?
I'll like to play a custom sound on notification so i made a little change based on https://www.b4x.com/android/forum/t...e-for-local-or-scheduled-notifications.54940/
B4X:
Sub LocManager_LocationChanged (Location1 As Location)
'Check position
p1.Initialize2("+42.0559340","+13.9242163")
p3.Initialize2(Location1.Latitude,Location1.Longitude)
Dim Distance As Float = p1.DistanceTo(p3)
'Log("Distance is "&Distance&" meters")
If Distance < 1000 Then
label4.Text=NumberFormat(Distance,2,2) & " metri"
Else
label4.Text="Too far..."
End If
ControllaPosizione(Distance)
End Sub
Sub ControllaPosizione(distanza As Float)
If distanza<=20
'Sending notification
App.RegisterUserNotifications(True, True, True)
Dim n As Notification
n.Initialize(DateTime.Now)
Dim no As NativeObject = n
n.PlaySound = True
n.AlertBody = "My messagei."
n.Register
If App.OSVersion >= 8.2 Then
no.SetField("alertTitle", "Check point")
'Custom sound
no.SetField("soundName", "ring2.wav")
End If
MostraTesto1.RootPanel.LoadLayout("ShowInfo")
NavControl.ShowPage(MostraTesto1)
myPhone.Vibrate
mp1.Initialize(File.DirAssets,"ring.mp3","MPlayer")
mp1.play
distanza=0
End If
End Sub
but i don't understand where i have to move/put the right codeYou should run this code before you register the notification (the code itself is correct).
Furthermore when i install the app on the phone the first time appears correctly a request to use gps location, but for notification the request for allow or not the request appears only first time that there is a notification, but if the smartphone it's not at hand i don't receive any notification except the one 'do you want to allow notifications'?
So it's possible to request directly at installation 'do you want to allow notifications'? changing/adding a row somewhere, my be in Project Attributes?