Inheritance: Android.App.Service, Android.Content.IServiceConnection
        public override void OnRestoreTransactionsResponse(BillingService.RestoreTransactions request, Consts.ResponseCode responseCode)
        {
            if (responseCode == Consts.ResponseCode.RESULT_OK)
            {
                if (Consts.DEBUG)
                    Log.Debug(Activity1.TAG, "completed RestoreTransactions request");

                // Update the shared preferences so that we don't perform
                // a RestoreTransactions again.
                ISharedPreferences prefs = _activity.GetPreferences(FileCreationMode.Private);
                ISharedPreferencesEditor edit = prefs.Edit();
                edit.PutBoolean(Activity1.DB_INITIALIZED, true);
                edit.Commit();
            }
            else
            {
                if (Consts.DEBUG)
                    Log.Debug(Activity1.TAG, "RestoreTransactions error: " + responseCode);
            }
        }
        private void StartBillingStuff()
        {
            _handler = new Handler();
            _inAppBillingDemoObserver = new InAppBillingDemoPurchaseObserver(this, _handler);
            _billingService = new BillingService();
            _billingService.Context = this;
            ResponseHandler.Register(_inAppBillingDemoObserver);
            var inAppsSupported = _billingService.CheckBillingSupportedMethod(Consts.ITEM_TYPE_INAPP);
            var subscriptionsSupported = _billingService.CheckBillingSupportedMethod(Consts.ITEM_TYPE_SUBSCRIPTION);

            _purchaseDatabase = new PurchaseDatabase(this);
            OwnedItemsCursor = _purchaseDatabase.QueryAllPurchasedItems();
            StartManagingCursor(OwnedItemsCursor);
            var from = new string[] { PurchaseDatabase.PURCHASED_PRODUCT_ID_COL, PurchaseDatabase.PURCHASED_QUANTITY_COL };
            var to = new int[] { Resource.Id.itemName };
            _ownedItemsAdapter = new SimpleCursorAdapter(this, Resource.Layout.Main, OwnedItemsCursor, from, to);

            if (OwnedItems.Count == 0)
                ItemName.Text = "No purchases";
        }
        public override void OnRequestPurchaseResponse(BillingService.RequestPurchase request, Consts.ResponseCode responseCode)
        {
            if (Consts.DEBUG)
                Log.Debug(Activity1.TAG, request.mProductId + ": " + responseCode);

            if (responseCode == Consts.ResponseCode.RESULT_OK)
            {
                if (Consts.DEBUG)
                    Log.Info(Activity1.TAG, "purchase was successfully sent to server");
            }
            else if (responseCode == Consts.ResponseCode.RESULT_USER_CANCELED)
            {
                if (Consts.DEBUG)
                    Log.Info(Activity1.TAG, "user canceled purchase");
            }
            else
            {
                if (Consts.DEBUG)
                    Log.Info(Activity1.TAG, "purchase failed");
            }
        }
 /// <summary>
 /// This is called when we receive a response code from Market for a
 /// RequestPurchase request that we made.  This is NOT used for any
 /// purchase state changes.  All purchase state changes are received in
 /// <seealso cref="#onPurchaseStateChange(PurchaseState, String, int, long)"/>.
 /// This is used for reporting various errors, or if the user backed out
 /// and didn't purchase the item.  The possible response codes are:
 ///   RESULT_OK means that the order was sent successfully to the server.
 ///       The onPurchaseStateChange() will be invoked later (with a
 ///       purchase state of PURCHASED or CANCELED) when the order is
 ///       charged or canceled.  This response code can also happen if an
 ///       order for a Market-managed item was already sent to the server.
 ///   RESULT_USER_CANCELED means that the user didn't buy the item.
 ///   RESULT_SERVICE_UNAVAILABLE means that we couldn't connect to the
 ///       Android Market server (for example if the data connection is down).
 ///   RESULT_BILLING_UNAVAILABLE means that in-app billing is not
 ///       supported yet.
 ///   RESULT_ITEM_UNAVAILABLE means that the item this app offered for
 ///       sale does not exist (or is not published) in the server-side
 ///       catalog.
 ///   RESULT_ERROR is used for any other errors (such as a server error).
 /// </summary>
 public abstract void OnRequestPurchaseResponse(BillingService.RequestPurchase request, Consts.ResponseCode responseCode);
 /// <summary>
 /// This is called when we receive a response code from Android Market for a
 /// RestoreTransactions request that we made.  A response code of
 /// RESULT_OK means that the request was successfully sent to the server.
 /// </summary>
 public abstract void OnRestoreTransactionsResponse(BillingService.RestoreTransactions request, Consts.ResponseCode responseCode);
 /// <summary>
 /// Constructor
 /// 
 /// Note: Support for subscriptions implies support for one-time purchases. However, the
 /// opposite is not true.
 /// 
 /// Developers may want to perform two checks if both one-time and subscription products are
 /// available.
 /// 
 /// @pram itemType Either Consts.ITEM_TYPE_INAPP or Consts.ITEM_TYPE_SUBSCRIPTION, indicating
 /// the type of item support is being checked for.
 /// </summary>
 public CheckBillingSupported(BillingService outerInstance, string itemType)
     : base(outerInstance, -1)
 {
     this.outerInstance = outerInstance;
     mProductType = itemType;
 }
 public ConfirmNotifications(BillingService outerInstance, int startId, string[] notifyIds)
     : base(outerInstance, startId)
 {
     this.outerInstance = outerInstance;
     mNotifyIds = notifyIds;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="itemId">  The ID of the item to be purchased. Will be assumed to be a one-time
 ///                purchase. </param>
 /// <param name="itemType">  Either Consts.ITEM_TYPE_INAPP or Consts.ITEM_TYPE_SUBSCRIPTION,
 ///                  indicating the type of item type support is being checked for. </param>
 /// <param name="developerPayload"> Optional data. </param>
 public RequestPurchase(BillingService outerInstance, string itemId, string itemType, string developerPayload)
     : base(outerInstance, -1)
 {
     this.outerInstance = outerInstance;
     // This object is never created as a side effect of starting this
     // service so we pass -1 as the startId to indicate that we should
     // not stop this service after executing this request.
     mProductId = itemId;
     mDeveloperPayload = developerPayload;
     mProductType = itemType;
 }
 public CheckBillingSupported(BillingService outerInstance)
     : base(outerInstance, -1)
 {
     this.outerInstance = outerInstance;
     // This object is never created as a side effect of starting this
     // service so we pass -1 as the startId to indicate that we should
     // not stop this service after executing this request.
 }
 public RequestPurchase(BillingService outerInstance, string itemId, string developerPayload)
     : this(outerInstance, itemId, null, developerPayload)
 {
     this.outerInstance = outerInstance;
 }
 public RequestPurchase(BillingService outerInstance, string itemId)
     : this(outerInstance, itemId, null, null)
 {
     this.outerInstance = outerInstance;
 }
 public GetPurchaseInformation(BillingService outerInstance, int startId, string[] notifyIds)
     : base(outerInstance, startId)
 {
     this.outerInstance = outerInstance;
     mNotifyIds = notifyIds;
 }
 public BillingRequest(BillingService outerInstance, int startId)
 {
     this.outerInstance = outerInstance;
     mStartId = startId;
 }
 /// <summary>
 /// This is called when we receive a response code from Android Market for a
 /// RestoreTransactions request. </summary>
 /// <param name="context"> the context </param>
 /// <param name="request"> the RestoreTransactions request for which we received a
 ///     response code </param>
 /// <param name="responseCode"> a response code from Market to indicate the state
 ///     of the request </param>
 public static void ResponseCodeReceived(Context context, BillingService.RestoreTransactions request, Consts.ResponseCode responseCode)
 {
     if (sPurchaseObserver != null)
     {
         sPurchaseObserver.OnRestoreTransactionsResponse(request, responseCode);
     }
 }