对于ACTION_IM​​AGE_CAPTURE没有出现在三星Galaxy Nexus的摄像头意图(4.0.2) [英] Camera intent for ACTION_IMAGE_CAPTURE does not appear on Samsung Galaxy Nexus(4.0.2)

查看:146
本文介绍了对于ACTION_IM​​AGE_CAPTURE没有出现在三星Galaxy Nexus的摄像头意图(4.0.2)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的code拍摄照片从相机获取的图片的路径。

I use following code take a Picture from camera and to obtain picture's path.

...
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_IMAGE_CAPTURE); // image capture
...
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.d(TAG, "onActivityResult:" + resultCode + " request:" + requestCode);

    switch (requestCode) {
        case CAMERA_IMAGE_CAPTURE:
            Uri selectedImageUri = data.getData();
            userImagePath = getPath(selectedImageUri);
        break;
    }
}

它的工作原理很好的仿真器和不同的设备。但在三星GALAXY Nexus(4.0.2)不启动相机应用。但它返回RESULT_OK到onActivityResult我看到LogCat中概莫能外。 请给我和建议如何解决这个问题。 在此先感谢!

It works good on emulator and on different devices. But on Samsung Galaxy Nexus(4.0.2) it does not launches Camera app. But it returns RESULT_OK to onActivityResult and I see no exceptions in LogCat. Please give me and advice how to solve this issue. Thanks in advance!

推荐答案

您缺少 EXTRA_OUTPUT ,这可能会影响的事项。我的Galaxy Nexus的可运行此示例项目成功,它使用下面code要求的图片:

You are missing EXTRA_OUTPUT, which may impact matters. My Galaxy Nexus can run this sample project successfully, which uses the following code to request the picture:

Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File dir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);

output = new File(dir, "CameraContentDemo.jpeg");
i.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(output));

startActivityForResult(i, CONTENT_REQUEST);

这篇关于对于ACTION_IM​​AGE_CAPTURE没有出现在三星Galaxy Nexus的摄像头意图(4.0.2)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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