使用ACTION_IMAGE_CAPTURE从相机拍摄照片后如何跳过或避免“重新拍摄并查看"选项 [英] How to skip or avoid 'retake and review' option after capturing photo from camera using ACTION_IMAGE_CAPTURE

查看:733
本文介绍了使用ACTION_IMAGE_CAPTURE从相机拍摄照片后如何跳过或避免“重新拍摄并查看"选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单击照片时显示图像,并希望在ImageView中进行设置,而无需用户选择是或否.

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.....

我正在尝试使用此代码

初始化

  Uri mImageCaptureUri;

用于单击按钮

  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);

    
}

当我单击我比我照相"时,请使用此屏幕选择是或否...

但是我的要求不是选择审阅/重取任务,而是只需单击并设置...即可直接在活动显示上直接设置为ImageView.

推荐答案

实际上,确认拍摄的照片非常有用.但是,如果您真的不想拥有它,则必须在应用程序内使用SurfaceView并在此处显示相机流.有示例说明该怎么做,例如考虑检查一个.

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.

这篇关于使用ACTION_IMAGE_CAPTURE从相机拍摄照片后如何跳过或避免“重新拍摄并查看"选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆