1

So I want to use the camera intent

Intent intent =new Intent("android.media.action.IMAGE_CAPTURE");

and I want to do something while the picture is capturing, and my question is can I do the capturing in background while on the display is something else and than show the picture ?. Thanks in advance for help

Anand Dwivedi
  • 1,452
  • 13
  • 23
Ervin Cosic
  • 114
  • 1
  • 12
  • 1
    I think this question should be what you serch on: http://stackoverflow.com/questions/21752637/how-to-capture-an-image-in-background-without-using-the-camera-application – Youcam39 Jan 14 '16 at 10:33
  • not really i want to use the camera app because its way better than writing your own code for the camera, thats why I use the Intent. But thanks it can be useful. – Ervin Cosic Jan 14 '16 at 10:37
  • In this case you should onActivityResult(), but you can't do it in background, there is not other solution – Youcam39 Jan 14 '16 at 10:43
  • I want to see the preview of the camera and then take a picture, when I press capture it should do it in background and display something else while capturing. – Ervin Cosic Jan 14 '16 at 10:46
  • As Youcam39 already pointed out correctly - if you want this type of control you've to implement it yourself. – Foxtur Jan 14 '16 at 12:46

1 Answers1

0

This is a snippet from a project a did before, I hope it will help you:

  // Open the camera and take a picture
public void openCamera() {
    Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
    getIntent.setType("image/*");
    startActivityForResult(getIntent, SEND_MESSAGE_IMG_REQUEST_IMAGE_PICK);
}

// handle the result from camera
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == SEND_MESSAGE_IMG_REQUEST_IMAGE_PICK && resultCode == RESULT_OK) {

        Uri selectedImage = data.getData();
        String[] filePathColumn = {MediaStore.Images.Media.DATA};

        Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String filePath = cursor.getString(columnIndex);
        cursor.close();

        // do a background task to handle the captured image (upload it to a server or something like that)



    }
}
Youcam39
  • 102
  • 5
  • I want to display something between the camera preview and taking a picture so when I press the capture button i want to display an image and then take the picture while displaying the image. – Ervin Cosic Jan 14 '16 at 11:06