Android Question [solved}Notification with custom sound.


Licensed User
Longtime User
I am trying to update a five year old project to use a Notification with Custom Sound.
I down loaded the example from this forum, changed the custom sound from "Shotgun.mp3", to an mp3 of my choosing, compiled and Success.

I then copied the subs "Notification_WithCustomSound" and "CreateFileProviderUri" to a Service Module in my application I named "Tracker" , as in the code below. I renaming the sub "Notification_WithCustomSound" to Simple_Notification_3.

Sub Simple_Notification_2
    Dim n As NB6
    n.Initialize("default", Application.LabelName, "DEFAULT").AutoCancel(True).SmallIcon(Smiley)
    n.Build("Arriving at", Starter.strBody, "", Main).Notify(2) 'It will be Main (or any other activity) instead of Me if called from a service.
End Sub

Sub Simple_Notification_3
    Dim rp As RuntimePermissions
    Dim folder As String = rp.GetSafeDirDefaultExternal("shared")
    Dim FileName As String = "NOA.mp3"
    'copy the file to the shared folder
    File.Copy(File.DirAssets, FileName, folder, 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, False)
    'set custom sound
    n.CustomSound(CreateFileProviderUri(folder, FileName))
    Dim Notification As Notification = n.Build("Arriving at", Starter.strBody, "", Main)
End Sub

Sub CreateFileProviderUri (Dir As String, FileName As String) As Object
    Dim FileProvider As JavaObject
    Dim context As JavaObject
    Dim f As JavaObject
    f.InitializeNewInstance("", Array(Dir, FileName))
    Return FileProvider.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
End Sub

When I try to call Simple_Notification_3, (BTW, I know it is not a "Simple Notification") the Applications crashes on the final line of the CreateFileProviderUri sub.
If I call Simple_Notification_2, the application run as expected.

Originally, I was using the NB6 Module, but the application crashed when I updated to targetSdkVersion="33"
Changing to the Internal NB6 Library solved this problem but now the problem with Custom Sounds has arisen.

Oh, the joys of trying to update an old project.
Once again, any assistance greatly appreciated.


I am aware of the new Notification requirements for Sdk Version 33 and am presently trying to learn what is required but, I don't think this is the problem here.

Sorry, I forgot to include the Crash report.
** Service (tracker) Start **
tracker_vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv1 (java line: 161)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(
    at b4a.CheckList.tracker._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv1(
    at b4a.CheckList.tracker._simple_notification_3(
    at b4a.CheckList.tracker._gps_locationchanged(
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(
    at anywheresoftware.b4a.BA.raiseEvent(
    at anywheresoftware.b4a.gps.GPS$1.onLocationChanged(
    at android.location.LocationListener.onLocationChanged(
    at android.location.LocationManager$LocationListenerTransport$1.operate(
    at android.location.LocationManager$LocationListenerTransport$1.operate(
    at$$ Source:8)
    at android.os.Handler.handleCallback(
    at android.os.Handler.dispatchMessage(
    at android.os.Looper.loopOnce(
    at android.os.Looper.loop(
    at java.lang.reflect.Method.invoke(Native Method)
Caused by: java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority b4a.CheckList.provider
    at androidx.core.content.FileProvider.getFileProviderPathsMetaData(
    at androidx.core.content.FileProvider.parsePathStrategy(
    at androidx.core.content.FileProvider.getPathStrategy(
    at androidx.core.content.FileProvider.getUriForFile(
    ... 22 more
Last edited:


Licensed User
Longtime User
I simply forgot to update the Manifest.
I have read this post before

but did not read it carefully enough.

Upvote 0