O'Reilly logo

Building Android Apps with HTML, CSS, and JavaScript, 2nd Edition by Brian MacDonald, Brian Jepson, Jonathan Stark

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix A. Detecting Browsers with WURFL

WURFL (Wireless Universal Resource File) is an XML file that contains the information needed to identify a wide range of mobile devices. On its own, it doesn’t do anything. But if you use one of the many available libraries for it, you can create web apps that can figure out what kind of device has connected to your app.

For example, wurfl-php (http://wurfl.sourceforge.net/nphp/) lets you detect which operating system a remote device is running from within a PHP script.

Note

To use WURFL and wurfl-php, you’ll need to be running your web app on a hosting provider that supports PHP. You’ll also need to understand how to install files and PHP libraries onto your server. In this appendix, I show you how to do this using the Unix or Mac OS X command line. If you are uncomfortable with any of this, but are comfortable working with PHP, contact your hosting provider’s support department and ask if they’d be willing to install WURFL and wurfl-php on the server you use. If you’re using a shared server, it would give your hosting provider a competitive advantage to offer this feature to all their customers.

Installation

First, download wurfl-php and extract it somewhere on your server (in general, it’s best to not put libraries in your public web folder, so I’m putting it into the src directory in my home directory). Replace ~/src with the location you want to install it to and replace wurfl-php-1.3.1.tar.gz with the name of the file you actually downloaded: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required