Android Question NB6 Sound Problem

fishwolf

Well-Known Member
Licensed User
Longtime User
I have integrated nb6 big picture with sound into FirebaseMessaging Receiver.

i have this error when is into receiver, into activity work fine

Suggestions?

FirebaseMessagging:
Sub ShowNotification2
Dim n As NB6
Dim NotifSound As String
Dim rp As RuntimePermissions
Dim Folder As String = rp.GetSafeDirDefaultExternal("shared")   
    
    
    n.Initialize("default", Application.LabelName, "HIGH").SmallIcon(NotifIcon)
        
    n.BigPictureStyle(NotifImage.Resize(256dip, 256dip, True), NotifImage, NotifTitle, NotifBody)
    n.Color(0xFF00AEFF)
    
    NotifSound = "notification.mp3"
    'copy the file to the shared folder
    File.Copy(File.DirAssets, NotifSound, Folder, NotifSound)
    'disable the default sound
    n.SetDefaults(False, True, True)
    
    'set custom sound
    'n.CustomSound(CreateFileProviderUri(Folder, NotifSound))
    
    Dim Obj As Object = CreateFileProviderUri(Folder, NotifSound)
    n.CustomSound(Obj)
    
    n.Build(NotifTitle, NotifBody, "tag", NotifActivity).Notify(1)
    
End Sub

Sub CreateFileProviderUri (Dir As String, FileName As String) As Object
Dim ObjFileProvider As JavaObject
Dim ObjContext As JavaObject
Dim ObjFile As JavaObject
    
    Log ("Dir=" & Dir)
    Log ("FileName=" & FileName)
    
    ObjContext.InitializeContext
    ObjFileProvider.InitializeStatic("android.support.v4.content.FileProvider")
    
    ObjFile.InitializeNewInstance("java.io.File", Array(Dir, FileName))
    Return ObjFileProvider.RunMethod("getUriForFile", Array(ObjContext, Application.PackageName & ".provider", ObjFile))
End Sub

Error:
*** Receiver (firebasemessaging) Receive  ***
Message arrived
Dir=/storage/emulated/0/Android/data/myapp/files/shared
FileName=notification.mp3
firebasemessaging_createfileprovideruri (java line: 91)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at myapp.firebasemessaging._createfileprovideruri(firebasemessaging.java:91)
    at myapp.firebasemessaging._shownotification2(firebasemessaging.java:291)
    at myapp.firebasemessaging._shownotification(firebasemessaging.java:237)
    at myapp.firebasemessaging._fm_messagearrived(firebasemessaging.java:131)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA$1.run(BA.java:360)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:8167)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Caused by: java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority myapp.provider
    at androidx.core.content.FileProvider.getFileProviderPathsMetaData(FileProvider.java:664)
    at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:695)
    at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:645)
    at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:449)
    ... 16 more
firebasemessaging_createfileprovideruri (java line: 91)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at myapp.firebasemessaging._createfileprovideruri(firebasemessaging.java:91)
    at myapp.firebasemessaging._shownotification2(firebasemessaging.java:291)
    at myapp.firebasemessaging._shownotification(firebasemessaging.java:237)
    at myapp.firebasemessaging._fm_messagearrived(firebasemessaging.java:131)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
    at anywheresoftware.b4a.BA$1.run(BA.java:360)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:8167)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
Caused by: java.lang.IllegalArgumentException: Couldn't find meta-data for provider with authority myapp.provider
    at androidx.core.content.FileProvider.getFileProviderPathsMetaData(FileProvider.java:664)
    at androidx.core.content.FileProvider.parsePathStrategy(FileProvider.java:695)
    at androidx.core.content.FileProvider.getPathStrategy(FileProvider.java:645)
    at androidx.core.content.FileProvider.getUriForFile(FileProvider.java:449)
    ... 16 more
 
Top