Detect if the app is the one in Beta in Play Store
Asked Answered
C

4

19

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.
Caracole answered 22/5, 2013 at 19:44 Comment(3)
Just to clarify - You want a single APK to have a different functionality when deployed as beta or pushed to production?Settera
@uval you totally understood my need..Caracole
So I think what you really mean is, how to detect if the current user has activated the beta channel. I agree this would be very useful as the beta process and dev console lend themselves to a workflow of continuously pushing the same APK through to production. So we don't want to build separate APKs for just beta but otoh we sometimes want features that are exclusive to beta users even when it's in production, maybe as beta-only features for weeks or months, or even permanent features like this debug menu, which survive across many new APK releases.Catalyst
S
0

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.

Settera answered 22/5, 2013 at 21:12 Comment(2)
I'm wondering if you could hook into the G+ API or the Groups API to test the current user against your list of alpha/beta users. As far as the software knows, a beta user always gets a beta version of the app.Szabadka
@BrillPappin It seems possible, but not easy to implement. And the OP use case it means that these checks will continue forever for all users, even long after the beta is over. If you're using network, you might find it easier to use a json file on a web server, or GCMSettera
R
1

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.

Regicide answered 24/5, 2013 at 17:13 Comment(0)
C
0

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?

Coelacanth answered 22/5, 2013 at 19:51 Comment(4)
Might want to look into the new Gradle build system, too. It provides some excellent support for this type of thing.Bash
Uploading a different APK is, yes, simple, but very tedious if you want to "dark launch" a feature so it's exclusive to beta users for a long time. It also means beta users get hammered with extra releases as you promote the app and then re-distribute the beta.Catalyst
Thats not a good solution because it introduces the potential for a beta build to be pushed to production. The idea with the alpha/beta deployments is to allow an increasing number of users access to the features you will release. Think of it a crowd sourced QA.Szabadka
The way beta testing on Google Play works is that you upload an APK to one of the testing lanes (beta, alpha) and then promote it to a more public lane, until it is in production.Lambert
S
0

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.

Settera answered 22/5, 2013 at 21:12 Comment(2)
I'm wondering if you could hook into the G+ API or the Groups API to test the current user against your list of alpha/beta users. As far as the software knows, a beta user always gets a beta version of the app.Szabadka
@BrillPappin It seems possible, but not easy to implement. And the OP use case it means that these checks will continue forever for all users, even long after the beta is over. If you're using network, you might find it easier to use a json file on a web server, or GCMSettera
A
-1

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();
}
Atrium answered 28/4, 2020 at 6:38 Comment(1)
First of all this piece of code contains a typo in url "sore"->"store". Then if you send a simple Get request like shown in this answer, then you will receive the content of the usual page from your production, without any beta text and so on and so for. Check it and can say that this is the wrong answer.Unclothe

© 2022 - 2024 — McMap. All rights reserved.