I am writing an Android app which can take pictures and save them on the SD card. Later, I need to display the pictures in a GridView and the user can select one. This is my code to save pictures:
Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera c) {
currentPictureName = (String) getResources().getText(R.string.username)
+ System.currentTimeMillis() + ".jpg";
FileOutputStream outStream = null;
try {
outStream = new FileOutputStream(sdcardPath + currentPictureName);
outStream.write(data);
outStream.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
mCamera.startPreview();
}
}
However, none of the saved images have thumbnails to show in the GridView. How do I automatically generate thumbnails for all images that I save and add everything to MediaStore so that they can be accessed later?
Found this. This works perfectly fine, all thumbnails are automatically generated