Android - Take a photo, save it in app drawables and display it in an ImageButton
Posted
by
Andres7X
on Stack Overflow
See other posts from Stack Overflow
or by Andres7X
Published on 2012-11-20T22:46:05Z
Indexed on
2012/11/20
23:00 UTC
Read the original article
Hit count: 197
I have an Android app with an ImageButton. When user clicks on it, intent launches to show camera activity. When user capture the image, I'd like to save it in drawable folder of the app and display it in the same ImageButton clicked by the user, replacing the previous drawable image. I used the activity posted here: Capture Image from Camera and Display in Activity
...but when I capture an image, activity doesn't return to activity which contains ImageButton.
Edit code is:
public void manage_shop() { static final int CAMERA_REQUEST = 1888; [...] ImageView photo = (ImageView)findViewById(R.id.getimg); photo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent camera = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(camera, CAMERA_REQUEST); } }); [...] }
And onActivityResult():
protected void onActivityResult(int requestCode, int resultCode, Intent data) { ImageButton getimage = (ImageButton)findViewById(R.id.getimg); if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) { Bitmap getphoto = (Bitmap) data.getExtras().get("data"); getimage.setImageBitmap(getphoto); } }
How can I also store the captured image in drawable folder?
© Stack Overflow or respective owner