public class GettingStarted extends Object implements Closeable
provider = new Provider(StreamFactory.create(
Shared.getLitePatternV32(), false));
Match match = provider.match(userAgent);
match.getValues("IsMobile").toString();
| Modifier and Type | Field and Description |
|---|---|
protected String |
desktopUserAgent |
protected String |
mediaHubUserAgent |
protected String |
mobileUserAgent |
protected Provider |
provider |
| Constructor and Description |
|---|
GettingStarted()
Initialises the device detection Provider with the included Lite data
file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the
Dataset by releasing data
file readers and freeing the data file from locks. |
String |
detect(String userAgent)
Matches provided User-Agent string and returns IsMobile property value.
|
static void |
main(String[] args)
Main entry point for this example.
|
protected final Provider provider
protected final String mobileUserAgent
protected final String desktopUserAgent
protected final String mediaHubUserAgent
public GettingStarted()
throws IOException
IOException - can be thrown if there is a problem reading from the
provided data file.public String detect(String userAgent) throws IOException
Provider.match(java.lang.String).
Detection results are then stored in the Match object and can be
accessed using the Match.getValues("PropertyName") method.userAgent - HTTP User-Agent string.IOException - if there is a problem accessing the data file.public static void main(String[] args) throws IOException
detect(java.lang.String) method; and
args - command line arguments, not used.IOException - if there is a problem accessing the data file
that will be used for device detection.public void close()
throws IOException
Dataset by releasing data
file readers and freeing the data file from locks. This method should
only be used when the Dataset is no longer required, i.e. when
device detection functionality is no longer required, or the data file
needs to be freed.close in interface Closeableclose in interface AutoCloseableIOException - if there is a problem accessing the data file.Copyright © 2016 51Degrees. All rights reserved.