Android计费API onBillingSetupFinished可能的状态 [英] Android billing api onBillingSetupFinished possible states

查看:149
本文介绍了Android计费API onBillingSetupFinished可能的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应处理onBillingSetupFinished哪个状态?

Which states on onBillingSetupFinished should I handle?

我的意思是,BillingResponseCode接口上有12种可能的状态:

What I mean is, there are 12 possible states on the BillingResponseCode interface:

int SERVICE_TIMEOUT = -3;
int FEATURE_NOT_SUPPORTED = -2;
int SERVICE_DISCONNECTED = -1;
int OK = 0;
int USER_CANCELED = 1;
int SERVICE_UNAVAILABLE = 2;
int BILLING_UNAVAILABLE = 3;
int ITEM_UNAVAILABLE = 4;
int DEVELOPER_ERROR = 5;
int ERROR = 6;
int ITEM_ALREADY_OWNED = 7;
int ITEM_NOT_OWNED = 8;

但是我想只有其中的一部分真的被发送到这种方法,所以我应该关心其中的哪一部分?

But I imagine only a few of them are really send to this method, so which of them I should care?

public void onBillingSetupFinished(@NonNull BillingResult billingResult)
{
  switch(billingResult.getResponseCode())
  {
    case BillingClient.BillingResponseCode.OK:
      break;
    case BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED:
      break;
    case BillingClient.BillingResponseCode.ITEM_NOT_OWNED:
      break;
    case BillingClient.BillingResponseCode.BILLING_UNAVAILABLE:
      break;
    case BillingClient.BillingResponseCode.DEVELOPER_ERROR:
      break;
    ...
    default:
      
  }
}

如果找到计费api的源代码,我将找不到帮助.

Would help if I find the source code for the billing api, I couldn't find it.

推荐答案

这是Google的官方计费示例

This is the google's official billing sample project. Hope this answers your question.

这篇关于Android计费API onBillingSetupFinished可能的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆