Android Question Error customsound NB6

Pooya1

Active Member
Licensed User
Hi
I use NB6 class for show notification
There is problem in use customsound

In my manifest
B4X:
'************ Required with GetSafeDirDefaultExternal ***********
AddManifestText(<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="18" />
)
'**************************************

'********************  Required for file provider *************************
AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <external-files-path name="name" path="shared" />
)
'***************************************************************

And my code is :
B4X:
If File.Exists(MyLibrary.Permissions.GetSafeDirDefaultExternal("share"),"notification.mp3") Then
        nb.CustomSound(MyLibrary.CreateFileProviderUri(MyLibrary.Permissions.GetSafeDirDefaultExternal("share"),"notification.mp3"))
    Else
        File.Copy(File.DirAssets,"notification.mp3",MyLibrary.Permissions.GetSafeDirDefaultExternal("share"),"notification.mp3")
        nb.CustomSound(MyLibrary.CreateFileProviderUri(MyLibrary.Permissions.GetSafeDirDefaultExternal("share"),"notification.mp3"))
    End If

But i have error
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at com.poolma.hotel.mylibrary._createfileprovideruri(mylibrary.java:894)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:735)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:360)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at com.poolma.hotel.poolma._notify(poolma.java:122)
at com.poolma.hotel.firebasemessaging._service_create(firebasemessaging.java:370)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:735)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:360)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:260)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at com.poolma.hotel.firebasemessaging.onCreate(firebasemessaging.java:56)
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877)
at android.app.ActivityThread.-wrap4(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Android/data/com.poolma.hotel/files/share/notification.mp3
at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:711)
at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:400)
... 27 more
 

Pooya1

Active Member
Licensed User
Problem was solved
In my resource i add below
<?xml version="1.0" encoding="utf-8"?>
<external-files-path name="name" path="shared" />
but i had used share folder while i define shared folder in resource
 
Upvote 0

Similar Threads

Top