今天调试app中的webview接入视频聊天
需要重写
WebChromeClient中的onPermissionRequest方法来允许h5调用资源
@Override
public void onPermissionRequest(PermissionRequest permissionRequest) {
// super.onPermissionRequest(permissionRequest);
String[] resources=permissionRequest.getResources();
if (Build.VERSION.SDK_INT<Build.VERSION_CODES.M){
permissionRequest.grant(resources);
return;
}
ArrayList<String> permissionList=new ArrayList<>();
for (String resource:resources){
if (resource.equals(PermissionRequest.RESOURCE_VIDEO_CAPTURE)){
permissionList.add(Manifest.permission.CAMERA);
}else if (resource.equals(PermissionRequest.RESOURCE_AUDIO_CAPTURE)){
permissionList.add(Manifest.permission.RECORD_AUDIO);
}
}
if (per