0

So i try to open a PNG File on the system using the Gallery, but for some reason I always get an ActivityNotFoundException saying the following :

No Activity found to handle Intent { act=android.intent.action.VIEW dat=context://storage/emulated/0/Android/data/com.myapp/files/MyApp/1533800534172image001.png typ=image/* }

My code looks like this :

val intent = Intent()
intent.action = Intent.ACTION_VIEW
intent.setDataAndType(uri,"image/*")
context.startActivity(intent)
T.Furholzer
  • 199
  • 1
  • 8

1 Answers1

0

I think the problem is on your variable uri. it should be like:

uri = Uri.parse("file://" + "/sdcard/path-to-your-file.png")
chiappins
  • 202
  • 3
  • 16
  • i have tried replacing "context://" with "file://" which leads to a android.os.FileUriExposedException – T.Furholzer Aug 09 '18 at 08:03
  • yes here can find the right way to avoid this exception: https://stackoverflow.com/questions/38200282/android-os-fileuriexposedexception-file-storage-emulated-0-test-txt-exposed – chiappins Aug 09 '18 at 08:08