Tutorial about Detecting User Agent Types and Client Device Capabilities

A major problem faced by mobile application developers is that wireless devices such as cell phones have very different capabilities. One feature that is supported on one cell phone model may not be available on another model.

There are a number of methods for detecting the features and capabilities of a user agent or wireless device. In this tutorial, we focus on two of them. The first method is to make use of HTTP headers such as Accept, User-Agent, Accept-Charset and Accept-Language. The other method is to retrieve information from a UAProf (User Agent Profile) document. UAProf was defined by the Open Mobile Alliance for user agent detection and client device capabilities detection.

Table of Contents

1. User Agent Detection and Client Device Capabilities Detection

1.1. Introduction

2. Headers in HTTP Requests

2.1. The Accept Header -- Find the MIME Media Types that will be Accepted by a User Agent

2.1.1. Common MIME Types List

2.2. The User-Agent Header -- Identify a User Agent and Client Device

2.2.1. To Identify a Specific Mobile Device Model with the User-Agent Header

2.2.2. To Differentiate Mobile Devices or User Agents Made by Different Companies with the User-Agent Header

2.2.3. To Determine Whether a User Agent is a Web Browser on a Personal Computer or a Microbrowser on a Mobile Device with the User-Agent Header

2.3. The Accept-Charset Header -- Find Character Sets that are Supported by a User Agent

2.4. The Accept-Language Header -- Find the Language Preference

2.5. The x-wap-profile Header and the Profile Header -- Find the UAProf Document of a Mobile Device

3. How to Read the Value of an HTTP Header

3.1. Retrieving HTTP Headers with ASP

3.2. Retrieving HTTP Headers with Java Servlet / JSP

3.3. Retrieving HTTP Headers with Perl

3.4. Retrieving HTTP Headers with PHP

4. Using UAProf (User Agent Profile) to Detect User Agent Types and Device Capabilities

4.1. Introduction

4.2. Where to Find the URL of the UAProf Document of a Mobile Device

4.3. UAProf Profile Resolution

4.3.1. Free Library / Tool for Retrieving UAProf Attribute Values

4.3.2. A Simple Way for Retrieving UAProf Attribute Values

4.4. UAProf Components and Attributes

4.4.1. Collection Types and Attribute Types in UAProf