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 附件
15871 查看
平均 (1 投票)
满分为 5,平均得分为 4.0。
评论
讨论主题回复 作者 日期
Good feature. Gaurav Jain 2012年9月12日 上午3:07
Useful to make your portlets mobile-aware in... Peter Mesotten 2012年9月17日 上午12:06
Great!! Paras Jain 2012年9月27日 下午12:52
Good Feature., Thanks its help me to implements... M. Ahamed Maqbool 2012年10月1日 上午5:31
Has anyone tested the capabilities that are... Huage Chen 2013年7月24日 上午8:11

在 12-9-12 上午3:07 发帖。
Useful to make your portlets mobile-aware in combination with media query enabled themes! Thanks for sharing.
在 12-9-17 上午12:06 发帖。
在 12-9-27 下午12:52 发帖以回复 Peter Mesotten
Good Feature., Thanks its help me to implements this feature in my Projects
在 12-10-1 上午5:31 发帖。
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:
${device.getCapability("is_wireless_device")}
在 13-7-24 上午8:11 发帖以回复 M. Ahamed Maqbool