相机访问权限,拒绝权限

时间:2015-11-17 14:15:45

标签: android

我已经在stackoverflow上搜索并找到了非常有用的答案,但没有一个对我有用。 我试图通过android studio的模拟器访问我的笔记本电脑的网络摄像头。

这是我的代码:

    @Override
    public void onClick(View v) {
          Intent intent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
          intent.putExtra(MediaStore.EXTRA_OUTPUT,
                          MediaStore.Images.Media.EXTERNAL_CONTENT_URI.getPath());
          startActivityForResult(intent, 1);
                        }

我还添加了以下权限:

 <uses-permission android:name="android.permission.CAMERA"/>
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
 <uses-feature android:name="android.hardware.camera"/>

我还在avd中启用了以下设置: 相机:Front set to WebCam0Back set to WebCam0

我得到的错误是:

        java.lang.SecurityException: Permission Denial: starting Intent { 
        act=android.media.action.IMAGE_CAPTURE cmp=com.android.camera/.Camera 
        (has extras) } from ProcessRecord{8f8626     
        3870:com.example.felix.eitimer/u0a57} (pid=3870, uid=10057) with
        revoked permission android.permission.CAMERA

也许有人知道答案,我觉得很奇怪,因为每个关于它的教程都解释了我到目前为止所做的尝试。

0 个答案:

没有答案
相关问题