As Android devices grow, many sites are starting to device Android devices, while Android's mainstream devices are mobile phones and tablets. Web site in the adaptation through the user agent (user agents, hereinafter referred to as UA) and how to distinguish it, this part of the content translated from Google's official blog Mo ' better to also detect "mobile" user-agent.
Sharply
Standard judgment rule: Mobile Android has "mobile" string in the User-agent header. Tablet Android does not.
In the Android device UA string, the mobile device contains a mobile string, and the tablet device does not.
Erudite
Android is included in the UA string in the original Android device (that is, the phone), so you can use the Detect UA string to determine whether (case-insensitive) Android is included.
But then a new Android device appeared, the Android tablet, and unfortunately, the UA on the Android tablet also contains Android, which is better suited for displaying desktop (PC) Web layouts on the tablet. And if only by the above rules of judgment, the tablet users will not be very good user experience.
In view of the above problems, Google's Android engineers have proposed a solution. For devices that boot to a mobile layout, that is, a cell phone, you need to determine from the UA string whether to include both mobile and Android two words. Let's look at some examples first.
Like this UA string.
mozilla/5.0 (Linux; U Android 3.0; En-us; Xoom build/hri39) applewebkit/534.13 (khtml, like Gecko) version/4.0 safari/534.13
Because there is no mobile in the UA string, it needs to be booted to a desktop layout (or a layout tailored to the Android big screen device). As we can see from this UA string, it comes from a large screen setting, Motorola's Xoom tablet.
We'll look at another UA string.
mozilla/5.0 (Linux; U Android 2.2.1; En-us; Nexus one build/frg83) applewebkit/533.1 (khtml, like Gecko) version/4.0 Mobile safari/533.1
Includes mobile and Android, so take this nexus one phone to the mobile layout.
I believe that by comparing the two UA strings above, you have found some commonalities in UA, let's look at these commonalities. Android User Agent Commonalities
At last
So, when you're judging the Android phone device based on UA detection, check both Android and mobile two strings.
The above is the information on the Android identification equipment collation, follow-up to continue to update the relevant articles, thank you for your support of this site!