當前位置: 首頁>>代碼示例>>Java>>正文


Java Inventory類代碼示例

本文整理匯總了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();
        }
    };
}
 
開發者ID:andyCano,項目名稱:TaskApp,代碼行數:19,代碼來源:InventoryHelper.java

示例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);
	}
}
 
開發者ID:jeisfeld,項目名稱:Augendiagnose,代碼行數:48,代碼來源:GoogleBillingHelper.java


注:本文中的com.android.vending.billing.Inventory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。