How to skip or avoid 'retake and review' o

2019-04-20 05:33发布

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

I Am research more for that and I know also 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 without review/retake the activity display it.....

I am trying this code fine

Initilize

  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

4条回答
Rolldiameter
2楼-- · 2019-04-20 06:19

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);
  }   
}
查看更多
放荡不羁爱自由
3楼-- · 2019-04-20 06:19

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.

查看更多
小情绪 Triste *
4楼-- · 2019-04-20 06:28

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.

查看更多
来,给爷笑一个
5楼-- · 2019-04-20 06:29

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

查看更多
登录 后发表回答