Dragonsaber Website Design Banners Computer Art Print Design Kerwin"s Resume About Dragonsaber

March 18, 2012

Mobile Detection for Android Tablets

Any website that had device detection + redirection created over a year ago will now run into the issue of sending Android tablet users to the mobile version. Detection scripts usually look at the user-agent for the device type, which isn't a problem for Apple because they distinguish "iPhone" from "iPad" for iOS. Android only has a device type of "Android" since they had all phones back then. Even the early tablets were really just phones with larger screens as they shared the same exact OS (2.x) as their smaller siblings. Over the past year Android evolved into a dual device operating system and several manufacturers released popular tablet models. Their device type was still "Android" in the user-agent for everything rather than moving to "Android Phone" and "Android Tablet." Fortunately, they started distinguishing tablet from phone in 3.1. The browser portion of the string has "Safari" for tablets and "Mobile Safari" for phones. So an Android device should get sent to the mobile site if "Android" + "Mobile" are both found in the full string. "Mobile" can't be used as a catch-all term because that word in Apple lingo refers to phones and tablets. Both the iPhone and iPad use "Mobile" in their user-agent strings.

Of course, all of this may change soon as pixel density continues to increase in newer screens and manufacturers release devices that fill in all sizes between 4" phones and 10" tablets!

No comments: