This wiki does not contain official documentation and is currently deprecated and read only. Please try reading the documentation on the Liferay Developer Network, the new site dedicated to Liferay documentation. DISCOVER Build your web site, collaborate with your colleagues, manage your content, and more. DEVELOP Build applications that run inside Liferay, extend the features provided out of the box with Liferay's APIs. DISTRIBUTE Let the world know about your app by publishing it in Liferay's marketplace. PARTICIPATE Become a part of Liferay's community, meet other Liferay users, and get involved in the open source project. 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")