C# Класс Billing.PurchaseObserver

An interface for observing changes related to purchases. The main application extends this class and registers an instance of that derived class with ResponseHandler. The main application implements the callbacks #onBillingSupported(boolean) and #onPurchaseStateChange(PurchaseState, String, int, long). These methods are used to update the UI.
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
OnBillingSupported ( bool supported, string type ) : void

This is the callback that is invoked when Android Market responds to the BillingService#checkBillingSupported() request.

OnPurchaseStateChange ( Consts purchaseState, string itemId, int quantity, long purchaseTime, string developerPayload ) : void

This is the callback that is invoked when an item is purchased, refunded, or canceled. It is the callback invoked in response to calling BillingService#requestPurchase(String). It may also be invoked asynchronously when a purchase is made on another device (if the purchase was for a Market-managed item), or if the purchase was refunded, or the charge was canceled. This handles the UI update. The database update is handled in {@link ResponseHandler#purchaseResponse(Context, PurchaseState, String, String, long)}.

OnRequestPurchaseResponse ( BillingService request, Consts responseCode ) : void

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 #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).

OnRestoreTransactionsResponse ( BillingService request, Consts responseCode ) : void

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.

PurchaseObserver ( Android.App.Activity activity, Android.OS.Handler handler ) : System

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

Метод Описание
InitCompatibilityLayer ( ) : void
PostPurchaseStateChange ( Consts purchaseState, string itemId, int quantity, long purchaseTime, string developerPayload ) : void

Updates the UI after the database has been updated. This method runs in a background thread so it has to post a Runnable to run on the UI thread.

StartBuyPageActivity ( Android.App.PendingIntent pendingIntent, Android.Content.Intent intent ) : void

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

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

This is the callback that is invoked when Android Market responds to the BillingService#checkBillingSupported() request.
public abstract OnBillingSupported ( bool supported, string type ) : void
supported bool true if in-app billing is supported.
type string
Результат void

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

This is the callback that is invoked when an item is purchased, refunded, or canceled. It is the callback invoked in response to calling BillingService#requestPurchase(String). It may also be invoked asynchronously when a purchase is made on another device (if the purchase was for a Market-managed item), or if the purchase was refunded, or the charge was canceled. This handles the UI update. The database update is handled in {@link ResponseHandler#purchaseResponse(Context, PurchaseState, String, String, long)}.
public abstract OnPurchaseStateChange ( Consts purchaseState, string itemId, int quantity, long purchaseTime, string developerPayload ) : void
purchaseState Consts the purchase state of the item
itemId string a string identifying the item (the "SKU")
quantity int the current quantity of this item after the purchase
purchaseTime long the time the product was purchased, in /// milliseconds since the epoch (Jan 1, 1970)
developerPayload string
Результат void

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

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 #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).
public abstract OnRequestPurchaseResponse ( BillingService request, Consts responseCode ) : void
request BillingService
responseCode Consts
Результат void

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

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.
public abstract OnRestoreTransactionsResponse ( BillingService request, Consts responseCode ) : void
request BillingService
responseCode Consts
Результат void

PurchaseObserver() публичный Метод

public PurchaseObserver ( Android.App.Activity activity, Android.OS.Handler handler ) : System
activity Android.App.Activity
handler Android.OS.Handler
Результат System