Java Code Examples for android.content.Intent.ACTION_MEDIA_MOUNTED

The following are Jave code examples for showing how to use ACTION_MEDIA_MOUNTED of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: SaveImage2SystemAlbum   File: AlbumManager.java   View Source Code Vote up 6 votes
/**
 * 同步刷新系统相册
 * @param imageUrl
 */
private static void syncAlbum(String imageUrl) {
    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(FileUtils.createFileFrom(imageUrl).getAbsoluteFile());
        scanIntent.setData(contentUri);
        ApplicationProvider.IMPL.getApp().sendBroadcast(scanIntent);
    } else {
        //4.4开始不允许发送"Intent.ACTION_MEDIA_MOUNTED"广播, 否则会出现: Permission Denial: not allowed to send broadcast android.intent.action.MEDIA_MOUNTED from pid=15410, uid=10135
        final Intent intent = new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://" + Environment.getExternalStorageDirectory()));
        ApplicationProvider.IMPL.getApp().sendBroadcast(intent);
    }
}