Android Question NB6 Notification With CustomSound issue

hanyelmehy

Well-Known Member
Licensed User
Longtime User
i use this code to make Notification With CustomSound
B4X:
Sub Notification_WithCustomSound
    Dim FileName As String = "short.mp3"
    File.Copy(File.DirAssets, FileName, Provider.SharedFolder, FileName)
    Dim in As Intent
    in.Initialize(in.ACTION_VIEW, "")
    Provider.SetFileUriAsIntentData(in, FileName)
    Dim n As NB6
    n.Initialize("custom sound", Application.LabelName, "DEFAULT")
    n.SmallIcon(LoadBitmapResize(File.DirAssets, "smiley.png", 32dip, 32dip, True))
    'disable the default sound
    n.SetDefaults(False, True, True)
    'set custom sound
    n.CustomSound(Provider.GetFileUri(FileName))
    Dim Notification As Notification = n.Build("Notification with custom sound", "...", "", Main)
    Notification.Notify(3)
End Sub
Notification shown but with no sound
other Notifications show correctly
i add FileProvider in Manifest
i use
B4X:
<uses-sdk android:minSdkVersion="19" android:targetSdkVersion="34"/>
 

hanyelmehy

Well-Known Member
Licensed User
Longtime User
Just tried it here on an Android 18 device. Works fine. With targetSdkVersion=34.

Make sure that the device isn't silent and that other notifications do play sound.
Worth testing it with a different package name. This will force the device to treat the notifications channels as new channels.
it work now after making new project,but when change sound file ,it keep playin old file
note :i think issue that we must change channelid if we change sound ,otherwise it well still using old sound
 
Last edited:
Upvote 0
Top