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";
Android webview to load desktop view
Web sites use a variety of mechanisms to decide to serve a mobile version of a page; the user agent is just one of them. They may set a cookie or some other piece of state that will always redirect to the mobile page after you've visited once. They might look at screen dimensions and do it that way. It's very hard to say what this particular website is doing. Maybe try clearing cookies?
Are you certain that the UA you have set is a desktop UA that the site recognises as a desktop browser?
Load desktop version WKWebView iOS 9
To help any who find themselves here for an answer.
The solution was
UserDefaults.standard.register(defaults: ["UserAgent" : "Chrome Safari"])
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);
Xamarin WebView request desktop site
You need to do this per platform
Android
In Android you have to implement a custom renderer. Add this into your Android code:
// this line directly ubleow usings, before namespace declaration
[assembly:ExportRenderer(typeof(WebView), typeof(DesktopWebViewRenderer))]
// this in your namespace
public class DesktopWebViewRenderer : WebViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
{
base.OnElementChanged(e);
Control.Settings.UserAgentString = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/4.0";
}
}
iOS
Xamarin Forms is using UIWebView, so you have to call
NSUserDefaults.StandardUserDefaults.RegisterDefaults(new NSDictionary("UserAgent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A"));
some where in your startup code. E.g. in FinishedLaunching
of your AppDelegate
.
Related Topics
How to Parse JSON Array Without Any Object in Retrofit
Partial Invalidation in Custom Android View with Hardware Acceleration
Layout Problem with Button Margin
Android - Choose File Button in Webview
How to Remove Child Nodes in Firebase Android
Why Did The Listview Repeated Every 6Th Item
Eclipse Indexer Errors When Using Stl with Android Ndk
Didn't Find Class on Path: Dexpathlist
Get Android .Apk File Versionname or Versioncode Without Installing APK
How to Make Grid View Scroll Horizontally Not Vertically in Android
Android Webview HTML5 Video Autoplay Not Working on Android 4.0.3
Parsing Date/Time to Localtimezone
Get Font Scaling Factor to Calculate the Fontsize
Insufficent_Storage_Memory Message While Install 50 Mb APK in Emulator
How to Integrate Opencv 4.0 into a Pure C++ Android Ndk Project