Twitter not loading in a WebView

MDEnt

Member
Licensed User
Longtime User
Wondering if anyone else has tried or is having a problem loading the Twitter website in a WebView. It just shows a blank page.

I have tried to regular site twitter.com and the mobile site with mobile.twitter.com with both http and https.

It loads fine in Dolphin,Firefox, for Android, etc.

Is the WebView missing something that Twitter needs to display?
 

pluton

Active Member
Licensed User
Longtime User
Hi MDEnt

You are right. If you just go with your webview on m.twitter.com or mobile.twitter.com you will get this:

twitt.png


But if you set User Agent String you will get normal site :D
B4X:
   Dim Obj1 As Reflector
   Obj1.Target = Web 'name of your webview
   Obj1.Target = Obj1.RunMethod("getSettings")
   Obj1.RunMethod2("setUserAgentString", "Android 2.2", "java.lang.String")

Don't forget to add Reflection library

tw2.png
 
Upvote 0

MDEnt

Member
Licensed User
Longtime User
Ah nice. Thanks to both. It's my first time using a webview.

Is it recommended to set the user agent string for any webview - even if the page is already showing up correctly?
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Ah nice. Thanks to both. It's my first time using a webview.

Is it recommended to set the user agent string for any webview - even if the page is already showing up correctly?

No i'd say not.
If the web page loads correctly without modifying the user agent string then no need to bother.

Martin.
 
Upvote 0

MDEnt

Member
Licensed User
Longtime User
Thanks for the info - I've now tried to do a viewbiew with linkedin's new mobile site with no luck - using the user agent - this one hangs on a blank screen - loads fine in dolphin etc. m.linkedin.com
 
Upvote 0
Top