0

I've written a code that opens a file in another app. For some reason I am getting this error. I've been using two devices; a tablet with 4.2.2 and a phone with 4.4.2.

java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.MEDIA_MOUNTED from pid=26089, uid=10120

My code:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(file.toString()));
    intent.setDataAndType(Uri.parse(file.toString()), file.getMimeType());
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

Also to mention, there's this code, but I am not using it when the error appears. It doesn't work even after I delete this code.

Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri contentUri = Uri.fromFile(file);
            mediaScanIntent.setData(contentUri);
            this.sendBroadcast(mediaScanIntent);
slanecek
  • 808
  • 1
  • 8
  • 24
  • possible duplicate of [Permission Denial: not allowed to send broadcast in android](http://stackoverflow.com/questions/21469431/permission-denial-not-allowed-to-send-broadcast-in-android) – nKn May 01 '14 at 19:46
  • Duplicate issue: http://stackoverflow.com/questions/21469431/permission-denial-not-allowed-to-send-broadcast-in-android – FriendlyMikhail May 01 '14 at 19:48
  • Yes, I've googled it, but there is no solution. – slanecek May 01 '14 at 19:49

0 Answers0