public static int getActivityResultCode(Activity activity) {
    // We need to use Reflection because the code is stored in the resultCode field with package
    // private visibility.
    try {
      Field field = Activity.class.getDeclaredField("mResultCode");
      field.setAccessible(true);
      // The field is guarded (for concurrency) by the Activity instance.
      synchronized (activity) {
        return field.getInt(activity);
      }
    } catch (Exception e) {
      throw new RuntimeException("Failed to get Acitivity.mResultCode for " + activity, e);
    }
  }
Gets the result code that the provided {@link Activity} is currently set to return.
javatests/com/google/android/apps/authenticator/testing/TestUtilities.java