Android mediaScannerConnection.scanFile failing to refresh images in gallery

好久不见. 提交于 2019-12-06 04:19:51
Android2390

i was having mixed results with MediaScannerConnection so i used the sendBroadcast method instead. I do not know if the sendBroadcast method is not standard/should not be used but it works for me.

public void galleryAddPic(File currentPhotoPath) {  
    Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
    Uri contentUri = Uri.fromFile(currentPhotoPath);
    mediaScanIntent.setData(contentUri);
    this.sendBroadcast(mediaScanIntent);
}

Also regarding the MediaScannerConnection : https://stackoverflow.com/a/4825615/1497188

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!