Android Question FileProvider problems

imbault

Well-Known Member
Licensed User
Longtime User
Using FileProvider class, I'm unable to send any file : example :

B4X:
    If File.Exists(Starter.SharedFolder,"fullimage.jpg") Then
        File.Copy(Starter.SharedFolder, "fullimage.jpg", Starter.Provider.SharedFolder, "fullimage.jpg")
        
        message.Attachments.Add(Starter.Provider.GetFileUri("fullimage.jpg"))
    '    message.Attachments.Add(File.Combine(Starter.SharedFolder, "fullimage.jpg"))
    End If

    message.Subject="photo"
    message.Body =  "essai de photo"
    Dim in As Intent = message.GetIntent
    in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
    StartActivity(in)

I've got the error :
fileprovider_getfileuri (java line: 86)
java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Android/data/com.pitechnic.smile/files/shared/Riskup.jpg
at android.support.v4.content.FileProvider$SimplePathStrategy.getUriForFile(FileProvider.java:711)
at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:400)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
at com.pitechnic.smile.fileprovider._getfileuri(fileprovider.java:86)
at com.pitechnic.smile.riskanalysis._email_photo(riskanalysis.java:1226)
at com.pitechnic.smile.riskanalysis._photo_click(riskanalysis.java:1488)
at com.pitechnic.smile.riskanalysis$ResumableSub_clv1_ItemLongClick.resume(riskanalysis.java:704)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:190)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.keywords.Common$1.onClick(Common.java:492)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:184)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7073)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
java.lang.IllegalArgumentException: Failed to find configured root that contains /storage/emulated/0/Android/data/com.pitechnic.smile/files/shared/Riskup.jpg
 
Top