Question

Okay, so I have an onclick on a button that opens the camera, when I take a picture and save it how do I get the file name+location of where it was saved to open it in my app?

Here is my button click

Button btncamera = (Button)findViewById(R.id.btncamera);
btncamera.setOnClickListener(new OnClickListener(){
    public void onClick(View v){
        Intent cameraIntent = nwe Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(cameraIntent, 2500);
    }
}

Here is my Result it doesn't contain anything, but it will start another Intent to display the image:

protected void onActivityResult(int requestCode, int resultCode, Intent data){

}

Maybe I am doing it wrong, but any guidance would be much appreciated thanks!

Was it helpful?

Solution

Try adding this to your onActivityResult.

Bitmap picture = (Bitmap) data.getExtras().get("data");

Take the image out of the camera intent, create a bitmap out of it, and then use it from there. Write it to a file, or import it directly into a display resource. Also be sure to check your ResultCode to determine if a picture actually has been taken.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top