1

Ok, so I have looked around a lot for this but I can't seem to find anyone else that's had this problem.

I am making a simple application just to test out working with the camera. Everything works up until I actually press the button to capture the image. When I do, instead of freezing and asking for confirmation that this is the picture I want, the confirmation button come up at the bottom, but the live feed from the camera keeps going.

I am using the most basic way of sending an intent to ask android to take a picture so I don't know why this is happening.

Here is the code:

private static final int IMAGE_CAPTURE = 1;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    addCaptureButtonListener();
}

private void addCaptureButtonListener() {
    Button capture = (Button) findViewById(R.id.captureButton);

    capture.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i, IMAGE_CAPTURE);
        }
    });
}



@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(resultCode == RESULT_OK) {
        if(requestCode == IMAGE_CAPTURE) {
            Toast.makeText(this, "Image Successfully Taken", Toast.LENGTH_SHORT).show();
        }
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}
OnePphire
  • 23
  • 1
  • 1
  • 4

1 Answers1

0

The camera feature depends vastly on the device you are using you may be using the correct method but sometimes it's the hardware issue. Also Please post the code, cross check if everything is fine from this example .

Capture Image from Camera and Display in Activity

try testing it on some other device if it works fine then look for the documentation of the bug for the device.

Edit

The problem is with the S4 it conflicts between the capture image resolution and the Preview image resolution the similar issues have been reported here too

Samsung Galaxy S4 , Image gets corrupted while taking from camera

Samsung galaxy S4 image capture Issue

your code is perfect it's just that the resolution camera clicks the image is not supported for the preview by the same device.

Community
  • 1
  • 1
Aashish Bhatnagar
  • 2,595
  • 2
  • 22
  • 37
  • I tried it with an emulated device and that seemed to work with the camera set to emulated. I don't see why it wouldn't work with my phone. I'm using a Galaxy S4. – OnePphire Jun 21 '13 at 20:24
  • Figured it out. It wasn't the S4 Image Capture Issue at all, I borrowed a friends S4 and tried it on there, worked perfectly. I'm pretty sure it's just because I'm using Cyanogenmod. I've been using it for such a long time I forgot it wasn't the stock OS. Thanks for your help though. – OnePphire Jun 22 '13 at 16:44