Warning: This project is end-of-life and will not be updated regularly any longer . As alternative have a look at the Browscap project and its implementations.
Fast detection of:
- more than 150 different browsers
- 7 different browser types
- more than 60 different operating systems
- 6 different device types
- 9 different rendering engines
- 9 different web applications
By not trying to identify hundreds or even thousands of different clients and operating systems it tries to offer a compromise between performance and usability. Other libraries (some commercial) offer a more detailed detection.
For the latest release, go to https://github.com/HaraldWalker/user-agent-utils/tree/release-1.21
For the latest snapshot version, go to https://github.com/HaraldWalker/user-agent-utils
<dependency> <groupId>eu.bitwalker</groupId> <artifactId>UserAgentUtils</artifactId> <version>1.21</version> </dependency>
If you need more frequent updates, using the snapshot version is another option:
<dependency> <groupId>eu.bitwalker</groupId> <artifactId>UserAgentUtils</artifactId> <version>1.22-SNAPSHOT</version> </dependency>
Pass the user-agent string from the request as parameter to the parser.
UserAgent userAgent = UserAgent.parseUserAgentString(request.getHeader("User-Agent"));
How to support this project
Can I add new browsers or operating systems?
Unfortunately not directly. This library uses enums to represent browsers and operating systems to make using it easy and readable. Unfortunately the use of enums also has some disadvantages.
You can make a pull request on trunk for a new browser or operating system if all tests are still passing. The purpose of this library was and is not to detect every possible version.
Where can I report bugs or make feature requests?
This project is not accepting issues or change requests any longer.
When handling requests on a web-server, consider if you need both the browser and operating system or if one of the two gives you enough information. As the parsing uses an ordered tree structure, performance depends a lot on the type of clients making the requests. The most common browsers and operating systems will be parsed faster than exotic ones. Consider caching the results temporarily.
When I started this project in 2010 there were no other libraries offering the features I was looking for. Currently there are both open source as well as commercial solutions.
Should I use this library for my web-project?