Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know a user-agent string for specific android devices?

The mission is to get some statistics on some of the devices at the web-server side. For that, I would like to know the user-agent string for default browsers on specific Android devices such as:


  • HTC:
    • HTC Jetstream
    • HTC Flyer
    • HTC Evo View 4G

  • NEXUS:
    • Nexus 7
    • Nexus 10

  • SAMSUNG:
    • Galaxy Tab
    • Galaxy Tab 2
    • Galaxy Note

  • MOTOROLA:
    • Motorola Xyboard 8"
    • Droid Xyboard
    • Motorola Xyboard 10"

Is there an easy way to know it? Is there a well-known list that maps device name to user-agent string? Also, if I should take a different approach - please advice.

like image 364
BreakPhreak Avatar asked Dec 25 '12 16:12

BreakPhreak


People also ask

Where is the user agent string?

The User-Agent (UA) string is contained in the HTTP headers and is intended to identify devices requesting online content. The User-Agent tells the server what the visiting device is (among many other things) and this information can be used to determine what content to return.

What is the user agent string?

A browser's User-Agent string (UA) helps identify which browser is being used, what version, and on which operating system. When feature detection APIs are not available, use the UA to customize behavior or content to specific browser versions.

How do I find my user agent?

The user-agent string of the browser is accessed using the navigator. userAgent property and then stored in a variable. The presence of the strings of a browser in this user-agent string is detected one by one. Detecting the Chrome browser: The user-agent of the Chrome browser is “Chrome”.

What does a user agent string contain?

Described in the HTTP standard, the User-Agent string contains a number of tokens that refer to various aspects of the request, including the browser's name and version, rendering engine, device's model number, operating system and its version, etc.


3 Answers

In my opinion to count the Hit from various User Agent on base of Android Device you should make one URL pointing to server. In the starting of application get User Agent and send to your server.

I run this code to get User Agent

        WebView mes = new WebView(this);
        String str = mes.getSettings().getUserAgentString();
        Log.i("My User Agent", str);

On Samsung Tablet 10.1 inch emulator i got user agent

Mozilla/5.0 (Linux; U; Android 3.0; en-us; sdk Build/HONEYCOMB) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13

and on Nexus emulator i got

Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; google_sdk Build/MR1) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
like image 149
Tofeeq Ahmad Avatar answered Sep 21 '22 12:09

Tofeeq Ahmad


Although this is not a direct answer, I would like to raise out the issue:

Please note that user-agent in client side can be modified easily. For example in programming aspect:

HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);
HttpProtocolParams.setUserAgent(params, "WAHAHAHA");
HttpConnectionParams.setConnectionTimeout(params, HTTP_CONNECTION_TIMEOUT);
HttpConnectionParams.setSoTimeout(params, HTTP_READ_TIMEOUT);
HttpClient newHttpClient = new DefaultHttpClient(params);

When using this HttpClient to access your site, the user agent will be "WAHAHAHA"

In addition, some web browsers available in market such as dolphin browser allows user to input any user agent combination they want.

Therefore what i think is the hit count statistic collected from the user agent will be not so reliable, I would recommend to find another criteria to collect the hit count information =]

like image 40
hungr Avatar answered Sep 21 '22 12:09

hungr


I would recommend you to modify an existing solution such as Apache Mobile Filter which is written in perl. It uses 51Degrees XML file with something about 70k user agents. You simply would have to find interesting ones and modify AMF script in such way that it would collect interesting data. What is more 51Degrees and AMF might be used also to recognize whether the user's device is mobile, it's screen dimensions etc.

like image 44
Adam Sznajder Avatar answered Sep 21 '22 12:09

Adam Sznajder