Open esiokugbechoice opened 2 years ago
The camera's permission is disabled, that's why you are getting this error. Simply follow the code given below, the camera will start working as well as your scanner which depends on it.
Under MainActivity.Java file / asw_view.SetwebChromeClient. Post this code
@Nullable
public Bitmap getDefaultVideoPoster() {
return Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
}
@Override
public void onPermissionRequest(@NotNull final PermissionRequest request) {
final String[] requestedResources = request.getResources();
for (String r : requestedResources) {
if (r.equals(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) {
request.grant(new String[]{PermissionRequest.RESOURCE_VIDEO_CAPTURE});
break;
}
if (r.equals(PermissionRequest.RESOURCE_AUDIO_CAPTURE)) {
request.grant(new String[] { PermissionRequest.RESOURCE_AUDIO_CAPTURE});
break;
}
}
}
Add the line under websettings
webSettings.setMediaPlaybackRequiresUserGesture(false);
And make sure record_audio and camera permissions are granted in android manifest xml.
i got the same problem and @husaindevelop, i put your code but give me error when i build app.
error: cannot find symbol public void onPermissionRequest(@NotNull final PermissionRequest request) { ^ symbol: class PermissionRequest
@mgks any idea?
replace @NotNull with @Nullable also import import androidx.annotation.NonNull; import org.jetbrains.annotations.Nullable;
I am using an HTML5 QR code reader https://github.com/mebjas/html5-qrcode. everything works fine on chrome, but I get the following error when i try from the webview
Please help...