Android 如何从 GooglePlay 控制台获取产品列表

kim*_*vin 5 android in-app-purchase in-app-billing google-play

我正在我的产品中开发 Android In-app Billing。想请教一下,如何获取我已经在谷歌游戏机上注册的所有产品

这是来自 Google Play 的示例代码。

List additionalSkuList = new List();
additionalSkuList.add(SKU_APPLE);
additionalSkuList.add(SKU_BANANA);
mHelper.queryInventoryAsync(true, additionalSkuList, mQueryFinishedListener);
Run Code Online (Sandbox Code Playgroud)

但是如果我放了 additionalSkuList 什么都没有,它什么也不会返回。

我想提前知道我在谷歌游戏控制台的应用内产品中注册的所有产品,以便使用产品信息进行查看。

有人有同样的问题吗?任何人都知道解决它的方法吗?

Fad*_*ils 3

你不能。嗯,据我所知。

基本上最终直接mHelper.queryInventoryAsync(true, additionalSkuList, mQueryFinishedListener);调用方法getSkuDetails()InAppBillingService.aidl

 /**
 * 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" }'
 */
Bundle getSkuDetails(int apiVersion, String packageName, String type, in Bundle skusBundle);
Run Code Online (Sandbox Code Playgroud)

如果您在 中没有指定列表additionalSkuList,那么您将不会得到任何返回结果。

简而言之,您只需知道(并列出)所有 SKU,然后将此列表放入查询中即可。