Hi
Trying to send an email (with attachment) within my app. Was working fine till some recent android change.
But now I have an error. It occurs on this line: StartActivity (FinalEmailIntent)
This is the error log in debug mode:
Send Att: /storage/emulated/0/scripts/EmailedBox.f3a
Error occurred on line: 345 (LoadTheBox)
android.os.FileUriExposedException: file:///storage/emulated/0/scripts/EmailedBox.f3a exposed beyond app through ClipData.Item.getUri()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1958)
at android.net.Uri.checkFileUriExposed(Uri.java:2356)
at android.content.ClipData.prepareToLeaveProcess(ClipData.java:944)
at android.content.Intent.prepareToLeaveProcess(Intent.java:10494)
at android.content.Intent.prepareToLeaveProcess(Intent.java:10479)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1617)
at android.app.Activity.startActivityForResult(Activity.java:4564)
at android.app.Activity.startActivityForResult(Activity.java:4522)
at android.app.Activity.startActivity(Activity.java:4883)
at android.app.Activity.startActivity(Activity.java:4851)
at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:848)
at f3azone.pro.reader.loadthebox._sendemail(loadthebox.java:747)
at f3azone.pro.reader.loadthebox$ResumableSub_Button3_Click.resume(loadthebox.java:617)
at f3azone.pro.reader.loadthebox._button3_click(loadthebox.java:546)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
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.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6897)
at android.widget.TextView.performClick(TextView.java:12693)
at android.view.View$PerformClick.run(View.java:26100)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6942)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Any help greatly appreciated.
Trying to send an email (with attachment) within my app. Was working fine till some recent android change.
But now I have an error. It occurs on this line: StartActivity (FinalEmailIntent)
B4X:
Sub SendEmail (SendTo As String, SendBody As String, SendSub As String, SendAtt As String)
Dim FinalEmailIntent As Intent, sPackageName As String
LogColor("Send Att: "&SendAtt,Colors.Red)
If SendAtt = "" Then ' Use new method - will not work with attachments
File.Copy(path1, GlobFileName, Starter.shared, GlobFileName)
FinalEmailIntent.Initialize("android.intent.action.SENDTO", "mailto:" & SendTo)
FinalEmailIntent.putExtra("android.intent.extra.SUBJECT", SendSub)
FinalEmailIntent.putExtra("android.intent.extra.TEXT", SendBody)
FinalEmailIntent.PutExtra("android.intent.extra.STREAM", CreateFileProviderUri(Starter.shared, GlobFileName))
FinalEmailIntent.Flags = 1
FinalEmailIntent.WrapAsIntentChooser("Send E-mail")
Else ' Make our own list of email apps
sPackageName = GetEmailPackage
If sPackageName = "/cancel/" Then Return
If sPackageName = "" Then
Msgbox ("Unable to send email.", "")
Return
End If
Dim MyEmail As Email
MyEmail.To.Add (SendTo)
MyEmail.Body = SendBody
MyEmail.Subject = SendSub
MyEmail.Attachments.Add(SendAtt)
FinalEmailIntent = MyEmail.GetIntent
FinalEmailIntent.SetComponent (sPackageName)
End If
StartActivity (FinalEmailIntent)
End Sub
This is the error log in debug mode:
Send Att: /storage/emulated/0/scripts/EmailedBox.f3a
Error occurred on line: 345 (LoadTheBox)
android.os.FileUriExposedException: file:///storage/emulated/0/scripts/EmailedBox.f3a exposed beyond app through ClipData.Item.getUri()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1958)
at android.net.Uri.checkFileUriExposed(Uri.java:2356)
at android.content.ClipData.prepareToLeaveProcess(ClipData.java:944)
at android.content.Intent.prepareToLeaveProcess(Intent.java:10494)
at android.content.Intent.prepareToLeaveProcess(Intent.java:10479)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1617)
at android.app.Activity.startActivityForResult(Activity.java:4564)
at android.app.Activity.startActivityForResult(Activity.java:4522)
at android.app.Activity.startActivity(Activity.java:4883)
at android.app.Activity.startActivity(Activity.java:4851)
at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:848)
at f3azone.pro.reader.loadthebox._sendemail(loadthebox.java:747)
at f3azone.pro.reader.loadthebox$ResumableSub_Button3_Click.resume(loadthebox.java:617)
at f3azone.pro.reader.loadthebox._button3_click(loadthebox.java:546)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
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.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:6897)
at android.widget.TextView.performClick(TextView.java:12693)
at android.view.View$PerformClick.run(View.java:26100)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6942)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Any help greatly appreciated.