I have put my app on the Google Play Store. It has been installed by lots of my company's customers. I understand the mechanism of how the app is intended to upgrade.
The users should check the auto-update check box in the Playstore app for each app they want to auto-update. However some users have unchecked it or not checked it in the first place.
The app i have written is for the care industry and is used by carers to deliver homecare. Some of our customers my have 1200 carers. They would have to call all the carers into the office to update the phones individually. This is obviously unacceptable.
Is there a way to programmatically check if there is an updated version of my app on the Play Store?
Could i have code that runs every time the user starts the app that checks the Play Store? If there is an updated version then the user could be directed to the Playstore. This will mean it is not essential to have the auto-update checked.
The users should check the auto-update check box in the Playstore app for each app they want to auto-update. However some users have unchecked it or not checked it in the first place.
Try this google official api: github.com/googlesamples/android-play-publisher-api/tree/master/…
By default, apps are updated automatically when the following constraints are met: The device is connected to a Wi-Fi network. The device is charging. The device is idle (not actively used).
Update 17 October 2019
https://developer.android.com/guide/app-bundle/in-app-updates
Update 24 april 2019:
Android announced a feature which will probably fix this problem. Using the in-app Updates API: https://android-developers.googleblog.com/2018/11/unfolding-right-now-at-androiddevsummit.html
Original:
As far a I know, there is no official Google API which supports this.
You should consider to get a version number from an API.
Instead of connecting to external APIs or webpages (like Google Play Store). There is a risk that something may change in the API or the webpage, so you should consider to check if the version code of the current app is below the version number you get from your own API.
Just remember if you update your app, you need to change the version in your own API with the app version number.
I would recommend that you make a file in your own website or API, with the version number. (Eventually make a cronjob and make the version update automatic, and send a notification when something goes wrong)
You have to get this value from your Google Play Store page (is changed in the meantime, not working anymore):
<div class="content" itemprop="softwareVersion"> x.x.x </div>
Check in your app if the version used on the mobile is below the version nummer showed on your own API.
Show indication that she/he needs to update with a notification, ideally.
Include JSoup in your apps build.gradle file :
dependencies { compile 'org.jsoup:jsoup:1.8.3' }
and get current version like :
currentVersion = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
And execute following thread :
private class GetVersionCode extends AsyncTask<Void, String, String> { @Override protected String doInBackground(Void... voids) { String newVersion = null; try { newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + MainActivity.this.getPackageName() + "&hl=it") .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(".hAyfc .htlgb") .get(7) .ownText(); return newVersion; } catch (Exception e) { return newVersion; } } @Override protected void onPostExecute(String onlineVersion) { super.onPostExecute(onlineVersion); Log.d("update", "Current version " + currentVersion + "playstore version " + onlineVersion); if (onlineVersion != null && !onlineVersion.isEmpty()) { if (Float.valueOf(currentVersion) < Float.valueOf(onlineVersion)) { //show dialog } } }
For more details visit : http://revisitingandroid.blogspot.in/2016/12/programmatically-check-play-store-for.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With