コード例 #1
0
 /**
  * Requests the purchase of the specified subscription item with optional automatic confirmation.
  *
  * @param context
  * @param itemId id of the item to be purchased.
  * @param confirm if true, the transaction will be confirmed automatically. If false, the
  *     transaction will have to be confirmed with a call to {@link #confirmNotifications(Context,
  *     String)}.
  * @param developerPayload a developer-specified string that contains supplemental information
  *     about the order.
  * @see IBillingObserver#onPurchaseIntent(String, PendingIntent)
  */
 public static void requestSubscription(
     Context context, String itemId, boolean confirm, String developerPayload) {
   if (confirm) {
     automaticConfirmations.add(itemId);
   }
   BillingService.requestSubscription(context, itemId, developerPayload);
 }
コード例 #2
0
 /**
  * Returns the subscription billing support status, and checks it asynchronously if it is
  * currently unknown. Observers will receive a {@link
  * IBillingObserver#onSubscriptionChecked(boolean)} notification in either case.
  *
  * <p>No support for subscriptions does not imply that in-app products are also unsupported. To
  * check if in-app products are supported, use {@link
  * BillingController#checkBillingSupported(Context)}.
  *
  * @param context
  * @return the current subscription billing status (unknown, supported or unsupported). If it is
  *     supported, in-app products are also supported.
  * @see IBillingObserver#onSubscriptionChecked(boolean)
  * @see BillingController#checkBillingSupported(Context)
  */
 public static BillingStatus checkSubscriptionSupported(Context context) {
   if (subscriptionStatus == BillingStatus.UNKNOWN) {
     BillingService.checkSubscriptionSupported(context);
   } else {
     boolean supported = subscriptionStatus == BillingStatus.SUPPORTED;
     onSubscriptionChecked(supported);
   }
   return subscriptionStatus;
 }
コード例 #3
0
 /**
  * Returns the in-app product billing support status, and checks it asynchronously if it is
  * currently unknown. Observers will receive a {@link IBillingObserver#onBillingChecked(boolean)}
  * notification in either case.
  *
  * <p>In-app product support does not imply subscription support. To check if subscriptions are
  * supported, use {@link BillingController#checkSubscriptionSupported(Context)}.
  *
  * @param context
  * @return the current in-app product billing support status (unknown, supported or unsupported).
  *     If it is unsupported, subscriptions are also unsupported.
  * @see IBillingObserver#onBillingChecked(boolean)
  * @see BillingController#checkSubscriptionSupported(Context)
  */
 public static BillingStatus checkBillingSupported(Context context) {
   if (billingStatus == BillingStatus.UNKNOWN) {
     BillingService.checkBillingSupported(context);
   } else {
     boolean supported = billingStatus == BillingStatus.SUPPORTED;
     onBillingChecked(supported);
   }
   return billingStatus;
 }
コード例 #4
0
 /**
  * Requests to restore all transactions.
  *
  * @param context
  */
 public static void restoreTransactions(Context context) {
   final long nonce = Security.generateNonce();
   BillingService.restoreTransations(context, nonce);
 }
コード例 #5
0
 /**
  * Requests purchase information for the specified notification. Immediately followed by a call to
  * {@link #onPurchaseInformationResponse(long, boolean)} and later to {@link
  * #onPurchaseStateChanged(Context, String, String)}, if the request is successful.
  *
  * @param context
  * @param notifyId id of the notification whose purchase information is requested.
  */
 private static void getPurchaseInformation(Context context, String notifyId) {
   final long nonce = Security.generateNonce();
   BillingService.getPurchaseInformation(context, new String[] {notifyId}, nonce);
 }
コード例 #6
0
 /**
  * Requests to confirm all specified notifications.
  *
  * @param context
  * @param notifyIds array with the ids of all the notifications to confirm.
  */
 private static void confirmNotifications(Context context, String[] notifyIds) {
   BillingService.confirmNotifications(context, notifyIds);
 }