我希望使用IabHelper获取单个SKU详细信息(Not ArrayList),通过放置单个productID putString()(不是putStringArrayList)
...
final int API_VERSION = 3;
final String PACKAGE_NAME = mContext.getPackageName();
Bundle bandleSKU = new Bundle();
querySkus.putString(GET_SKU_DETAILS_ITEM_LIST, "<someProcuctID>");
Bundle skuDetails = mService.getSkuDetails(API_VERSION, PACKAGE_NAME, type, bandleSKU);
if (null != skuDetails) {
int response = skuDetails.getInt(RESPONSE_CODE);
if (response == BILLING_RESPONSE_RESULT_OK) {
String response = skuDetails.getString(RESPONSE_GET_SKU_DETAILS_LIST);
}
}
...
答案 0 :(得分:1)
不,这违反了该电话的合同。您应该做的是创建一个大小为1的新ArrayList
并在那里添加您的产品ID:
...
Bundle bandleSKU = new Bundle();
ArrayList<String> productIds = new ArrayList<>(1);
productIds.add("<someProductID>");
querySkus.putString(GET_SKU_DETAILS_ITEM_LIST, productIds);
Bundle skuDetails = mService.getSkuDetails(API_VERSION, PACKAGE_NAME, type, bandleSKU);
if (null != skuDetails) {
int response = skuDetails.getInt(RESPONSE_CODE);
if (response == BILLING_RESPONSE_RESULT_OK) {
ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);
String productDetailsJson = responseList.get(0);
}
}
...