RSS

Monthly Archives: August 2012

Released: uasniffer 1.1

The uasniffer library just got upgraded to 1.1. Highlights of the new release:

  1. Now detecting Kindle Fire, PlayStation Portable and Opera Tablets.
  2. Improved detection of Nook e-readers.

With uasniffer you get a Java-based library that detects a wide range of devices, OSes, browsers and browser engines:

  • common browsers: MSIE, Firefox, Safari, Chrome, Opera, etc.
  • e-readers, e.g. including the Nook, Kindle, Kindle Fire, etc.
  • all iOS devices (iPod Touch, iPhone, iPad)
  • Microsoft Windows (3.1, 95, 98, ME, 2000, XP, 7, 8, etc.)
  • MacOS (up until Mountain Lion)
  • Linux, including Android variants
  • less common OSes: AIX, FreeBSD, HPUX, IRIX, BeOS, etc.
  • Firefox (from early Phoenix prototypes up until 15+)
  • Blackberry devices
  • Symbian devices (e.g. Nokia and Samsung phones)
  • Sony PlayStation (PSP) devices, including the Vita
  • less common browsers: Epiphany, Maxthon, Flock, Camino, Konqueror, OmniWeb, Dolphin, etc.
  • old browsers: NCSA Mosaic, Netscape 1+, MSIE 2+, etc.
  • mobile and mini variants, e.g. Opera Mini, Fennec, IE Mobile, etc.
  • bots, such as Pingdom and the Google Bot

To use uasniffer in your Maven-based project, declare the following dependency:

<dependency>
<groupId>org.znerd</groupId>
<artifactId>uasniffer</artifactId>
<version>1.1</version>
</dependency>

Then in your Java code analyze a specific agent string as follows:

UserAgent ua = Sniffer.analyze(agentString);

To output the detected names for inclusion in an HTML class attribute, use the getNamesAsString() method:

String allNames = ua.getNamesAsString();

E.g. for an Amazon Kindle 3 the output will be something like this:

Device-NoPhone
Device-Mobile
Device-Ereader
Device-AmazonKindle
Device-AmazonKindle-3
Device-AmazonKindle-3-0
Browser-Kindle
Browser-Kindle-4
Browser-Kindle-4-0
BrowserEngine-WebKit
BrowserEngine-WebKit-528
BrowserEngine-WebKit-528-5
BrowserEngine-WebKit-528-5-0
BrowserEngine-WebKit-528-5-0-0
BrowserOS-NIX
BrowserOS-Linux
Advertisements
 
Leave a comment

Posted by on 25 August 2012 in Geen categorie