本文整理汇总了Java中com.amazon.device.iap.PurchasingService类的典型用法代码示例。如果您正苦于以下问题:Java PurchasingService类的具体用法?Java PurchasingService怎么用?Java PurchasingService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PurchasingService类属于com.amazon.device.iap包,在下文中一共展示了PurchasingService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryInventory
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
@Override
public Inventory queryInventory(boolean querySkuDetails, List<String> moreSkus) throws IabException {
Log.d(TAG,"queryInventory");
try {
mInventory = new Inventory();
Log.d(TAG,"getPurchaseUpdates");
synchronized(mLock) {
PurchasingService.getPurchaseUpdates(true);
mLock.wait(10000);
}
Log.d(TAG,"getProductData");
synchronized(mLock) {
PurchasingService.getProductData(new HashSet<String>(moreSkus));
mLock.wait(10000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
return mInventory;
}
示例2: install
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
@Override
public void install (final PurchaseObserver observer, PurchaseManagerConfig config, boolean autoFetchInformation) {
this.observer = observer;
this.config = config;
// --- copy all available products to the list of productIdentifiers
int offerSize = config.getOfferCount();
productIdentifiers = new HashSet<String>(offerSize);
for (int z = 0; z < config.getOfferCount(); z++) {
productIdentifiers.add(config.getOffer(z).getIdentifierForStore(storeName()));
}
PurchasingService.registerListener(activity.getApplicationContext(), this);
// PurchasingService.IS_SANDBOX_MODE returns a boolean value.
// Use this boolean value to check whether your app is running in test mode under the App Tester
// or in the live production environment.
showMessage(LOGTYPELOG, "Amazon IAP: sandbox mode is:" + PurchasingService.IS_SANDBOX_MODE);
observer.handleInstall();
PurchasingService.getUserData();
PurchasingService.getProductData(productIdentifiers);
}
示例3: startSetup
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
@Override
public void startSetup(OnIabSetupFinishedListener listener) {
mOnIabSetupFinishedListener = listener;
if (mPurchasingObserver == null) {
mPurchasingObserver = new PurchasingObserver();
}
mHandler.removeMessages(MSG_SETUP_TIMEOUT);
mHasSetupTimeout = false;
mHandler.sendEmptyMessageAtTime(MSG_SETUP_TIMEOUT, SETUP_TIMEOUT);
PurchasingService.registerListener(ArchosUtils.getGlobalContext(), mPurchasingObserver);
PurchasingService.getUserData();
}
示例4: launchPurchaseFlow
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
@Override
public void launchPurchaseFlow(Activity act, String sku, int requestCode, OnIabPurchaseFinishedListener listener, String extraData) {
mExtraData = extraData;
mLastOperationSKU = sku;
mOnIabPurchaseFinishedListener = listener;
PurchasingService.purchase(sku);
}
示例5: init
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
@Override
public void init(String key) {
mAmazonBillingListener = new AmazonBillingListener(this);
PurchasingService.registerListener(context, mAmazonBillingListener);
final Set<String> productSkus = new HashSet<>(iapkeys);
PurchasingService.getProductData(productSkus);
PurchasingService.getPurchaseUpdates(true);
}
示例6: purchase
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
@Override
public void purchase(final String productId, int quantity, PurchaseCallback callback) {
dispatchCallback(new Runnable() {
@Override
public void run() {
notifyPurchaseStarted(productId);
}
});
RequestId request = PurchasingService.purchase(productId);
mProductIds.put(request, productId);
mPurchaseCallbacks.put(request, callback);
}
示例7: handleReceipt
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
/**
* Method to handle receipts
*
* @param requestId
* @param receipt
* @param userData
*/
public void handleReceipt(final String requestId, final Receipt receipt, final UserData userData) {
showMessage(LOGTYPELOG, "Handle receipt: requestId (" + requestId
+ ") receipt: "
+ receipt
+ ")");
// convert receipt to transaction
Transaction trans = AmazonTransactionUtils.convertReceiptToTransaction(1, requestId, receipt, userData); // provides cancleState also
switch (receipt.getProductType()) {
case CONSUMABLE:
// inform the listener
observer.handlePurchase(trans);
// Automatically consume item
PurchasingService.notifyFulfillment(receipt.getReceiptId(), FulfillmentResult.FULFILLED);
break;
case ENTITLED:
// inform the listener
observer.handlePurchase(trans);
break;
case SUBSCRIPTION:
// TODO: check subscription sample for how to handle consumable purchases
break;
}
}
示例8: getInstance
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
@SuppressWarnings("PMD.NonThreadSafeSingleton")
public static AmazonBillingHelper getInstance(@NonNull final Context context) {
if (instance == null) {
instance = new AmazonBillingHelper();
PurchasingService.registerListener(context, instance);
}
return instance;
}
示例9: getUserData
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
/**
* Requests user data form Amazon SDK.
*
* @return User data if received withing {@link #USER_DATA_TIMEOUT}, null otherwise.
*/
@Nullable
UserData getUserData() {
final SyncedReference<UserData> syncUserData = new SyncedReference<>();
try {
this.syncUserData = syncUserData;
PurchasingService.getUserData();
return syncUserData.get(USER_DATA_TIMEOUT);
} finally {
this.syncUserData = null;
}
}
示例10: handleFailure
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
/**
* Tries to guess appropriate error code.
*
* @return Most suitable status.
*/
protected Status handleFailure() {
// Unfortunately Amazon doesn't report a reason for error
if (!PurchasingService.IS_SANDBOX_MODE && !OPFUtils.isConnected(context)) {
return SERVICE_UNAVAILABLE;
}
return UNKNOWN_ERROR;
}
示例11: isAvailable
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
@Override
public boolean isAvailable() {
final PackageManager packageManager = context.getPackageManager();
for (final PackageInfo info : packageManager.getInstalledPackages(0)) {
if (PATTERN_STORE_PACKAGE.matcher(info.packageName).matches()) {
// Check sdk tester package if app is in sandbox mode.
return !PurchasingService.IS_SANDBOX_MODE
|| OPFUtils.isInstalled(context, TESTER_PACKAGE);
}
}
return false;
}
示例12: consume
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
@Override
public void consume(@NonNull final ConsumeRequest request) {
final Purchase purchase = request.getPurchase();
final String token = purchase.getToken();
if (!TextUtils.isEmpty(token)) {
PurchasingService.notifyFulfillment(token, FulfillmentResult.FULFILLED);
postResponse(new ConsumeResponse(SUCCESS, getName(), purchase));
} else {
postEmptyResponse(request, ITEM_UNAVAILABLE);
}
}
示例13: startSetupInner
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
/**
* see parent
*/
@Override
protected void startSetupInner() {
if (mPurchasingObserver == null) {
mPurchasingObserver = new PurchasingObserver();
}
PurchasingService.registerListener(SoomlaApp.getAppContext(), mPurchasingObserver);
PurchasingService.getUserData();
}
示例14: fetchSkusDetailsAsyncInner
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
/**
* see parent
*/
@Override
protected void fetchSkusDetailsAsyncInner(List<String> skus) {
if (skus == null || skus.isEmpty()){
SoomlaUtils.LogDebug(TAG, "skus is null or empty, nothing to fetch.");
// Finish the fetch so it doesn't get stuck
AmazonIabHelper.this.fetchSkusDetailsSuccess(new IabInventory());
return;
}
PurchasingService.getProductData(new HashSet<String>(skus));
}
示例15: startSetup
import com.amazon.device.iap.PurchasingService; //导入依赖的package包/类
/**
* @param listener - is triggered when {@link #onUserDataResponse(UserDataResponse)} happens
*/
@Override
public void startSetup(IabHelper.OnIabSetupFinishedListener listener) {
this.setupListener = listener;
PurchasingService.registerListener(context, this);
PurchasingService.getUserData();
}