0

This doesn't throw FileUriExposedException:

Intent mediaScanIntent = new Intent( Intent.ACTION_MEDIA_SCANNER_SCAN_FILE );
mediaScanIntent.setData( Uri.fromFile( new File( path ) ) );
context.sendBroadcast( mediaScanIntent );

This does:

Intent intent = new Intent();
intent.setAction( Intent.ACTION_VIEW );
intent.setDataAndType( Uri.fromFile( new File( path ) ), "image/*" );
context.startActivity( Intent.createChooser( intent, "View image" ) );

I was expecting a FileUriExposedException on the first one, as well?

yasirkula
  • 591
  • 2
  • 8
  • 47
  • You have to use FileProvider If your targetSdkVersion >= 24 just refer this answer https://stackoverflow.com/a/38858040/5514839 – Rahul Goswami Oct 09 '19 at 10:06
  • @RahulGoswami Yes, the second code snippet does throw an exception if I don't use a FileProvider. But the first code snippet doesn't throw an exception if I don't use a FileProvider. That's what I'm trying to figure out: why doesn't the first code snippet throw an exception when targetSdkVersion >= 24? – yasirkula Oct 09 '19 at 16:30

0 Answers0