Change PhoneGap / Cordova User-Agent for AJAX
android, cordova, jquery, user-agent
Solution
put this in your onCreate method: (after super.init();)
super.appView.getSettings().setUserAgentString("Your own agent string");
this worked for me.
See for more settings: http://developer.android.com/reference/android/webkit/WebSettings.html
Problem
I'm using phonegap / cordova for developing an Android app. The app has to read files on a remote server. Therefore I'm using AJAX (jQuery). The problem is: The remote server redirects all connections from mobile devices to a mobile version, which doesn't work for me, so I have to change the User Agent to a desktop browser. How can I do this? I've seen a solution for iOS. Is something like this possible for Android? Edit: I found a solution myself: Just add ``` WebSettings w = this.appView.getSettings(); w.setUserAgentString("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1"); ``` to `/src/com/a/b/c.java` in `onCreate`-method.