Android异常篇 Fail to connect to camera service

Posted 彭老希

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android异常篇 Fail to connect to camera service相关的知识,希望对你有一定的参考价值。

一、版本区别

在Java代码中添加运行时权限授权,在Activity的onCreate函数中添加如下代码

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) 
            if (checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) 
                requestPermissions(new String[] Manifest.permission.CAMERA, 1);
            
        

二、权限未添加

androidManifest.xml中没有添加Camera的权限申请,对策则是添加相机权限申请。

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

三、相机资源打开后未释放

  if(mCamera != null)
    mCamera.stopPreview();
  	mCamera.release();
  	mCamera= null;
  

以上是关于Android异常篇 Fail to connect to camera service的主要内容,如果未能解决你的问题,请参考以下文章

Android异常篇 Failed to initialize editor

Android异常篇 Installation failed due to: ‘INSTALL_FAILED_TEST_ONLY‘

Android异常篇 Error: Execution failed for task ‘:app:clean‘. Unable to delete file

Android的java的报错提示:java.lang.RuntimeException: Fail to connect to camera service

关于HBuilderX(app端android)真机调试一直显示ip和端口不能为空或fail to connect ....from....

Connecting to 172.16.128.14:22...Could not connec