Device detection capabilities

Liferay 6.1 includes a new API for detecting the capabilities of the device which is making a request to your portal.

In order to be able to use this feature, you will need to deploy a plugin called "Device Recognition". This plugin is using a device database called WURFL to determine the capabilities of the device, but you could create your own plugin to use your own devices database.

Using the Device API #

The object Device can be obtained from the themeDisplay object like this:

 Device device = themeDisplay.getDevice();

And the API can be seen in the Device javadocs.

For example, in order to obtain the dimensions of the device you could do:

Dimensions dimensions = device.getScreenSize();
float height = dimensions.getHeight();
float width = dimensions.getWidth();

Device Capabilities #

Most of the capabilities of the device can be detected, but this depends on the device detection implementation you're using. In the case of WURFL (the default with the Device Recognition plugin), you can see the list of WURFL capabilities here and you would obtain them like this:

String brand = device.getCapability("brand_name")  

0 Attachments
Average (1 Vote)
The average rating is 4.0 stars out of 5.
Threaded Replies Author Date
Good feature. Gaurav Jain September 12, 2012 3:07 AM
Useful to make your portlets mobile-aware in... Peter Mesotten September 17, 2012 12:06 AM
Great!! Paras Jain September 27, 2012 12:52 PM
Good Feature., Thanks its help me to implements... M. Ahamed Maqbool October 1, 2012 5:31 AM
Has anyone tested the capabilities that are... Huage Chen July 24, 2013 8:11 AM

Good feature.
Posted on 9/12/12 3:07 AM.
Useful to make your portlets mobile-aware in combination with media query enabled themes! Thanks for sharing.
Posted on 9/17/12 12:06 AM.
Posted on 9/27/12 12:52 PM in reply to Peter Mesotten.
Good Feature., Thanks its help me to implements this feature in my Projects
Posted on 10/1/12 5:31 AM.
Has anyone tested the capabilities that are able to be detected through "device" object. I tried to get identify whether the device is a desktop or not. Failed to get it with the following expression:
Posted on 7/24/13 8:11 AM in reply to M. Ahamed Maqbool.