3
votes

I'm testing a version check feature in our app. Our Android client queries data from our servers that returns the minimum client version we will allow to access our service. Users running older versions are directed to the Play Store to update.

If the user is out of date, we direct them to the Play store using code like:

final String appPackageName = getPackageName();
try {
  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}

From within our app, out of date clients are directed to the market:// url. This launches the Play Store app and loads the target page for our app.

To test this, I created a special "out of date" version of the app. In the manifest I set the versionCode to 1 so it is lower than our current version in the Play store. I also set a falsely low versionName to trigger our update process.

android:versionCode="1"   
android:versionName="1.0.1"

I built a signed version of the app, installed it using ADB (not through play store) and tested it.

The version check triggers and I get directed to the Play store app and to my app page. But, the play store page offers me the actions to Uninstall or Open the app. It does not give me the option to Update the app.

Why doesn't the Play Store offer me an Update button? Is this because my app was not originally installed through Play Store? Is there a way around this?

1

1 Answers

1
votes

I believe your guess about the app not being originally being installed from the store is correct. I'd recommend utilizing the Google Play Beta program for this. As long as your device is registered as a Beta tester for that particular app it will receive the option to update (after the 3+ hours it takes to be put on the store).

The unfortunate thing is that you will need to upload twice. Once to get the functionality you want to test, and once to test that it works.

This being said, the fact that you are getting to the app store with your app showing is the burden of proof that your code works. The remaining part is Google's problem. So you should feel safe that your code is working, and as long as the Play Store is ready for people to update you should be fine.

I have implemented this functionality into two separate apps, and only tested (before initial release) that the user was directed correctly into the app store. I typically wait 24+ hours to update the minimum version on the server just incase a user has the old version cached.