C# Класс Billing.ResponseHandler

This class contains the methods that handle responses from Android Market. The implementation of these methods is specific to a particular application. The methods in this example update the database and, if the main application has registered a {@llink PurchaseObserver}, will also update the UI. An application might also want to forward some responses on to its own server, and that could be done here (in a background thread) but this example does not do that. You should modify and obfuscate this code before using it.
Показать файл Открыть проект

Открытые методы

Метод Описание
BuyPageIntentResponse ( Android.App.PendingIntent pendingIntent, Android.Content.Intent intent ) : void

Starts a new activity for the user to buy an item for sale. This method forwards the intent on to the PurchaseObserver (if it exists) because we need to start the activity on the activity stack of the application.

CheckBillingSupportedResponse ( bool supported, string type ) : void

Notifies the application of the availability of the MarketBillingService. This method is called in response to the application calling BillingService#checkBillingSupported().

PurchaseResponse ( Android.Content.Context context, Consts purchaseState, string productId, string orderId, long purchaseTime, string developerPayload ) : void

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.

ResponseCodeReceived ( Android.Content.Context context, BillingService request, Consts responseCode ) : void

This is called when we receive a response code from Android Market for a RequestPurchase request that we made. This is used for reporting various errors and also for acknowledging that an order was sent successfully to the server. This is NOT used for any purchase state changes. All purchase state changes are received in the BillingReceiver and are handled in Security#verifyPurchase(String, String).

Приватные методы

Метод Описание
Register ( PurchaseObserver observer ) : void
Unregister ( PurchaseObserver observer ) : void

Описание методов

BuyPageIntentResponse() публичный статический Метод

Starts a new activity for the user to buy an item for sale. This method forwards the intent on to the PurchaseObserver (if it exists) because we need to start the activity on the activity stack of the application.
public static BuyPageIntentResponse ( Android.App.PendingIntent pendingIntent, Android.Content.Intent intent ) : void
pendingIntent Android.App.PendingIntent a PendingIntent that we received from Android Market that /// will create the new buy page activity
intent Android.Content.Intent an intent containing a request id in an extra field that /// will be passed to the buy page activity when it is created
Результат void

CheckBillingSupportedResponse() публичный статический Метод

Notifies the application of the availability of the MarketBillingService. This method is called in response to the application calling BillingService#checkBillingSupported().
public static CheckBillingSupportedResponse ( bool supported, string type ) : void
supported bool true if in-app billing is supported.
type string
Результат void

PurchaseResponse() публичный статический Метод

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
Результат void

ResponseCodeReceived() публичный статический Метод

This is called when we receive a response code from Android Market for a RequestPurchase request that we made. This is used for reporting various errors and also for acknowledging that an order was sent successfully to the server. This is NOT used for any purchase state changes. All purchase state changes are received in the BillingReceiver and are handled in Security#verifyPurchase(String, String).
public static ResponseCodeReceived ( Android.Content.Context context, BillingService request, Consts responseCode ) : void
context Android.Content.Context the context
request BillingService the RequestPurchase request for which we received a /// response code
responseCode Consts a response code from Market to indicate the state /// of the request
Результат void