User agents are dead
Most end-users don’t think about user agents, but to a web programmer, they’ve been both a blessing and a bane of our existence for years.
Anyone who has used more than one browser over the years will know that web pages sometimes don’t show up exactly the same in one browser or another. A margin will be a little wider here, or an image will be shifted slightly over there. This is normal, and stems from the fact that there’s no standard implementation of HTML; it’s up to each web browser to handle it the best they can (and some are certainly better than others). Part of the reason web pages show up differently is due to the little quirks between rendering engines. The other reason is due to developers trying to work around these quirks.
Checking the user agent is one way that developers use to know if they need to use a workaround. However, as more and more browsers have entered the market, the number of user agents has grown. Nowadays, between all the various desktop and mobile browsers, it’s an impossible feat to try and do anything relying on user agents. Not only are they highly varied, they tend to be highly varied for no major reason. Three different browsers that all use WebKit could very well report different user agents. Not to mention the fact that several browsers have the ability (through plugins) to change the default user agent to something you’d like.
In comes Android to make the job a whole lot messier. They’ve got a method called WebSettings::setUserAgent() which allows you to set the user agent to 1 of three things (god forbid if they’d made it free-form):
- Android user agent–the default. As far as I can tell, this is something to the tune of “Mozilla/5.0 (Linux; U; Android 1.1; en-us; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2″
- What it calls a “desktop user agent.” Haven’t tried it yet to find out what exactly this is.
- iPhone user agent
Whoopie. Three different user agents, all for the same rendering engine :-\ The first one is the best–although I was pretty sure the browser on Android is supposed to be more like Chrome, I guess they haven’t added it to the user agent yet. The second one makes a little bit of sense, actually. Android is cross-platform, so being able to request a desktop-like user agent might actually be useful in some scenarios. I don’t know why the hell we should pretend to be an iPhone though.
As if it’s not bad enough that there’s no uniformity to user agents, and that end-users can tweak them in some browsers, Android has now given its developers to choose user agents in their applications. Thank you Android: you just made user agents a little less useful.
