Device Detection and Capabilities
We looked at what WALL can do and how easy it is to implement it. But how does it do that? WALL, and many other open-source (and commercial) tools use WURFL—Wireless Universal Resource File. The mDevInf tool that we saw earlier in this chapter is entirely based on WURFL. WURFL is a massive XML file, listing capabilities of all known mobile devices (almost!). It is actively maintained and also derives information from UAProf—another standard for managing device capabilities.
At the heart of any device detection is the User Agent header sent by the browser. All device detection techniques check the User Agent ($_SERVER['HTTP_USER_AGENT'] variable for PHP) and look up their database to find the characteristics of that device.
Here are some of the things WURFL can tell you about a device:
Screen size of the device
Supported image, audio, video, ringtone, wallpaper, and screensaver formats
Whether the device supports Unicode
Is it a wireless device? What markup does it support?
What XHTML MP/WML/cHTML features does it support? Does it work with tables? Can it work with standard HTML?
Does it have a pointing device? Can it use CSS?
Does it have Flash Lite/J2ME support? What features?
Can images be used as links on this device? Can it display image and text on the same line?
If this is an iMode phone, what region is it from? Japan? US? Europe?
Does the device auto-expand a select drop down? Does it have inline input for text fields?
What SMS/MMS features are supported?
The list goes on. But you can make some intelligent decisions in your application based on the device now. You can even conditionally print <wall> tags. E.g. show a download link only if the device has download support.
WURFL API is available in many programming languages, including Java, PHP, .Net, Ruby, and Python. You can download it from: http://wurfl.sourceforge.net/.
XML Processing can Bog Down My Server, is There Something Easier?
Yes! The WURFL XML file is above 4MB, and despite many structural optimizations, processing it on every request will certainly slow down your server. Many APIs provide caching to speed things up. But having this available in a database will be best. Tera-WURFL is a PHP package that uses MySQL to store WURFL data. It bundles WALL and an admin panel—making it the top choice for mobile web adaptation.
Setting up Tera WURFL involves downloading the latest package from http://www.tera-wurfl.com/, extracting the files and entering the database connection information in the configuration file. It will load up the device data to the database and can start serving WALL pages.
What About W3C's DIAL?
W3C's DIAL (Device Independent Authoring Language) is a combination of XHTML 2, XForms, and DISelect. DIAL (http://www.w3.org/TR/dial/) was created to develop a language that will allow consistent delivery across devices and contexts. Though the language is new, it's getting a good response and is something to keep track of!
Previous Page | Page 3 of 4 | Next Page |