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.
#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.
Related
I want to use whats app in Webview android. I've already tried to set user agent but it didn't help.
Is there any way that whats app recognize webview as Chrome browser.
String newUA= "";
newUA= "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.181 Safari/537.36";
binding.webView.getSettings().setJavaScriptEnabled(true);
binding.webView.loadUrl("https://web.whatsapp.com/");
binding.webView.getSettings().setUserAgentString(newUA);
try to set User Agent BEFORE calling URL load (make all settings-related calls before any page load try)
Take the following useragent:
Mozilla/5.0 (Linux; Android 11; SM-G991B Build/RP1A.200720.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.120 Mobile Safari/537.36 EdgW/1.0
What does EdgW mean?
EdgA means its Edge on Android
EdgiOS means its Edge on IOS
(source: https://blogs.windows.com/msedgedev/2017/10/05/microsoft-edge-ios-android-developer/)
but what does EdgW mean? Especially given that the useragent states that the user is using an Android device
we believe that this is an Edge WebView (this is just a guess so far)
https://github.com/matomo-org/device-detector/issues/6636
I'm uploading a URL to CustomTabs. I want to enable pinch zoom in CustomTabs. By default it does not enable zoom pinch, but if you go to the menu and tapDesktop Site, enable pinch zoom.
I want to know that if there is a way to open Desktop site by default when the user launches a web URL from my app.
Checkout this answer...
I've tried this and it works well
How to open desktop site in webview in android
You can set user agent for your webView programmatically
In case something happens to the link, here's the answer for your question from that link:
private static final String DESKTOP_USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36";
private static final String MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; U; Android 4.4; en-us; Nexus 4 Build/JOP24G) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30";
//Choose Mobile/Desktop client.
WebSettings settings = mWebView.getSettings();
settings.setUserAgentString(DESKTOP_USER_AGENT);
I used User agent Mozilla/5.0 (Linux; Android 4.4.4; One Build/KTU84L.H4) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/56 Mobile Safari/537.36 that show my user as chrome 56, if I edit that it shows default Android webView or Android Browser. But I want to show my browser name.
Yes you can change user-agent :
WebSettings settings = webView.getSettings();
settings.setUserAgentString(" MY BROWSER ");
This is just a string , it is still chrome ;)
I'm having a problem related to this one. Basically, the same WebView displays differently on Android 2.2 and Android 4.0. In Android 4.0 it displays the mobile version of the website, while in 2.2 it displays the web version of it. Also, in the default web browser on Android 2.2 it displays the mobile version like it should. Is this a known bug? I have tried different settings for the webview so far but I always get this problem, on real devices and in the emulator.
I have attached 2 screens to see the difference. And here is the code. Note that I have tested pretty much all the combinations for the settings and to no use.
`
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setSupportZoom(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.setInitialScale(1);
webView.getSettings()
.setUserAgentString(
"Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3");
webView.loadUrl("http://www.fernbus24.de/");
}`
Why is the display different? What does the WebView on Android 4.0 have that the other one doesn't?
It's not an Android bug, it's the website and the way it recognizes mobile devices. I tried google.com and facebook.com and they loaded the mobile version without problems.