【问题标题】:In-App Billing isBillingSupported - returns what and functions how?应用内计费 isBillingSupported - 返回什么和功能如何?
【发布时间】:2014-11-20 09:17:48
【问题描述】:

这个问题是基于适用于 Android 的 Google 应用内结算服务。特别是函数isBillingSupported

int result = mBillingService.isBillingSupported(3, mOwner.getPackageName(), "inapp")

首先,这个函数返回什么?文档对此非常保密:

成功时RESULT_OK(0),失败时对应的结果代码

only codes I found 似乎与支持的计费问题无关。看起来很具体,就是 0 是成功的。会出现什么错误?

其次,这个功能检查什么来知道是否支持计费?我有一部完全能够进行应用内计费的手机,当我连接到合理的互联网资源(例如 WiFi)时,此功能确实返回“true”。但是,如果我的连接不太稳定,它不会返回“true”。所以我假设它会检查连接是否良好。它还检查什么?

【问题讨论】:

    标签: android in-app-billing


    【解决方案1】:

    其他响应代码是:-

    • RESULT_OK = 0 - 成功
    • RESULT_USER_CANCELED = 1 - 用户按下或取消对话
    • RESULT_BILLING_UNAVAILABLE = 3 - 请求的类型不支持此计费 API 版本
    • RESULT_ITEM_UNAVAILABLE = 4 - 请求的 SKU 不可购买
    • RESULT_DEVELOPER_ERROR = 5 - 提供给 API 的参数无效
    • RESULT_ERROR = 6 - API 操作期间出现致命错误
    • RESULT_ITEM_ALREADY_OWNED = 7 - 购买失败,因为项目已经拥有
    • RESULT_ITEM_NOT_OWNED = 8 - 由于项目不拥有而未能消费

    【讨论】:

    • 我以前读过那些,但我认为它们是用于交易的。它们适用于整个 API 吗?在查询是否可以计费时,已经拥有没有任何意义。您知道计费支持功能检查什么吗?
    • 是的,它们适用于整个 API。此功能实际上检查您在应用内购买使用的商品是否支持应用内计费。这里的支持意味着项目是否可以购买。因此,在前面的答案中编写的代码是针对这种情况的,即如果用户已经拥有该项目,项目 SKU 不可用或不正确等。
    【解决方案2】:
    public int isBillingSupported(int apiVersion, java.lang.String packageName, java.lang.String type) throws android.os.RemoteException;
    
    /**
         * Provides details of a list of SKUs
         * Given a list of SKUs of a valid type in the skusBundle, this returns a bundle
         * with a list JSON strings containing the productId, price, title and description.
         * This API can be called with a maximum of 20 SKUs.
         * @param apiVersion billing API version that the Third-party is using
         * @param packageName the package name of the calling app
         * @param skusBundle bundle containing a StringArrayList of SKUs with key "ITEM_ID_LIST"
         * @return Bundle containing the following key-value pairs
         *         "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
         *              failure as listed above.
         *         "DETAILS_LIST" with a StringArrayList containing purchase information
         *              in JSON format similar to:
         *              '{ "productId" : "exampleSku", "type" : "inapp", "price" : "$5.00",
         *                 "title : "Example Title", "description" : "This is an example description" }'
         */
    

    【讨论】:

    • 它不能只检查服务版本,因为它的返回取决于我是否打开了 WiFi 或 3G 或 3G(但接收非常糟糕)。我知道成功返回码为 0,但还有什么?
    • 那是错误的注释(对应getSkuDetails)。
    猜你喜欢
    • 2018-08-01
    • 1970-01-01
    • 2011-08-02
    • 2015-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多