Android Question exposed beyond app through ClipData [solved]

Didier9

Well-Known Member
Licensed User
Longtime User
Getting an error trying to open an email intent with a file attached:
B4X:
Try
    ei.To.Add( email )
    ei.Body = Starter.CaptureFileName & " is attached."
    ei.Subject = Starter.CaptureFileName
    ei.Attachments.Add( File.Combine( Starter.AppFolder, Starter.CaptureFileName ))
    StartActivity( ei.GetIntent )
Catch
    ToastMessageShow( "Mail app failed", True )
End Try
B4X:
android.os.FileUriExposedException: file:///storage/emulated/0/xxxxxxxxxxxxxxx.zip exposed beyond app through ClipData.Item.getUri()
    at android.os.StrictMode.onFileUriExposed(StrictMode.java:2083)
    at android.net.Uri.checkFileUriExposed(Uri.java:2388)
    at android.content.ClipData.prepareToLeaveProcess(ClipData.java:977)
    at android.content.Intent.prepareToLeaveProcess(Intent.java:10759)
    at android.content.Intent.prepareToLeaveProcess(Intent.java:10744)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1710)
    at android.app.Activity.startActivityForResult(Activity.java:5192)
    at android.app.Activity.startActivityForResult(Activity.java:5150)
    at android.app.Activity.startActivity(Activity.java:5521)
    at android.app.Activity.startActivity(Activity.java:5489)
    at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:859)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA$1.run(BA.java:335)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7356)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
That was working under Android 9 I believe. Should I add some missing permission?
 
Last edited:

Didier9

Well-Known Member
Licensed User
Longtime User
Thank you Erel, as always to the rescue... :)

It actually stopped working when I upgraded the TargetSDKVersion to 26, it was working on the Android 9 phone because the TargetSDKVersion was set to a lower value..
 
Upvote 0
Top