Skip navigation links

Package fiftyone.mobile.detection

Contains classes necessary to perform device detection and access device data.

See: Description

Package fiftyone.mobile.detection Description

Contains classes necessary to perform device detection and access device data.

Use like:
Provider p = new Provider(StreamFactory.create("path_to_file", false));
Match m = p.match("User-Agent string here");
System.out.println(m.getValues("IsMobile"));

Where StreamFactory.create initialises a Dataset object which is responsible for interacting with device data.

Two factories are available: Stream and Memory.
Stream factory creates a Dataset object that maintains a pool of binary readers. Each reader maintains an open channel to the data file and is used to look up device data when required.
Memory factory creates a Dataset where the data file is loaded into memory as either an array of bytes or a complete set of entities. Whether the data file is loaded fully or as an array of bytes is controlled by the boolean flag when invoking the ;

The Provider object should be used to perform device detection. It exposes several match() methods that take in a User-Agent, a collection of HTTP headers and a device Id and return a Match object with detection results.

Along with detection results Match objects also contain match metrics information such as the device Id, detection method, difference and rank. Match metrics information can be used for a number of things such as spotting fake User-Agents. How device detection works.

Device detection uses LRU (Least Recently Used) caching algorithm to speed up detections for the more frequently occurring User-Agents. Caching is also used internally with the stream detection method to speed up the retrieval of various entities.

AutoUpdate class provides a method that should be used to retrieve the latest device data. The automatic update requires a licence key. Get a licence key.

51Degrees device data is supplied in the binary form but Java API can be used to work with data entities. The tutorials on the Web site as well as the examples in the example.illustration package (located in the different module of this Maven project) provide several examples of working with data. For more information about the data model please see: Pattern data model.

For more information please see the Java documentation pages.

Skip navigation links

Copyright © 2015 51Degrees. All rights reserved.