2016-09-24 157 views
0

我正在开发一个使用opentok的webRTC应用程序。该应用程序工作正常。我将应用程序转换为库并通过将其添加到另一个项目来启动库活动。该应用程序正在连接到服务器,但相机未打开。我得到相机错误如下相机正在被其他应用程序使用

E/opentok-videocapturer: The camera is in use by another app 
                   java.lang.RuntimeException: Fail to connect to camera service 
                    at android.hardware.Camera.<init>(Camera.java:518) 
                    at android.hardware.Camera.open(Camera.java:360) 
                    at com.opentok.android.DefaultVideoCapturer.init(DefaultVideoCapturer.java:110) 
                    at com.opentok.android.BaseVideoCapturer.initTrap(BaseVideoCapturer.java:223) 

回答

0
public boolean isCameraUsebyApp() { 
     Camera camera = null; 
     try { 
      camera = Camera.open(); 
     } 
     catch (RuntimeException e) 
     { 
      return true; 
     } 
     finally 
     { 
      if (camera != null) 
      { 
       camera.release(); 
      } 
     } 
     return false; 
    } 
相关问题