13

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

Community
  • 1
  • 1
Arjun saini
  • 4,223
  • 3
  • 23
  • 51
  • I don't there is a workthrough for that but instead of using the camera intent, you can use a framelayout and start the camera in your application only. It is easier that way. – Geet Choubey Jul 26 '16 at 05:02
  • Yes I know But My requirement to use only inbuilt camera......... – Arjun saini Jul 26 '16 at 05:04
  • Even in WhatsApp, in previous versions, when they used the stock camera application, even they had the same confirm option after capturing the picture. – Geet Choubey Jul 26 '16 at 05:05

5 Answers5

5

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.

Community
  • 1
  • 1
Divers
  • 9,531
  • 7
  • 45
  • 88
  • Thanks @Divers Sir.... I am Using Oppo Mobile as you know it's a selfie expert so my requirement to do work on it's inbulit camera image...... – Arjun saini Jul 26 '16 at 05:15
  • @Er.Arjunsaini To be honest, don't have an idea what are talking about, but seems it is impossible to comply with your requirements – Divers Jul 26 '16 at 05:17
  • Thanks... I am also.... refused to do like that... But I am trying so hard to fulfill my requirement – Arjun saini Jul 26 '16 at 05:20
3

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);
  }   
}
Sohail Zahid
  • 8,099
  • 2
  • 25
  • 41
  • Is it somehow related to question - `When I am Click the Photo Than I am Take this screen to select yes or not......? – Divers Jul 26 '16 at 05:08
  • Thanks @Sohail Zahid sir For Answer......I am trying this also But I want to avoid the functionality of review/retake......... – Arjun saini Jul 26 '16 at 05:13
  • @Er.Arjunsaini retake/review is belong to camera app you cant control them camera app interface give us event only on `cancel` or `Ok` with result. – Sohail Zahid Jul 26 '16 at 05:15
  • @Sohail Zahid..... Thanks.... I am also search about that...But not getting something all are said that you also said that... – Arjun saini Jul 26 '16 at 05:22
  • @Er.Arjunsaini you are welcome dear something are out of our control so look for other solution.Happy Coding – Sohail Zahid Jul 26 '16 at 05:24
  • @Sohail Zahid.... I have Some More Idea Can I Review image with Selfie Kit?? click image with selfie Stick and review also with selfie Stick....?? – Arjun saini Jul 26 '16 at 05:26
2

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.

Ankit Aggarwal
  • 5,317
  • 2
  • 30
  • 53
1

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

Community
  • 1
  • 1
1

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.

Pyojin Kim
  • 11
  • 2