Android Question Show image, now it does not work.

vecino

Well-Known Member
Licensed User
Longtime User
Hello, I use this "sub" to show the image that the user selects from a list.
B4X:
Sub ImgShow( cFile As String )
   If cFile="" Then Return   
   '   
   Dim inttFile As Intent
   Dim cDir As String = cLocalPath
   '
   inttFile.Initialize(inttFile.ACTION_VIEW, "file://" & File.Combine(cDir,cFile))
   inttFile.SetType("image/*")
   '
   StartActivity( inttFile )
End Sub
It works for several years, however now it shows this error and I do not know what it is.
acinfocomercial_mostrar (java line: 857)
android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/conkex.preventa/files/infocomercial/100Euros.jpeg exposed beyond app through Intent.getData()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1799)
at android.net.Uri.checkFileUriExposed(Uri.java:2346)
at android.content.Intent.prepareToLeaveProcess(Intent.java:8970)
at android.content.Intent.prepareToLeaveProcess(Intent.java:8931)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1517)
at android.app.Activity.startActivityForResult(Activity.java:4225)
at android.app.Activity.startActivityForResult(Activity.java:4183)
at android.app.Activity.startActivity(Activity.java:4522)
at android.app.Activity.startActivity(Activity.java:4490)
at anywheresoftware.b4a.keywords.Common.StartActivity(Common.java:848)
at conkex.preventa.acinfocomercial._mostrar(acinfocomercial.java:857)
at conkex.preventa.acinfocomercial._lvfiles_itemclick(acinfocomercial.java:732)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:191)
at anywheresoftware.b4a.BA$1.run(BA.java:330)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:969)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:859)
android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/conkex.preventa/files/infocomercial/100Euros.jpeg exposed beyond app through Intent.getData()
** Activity (acinfocomercial) Pause, UserClosed = true **
** Activity (main) Resume **
I am sorry to bother again with my problems, but I still consider myself quite new and I get stuck with many doubts.
 

Star-Dust

Expert
Licensed User
Longtime User
From SDK23 + you can not share an internal file with an intent without using secure folders.
See this tutorial and this.

If the file is in the root Root (from sdk23 +) you must have runtime permissions. See this.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thanks for the info.
So, should I share my images so that they can be displayed by the default application that is installed on the system?

Is the same system if the files are pdf, txt, png, mp4, etc.?
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Yes
 
Upvote 0
Top