zoukankan      html  css  js  c++  java
  • Android高版本使用照相机报错 Camera error

    Android高版本使用照相机报错 Camera error

    谷歌在安卓6.0以后增加了运行时权限功能,即在程序运行时需要用户手动授权,才可以正常运行。

    当使用相机时,除了需要在AndroidManifest文件中添加相应的权限

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

    在代码需要调用相机部分做如下修改:

    //运行时权限
            if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.CAMERA)!= PackageManager.PERMISSION_GRANTED){
                ActivityCompat.requestPermissions(MainActivity.this,new String[]{Manifest.permission.CAMERA},1);
            }else {
                startActivityForResult(new Intent(MainActivity.this, CaptureActivity.class),0);
            }
  • 相关阅读:
    python
    python
    python
    python
    python
    python
    python
    python
    人生苦短,我用python,为什么选择python,python简介
    Mysql-查询
  • 原文地址:https://www.cnblogs.com/wookong/p/9241660.html
Copyright © 2011-2022 走看看