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 give me some examples how can I do that in easy way?
Asked
Active
Viewed 2,291 times
-1
-
use this link http://stackoverflow.com/questions/15115498/let-user-crop-image/15263571#15263571 – Zala Janaksinh Jun 26 '13 at 08:55
-
save photo on sdcard and then pass the address of photo to another activity,then in another activity load photo from sdcard! and there is dozen ways like this to achieve what you want,google it! – Saeed-rz Jun 26 '13 at 09:23
1 Answers
0
To capture image: int CAMERA_REQUEST = 1888;
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra("putSomething", true);
startActivityForResult(cameraIntent, CAMERA_REQUEST);
Get image whan photo captured through onActivityResult:
@Override
protected 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
ByteArrayOutputStream stream = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.PNG, 90, stream);
byte[] image = stream.toByteArray();
Intent intent = new Intent(this, YourActivity.class);
intent.putExtra("photo", image);
startActivity(intent);

Muhammad Aamir Ali
- 20,419
- 10
- 66
- 57
-
4Passing big data through intent is not a good practice. It will cause exceptions or slow down your application. – dumbfingers Jun 26 '13 at 09:08
-
you can use Bundle Bundle bundle = new Bundle(); //Add your data from getFactualResults method to bundle bundle.putString("VENUE_NAME", venueName); //Add the bundle to the intent i.putExtras(bundle); – Yogesh Tatwal Jun 26 '13 at 09:29
-
Bundle bundle = getIntent().getExtras(); //Extract the data… String venName = bundle.getString("VENUE_NAME"); – Yogesh Tatwal Jun 26 '13 at 09:31