Setting WebView to view Desktop Site and Not Mobile Site
Change the user agent of webview
String newUA="Foo/"; // Change this to desired UA
like
String newUA= "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
mWebView.getSettings().setUserAgentString(newUA);
How to open desktop site in webview in android
This is the perfect solution:
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);
UPDATE
The above MOBILE_USER_AGENT is no longer supported.
so use the given below user agent
private static final String MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 9; Redmi 6 Pro Build/PKQ1.180917.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/89.0.4389.105 Mobile Safari/537.36";
Want to load desktop version in my webview using uastring
It might be that they know you are on a mobile phone because you have Android
in the user agent. Try something more desktop browser looking such as:
String ua = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
Related Topics
Android Adb Doesn't See Device
How to Get the Timezone Offset in Gmt(Like Gmt+7:00) from Android Device
Import Android.Support.V7.App Cannot Be Resolved
Decrease Image Size Without Losing Its Quality in Android
How to Launch the Android Emulator from the Command Line
How to Install the App Twice Without Interference in Android
How to Handle Parameters That Can Be an Array or Object in Retrofit on Android
I Want to Change Actionbar Icon Size
Html File Input Control With Capture and Accept Attributes Works Wrong
Change App Language Programmatically in Android
React-Native Run-Android Has Error, How to Fix It
How to Access the Camera from Within a Webview
Download Manager Progress Not Visible in the Notification Area
Where Is Adb.Exe in Windows 10 Located
How to Clear Navigation Stack After Navigating to Another Fragment in Android
Fragment Is Not Being Replaced But Put on Top of the Previous One