Java Client 1.1.0
2014-12-17
-Include the following 2 maven dependencies:
{{{#!highlight xml
<dependency>
<groupId>org.apache.devicemap</groupId>
<artifactId>devicemap-client</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.devicemap</groupId>
<artifactId>devicemap-data</artifactId>
<version>1.0.1</version>
</dependency>
}}}
NOTE: If using LoaderOption URL or FOLDER, you can drop the above devicemap-data dependency.
-Include the following Java code:
{{{#!highlight java
//get client using JAR data source
DeviceMapClient client = DeviceMapFactory.getClient(LoaderOption.JAR);
//get client using data from a URL
//DeviceMapClient client = DeviceMapFactory.getClient(LoaderOption.URL, "http://devicemap-vm.apache.org/data/latest");
//get client using data from a local filesystem
//DeviceMapClient client = DeviceMapFactory.getClient(LoaderOption.FOLDER, "/some/path/devicemap/latest/devicedata");
String userAgent = "Mozilla/5.0 (Linux; U; Android 2.2; en; HTC Aria A6380 Build/ERE27) AppleWebKit/540.13+ (KHTML, like Gecko) Version/3.1 Mobile Safari/524.15.0";
//classify the userAgent
Device device = client.classifyDevice(userAgent);
System.out.println("Device detected: " + device.getId());
//iterate thru the attributes
for (String attr : device.getAttributes().keySet()) {
System.out.println(attr + ": " + device.getAttribute(attr));
}
}}}
Java Client 1.0.0
2014-07-16