1

Android has deprecated WebViewClient method

public boolean shouldOverrideUrlLoading(WebView view, String url) { throw new RuntimeException("Stub!"); }

in android api 24 but after going though their documentation i am not able to find why? what was the reason behind this? if any one has any idea please share your thoughts. Thanks in advance.

Faisal Khan
  • 2,574
  • 3
  • 20
  • 36
  • 4
    They replaced it [with `shouldOverrideUrlLoading(WebView, WebResourceRequest)`](https://developer.android.com/reference/android/webkit/WebViewClient.html#shouldOverrideUrlLoading(android.webkit.WebView,%20android.webkit.WebResourceRequest)), presumably for greater long-term flexibility. In general, questions asking "why did Developer X make Decision Y?" are not well-suited for Stack Overflow, as usually only Developer X can answer the question authoritatively. – CommonsWare May 08 '17 at 14:08
  • Okey Thank you @CommonsWare but i am still curious about what are the advantages of shouldOverrideUrlLoading(WebView, WebResourceRequest) over shouldOverrideUrlLoading(WebView view, String url). They have replaced url with WebResourceRequest and in WebResourceRequest we are getting all things like header, url etc. So i just wanted to know is there any issue in previous WebViewClient version so they came with this new method? – Faisal Khan May 08 '17 at 14:23
  • 1
    Presumably, the issue is: the old version only gave us the URL. Presumably, some apps may need to do different things based upon the other data in a `WebResourceRequest` (e.g., work with session cookies). – CommonsWare May 08 '17 at 14:25
  • But for that they can add one new method. what was the need to deprecating shouldOverrideUrlLoading(WebView view, String url)? – Faisal Khan May 08 '17 at 14:35
  • Presumably, they want to steer developers towards using the new method on new devices. – CommonsWare May 08 '17 at 14:38
  • 1
    You might be right ... Well thanks for answers – Faisal Khan May 08 '17 at 14:39

0 Answers0