Android N has the signature of this method:
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
The one that is supported by all versions of Android has the signature of this method:
public boolean shouldOverrideUrlLoading(WebView view, String url)
What to do to make it work on all versions?
you need to override both methods
api, Android N, ... .. API N
@SuppressWarnings("deprecation")
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
initiateCall(url);
return true;
}
if (url.startsWith("mailto:")) {
sendEmail(url.substring(7));
return true;
}
return false;
}
@RequiresApi(Build.VERSION_CODES.N)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
String url = request.getUrl().toString();
if (url.startsWith("tel:")) {
initiateCall(url);
return true;
}
if (url.startsWith("mailto:")) {
sendEmail(url.substring(7));
return true;
}
return false;
}