Android Question Notification sound

fishwolf

Well-Known Member
Licensed User
Longtime User
I have problem with app sound when arrived a push and show the notification
The sound is not always played, one time yes, one time no, ecc,ecc.

Why?

Thanks

B4X:
sub Process_Globals
Private fm As FirebaseMessaging
Dim NotifSound As SoundPool
Dim NotifID As Int
End Sub

Sub Service_Create
    fm.Initialize("fm")
    
    NotifSound.Initialize(2)
    NotifID = NotifSound.Load(File.DirAssets, "notification.ogg")
    
End Sub


Sub fm_MessageArrived (Message As RemoteMessage)
Dim n As Notification

    n.Initialize
    
    n.Icon = "notification"
    n.Sound = False
    n.Vibrate = False
    n.Light = False
    n.OnGoingEvent = False
    n.AutoCancel = True
    
    n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Message.GetData.Get("activity"))
        
    n.Notify(1)
    
    NotifSound.Play(NotifID, 1, 1, 1, 0, 1)
    
end sub
 

fishwolf

Well-Known Member
Licensed User
Longtime User
Which copy?
Copy sound file to share folder.
B4X:
Dim folder As String = rp.GetSafeDirDefaultExternal("shared")
    Dim FileName As String = "shotgun.mp3"
    'copy the file to the shared folder
    File.Copy(File.DirAssets, FileName, folder, FileName)
n.CustomSound(CreateFileProviderUri(folder, FileName))
 
Upvote 0
Top