使用ACTION_IMAGE_CAPTURE从相机拍摄照片后如何跳过或避免“重新拍摄和查看”选项

问题描述 投票:11回答:5

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

我已经搜索过它,而且我也非常了解相机应用程序本身使您能够查看/重新拍摄图像,一旦图像被接受,活动就会显示出来。但是,我想不做任何检查/重新获得显示它的活动.....

我正在尝试这段代码很好

Initialise

  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设置为...。

enter image description here

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

java android camera android-camera android-camera-intent
5个回答
4
投票

实际上,确认拍摄的照片非常有用。但是,如果您真的不想拥有它,则必须在应用程序内使用SurfaceView并在此处显示相机流。有示例音调,例如,考虑检查one


3
投票

使用方法setImageURI(),它将从uri获取位图并为您设置。


2
投票

您无法避免该屏幕。原因是,当您使用新的MediaStore.ACTION_IMAGE_CAPTURE时,您正在使用其他相机应用程序单击图像。显示此屏幕可能是的默认功能。此屏幕在不同设备中会有所不同,具体取决于相机的应用程序。


1
投票

根据默认的相机应用程序,您不能违反该功能。而是可以使用SurfaceView在应用程序内部捕获图像。请查看此answer thread


0
投票

将“ android.intent.extra.quickCapture”用于您的图片意图。

© www.soinside.com 2019 - 2024. All rights reserved.