Android Question Weird error

imbault

Well-Known Member
Licensed User
Longtime User
Hi,
I take a Snapshot, then I want to send the picture, error!

android.os.FileUriExposedException: file:///data/user/0/b4a.example.panel8/files/fullimage.jpg exposed beyond app through ClipData.Item.getUri()
...
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Here is the code :

B4X:
Sub btnSave_Click
    Dim x As B4XView = Panel1
    Dim b As Bitmap = x.Snapshot

    If b.IsInitialized = False Then Return

    Dim out As OutputStream
    out = File.OpenOutput(File.DirInternal, "fullimage.jpg", False) 
    b.WriteToStream(out, 100, "JPEG")
    
    out.Close
    email_photo

End Sub

Sub email_photo
    Dim message As Email
    message.To.Add("[email protected]")
    If File.Exists(File.DirInternal,"fullimage.jpg") Then
        message.Attachments.Add(File.Combine(File.DirInternal, "fullimage.jpg"))
    End If

    message.Subject="photo"
    message.Body =  "essai de photo"
    StartActivity(message.GetIntent)

End Sub
 

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

imbault

Well-Known Member
Licensed User
Longtime User
Hi Don,

But all seems correct:

Manifest :
AddManifestText(
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="26"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.DarkTheme)

AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)


Libs:

upload_2018-12-3_7-51-33.png



Here is the project :
 

Attachments

  • mosaic.zip
    27.4 KB · Views: 230
Upvote 0
Top