Question

I fear that the answer will likely be "impossible", but I would like to know if there is a way to detect if my uploaded apk to the Play Store is the alpha/beta or stable channel.

I would like to achieve this because I have a whole menu leading to Beta features that I would like to hide in the stable channel.

This is really usefull because while I fix generic bugs that I push to the Store, I don't want to recompile each time with or without the beta button.

I have unfortunately no code to share, but any help or suggestion would be highly appreciated

enter image description here


I feel like there is actually a good use case for this functionality. Consider the following scenario:

  1. I have an API that increments versions at prod.api.example.com
  2. I have a mobile app that increments versions independently but relies upon the api.
  3. Before the api developers add or remove functionality, they expose the changes at a different url. Say: beta.api.example.com
  4. I want my alpha or beta testers to always be working against the beta url of the api because they will find breaking changes.
  5. When new api changes are released from beta to prod then I want to promote my Android app from alpha or beta to prod without incrementing my mobile app version number and having to rebuild if everything is working properly.
Was it helpful?

Solution 3

The Alpha/Beta was just launched, and Google didn't mention anything like what you want.
If something like this was possible, the place for it would have probably been Google Play Services.
It's not there.

A possible workaround -
If you know the date in which you want to move from beta to production, you can use this little trick: set the default visibility of the debug menu to gone, and until that date, set it to visible in code.

OTHER TIPS

It's pretty simple really, upload a different APK. Maintain a different branch of code with only the beta features in your beta channel. Recompiling shouldn't be a big hassle. You are using some form of source control right?

I hope there is a way do this easily as well, but I have not found one yet.

Another option would be to have a flag which wraps the beta functionality and then use Google Tag Manager http://www.google.com/tagmanager/ to toggle the features you only want on the beta release off before you upgrade the app to production.

Assuming the same apk is typically promoted from Beta to Production, your app can use an android HttpURLConnnection to read the Google Play store details page for your own app id.

If the current user is enrolled in Beta, the app name is presented as "App Name (Beta)", otherwise it will just be "App Name"

Sample Java code for how you might implement this below:

boolean isBeta = false;
URL url = new URL("https://play.google.com/sore/apps/details?id=com.example.app");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try {
  InputStream in = new BufferedInputStream(urlConnection.getInputStream());
  Scanner scanner = new Scanner(in);
  isBeta = (scanner.findWithinHorizon("\\s\\(Beta\\)", 650000) != null);
} finally {
  urlConnection.disconnect();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top