Hi I'm inserting an image from the camera (Taking a picture) into the MediaStore.Images.Media datastore.
Does anyone know how I can go about displaying the last picture taken?
I used Uri image = ContentUris.withAppendedId(externalContentUri, 45); to display an image from the datastore but obviously 45 is not the correct image.
I try to pass the information from the previous activity (Camera) to the display activity but I'm assuming due to the photo call back being its own thread the value never gets set. Photo code is as follows
Camera.PictureCallback photoCallback = new Camera.PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
// TODO Auto-generated method stub
FileOutputStream fos;
try
{
Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length);
fileUrl = MediaStore.Images.Media.insertImage(getContentResolver(), bm, "LastTaken", "Picture");
if(fileUrl == null)
{
Log.d("Still", "Image Insert Failed");
return;
} else
{
picUri = Uri.parse(fileUrl);
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, picUri));
}
}
catch(Exception e)
{
Log.d("Picture", "Error Picture: ", e);
}
camera.startPreview();
}
};