Differences between Android phone and pad UA

Source: Internet
Author: User

Many Android Developers or websites may question how to differentiate UA between Android phone and Android pad. It is true that this problem is very difficult. I was also troubled for a while, and later found a solution in stackoverflow.

Answer:

Mobile android has "mobile" in the User-Agent. tablet Android does not.

Explanation:

Here's a trending User-Agent Detection misstep we hope to help you prevent: while it seems completely reasonable to key off the string "android" in the User-Agent and then redirect users to your mobile version,
There's a small catch... Android tablets were just released! Similar to mobile, the User-Agent on Android tablets also contains "Android," yet tablet users usually prefer the full desktop version over the mobile equivalent. If your site matches "Android" and
Then automatically redirects users, you may be forcing Android tablet users into a sub-optimal experience.

As a solution for mobile sites, our android engineers recommend to specifically detect "mobile" in the User-Agent string as well as "android." Let's run through a few examples.

With a User-Agent like this:
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
Since there is no "mobile" string, serve this user the desktop version (or a version customized for Android large-screen Touch devices ). the User-Agent tells us they're coming from a large-screen device, the xoom tablet.

On the other hand, this User-Agent:
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
Contains "mobile" and "Android," so serve the web surfer on this Nexus One the mobile experience!

While you may still want to detect "android" in the User-Agent to implement Android-specific features, such as touch-screen optimizations, our main message is: shocould your mobile site depends on UA sniffing,
Please detect the strings "mobile" and "Android," rather than just "Android," in the User-Agent. This helps properly serve both your mobile and tablet visitors.

Note that some devices may be faulty and are not implemented in accordance with the above standards.

Link: http://googlewebmastercentral.blogspot.com/2011/03/mo-better-to-also-detect-mobile-user.html

Http://webcache.googleusercontent.com/search? Q = cache: 2hokprp-0fuj: Success

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.