Take Photo And Pass It To Another Activity
I want to create simple app where I can take a photo and pass this photo and after that close camera and pass this photo to another activity. I don't know how can I start. Can you
Solution 1:
To capture image: int CAMERA_REQUEST = 1888;
IntentcameraIntent=newIntent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra("putSomething", true);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
Get image whan photo captured through onActivityResult:
@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
this.photo = (Bitmap) data.getExtras().get("data");
}
}
You can pass photo by converting photo into byte array and pass through intent
ByteArrayOutputStreamstream=newByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.PNG, 90, stream);
byte[] image = stream.toByteArray();
Intentintent=newIntent(this, YourActivity.class);
intent.putExtra("photo", image);
startActivity(intent);
Post a Comment for "Take Photo And Pass It To Another Activity"