Getting a blank page in Android WebViewClient

I am trying to open a twitter link: http://mobile.twitter.com/pawan_rathore88 in my activity. If I install WebViewClient in webview, I get a blank page. But when I download the URL without installing any web client, it loads the page correctly. Does anyone know what could be the problem. Below is a snippet of code.

webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
//if I comment the following line then webpage loads properly in default Android browser.
webview.setWebViewClient(new WebViewClient() {
   public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                 Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
               }
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {

    Log.v(tag, "url :" + url);
    view.loadUrl(url);
    return true;
        }
 });
    webview.loadUrl("http://mobile.twitter.com/pawan_rathore88");

Thanks Pavan

+5
source share
3 answers

After setting up the code around, there seems to be a problem with the user agent, it seems that changing it to a user custom descriptor fixes this problem:

  WebView web = (WebView)findViewById(R.id.webView1);
        web.getSettings().setUserAgentString("Mozilla/5.0 (Macintosh; " +
            "U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, " +
            "like Gecko) Version/5.0 Safari/533.16");

        String url = "http://mobile.twitter.com/pawan_rathore88";
        web.loadUrl(url);
+1
source

-.

0

This is also my problem. Downloading the Desktop version is very good, but not the mobile version. If you are using the default browser, the Mobile version is usually executed. I think the problem is not to execute the user string agent. But I can’t find out now.

0
source

All Articles