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 ;)
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);
This is my url that I want to open in webview but its show different UI rather than the chrome or mozila browser.
http://www.nigeriatoday.ng/
Try to open it in webview and browser and you know the difference.
I need same like browser. Please help me. It would be appreciatable.
WebSettings settings = webvw.getSettings();
webvw.setWebViewClient(new WebViewClient());
webvw.setWebChromeClient(new WebChromeClient());
webvw.getSettings().setJavaScriptEnabled(true);
webvw.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
webvw.loadUrl(Url);
Thanks
As Murat said, You have different look and feel for Mobile version and desktop version.
If you have any specific requirement that you need to display Web content with desktop version on webview, then you can use below code.
String ua = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
webvw.getSettings().setUserAgentString(ua);
You can see below output...
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.