Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is BILLING_RESULT_OK defined?

Tags:

android

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

?

like image 631
user1785730 Avatar asked Dec 08 '18 18:12

user1785730


4 Answers

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.

like image 88
CaptainCrunch Avatar answered Nov 01 '22 03:11

CaptainCrunch


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

like image 4
Ben P. Avatar answered Nov 01 '22 03:11

Ben P.


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;
}
like image 1
hiddeneyes02 Avatar answered Nov 01 '22 03:11

hiddeneyes02


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;
}
like image 1
Torello Avatar answered Nov 01 '22 01:11

Torello