2

I save an image under cache at runtime. Then I want to read and show it with system image viewer.

I use below code for under api level 24:

File f = new File(getApplicationContext().getCacheDir(), "sample.png"); 

Intent intent = new Intent(Intent.ACTION_VIEW);               
Uri uri = Uri.fromFile(f);
imgView.setImageURI(uri); // It works 
intent.setDataAndType(uri,"image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(intent); // It shows an blank image

EDIT Upper code works for /sdcard/test.jpg. Can I use app cache folder with gallery?

zakjma
  • 2,030
  • 12
  • 40
  • 81

0 Answers0