本文整理汇总了Java中com.android.vending.billing.Inventory类的典型用法代码示例。如果您正苦于以下问题:Java Inventory类的具体用法?Java Inventory怎么用?Java Inventory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Inventory类属于com.android.vending.billing包,在下文中一共展示了Inventory类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getQueryListener
import com.android.vending.billing.Inventory; //导入依赖的package包/类
private IabHelper.QueryInventoryFinishedListener getQueryListener(final IabHelper helper) {
return new IabHelper.QueryInventoryFinishedListener() {
@Override
public void onQueryInventoryFinished(IabResult result, Inventory inv) {
if (result.isSuccess()) {
inventory = inv;
checkPurchase(R.string.sku_tasker, R.string.p_purchased_tasker);
checkPurchase(R.string.sku_tesla_unread, R.string.p_purchased_tesla_unread);
checkPurchase(R.string.sku_dashclock, R.string.p_purchased_dashclock);
checkPurchase(R.string.sku_themes, R.string.p_purchased_themes);
broadcaster.refresh();
} else {
Timber.e("query inventory failed: %s", result.getMessage());
}
helper.dispose();
}
};
}
示例2: onQueryInventoryFinished
import com.android.vending.billing.Inventory; //导入依赖的package包/类
@Override
public void onQueryInventoryFinished(@NonNull final IabResult result, @NonNull final Inventory inventory) {
Log.d(TAG, "Query inventory finished - " + inventory);
// Have we been disposed of in the meantime? If so, quit.
if (mIabHelper == null) {
return;
}
// Is it a failure?
if (result.isFailure()) {
Log.e(TAG, "Failed to query inventory: " + result);
return;
}
Log.d(TAG, "Query inventory was successful.");
List<PurchasedSku> purchases = new ArrayList<>();
List<SkuDetails> nonPurchases = new ArrayList<>();
for (String purchaseId : Arrays.asList(PRODUCT_IDS)) {
Purchase purchase = inventory.getPurchase(purchaseId);
SkuDetails skuDetails = inventory.getSkuDetails(purchaseId);
if (purchase == null && skuDetails == null) {
Log.w(TAG, "Did not find entry for " + purchaseId);
}
else {
synchronized (GoogleBillingHelper.class) {
if (purchase == null) {
nonPurchases.add(skuDetails);
}
else {
Log.d(TAG, "Found purchase: " + purchase);
purchases.add(new PurchasedSku(skuDetails, purchase));
if (Arrays.asList(PREMIUM_IDS).contains(purchase.getSku())) {
mIsPremium = true;
}
}
}
}
}
if (mOnInventoryFinishedListener != null) {
mOnInventoryFinishedListener.handleProducts(purchases, nonPurchases, mIsPremium);
}
}