1

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)`
Zoe
  • 27,060
  • 21
  • 118
  • 148

1 Answers1

0

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/

Alok Singh
  • 640
  • 4
  • 14
  • First of all check you camera permission. – Alok Singh Feb 11 '19 at 05:48
  • i can handle run time permissions, but if with android 9, if i request the camera permission for sinch video call, the permission dialog will not show ( still showing if i request other permissions). Only android 9 crash my app, but if i open the activity as normal, the dialog will show. I am trying a new approach. thanks you btw – Trần Quốc Trung Feb 11 '19 at 07:51
  • @TrầnQuốcTrung...thanks for reply let me check again briefly on your problem.Can you please provide the code you are using for intent video so that it will help me to solve problem. – Alok Singh Feb 11 '19 at 08:27
  • I am not capturing a video. I a making a video call. But when i use A devoce to call B devide, instead of requesting the camera permission ( i put the code to request permissions in B ) , it crash my app with that error – Trần Quốc Trung Feb 11 '19 at 23:44
  • @TrầnQuốcTrung....ok just put your line of code which is responsible for crash so that I can understand more efficiently. – Alok Singh Feb 12 '19 at 05:02
  • @AlokSingh thanks you, but i dont know what to put. it's just a couple of lines to request permissions. but the permission dialog will show if i dont request the CAMERA permission. – Trần Quốc Trung Feb 14 '19 at 06:06
  • kk...Maybe its Security reason for Device that is responsible for the crash. – Alok Singh Feb 14 '19 at 06:11