androidsinchandroid-sinch-api

sinch video chat not showing local view or remote view


I have integrated sinch video chat in my application based of sinch video push sample

The local view and remote view only show black screen and does not show anything and it generate this crash in background

03-28 12:02:59.371 16607-19169/com.forsale.forsale E/Logging: VideoCapturerAndroid: java.lang.RuntimeException: Fail to connect to camera service
                                                              at android.hardware.Camera.<init>(Camera.java:568)
                                                              at android.hardware.Camera.open(Camera.java:405)
                                                              at org.webrtc.sinch.VideoCapturerAndroid.startCaptureOnCameraThread(VideoCapturerAndroid.java:450)
                                                              at org.webrtc.sinch.VideoCapturerAndroid.access$1100(VideoCapturerAndroid.java:47)
                                                              at org.webrtc.sinch.VideoCapturerAndroid$7.run(VideoCapturerAndroid.java:460)
                                                              at android.os.Handler.handleCallback(Handler.java:739)
                                                              at android.os.Handler.dispatchMessage(Handler.java:95)
                                                              at android.os.Looper.loop(Looper.java:158)
                                                              at android.os.HandlerThread.run(HandlerThread.java:61)

can any one help please?


Solution

  • Inside 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>
    

    Do not forget to request permissions like here discribed:

    https://developer.android.com/training/permissions/requesting.html

    In breif:

        if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 50);
    }    else {       
    
    
       startCamera();
    

    }