我正在制作一个小型应用程序,我使用sinch进行视频通话,它在android 8.1及更低版本上正常运行。但是在android 9上,当我进行视频通话时,我的应用程序崩溃了。这是错误:
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)`
答案 0 :(得分:0)
尝试使用这种方法进行相机视频拍摄可能对您有帮助:-
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);
}
有关权限实用程序,请检查此链接https://www.truiton.com/2016/04/obtaining-runtime-permissions-android-marshmallow-6-0/