I have the requirment in one my activity imageview and button if user click the take picture button.I have to show preview another activity from preview activity user click the button and take the picture and display in the imageview in previous activity I have to open front face camera for capturing开发者_如何学Python user image eg if i am using tablet I have to take my picture can anybody tell how to do? can anybody provide sample code
Thanks
You can start camera and take picture using this code
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, 999);
//this method will be called once user takes the pictur
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == 999)
{
if(data.getExtras() != null)
{
//here is the image from camera
Bitmap bitmap = (Bitmap) data.getExtras().get("data");
}
}
}
That is how you can create an image view and display Bitmap in that ImageView
ImageView imageView = new ImageView(context);
imageView.setImageBitmap(bitmap);
精彩评论