Android : Adding image to gallery in Android

on Thursday, September 11, 2014


I have an app which does two things :



  • it captures photo by camera app and saves it to gallery - and this works

  • generates .gif out of images and saves it in ExternalStoragePublicDirectory - and this doesn't work


This is the method I am using to add file to gallery :



public static void galleryAddPic(Context context, String currentPhotoPath) {
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
File f = new File(currentPhotoPath);
Uri contentUri = Uri.fromFile(f);
mediaScanIntent.setData(contentUri);
context.sendBroadcast(mediaScanIntent);
}


I have read somewhere that this doesn't work on Android Api 19, can anybody confirm? Is there any better solution for adding picture to gallery than my above method? Cheers


0 comments:

Post a Comment