Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.HaraldWalker:user-agent-utils:1.21'
}
dependencies {
implementation("com.github.HaraldWalker:user-agent-utils:1.21")
}
<dependency>
<groupId>com.github.HaraldWalker</groupId>
<artifactId>user-agent-utils</artifactId>
<version>1.21</version>
</dependency>
libraryDependencies += "com.github.HaraldWalker" % "user-agent-utils" % "1.21"
:dependencies [[com.github.HaraldWalker/user-agent-utils "1.21"]]
Utilities for processing user-agent strings. Can be used to handle http requests in real-time or to analyze log files.
http://www.bitwalker.eu/software/user-agent-utils
For the latest release, go to https://github.com/HaraldWalker/user-agent-utils/tree/master
This library has reached end-of-life and will not see regular updates any longer.
Version 1.21 was the last official release in 2018.
Pull request with significant feature changes will not get processed.
If you want to improve this library, fork it and release it yourself.
As alternative have a look at the Browscap project and its implementations.
https://github.com/HaraldWalker/user-agent-utils
If you used this library for a commercial product, a donation would have been great during the past years.
<a href="http://flattr.com/thing/1968218/HaraldWalkeruser-agent-utils-on-GitHub" target="_blank"><img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0" /></a>
A lot of user-agents lie about their identity. That makes UA sniffing a guessing game. On websites it is a better approach to detect features using a javascript library like Modernizr (http://modernizr.com/).
Instead of using browser switches, build sites and services that are cross-platform/cross-device compatible.
TBA
http://bitwalker.eu/user-agent-utils-snapshot/javadoc/index.html
Add dependency:
<dependency>
<groupId>eu.bitwalker</groupId>
<artifactId>UserAgentUtils</artifactId>
<version>1.21</version>
</dependency>
Add dependency for snapshot releases:
<dependency>
<groupId>eu.bitwalker</groupId>
<artifactId>UserAgentUtils</artifactId>
<version>1.22-SNAPSHOT</version>
</dependency>
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 is not to detect every possible version, so you’ll have to provide the business value for a change.
Where can I report bugs or make feature requests
Go to https://github.com/HaraldWalker/user-agent-utils/issues
How can I improve the performance of the user-agent parsing?
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.
Are there other libraries like this?
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.
http://www.bitwalker.eu/contact