17

BillingClient offers a method named isFeatureSupported(). The documentation for the int returned is:

BILLING_RESULT_OK if feature is supported and corresponding error code otherwise.

I could not find BILLING_RESULT_OK to be defined anywhere. It is not among the constants defined in BillingClient.BillingResponse. Should I just use

BillingClient.BillingResponse.OK

?

4 Answers 4

40

in 2019 running 'com.android.billingclient:billing:2.0.1' replace: BillingResponse.OK with BillingClient.BillingResponseCode.OK The whole documentation feels very unprecise. Shocking to see how weak Google handles this.

2
  • 4
    In 2019 BillingClient.BillingResponseCode.OK perfectly! Aug 13, 2019 at 14:57
  • Yes all the tutorials still say "BillingResponse". I wonder why they changed it?
    – winwaed
    Aug 21, 2019 at 15:47
4

I believe that's a typo in the documentation. Instead, you should use BillingResponse.OK: https://developer.android.com/reference/com/android/billingclient/api/BillingClient.BillingResponse#ok

You can see it in use in this example: https://github.com/googlesamples/android-play-billing/blob/master/TrivialDrive_v2/shared-module/src/main/java/com/example/billingmodule/billing/BillingManager.java#L126

1
  • import com.android.billingclient.api.BillingClient.BillingResponse; Is not work! error: cannot find symbol class BillingResponse
    – DongGeun
    Jul 3, 2019 at 9:32
1

For me useing BillingClient.BillingResponse.OKdid not work, it always acts like if the feature is not supported. I had to use this:

int response = billingClient.isFeatureSupported(BillingClient.FeatureType.SUBSCRIPTIONS);
if (response == BillingClient.BillingResponse.FEATURE_NOT_SUPPORTED) {
      Toast.makeText(this, "Feature not supported", Toast.LENGTH_SHORT).show();
      return;
}
1

So whole check for "com.android.billingclient:billing:2.0.3" looks like this:

public boolean isSubscriptionsSupported() {
  if (myBillingClient != null) {
      BillingResult isSubscriptionsSupported = myBillingClient.isFeatureSupported(BillingClient.FeatureType.SUBSCRIPTIONS);
      return isSubscriptionsSupported.getResponseCode() == BillingClient.BillingResponseCode.OK;
  }
  return false;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.