本文整理匯總了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);
}
}