android camera example
How to open Camera in android example
private static final int CAMERA_REQUEST = 1888;
private ImageView imageView;
this.imageView = (ImageView)this.findViewById(R.id.ImageView1);
ImageButton photoButton = (ImageButton) this.findViewById(R.id.imageButton1);
photoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
}
private static final int CAMERA_REQUEST = 1888;
private ImageView imageView;
this.imageView = (ImageView)this.findViewById(R.id.ImageView1);
ImageButton photoButton = (ImageButton) this.findViewById(R.id.imageButton1);
photoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
}
মন্তব্যসমূহ
একটি মন্তব্য পোস্ট করুন