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);