Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webview rendering page different on different devices

Tags:

android

My Webview setting for now is..

wv = (WebView) findViewById(R.id.webView1);
        wv.setHorizontalScrollBarEnabled(true);
        wv.setKeepScreenOn(true);
        wv.getSettings().setJavaScriptEnabled(true);
        wv.getSettings().setBuiltInZoomControls(true);
        wv.setInitialScale(1);
        wv.getSettings().setUserAgent(1);
//      wv.getSettings().setUserAgentString("Android");
//      wv.getSettings().setUserAgentString("Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7");
//      wv.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");
        wv.getSettings().setUserAgentString("Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
        wv.getSettings().setUseWideViewPort(true);
        wv.setWebViewClient(new MyWebViewClient());
        wv.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

I am trying to load https://www.facebook.com/Nissan on my Phone SAMSUNG GALAXY S (OS 2.3.5) and SAMSUNG NEXUS (4.0) it loads differently on both the phone..

it looks perfect on GALAXY S.. and create some prob on NEXUS 4.0 and not opening mobile view of page..

Already tried by supplying different user agent as listed and found some interesting results over http://www.anandtech.com/show/5310/samsung-galaxy-nexus-ice-cream-sandwich-review/5

Still couldn't solve it. Let me know where I'm wrong..

The problem comes with SAMSUNG NEXUS (4.0) only..

Thanks.

like image 280
Vishal Khakhkhar Avatar asked Mar 22 '26 23:03

Vishal Khakhkhar


1 Answers

@Paresh Mayani n All

succeed to reproduce the issue and solved.. changed a bit.. just removed User Agent String.. My current Webview Setting is..

        wv = (WebView) findViewById(R.id.webView1);
        wv.setKeepScreenOn(true);
        wv.getSettings().setJavaScriptEnabled(true);
        wv.getSettings().setDomStorageEnabled(true);
        wv.getSettings().setBuiltInZoomControls(true);
        wv.setInitialScale(100);
        wv.getSettings().setUseWideViewPort(true);
        wv.setWebViewClient(new MyWebViewClient());
        wv.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);

and added one line

wv.getSettings().setDomStorageEnabled(true);

to support twitter profile URL.

Thanks.

like image 91
Vishal Khakhkhar Avatar answered Mar 24 '26 11:03

Vishal Khakhkhar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!