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://whatsmyuse
Put this in the onCreate method of the java class for the activity that displays the WebView:
WebView myWebView = (WebView)findViewById(R.id.webview);
//get the UA of the current running device:
String userAgent = view.getSettings().getUserAgentString() ;
//set the UA of the webview to this value:
myWebView.getSettings().setUserAgentString(userAgent);
Don't use System.getProperty("http.agent") - this will return the 'Dalvik' user agent (Dalvik is the VM that individual Android apps run within)