Android Question android.media.action.IMAGE_CAPTURE and targetSdkVersion="26"

Semen Matusovskiy

Well-Known Member
Licensed User
Hi, guys --

Just found Erel's CameraIntent - https://www.b4x.com/android/forum/threads/intent-based-camera.69215/

Original code works in Oreo emulator. But if to change targetSDKVersion to 26, appears
Code: Copy
(FileUriExposedException) android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/b4a.example/files/tempimage.jpg exposed beyond app through ClipData.Item.getUri()

Is it possible to fix a problem somehow ?
 
Last edited:
Upvote 0
Great. Many thanx. Works fine under Oreo. But now there are problems in old Android releases.
https://developer.android.com/reference/android/support/v4/content/FileProvider.html talks - added in version 22.1.0
As I understand, it's necessary to use previous code for SDK < 23. Correct ?

And another question. The emulator rotates a photo. Meanwhile on native smartphones I don't see similar trouble. This is emulator's bug or it's necessary to check something ?
 
Upvote 0
New release doesn't work on my Samsung S4 (Android 4.4) and API 19 emulator (Unfortunately, Camera has stopped). Probably a problem not in FileProvider
Meanwhile, works in API 21 emulator
 
Last edited:
Upvote 0
Erel --
Like I wrote before, I tested on physical smartphone also (Samsung Galaxy S4 with Android 4.4)
Old release works, new release gives an error. But the error is inside Camera application, so there is no log.

Probably, old applications are not "FileProvider"-ready.
 
Upvote 0
Thanx, Erel. I did exactly so. The difference in one fragment only. Instead of
Code: Copy
 i.PutExtra("output", CreateFileProviderUri(imageFolder, tempImageFile)) 'the image will be saved to this path
shoud be
Code: Copy
 If SdkVersion >= 23 Then
        i.PutExtra("output", CreateFileProviderUri(imageFolder, tempImageFile)) 'the image will be saved to this path
Else
        uri.Parse("file://" & File.Combine(imageFolder, tempImageFile))
        i.PutExtra("output", uri) 'the image will be saved to this path
End If
 
Upvote 0

Similar Threads

Back
Top