Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to update/refresh device gallery after adding new images

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 558
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: