相机错误无法连接到相机

时间:2013-04-17 06:16:17

标签: android android-camera

我正在使用camera activity来抓取image,同时调用相机活动显示Camera错误无法连接到camera请任何人都可以关于此错误的解释

我称之为

Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
startActivityForResult(intent, TAKE_IMAGE);

错误消息:

camera error
cannot connect to the camera

2 个答案:

答案 0 :(得分:0)

add permission in your manifest file

<uses-feature
    android:name="android.hardware.camera" />
<uses-feature
    android:name="android.hardware.camera.autofocus" />

<uses-permission
    android:name="android.permission.CAMERA"></uses-permission>

如果仍无法正常工作,请点击编辑AVD,然后转到选择后挡相机模拟

答案 1 :(得分:0)

你也可以选择赞

    PackageManager pm = getPackageManager();
    if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
      // your Intent Goes Here Like
        Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        i.putExtra(MediaStore.EXTRA_OUTPUT,MyFileContentProvider.CONTENT_URI);
        startActivityForResult(i, CAMERA_RESULT);
    } else {   
        UtilityCommon.showDialogwithTitle(context,context.getResources().getString(R.string.strvalidcamera));               

    }

还在AndroidMAnifest.xml文件中添加需要权限