Pratibha Sarode
Pratibha Sarode

Reputation: 1849

Captured image is not get added in gallery in oreo

I am referring this android-image-picker third party library to pick multiple images from gallery and camera. I have downloaded this sample code. I am using Nougat and Oreo. It's working fine in nougat. In Oreo, I observed a problem that, Captured images are not added in gallery instantly as it is showing in all other lower OS. Can anyone suggest me what should I do?

Thanks for help!!

Upvotes: 0

Views: 572

Answers (1)

Rahul Samaddar
Rahul Samaddar

Reputation: 244

After clicking the image send a broadcast with the path of clicked image in order to display the image in gallery.

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

Upvotes: 1

Related Questions