简体   繁体   中英

Sinch VideoCaptureThread problem with camera “1” on android 9

I'm making a small app, I use sinch for video calling and it works fine on android 8.1 and lower. But on android 9, my app crash when I make a video call. and this is the error:

2019-02-11 11:36:56.895 1638-2821/? E/AndroidRuntime: FATAL EXCEPTION: VideoCapturerThread
Process: com.example.myapp.app, PID: 1638
java.lang.SecurityException: validateClientPermissionsLocked:1054: Caller "com.example.myapp.app" (PID 10319, UID 1638) cannot open camera "1" without camera permission
    at android.hardware.camera2.CameraManager.throwAsPublicException(CameraManager.java:747)
    at android.hardware.camera2.CameraManager.openCameraDeviceUserAsync(CameraManager.java:405)
    at android.hardware.camera2.CameraManager.openCameraForUid(CameraManager.java:567)
    at android.hardware.camera2.CameraManager.openCamera(CameraManager.java:495)
    at org.webrtc.Camera2Session.openCamera(Unknown Source:44)
    at org.webrtc.Camera2Session.start(Unknown Source:60)
    at org.webrtc.Camera2Session.<init>(Unknown Source:73)
    at org.webrtc.Camera2Session.create(Unknown Source:17)
    at org.webrtc.Camera2Capturer.createCameraSession(Unknown Source:17)
    at org.webrtc.CameraCapturer$5.run(Unknown Source:52)
    at android.os.Handler.handleCallback(Handler.java:891)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:207)
    at android.os.HandlerThread.run(HandlerThread.java:65)`

Try this method for video capture with camera may be it helps you :-

public void dispatchTakeVideoIntent() {
        PermissionUtil.with(this).setCallback(new PermissionUtil.PermissionGrantedListener() {
            @Override
            public void onPermissionResult(boolean isGranted, int requestCode) {
                if (isGranted) {
                    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
                    if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
                        startActivityForResult(takeVideoIntent, AppConstants.REQUEST_CODE.REQUEST_VIDEO_CAPTURE);
                    }
                }
            }
        }).validate(Manifest.permission.CAMERA);
    }

for the permission Util check this link https://www.truiton.com/2016/04/obtaining-runtime-permissions-android-marshmallow-6-0/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM