From 7fe268e7c80504332f212b3628d6ecee899496e8 Mon Sep 17 00:00:00 2001 From: shinriyo Date: Tue, 6 Oct 2020 16:41:54 +0900 Subject: [PATCH 1/2] onReceivedError Detail for warning: [deprecation] (shouldOverrideUrlLoading,onReceivedError,removeAllCookie) in WebViewClient has been deprecated #734 --- .../java/com/flutter_webview_plugin/BrowserClient.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/flutter_webview_plugin/BrowserClient.java b/android/src/main/java/com/flutter_webview_plugin/BrowserClient.java index d3e136e6..39f51e23 100644 --- a/android/src/main/java/com/flutter_webview_plugin/BrowserClient.java +++ b/android/src/main/java/com/flutter_webview_plugin/BrowserClient.java @@ -99,6 +99,14 @@ public void onReceivedHttpError(WebView view, WebResourceRequest request, WebRes FlutterWebviewPlugin.channel.invokeMethod("onHttpError", data); } + @TargetApi(android.os.Build.VERSION_CODES.M) + @Override + public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) { + // Redirect to deprecated method, so you can use it in all SDK versions + onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString()); + } + + @SuppressWarnings("deprecation") @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); @@ -116,4 +124,4 @@ private boolean checkInvalidUrl(String url) { return matcher.lookingAt(); } } -} \ No newline at end of file +} From 3860b2d2f7279d38bcd2ef6237e152da9c3a1048 Mon Sep 17 00:00:00 2001 From: shinriyo Date: Tue, 6 Oct 2020 16:43:15 +0900 Subject: [PATCH 2/2] I mistook import import android.webkit.WebResourceError; --- .../src/main/java/com/flutter_webview_plugin/BrowserClient.java | 1 + 1 file changed, 1 insertion(+) diff --git a/android/src/main/java/com/flutter_webview_plugin/BrowserClient.java b/android/src/main/java/com/flutter_webview_plugin/BrowserClient.java index 39f51e23..64b9bc78 100644 --- a/android/src/main/java/com/flutter_webview_plugin/BrowserClient.java +++ b/android/src/main/java/com/flutter_webview_plugin/BrowserClient.java @@ -7,6 +7,7 @@ import android.webkit.WebResourceResponse; import android.webkit.WebView; import android.webkit.WebViewClient; +import android.webkit.WebResourceError; import java.util.HashMap; import java.util.Map;