Prasanna
Prasanna

Reputation: 3771

Android: Webview loadUrl with query params

I want to load a web view using loadUrl that has query params in it. In ICS (4.0.3) webview opens but the URL fails to load. I have seen this issue has already been filed with google but I am not able to find a solution for it. This is what I am trying to do.

private class MyWebViewClient extends WebViewClient
{
    @Override
    public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error)
    {
       handler.proceed();
    }

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url)
   {
      return true;
   }
}

......

webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new MyWebViewClient());
webview.loadUrl("https://www.example.com?queryParam1=value1"); 

......

Upvotes: 1

Views: 9139

Answers (1)

bytebiscuit
bytebiscuit

Reputation: 3496

maybe you forgot to add view.loadUrl(url) in your:

   @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url)
   {
      return true;
   }

method. http://developer.android.com/resources/tutorials/views/hello-webview.html Make it like this:

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url)
   {
      view.loadUrl(url);
      return true;
   }

Upvotes: 5

Related Questions