0

I am using webview to load website. Website is loading properly. When i click on any link it redirects to mobile browser. So i searched on internet and used the function

myWebView.setWebViewClient(new WebViewClient() {
  private boolean shouldOverrideUrlLoading(WebView myWebView, WebResourseRequest request) {

    myWebView.loadUrl(request.toString());
    return true;
  }

});

Here WebResourseRequest and toString is not resolved. It saying cannot resolve symbol. How to solve it? Do i need to Import anything?

1 Answers1

0
myWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    myWebView.loadUrl(url);
}
 });

Change the parameters like this. Instead of WebResourseRequest use String

Ameer
  • 2,709
  • 1
  • 28
  • 44
  • if i use this structure, shouldOverrideUrlLoading is deprecated method in android.webkit message is coming and shouldOverrideUrlLoading not working. –  Jul 12 '17 at 09:51
  • WebResourseRequest added in N Developer Preview. You have to update the library. Check this answer https://stackoverflow.com/a/36484720/2610010 – Ameer Jul 12 '17 at 10:00
  • How to use the function you had given? is there any solution to make it work? –  Jul 12 '17 at 10:06
  • The code given will work even though it is deprecated – Ameer Jul 12 '17 at 10:08