Google has modified the mustInterceptRequest method to use a WebResourceRequest request instead of a string URL
No, they added a second shouldInterceptRequest() method. Both are available in API Level 21+; String option is available at API level 11+. Although the String character is deprecated, the String variant has to be supported for quite some time for backward compatibility.
Is there any way to write a general class extending WebViewClient and handle both methods?
The built-in implementation of the WebResourceRequest version of shouldInterceptRequest() simply calls the implementation of String shouldInterceptRequest() :
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { return shouldInterceptRequest(view, request.getUrl().toString()); }
(from source right now)
So, you have two options:
Just override the String version if you do not need WebResourceRequest and it will be used at all relevant API levels.
Cancel both parameters, knowing that WebResourceRequest will be used at API level 21+, and String version will be used at API levels 11-20.
source share