Answer the question
In order to leave comments, you need to log in
How do you compare versions of your app?
I have an application. Instead of going to the forums and posting a link to the new version when updating the application, I want to make the application connect to my server and check for a new version. But I can not find something on the Internet, how to compare versions. I think this is because the Play Market is mainly engaged in this. My application is not for Play Market'a. So how to compare, for example - "1.0.1", "1.2.99", "2.0.10"?
Answer the question
In order to leave comments, you need to log in
Searched wrong. Here is the correct request for google - java compare 2 version strings
For myself, I chose the Semver4j library (it also works in Android).
Examples:
implementation 'com.vdurmont:semver4j:3.1.0'
isGreaterThan returns true if the version is strictly greater than the other one.
Semver sem = new Semver("1.2.3");
sem.isGreaterThan("1.2.2"); // true
sem.isGreaterThan("1.2.4"); // false
sem.isGreaterThan("1.2.3"); // false
Semver sem = new Semver("1.2.3");
sem.isLowerThan("1.2.2"); // false
sem.isLowerThan("1.2.4"); // true
sem.isLowerThan("1.2.3"); // false
Semver sem = new Semver("1.2.3+sha123456789");
sem.isEqualTo("1.2.3+sha123456789"); // true
sem.isEqualTo("1.2.3+shaABCDEFGHI"); // false
Semver sem = new Semver("1.2.3+sha123456789");
sem.isEquivalentTo("1.2.3+sha123456789"); // true
sem.isEquivalentTo("1.2.3+shaABCDEFGHI"); // true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question