我正在尝试从Google Play商店获取产品详细信息,但我总是得到响应代码0和DETAILS_LIST为空。如果有人在下面有任何想法,请告诉我。谢谢你的回复。
APK是针对美国发布的,不是针对印度的,我可以在这里测试是否所有这些都是我需要注意的事情吗?
在某些博客中,我发现发布的APK不会立即生效,因为我需要等待多长时间。
公共类GetSkuDetails扩展了Activity实现 IabHelper.OnIabSetupFinishedListener { 上下文mContext; 私人IabHelper billingHelper;
protected void onCreate(Bundle savedInstanceState) {
billingHelper = new IabHelper(this, AppProperties.BASE_64_KEY);
billingHelper.startSetup(this);
}
public void onIabSetupFinished(IabResult result) {
if (result.isSuccess()) {
SkuDetails sku = billingHelper.getSkuDetails("tier2",
IabHelper.ITEM_TYPE_INAPP);
if (sku != null) {
Toast.makeText(mContext, sku.toString(), Toast.LENGTH_SHORT)
.show();
} else {
Log.d(" calling asynchronous to get sku detail");
getSku("tier2");
}
} else {
Log.d("Problem setting up In-app Billing: " + result);
}
}
protected void getSku(final String skuID){
List<String> skuList = new ArrayList<>();
skuList.add(skuID);
billingHelper.queryInventoryAsync(true, skuList, new IabHelper.QueryInventoryFinishedListener() {
@Override
public void onQueryInventoryFinished(IabResult result, Inventory inv) {
if (result.isSuccess()) {
Log.d(inv.toString() + " + " + inv.hasDetails(Passport.SKU));
SkuDetails sku = inv.getSkuDetails(skuID);
Log.d("onQueryInventoryFinished result = " + result.isSuccess() + " sku = " + sku);
if (sku != null) {
Toast.makeText(mContext, sku.toString(), Toast.LENGTH_SHORT).show();
}
}
finish();
}
});
}
}