当前位置: 首页>>代码示例>>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;未经允许,请勿转载。