Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip or avoid 'retake and review' option after capturing photo from camera using ACTION_IMAGE_CAPTURE

I want to display the image when I click on the photo and want to set in my ImageView without user select yes or not....

I had searched for it and I also know it very well that the camera app itself gives you the ability to review/retake the image, and once an image is accepted, the activity displays it. But, I want to do it without review/retake the activity display it.....

I am trying this code fine

Initialise

  Uri mImageCaptureUri;

For Click on Button

  Intent intent      = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    File file        = new File(Environment.getExternalStorageDirectory(),
            "tmp_avatar_" + String.valueOf(System.currentTimeMillis()) + ".jpg");
    mImageCaptureUri = Uri.fromFile(file);

    try {

        intent.putExtra(MediaStore.AUTHORITY, true);
        intent.putExtra("return-data", true);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageCaptureUri);
        startActivityForResult(intent, PICK_FROM_CAMERA);
    } catch (Exception e) {
        e.printStackTrace();
    }

onActivityResult

  @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

        Bitmap bitmap = null;


        mPath = mImageCaptureUri.getPath();

        System.out.println("THE PAtH:_" + mPath);

        BitmapFactory.Options o2 = new BitmapFactory.Options();
        bitmap = BitmapFactory.decodeFile(mPath, o2);
        ivSelfie.setImageBitmap(bitmap);

    
}

When I am Click the Photo Than I am Take this screen to select yes or not......

But My requirement is not select review/retake task and direct set to ImageView on activity display when just click and set.....

enter image description here

like image 733
Arjun saini Avatar asked Jul 26 '16 04:07

Arjun saini


People also ask

How do you open camera through intent and display captured image?

Intent camera_intent = new Intent(MediaStore. ACTION_IMAGE_CAPTURE); startActivityForResult(camera_intent, pic_id); Now use onActivityResult() method to get the result, here the captured image.

What is camera API in Android?

This package is the primary API for controlling device cameras. It can be used to take pictures or videos when you are building a camera application. Camera. This class is the older deprecated API for controlling device cameras.

How do you take a picture on an android?

Press the Power and Volume down buttons at the same time. If that doesn't work, press and hold the Power button for a few seconds. Then tap Screenshot. If neither of these work, go to your phone manufacturer's support site for help.


5 Answers

Actually it's quite useful to have confirmation of taken picture. But, in case if you really don't want to have it, you have to use SurfaceView inside your app and show camera stream here. There is tones of example how to do it, for example consider to check that one.

like image 62
Divers Avatar answered Oct 05 '22 23:10

Divers


Use method setImageURI() it will get the bitmap from the uri and set it for you.

Yes it will set the image weather the user press ok or cancel no matter because your file exists on your given path while launching intent.

 @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {

    if (requestCode == PICK_FROM_CAMERA) {
        // only one line code
        ivSelfie.setImageURI(mImageCaptureUri);
  }   
}
like image 23
Sohail Zahid Avatar answered Oct 05 '22 23:10

Sohail Zahid


You cannot avoid that screen. The reason is that when you use new MediaStore.ACTION_IMAGE_CAPTURE you are using a different camera application for clicking image. Showing this screen might be the default functionality of the. This screen will be different in different devices depending upon the camera application.

So to get rid of this the only thing you can do is to implement your custom camera instead of using default camera application.

like image 20
Ankit Aggarwal Avatar answered Oct 05 '22 23:10

Ankit Aggarwal


As per default camera app you can't breach that functionality. Instead of, you can use SurfaceView to capture image inside you application. Please have a look at this answer thread.

May be this link will help you.

Thank you

like image 23
Nikunj Patel Avatar answered Oct 06 '22 00:10

Nikunj Patel


Use "android.intent.extra.quickCapture" for your picture intent.

// File ImagePickerModule.java#248
cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra("android.intent.extra.quickCapture",true);

See https://github.com/react-native-community/react-native-image-picker/issues/647 for details.

like image 42
Pyojin Kim Avatar answered Oct 05 '22 23:10

Pyojin Kim