PictureCallback myPictureCallback_JPG = new PictureCallback(){
@Override
public void onPictureTaken(byte[] arg0, Camera arg1) {
// TODO Auto-generated method stub
/*Bitmap bitmapPicture
= BitmapFactory.decodeByteArray(arg0, 0, arg0.length); */
Uri uriTarget = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, new ContentValues());
OutputStream imageFileOS;
try {
imageFileOS = getContentResolver().openOutputStream(uriTarget);
imageFileOS.write(arg0);
imageFileOS.flush();
imageFileOS.close();
Toast.makeText(AndroidCamera.this,
"Image saved: " + uriTarget.toString(),
Toast.LENGTH_LONG).show();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
camera.startPreview();
}};
- Download the project
next:
- Start Camera auto-focusing, autoFocus()

9 comments:
I appreciate your nice work.
i test it in the phone with android 2.2 but i don't see the pictures saved
what's wrong?
my phone is a HTC inspire 4g
hello inotfortoni,
Try the proect: Download the project.
Tested on Nexus One.
Thank you very much.... Great tutorial... I searched so many sites for camera application.. am satisfied with your tutorial.. I tried your code and its working..
Thanks again...
Hi
Excellent tutorial, thanks for sharing your knowledge, I have a
query ... I add an opaque background and an image on the view (macro)...but when I
take a photo not recorded...this is the image http://dl.dropbox.com/u/46059390/fotos/imageOverlayAndroid.JPG
the upper image is in main.xml and the other in the same control.xml ...have any idea how to do this
App crashes when clicking the button, unless you add
to the manifest.
Great tutorial!
how to show the image capture in imageview ?
hello widi,
In the code, u know where the image saved. Such that you can load the image from it. Refer to Scale bitmap Efficiently.
Post a Comment