Dim Dim - 4 months ago 12
Android Question

Facebook on WebView looks weird

My WebView code:

WebViewClient yourWebClient = new WebViewClient()
{

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{

return false;
}

@Override
public void onPageFinished(WebView view, String url) {

super.onPageFinished(view, url);
}

@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {

super.onPageStarted(view, url, favicon);
}
};

webV = (WebView)findViewById(R.id.webView);

webV.getSettings().setJavaScriptEnabled(true);
webV.setWebViewClient(yourWebClient);
webV.getSettings().setBuiltInZoomControls(false);
webV.setSaveEnabled(true);

webV.loadUrl("http://"+value);


But Facebook looks weird on it and nothing like Facebook in web mode like in chrome, it looks like this:
enter image description here

And I wish it would look like regular web Facebook.

Answer

It's serving up the mobile optimised version of the site. It might be possible to get round this by changing the WebView's user agent like this;

String desktopUserAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
webV.getSettings().setUserAgent(desktopUserAgent);

Make sure you do this before trying to load the page.

Comments