0

My application takes pictures from camera by using Camera API.

However, I would prefer invoking the stock Camera application and receive back the Uri of the saved picture.

(I would prefer it that way because the Camera application has many features readily available which I otherwise have to code in my app).

Do you know if there is an intent for invoking the stock Camera that way?

Chintan Rathod
  • 25,864
  • 13
  • 83
  • 93
Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158

3 Answers3

0

To exploit the Default Camera API and to get back the saved picture URI, you can use this answer.

Community
  • 1
  • 1
0

Try something like this :

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 100);

and for retrieving the image try :

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap bitmap = null;
    if (requestCode == IMAGE_CAPTURE_REQUEST_CODE) {
      if (resultCode == Activity.RESULT_OK) {
        try {
          bitmap = (Bitmap) intent.getExtras().get("data");
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
}
lokoko
  • 5,785
  • 5
  • 35
  • 68
0

To capture images using camera call this intent

Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, requestCode);

and to handle the callback use onActivityResult function

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

Bitmap mImageBitmap;
            Bundle extras = data.getExtras();
            mImageBitmap = Bitmap.createScaledBitmap(
                    (Bitmap) extras.get("data"), 100, 100, false);
}

mImageBitmap will hold the image that you captured

Ajay
  • 1,796
  • 3
  • 18
  • 22