2

I am developing a Google Play services based app. I am using the suggested BaseGameActivity superclass to inherit lots of the functionality. The user can log in via their Google account.

I wanted to provide a special preference setting for testers of the android app. After looking in the SDK reference, I haven't been able to find if there is any way to determine whether the logged in user is configured as a tester for the app. Is this possible?

Is there another recommended way to provide extra functionality for testers of the app related to their testing? For instance, in my game app, I want to allow the testers to reset their achievements and leaderboard entries, which I found can be done via a web service call.

Thanks

Community
  • 1
  • 1
  • 1
    You can add an alpha or a beta version of your app to Google Play. You then need to invite emails to the alpha/beta groups. Your two apk's could be nearly identical minus a flag which says they're an alpha/beta tester. – Randy Dec 04 '13 at 18:57

1 Answers1

0

There's no such API that I know of.

The trick that I have been using, and you are welcome to use as well is to determine whether a device is a tester device by its ANDROID_ID, and fork different behaviors accordingly. Something like this:

 static String androidId;
 static boolean isTesterDevice;

 boolean isTesterDevice() {
      if (androidId != null) {
           return isTesterDevice; // optimization: run string compares only once
      }
      androidId = Secure.getString(context.getContentResolver(),Secure.ANDROID_ID);
      isTesterDevice = Arrays.asList(ALL_TESTER_DEVICES).contains(androidId);
      return isTesterDevice;
 }

Where ALL_TESTER_DEVICES is a String array containing all testers ANDROID_IDs:

 static final String[] ALL_TESTER_DEVICES = {
     "46ba345347f7909d", 
     "46b345j327f7909d" ... };

Once we have this working we can create tester specific logics inside our code:

 if (isTesterDevice()) {
     perform tester logic
 }

We can also pass a isTester field to the backend server as part of the handshake procedure, allowing it to perform its own set of tester handling.

This works just fine for small teams of testers. When QA teams grows larger, or when you cannot ingerrogate some of the tester devices for their ID, we find it useful to allow our testers to flag their identity by adding a special file to the SDCARD. In that case isTesterDevice() will change to:

 boolean isTesterDevice() {
      if (androidId != null) {
           return isTesterDevice; // optimization: run string compares only once
      }
      // check by device ID
      androidId = Secure.getString(context.getContentResolver(),Secure.ANDROID_ID);
      isTesterDevice = Arrays.asList(ALL_TESTER_DEVICES).contains(androidId);
      if (!isTesterDevice) {
          // check by tester file
          File sdcard = Environment.getExternalStorageDirectory();
          File testerFile = new File(sdcard.getAbsolutePath(), "I_AM_TESTER.txt");
          isTesterDevice = testerFile.exists();
      }
      return isTesterDevice;
 }

Hope it helps.

Gilad Haimov
  • 5,767
  • 2
  • 26
  • 30