Reputation: 89
I put my app to Google Play, now I do something like adding new function, new UI, etc then re-upload app into Google Play.
So I want, when user launch app, if there is a new update, one dialog show to remind the user, allow them to update the latest version.
Google seems not provide any API to get app version, so is there any solution to do?
Upvotes: 1
Views: 9878
Reputation: 8305
Use Jsoup library and follow these steps:
1.add the dependency in your app level build.gradle
compile 'org.jsoup:jsoup:1.10.2'
2. Add this class in your src
public class VersionChecker extends AsyncTask<String, String, String> {
private String newVersion;
@Override
protected String doInBackground(String... params) {
try {
newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID + "&hl=en")
.timeout(30000)
.userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
.referrer("http://www.google.com")
.get()
.select("div[itemprop=softwareVersion]")
.first()
.ownText();
} catch (IOException e) {
e.printStackTrace();
}
return newVersion;
}}// add following lines to your code where you want to get live app version
VersionChecker versionChecker = new VersionChecker();try {
mLatestVersionName = versionChecker.execute().get();} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();}
Upvotes: 0
Reputation: 595
Try to store current version in their mobile and store newest version in your server.
When user launch app, check if it different, app will display dialog to remind use download newest application.
EDIT:
Check it comment: https://stackoverflow.com/a/14512102/4531387
Upvotes: 1