@Test public void testShouldOverrideUrlLoadingDefault() { final MockWebViewClient webViewClient = new MockWebViewClient(); final WebResourceRequest resourceRequest = new WebResourceRequest() { @Override public Uri getUrl() { return Uri.parse(TEST_URL); } @Override public boolean isForMainFrame() { return false; } @Override public boolean isRedirect() { return false; } @Override public boolean hasGesture() { return false; } @Override public String getMethod() { return "GET"; } @Override public Map<String, String> getRequestHeaders() { return new HashMap<String, String>(); } }; Assert.assertFalse(webViewClient.shouldOverrideUrlLoading( mWebViewOnUiThread.getWebViewOnCurrentThread(), resourceRequest)); }
@Override @SuppressWarnings("deprecation") @RequiresApi(21) public boolean shouldOverrideUrlLoading(@NonNull WebView view, @NonNull WebResourceRequest request) { if (Build.VERSION.SDK_INT < 21) return false; return shouldOverrideUrlLoading(view, request.getUrl().toString()); }
WebViewClientCompat extends WebViewClient implements WebViewClientBoundaryInterface { @Override @SuppressWarnings("deprecation") @RequiresApi(21) public boolean shouldOverrideUrlLoading(@NonNull WebView view, @NonNull WebResourceRequest request) { if (Build.VERSION.SDK_INT < 21) return false; return shouldOverrideUrlLoading(view, request.getUrl().toString()); } }
WebViewClientCompat extends WebViewClient implements WebViewClientBoundaryInterface { @Override @SuppressWarnings("deprecation") @RequiresApi(21) public boolean shouldOverrideUrlLoading(@NonNull WebView view, @NonNull WebResourceRequest request) { if (Build.VERSION.SDK_INT < 21) return false; return shouldOverrideUrlLoading(view, request.getUrl().toString()); }  }
WebViewClientCompat extends WebViewClient implements WebViewClientBoundaryInterface { @Override @SuppressWarnings("deprecation") @RequiresApi(21) public boolean shouldOverrideUrlLoading(@NonNull WebView view, @NonNull WebResourceRequest request) { if (Build.VERSION.SDK_INT < 21) return false; return shouldOverrideUrlLoading(view, request.getUrl().toString()); }  @Override @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) final String[] getSupportedFeatures(); @Override void onPageCommitVisible(@NonNull WebView view, @NonNull String url); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(21) final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            /* WebResourceError */ @NonNull InvocationHandler handler); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(23) final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceError error); @SuppressWarnings("deprecation") // for invoking the old onReceivedError. @RequiresApi(21) void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceErrorCompat error); @Override void onReceivedHttpError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceResponse errorResponse); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override final void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType,
            /* SafeBrowsingResponse */ @NonNull InvocationHandler handler); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(27) final void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType, @NonNull SafeBrowsingResponse response); void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType, @NonNull SafeBrowsingResponseCompat callback); @Override @SuppressWarnings("deprecation") // for invoking the old shouldOverrideUrlLoading. @RequiresApi(21) boolean shouldOverrideUrlLoading(@NonNull WebView view,
            @NonNull WebResourceRequest request); }
WebViewClientCompat extends WebViewClient implements WebViewClientBoundaryInterface { @Override @SuppressWarnings("deprecation") @RequiresApi(21) public boolean shouldOverrideUrlLoading(@NonNull WebView view, @NonNull WebResourceRequest request) { if (Build.VERSION.SDK_INT < 21) return false; return shouldOverrideUrlLoading(view, request.getUrl().toString()); }  @Override @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) final String[] getSupportedFeatures(); @Override void onPageCommitVisible(@NonNull WebView view, @NonNull String url); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(21) final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            /* WebResourceError */ @NonNull InvocationHandler handler); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(23) final void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceError error); @SuppressWarnings("deprecation") // for invoking the old onReceivedError. @RequiresApi(21) void onReceivedError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceErrorCompat error); @Override void onReceivedHttpError(@NonNull WebView view, @NonNull WebResourceRequest request,
            @NonNull WebResourceResponse errorResponse); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override final void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType,
            /* SafeBrowsingResponse */ @NonNull InvocationHandler handler); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @Override @RequiresApi(27) final void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType, @NonNull SafeBrowsingResponse response); void onSafeBrowsingHit(@NonNull WebView view, @NonNull WebResourceRequest request,
            @SafeBrowsingThreat int threatType, @NonNull SafeBrowsingResponseCompat callback); @Override @SuppressWarnings("deprecation") // for invoking the old shouldOverrideUrlLoading. @RequiresApi(21) boolean shouldOverrideUrlLoading(@NonNull WebView view,
            @NonNull WebResourceRequest request);  }