Billing.ResponseHandler.PurchaseResponse C# (CSharp) Method

PurchaseResponse() public static method

Notifies the application of purchase state changes. The application can offer an item for sale to the user via BillingService#requestPurchase(String). The BillingService calls this method after it gets the response. Another way this method can be called is if the user bought something on another device running this same app. Then Android Market notifies the other devices that the user has purchased an item, in which case the BillingService will also call this method. Finally, this method can be called if the item was refunded.
public static PurchaseResponse ( Android.Content.Context context, Consts purchaseState, string productId, string orderId, long purchaseTime, string developerPayload ) : void
context Android.Content.Context
purchaseState Consts the state of the purchase request (PURCHASED, /// CANCELED, or REFUNDED)
productId string a string identifying a product for sale
orderId string a string identifying the order
purchaseTime long the time the product was purchased, in milliseconds /// since the epoch (Jan 1, 1970)
developerPayload string the developer provided "payload" associated with /// the order
return void
        public static void PurchaseResponse(Context context, Consts.PurchaseState purchaseState, string productId, string orderId, long purchaseTime, string developerPayload)
        {
            // Update the database with the purchase state. We shouldn't do that
            // from the main thread so we do the work in a background thread.
            // We don't update the UI here. We will update the UI after we update
            // the database because we need to read and update the current quantity
            // first.
            //JAVA TO C# CONVERTER TODO TASK: Anonymous inner classes are not converted to C# if the base type is not defined in the code being converted:
            new Thread(new Runnable(() =>
                {
                    PurchaseDatabase db = new PurchaseDatabase(context);
                    int quantity = db.UpdatePurchase(orderId, productId, purchaseState, purchaseTime, developerPayload);
                    db.Close();

                    // This needs to be synchronized because the UI thread can change the
                    // value of sPurchaseObserver.
                    lock (context)
                    {
                        if (sPurchaseObserver != null)
                        {
                            sPurchaseObserver.PostPurchaseStateChange(purchaseState, productId, quantity, purchaseTime, developerPayload);
                        }
                    }
                })).Start();
        }