May 11th, 2010, 04:41 PM
|
#3 (permalink)
|
|
Member
Join Date: Sep 2009
Location: Birmingham, UK
Posts: 148
Device(s): G1 (Developer model), HTC Tattoo, Nexus One.
Thanks: 1
Thanked 26 Times in 22 Posts
|
The information you're after is easy to get if you have a WebView object.
I'm not aware of any other way to get it. Although to be honest I only spent 2 minutes looking. (I stopped when I found the WebView solution.)
The code below is from one of my apps where I use a WebView to show an about/help page. I added the last 2 lines to get the User Agent string.
Code:
public class AboutActivity extends Activity {
private WebView m_webview = null ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about) ;
m_webview = (WebView) findViewById(R.id.aboutview);
m_webview.getSettings().setJavaScriptEnabled(false);
m_webview.loadUrl("file:///android_asset/about.html") ;
String ua = m_webview.getSettings().getUserAgentString() ;
Log.i("AboutActivity", "UA = "+ua) ;
}
}
And I get this result:
Code:
UA = Mozilla/5.0 (Linux; U; Android 2.1; en-us; sdk Build/ERD79) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17
Best of luck finding a alternative solution, if that won't work for you.
Regards,
Mark
|
|
|