本文整理匯總了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);
}
}