Usually in our project, may encounter write local files, most commonly used is the picture file, after this need to notify the system to rescan the SD card,
The scan is performed before Android4.4 to send a broadcast notification with an ACTION of "intent.action_media_mounted". As follows:
this. Sendbroadcast (new Intent (intent.action_media_mounted, Uri.parse ("file://" + Environment.getexternalstoragedirectory ())));
in Android4.4, however, the following exception is thrown:
W/activitymanager (498): Permission Denial:not allowed to send broadcast Android.intent.action.MEDIA_MOUNTED from pid=22 uid=20016,
That's because Android4.4 restricts system applications from using the broadcast notification system to scan the SD card.
How to resolve:
Use Mediascannerconnection to perform a scan of a specific file or folder.
Mediascannerconnection.scanfile (Thisnewnullnull);
Reprint: http://blog.csdn.net/sgz_china/article/details/24657709