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)
Related
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 ;)
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...
I am using android webview to show an article .
I need to re-wrap the text whenever the user make a zoom .
I'm using android lollipop .
I found this solution but it is not working for me ?
String userAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
settings.setUserAgentString(userAgent);
Any trick to do that?
Is there is a way to reload the webview whenever the user make a zoom so it will be loaded wrapped to the new size?
You have to do that in javascript function and call that through the javascript client of webview.
for details visit:
android webview basics
I have an image within a div container, that div container
has the style "overflow:hidden" which works on all major browsers
but for some reason doesn't work on Xoom, any ideas?
What browser is that anyway?
I've got a similar quandary in that overflow:auto stuff appears properly when the dom element is within the viewport, but once the element has moved above or below the viewport, it's content breaks free and becomes visible.
To answer your "what browser is that anyway", the User Agent I got during my tests was:
Mozilla/5.0 (Linux; Android 3.1; en-us; Xoom Build/HMJ37) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13
The interface certainly looks like Chrome, but I guess it's a custom browser(?)
Paste that into http://useragentstring.com to get a pretty good analysis of the agent string.