In some of the devices while uploading/adding new image into media are not shown to the custom gallery view. However this does not seem to update until the device reboots. To update your custom gallery with new images, below few lines of code will help you to update gallery. Just call galleryAddPic() method and pass your new image path.
private void galleryAddPic(String mCurrentPhotoPath) {
// media scanner intent
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
// creating new file instance
File f = new File(mCurrentPhotoPath);
Uri contentUri = Uri.fromFile(f);
mediaScanIntent.setData(contentUri);
// broadcast to update device media files
getActivity().sendBroadcast(mediaScanIntent);
}
0 Comment(s)