Display last picture
Posted
by steve
on Stack Overflow
See other posts from Stack Overflow
or by steve
Published on 2010-03-31T09:31:09Z
Indexed on
2010/04/01
0:33 UTC
Read the original article
Hit count: 383
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();
}
};
© Stack Overflow or respective owner