I need to take a picture with the camera
, save the picture, show in ImageView
and when I click the Imageview
show in fullscreen mode .
In the future will need to send the picture to the internet
.
This is what I've done :
public void captureImage(View v) {
Intent camera_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camera_intent, CAMERA_PIC_REQUEST);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
imgView = (ImageView) findViewById(R.id.formRegister_picture);
imgView.setScaleType(ImageView.ScaleType.CENTER_CROP);
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode){
case CAMERA_PIC_REQUEST:
if(resultCode==RESULT_OK){
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
imgView.setImageBitmap(thumbnail);
}
}
}
MainActivity.class
main.xml
Make sure your all id would be correct.
Anything you need to know, hassle free to contact me.
Try this, to save image to file explorer:
You can fetch image from path "imagePath" whenever you have to display it.
Since there is no proper solution for this, I will put here what I have put together that is working and correct.
Android Manifest :
Android Manifest again at the top :
External res/xml/file_paths.xml file:
CreateImageFile Function
AddPhoto Function
On activity callback
You can invoke camera Activity by adding these lines in your code :
Now create file
Uri
because in some android phones you will getnull
data inreturn
so here is the method to get the image
URI
:For retrieving clicked image :