2

I have published my native android application on Google play store. I want to notify users by showing a popup whenever a new version of application is available on Google play store.

I can check the current running version of my app by using the below code:

String versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;

This versionName returns the running app's version name, but I want to fetch the version which is currently available on Play store, so that I can check whether the current running app's version is less that that of Google play store's version, I will show a popup to users for upgrading the application.

How can I get the version of app available on Google play store.

Thanks in advanced for your help.

Prithniraj Nicyone
  • 5,021
  • 13
  • 52
  • 78
  • you can write another web-service which gives the information about your new updated apk version – Sree Jan 20 '16 at 06:07
  • 1
    Possible duplicate of [How to pop up 'new update available' dialogue, when user starts my app(android)](http://stackoverflow.com/questions/31967387/how-to-pop-up-new-update-available-dialogue-when-user-starts-my-appandroid) – Punit Sharma Jan 20 '16 at 06:13

3 Answers3

1

An alternate way to do this

Step 1: Create a GitHub Gist account.

Step 2: Create a text file with the latest version number and get the raw URL

For Instance: "https://gist.githubusercontent.com/YOUR_ACCOUNT_NAME/0df1fa45aa11753de0a85893448b22de/raw/YourData.txt";

Step 3: Retrieve the file contents from your app by invoking the WebService in GET request mode.

Step 4: Check with the existing app version in your activity and show the pop up if required

but you have to update this version number any time you update the app in the play store.

Shyju M
  • 9,387
  • 4
  • 43
  • 48
0

What can be a more suitable way of doing is to match the current version installed on the device with your server.

if(whatServerSays > installedOnDevice) {
    //Voila!!! Show the popup here
}

Reason

Google play store does not expose any api or method to check the current version installed on the market.

Reference

https://stackoverflow.com/a/21220203/1270865

Community
  • 1
  • 1
cafebabe1991
  • 4,928
  • 2
  • 34
  • 42
  • Can you please tell what kind of API code we need to write to check the current version on play store. Can you please give an example for this. – Prithniraj Nicyone Jan 20 '16 at 06:10
  • You would need to have a webservice on your server, to respond back with you current version which you should update manually or automatically increment when you release an update. – cafebabe1991 Jan 20 '16 at 06:12
0

Now this can be achieved using AppUpdateManager API

Supports from API 21

Follow below link form more details https://developer.android.com/guide/app-bundle/in-app-updates

Diptendu Das
  • 3,990
  • 7
  • 22
  • 38