This video tutorial describes how to capture an image using device camera.
To captured an Image using device camera use to following code:-
private static int REQ_CAMERA = 1001;
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(takePictureIntent, REQ_CAMERA);
}
To get the thumbnail of captured image override the onActivityResult() method of an activity class like this:-
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQ_CAMERA && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
// Now add this bitmap in the image view
}
}
0 Comment(s)