I have an android application of version say 6.0.3 In play store we have new version namely 6.0.4. I need a code to prompt the user with pop up notification to update if an installed version is older. How can i get version from play store and compare them.
-
try storing version your app only and then check for newer one – ashishmaurya Aug 27 '15 at 10:59
-
@user3091574 Hi tell me how to get new version from play store. Following code will give me a current version of an application. PackageInfo packageInfo = getPackageManager() .getPackageInfo(getPackageName(), 0); String appVersion = packageInfo.versionName; – Archana Aug 27 '15 at 11:10
-
store new version somewhere on web and then access it through "internet" – ashishmaurya Aug 27 '15 at 15:21
-
try this, works always: http://stackoverflow.com/questions/19244305/force-update-android-app-when-new-version-available/32942785#32942785 – AshuKingSharma Oct 28 '15 at 06:50
3 Answers
Hi guys i found an api to fetch version from play store. There are many other api's but this api worked for me. We can make use of jsoup library to solve this. Downlaod Jsoup library from here http://jsoup.org/packages/jsoup-1.8.3.jar
And add following code to get latest version from playstore.
try{
String latestVersion = Jsoup
.connect(
"https://play.google.com/store/apps/details?id="
+ "package_name" + "&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(Exception e){
e.printStackTrace();
}
This code will return version from play Store. We can compare current version with latest version and prompt alert dialog to update.

- 597
- 4
- 18
-
this is the answer I have given in http://stackoverflow.com/questions/19244305/force-update-android-app-when-new-version-available/32942785#32942785 – AshuKingSharma Oct 28 '15 at 06:49
there is no official api to do this.You will need one custom web service in your backed so that you can compare current version with what your api is returning to you and use that call on beginning of app to show user update screen.

- 1,782
- 1
- 13
- 35
-
Should also be noted that it is possible that different devices have different versions available to them. Depends if you are using multiple APK's or not. – Kuffs Aug 27 '15 at 11:07
People usually implement this flow via their own servers. You communicate with an API that tells you the latest version your app, and then you check and act accordingly if you are not on the latest version.
I'm not aware of any way of getting the latest version from the Play Store.

- 183
- 1
- 7