java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.MEDIA_MOUNTED on KitKat only
It seems that google is trying to prevent this from KITKAT.
Looking at core/rest/AndroidManifest.xml you will notice that broadcast android.intent.action.MEDIA_MOUNTED
is protected now. Which means it is a broadcast that only the system can send.
<protected-broadcast android:name="android.intent.action.MEDIA_MOUNTED" />
The following should work for all versions:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
final Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
final Uri contentUri = Uri.fromFile(outputFile);
scanIntent.setData(contentUri);
sendBroadcast(scanIntent);
} else {
final Intent intent = new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()));
sendBroadcast(intent);
}
If the above is not working try the following:
According to this post you need another way to fix it.
Like using MediaScannerConnection
or ACTION_MEDIA_SCANNER_SCAN_FILE
.
MediaScannerConnection.scanFile(this, new String[] {
file.getAbsolutePath()},
null, new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri)
{
}
});
Update APP automatically without user interaction facing issue== Permission Denial: not allowed to send broadcast android.intent.action.PACKAGE_ADDED
The error message you are getting pretty much tells you what the problem is. You have requested that the package installer notify you on completion by sending a broacast Intent
with ACTION = android.intent.action.PACKAGE_ADDED
. This broadcast Intent
can only be sent by the Android framework. Regular apps cannot send this broadcast Intent
.
You should use an explicit Intent
, where you specify the component (package name and class name) for this purpose. You can have the package installer launch an Activity
or a BroadcastReceiver
for this purpose.
NOTE: Your app must be device owner to be able to do this without user interaction.
Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE
For little info:
Use this Permission first..
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
further info: Just check this conversation
Related Topics
Enable C++11 Support on Android
Obtain Root Access via Su on the Android Emulator
Change Background Popupmenu in Android
Android - Textview Change Color on Changing of State
How to Read the Sd Card Id Number
Play Youtube HTML5 Embedded Video in Android Webview
Android How to Identify Item in Listview with Checkbox
How to Use Std::Stoul and Std::Stoull in Android
Build Android Release APK on Phonegap 3.X Cli
Signing an APK with an Upload Key Provided by Google Play
Permission Denial: Not Allowed to Send Broadcast in Android
Java.Lang.Nosuchmethoderror: No Static Method Setonapplywindowinsetslistener
Android Add Image to Webview from a Drawable
CSS Media Queries on Nexus 7, Display Resolution Not Working in Code