android user agent

Sagar Hatekar picture Sagar Hatekar · Apr 7, 2011 · Viewed 63.3k times · Source

I am writing an app in Android that uses a WebView to display HTML content. I was told to get an Android user agent for my app - how do I do that? I opened http://whatsmyuseragent.com from my app as well as the Android browser - both the user agents are the same.

Please help!

Answer

Sagar Hatekar picture Sagar Hatekar · Apr 8, 2011

After much research, I figured it out. There is a way to set a user agent for Android WebView.

webview.getSettings().setUserAgentString("user-agent-string");

http://developer.android.com/reference/android/webkit/WebSettings.html