From 299dbb3b277e62d3d1b9d1030fec8460b99ac98b Mon Sep 17 00:00:00 2001 From: Mikhail Date: Thu, 28 Oct 2021 20:33:48 +0300 Subject: [PATCH] getUserMedia fix for android --- .../java/com/flutter_webview_plugin/WebviewManager.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/android/src/main/java/com/flutter_webview_plugin/WebviewManager.java b/android/src/main/java/com/flutter_webview_plugin/WebviewManager.java index e19b2a08..834a0673 100644 --- a/android/src/main/java/com/flutter_webview_plugin/WebviewManager.java +++ b/android/src/main/java/com/flutter_webview_plugin/WebviewManager.java @@ -15,6 +15,7 @@ import android.webkit.GeolocationPermissions; import android.webkit.SslErrorHandler; import android.webkit.ValueCallback; +import android.webkit.PermissionRequest; import android.webkit.WebChromeClient; import android.webkit.WebSettings; import android.webkit.WebView; @@ -175,6 +176,14 @@ public void onScroll(int x, int y, int oldx, int oldy) { webView.setWebViewClient(webViewClient); webView.setWebChromeClient(new WebChromeClient() { + // For correct getUserMedia access + @Override + public void onPermissionRequest(PermissionRequest request) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + request.grant(request.getResources()); + } + } + //The undocumented magic method override //Eclipse will swear at you if you try to put @Override here // For Android 3.0+