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


Java IInAppBillingService.getBuyIntent方法代碼示例

本文整理匯總了Java中com.android.vending.billing.IInAppBillingService.getBuyIntent方法的典型用法代碼示例。如果您正苦於以下問題:Java IInAppBillingService.getBuyIntent方法的具體用法?Java IInAppBillingService.getBuyIntent怎麽用?Java IInAppBillingService.getBuyIntent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.android.vending.billing.IInAppBillingService的用法示例。


在下文中一共展示了IInAppBillingService.getBuyIntent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBuyIntent

import com.android.vending.billing.IInAppBillingService; //導入方法依賴的package包/類
private Bundle getBuyIntent(IInAppBillingService service, List<String> oldItemIds,
                            String itemId, String developerPayload) throws BillingException {
    try {
        // Purchase an item
        if (oldItemIds == null || oldItemIds.isEmpty()) {
            return service.getBuyIntent(
                    mApiVersion, mPackageName, itemId, mItemType, developerPayload);
        }
        // Upgrade/downgrade of subscriptions must be done on api version 5
        // See https://developer.android.com/google/play/billing/billing_reference.html#upgrade-getBuyIntentToReplaceSkus
        return service.getBuyIntentToReplaceSkus(
                BillingApi.VERSION_5.getValue(),
                mPackageName,
                oldItemIds,
                itemId,
                mItemType,
                developerPayload);

    } catch (RemoteException e) {
        throw new BillingException(Constants.ERROR_REMOTE_EXCEPTION, e.getMessage());
    }
}
 
開發者ID:alessandrojp,項目名稱:android-easy-checkout,代碼行數:23,代碼來源:PurchaseFlowLauncher.java

示例2: getBuyIntent

import com.android.vending.billing.IInAppBillingService; //導入方法依賴的package包/類
/**
 * Wraps {@link IInAppBillingService#getBuyIntent(int, String, String, String, String)}
 *
 * @param sku      SKU of a product to purchase.
 * @param itemType Type of an item to purchase.
 *
 * @return Bundle containing purchase intent. Can be null.
 */
@Nullable
Bundle getBuyIntent(@NonNull final String sku, @NonNull final ItemType itemType) {
    OPFLog.logMethod(sku, itemType);
    final IInAppBillingService service = getService();
    if (service == null) {
        return null;
    }
    try {
        final String type = itemType.toString();
        final Bundle result = service.getBuyIntent(API, packageName, sku, type, "");
        final Response response = GoogleUtils.getResponse(result);
        OPFLog.d("Response: %s. Result: %s", response, OPFUtils.toString(result));
        return result;
    } catch (RemoteException exception) {
        OPFLog.d("getBuyIntent request failed.", exception);
    }
    return null;
}
 
開發者ID:onepf,項目名稱:OPFIab,代碼行數:27,代碼來源:GoogleBillingHelper.java

示例3: purchaseUpgrade

import com.android.vending.billing.IInAppBillingService; //導入方法依賴的package包/類
public static void purchaseUpgrade(final IInAppBillingService mService, final Activity activity) {
    Thread t = new Thread(new Runnable() {
        public void run() {

            Bundle buyIntentBundle;
            try {
                if (mService == null) {
                    return;
                }
                buyIntentBundle = mService.getBuyIntent(3, activity.getPackageName(),
                        activity.getString(R.string.pro_iap_code), "subs", UUID.randomUUID().toString());

                PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
                if (pendingIntent == null) {
                    return;
                }

                if (buyIntentBundle.getInt("RESPONSE_CODE") == 0) {
                    // Start purchase flow (this brings up the Google Play UI).
                    // Result will be delivered through onActivityResult().
                    activity.startIntentSenderForResult(pendingIntent.getIntentSender(), UPGRADE_RETURN_CODE, new Intent(),
                            0, 0, 0);
                }

            } catch (RemoteException | IntentSender.SendIntentException e) {
                e.printStackTrace();
            }

        }
    });
    t.start();
}
 
開發者ID:dan-silver,項目名稱:cast-dashboard-android-app,代碼行數:33,代碼來源:BillingHelper.java

示例4: start

import com.android.vending.billing.IInAppBillingService; //導入方法依賴的package包/類
@Override
void start(@Nonnull IInAppBillingService service, int apiVersion, @Nonnull String packageName) throws RemoteException, RequestException {
	final Bundle bundle = service.getBuyIntent(apiVersion, packageName, sku, product, payload == null ? "" : payload);
	if (!handleError(bundle)) {
		final PendingIntent pendingIntent = bundle.getParcelable("BUY_INTENT");
		onSuccess(pendingIntent);
	}
}
 
開發者ID:xu6148152,項目名稱:binea_project_for_android,代碼行數:9,代碼來源:PurchaseRequest.java


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