本文整理汇总了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());
}
}
示例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;
}
示例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();
}
示例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);
}
}