7

I am trying to open twitter page begining with https in webview in android. But it is not opening and blank screen is coming with continous loading. Screen shot is below

enter image description here

Edit: In main webview I have link to twitter page https://twitter.com/mytwitterpage. On clicking that link that twitter url is opening in webview. I noticed that onPageFinished method of WebViewClient is called 2 times one time for https://twitter.com/mytwitterpage and second time for https://mobile.twitter.com/#!/mytwitterpage.

Anyone know what is wrong here?

Thanks in advance.

anujprashar
  • 6,263
  • 7
  • 52
  • 86
  • May be internet speed cause this problem. – Paresh Mayani Nov 08 '11 at 19:37
  • I dont think internet speed is issue here as I have searched internet and many people has faced this problem. – anujprashar Nov 08 '11 at 19:41
  • Have you enabled JavaScript for the webview by calling [`WebView.setJavaScriptEnabled(true)`](http://developer.android.com/reference/android/webkit/WebSettings.html#setJavaScriptEnabled(boolean))? It's disabled by default and it looks like this site depends on js to me. –  Nov 08 '11 at 19:45
  • @alextsc yes i have written this webView.getSettings().setJavaScriptEnabled(true). – anujprashar Nov 08 '11 at 19:50

4 Answers4

17

Ok done by adding below line in my code

webView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17");

I got it from this post at stackoverflow Problems loading mobile.twitter in webview.

Community
  • 1
  • 1
anujprashar
  • 6,263
  • 7
  • 52
  • 86
3
wv.getSettings().setDomStorageEnabled(true);

This worked for me!

sth
  • 222,467
  • 53
  • 283
  • 367
Abirami
  • 161
  • 1
  • 2
0

Just add this code below webview. It solved my problem.

webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(this, "TwitterDownloader");
holydragon
  • 6,158
  • 6
  • 39
  • 62
0

Are you hitting a https:// page? If so, try setting a WebViewClient on your webview and override onReceivedSslError and see if there something wrong.

Twitter changed some certificate stuff recently, if you're hitting twitter.com/... try hitting api.twitter.com/...

FunkTheMonk
  • 10,908
  • 1
  • 31
  • 37
  • I override that method and I see no error and also I am opening twitter page by clicking on link and not by directly supplying url. I have edited question, please check it. – anujprashar Nov 08 '11 at 21:31
  • Can open the URL in the devices browser? – FunkTheMonk Nov 08 '11 at 22:48
  • Yes, It opened in browser of phone. I typed https://twitter.com/mytwitterpage in address bar and initially black screen like above screen shot appeared for 3-4 seconds and after url changed to https://mobile.twitter.com/#!/mytwitterpage and page opened in browser. – anujprashar Nov 09 '11 at 05:03
  • Thanks for the tip, this was my case, I was getting "primary error: 3". This is on Android 1.6 only, later versions work fine. Any idea why this is happening? – Pēteris Caune Nov 28 '11 at 13:36