小编Jac*_*cob的帖子

在android上启动摄像头时无法提供结果ResultInfo

我正在尝试使用外部Android摄像头将图像放入ImageView中,但是我收到了"失败传递结果ResultInfo"错误.这是我的代码:

单击按钮以启动相机应用程序

public void takePhoto(View v) {


    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        // Creating the File where the photo should go
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
            // Error occurred while creating the File
            Log.e(TAG,"something went wrong", ex);
            return;
        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                    Uri.fromFile(photoFile));
            startActivityForResult(takePictureIntent, REQUEST_CODE);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

命名和创建临时.文件:

    String mCurrentPhotoPath;

private File createImageFile() …
Run Code Online (Sandbox Code Playgroud)

android image-capture android-intent android-camera

1
推荐指数
1
解决办法
2492
查看次数