5

I am trying open twitter link : http://mobile.twitter.com/pawan_rathore88 in my activity. If I set WebViewClient to webview I am getting blank page. But when I load url without setting any webviewclient, it loads page properly. Does anyone have idea what can be a problem. Following is my code snippet.

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, Pawan

Pawan
  • 1,503
  • 2
  • 19
  • 28

3 Answers3

1

After tweaking the code around, it seems to be a user agent problem, seems that changing it to a desktop useragent 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);
JoxTraex
  • 13,423
  • 6
  • 32
  • 45
0

That is exact my problem too. Load Desktop version very good but not mobile version. If running on default browser, then Mobile version normally run. I think the problem is not well perform user string agent. But cannot find it out now.

0

This is a problem with twitter at the moment and fails in all web kit mobile browsers.

kkk
  • 1
  • the android browser extends the base functionality that is WebKit. Stop assuming so much Pawan, do some research. – JoxTraex Jan 21 '12 at 14:13