C# Class Billing.BillingService

Inheritance: Android.App.Service, Android.Content.IServiceConnection
显示文件 Open project: MarkEaton1/Monodroid-InApp-Billing Class Usage Examples

Public Methods

Method Description
BillingService ( ) : System
CheckBillingSupportedMethod ( string itemType ) : bool

Checks if in-app billing is supported. @pram itemType Either Consts.ITEM_TYPE_INAPP or Consts.ITEM_TYPE_SUBSCRIPTION, indicating the type of item support is being checked for.

HandleCommand ( Android.Content.Intent intent, int startId ) : void

The BillingReceiver sends messages to this service using intents. Each intent has an action and some extra arguments specific to that action.

OnBind ( Android.Content.Intent intent ) : IBinder

We don't support binding to this service, only starting the service.

OnServiceConnected ( ComponentName name, IBinder service ) : void

This is called when we are connected to the MarketBillingService. This runs in the main UI thread.

OnServiceDisconnected ( ComponentName name ) : void

This is called when we are disconnected from the MarketBillingService.

OnStart ( Android.Content.Intent intent, int startId ) : void
RequestPurchaseMethod ( string productId, string itemType, string developerPayload ) : bool

Requests that the given item be offered to the user for purchase. When the purchase succeeds (or is canceled) the BillingReceiver receives an intent with the action Consts#ACTION_NOTIFY. Returns false if there was an error trying to connect to Android Market.

RestoreTransactionsMethod ( ) : bool

Requests transaction information for all managed items. Call this only when the application is first installed or after a database wipe. Do NOT call this every time the application starts up.

Unbind ( ) : void

Unbinds from the MarketBillingService. Call this when the application terminates to avoid leaking a ServiceConnection.

Private Methods

Method Description
BindToMarketBillingService ( ) : bool

Binds to the MarketBillingService and returns true if the bind succeeded.

CheckBillingSupportedMethod ( ) : bool
CheckResponseCode ( long requestId, Consts responseCode ) : void

This is called when we receive a response code from Android Market for a request that we made. This is used for reporting various errors and for acknowledging that an order was sent to the server. This is NOT used for any purchase state changes. All purchase state changes are received in the BillingReceiver and passed to this service, where they are handled in #purchaseStateChanged(int, String, String).

ConfirmNotificationsMethod ( int startId, string notifyIds ) : bool

Confirms receipt of a purchase state change. Each {@code notifyId} is an opaque identifier that came from the server. This method sends those identifiers back to the MarketBillingService, which ACKs them to the server. Returns false if there was an error trying to connect to the MarketBillingService.

GetPurchaseInformationMethod ( int startId, string notifyIds ) : bool

Gets the purchase information. This message includes a list of notification IDs sent to us by Android Market, which we include in our request. The server responds with the purchase information, encoded as a JSON string, and sends that to the BillingReceiver in an intent with the action Consts#ACTION_PURCHASE_STATE_CHANGED. Returns false if there was an error trying to connect to the MarketBillingService.

PurchaseStateChanged ( int startId, string signedData, string signature ) : void

Verifies that the data was signed with the given signature, and calls ResponseHandler#purchaseResponse(Context, PurchaseState, String, String, long) for each verified purchase.

RunPendingRequests ( ) : void

Runs any pending requests that are waiting for a connection to the service to be established. This runs in the main UI thread.

Method Details

BillingService() public method

public BillingService ( ) : System
return System

CheckBillingSupportedMethod() public method

Checks if in-app billing is supported. @pram itemType Either Consts.ITEM_TYPE_INAPP or Consts.ITEM_TYPE_SUBSCRIPTION, indicating the type of item support is being checked for.
public CheckBillingSupportedMethod ( string itemType ) : bool
itemType string
return bool

HandleCommand() public method

The BillingReceiver sends messages to this service using intents. Each intent has an action and some extra arguments specific to that action.
public HandleCommand ( Android.Content.Intent intent, int startId ) : void
intent Android.Content.Intent the intent containing one of the supported actions
startId int an identifier for the invocation instance of this service
return void

OnBind() public method

We don't support binding to this service, only starting the service.
public OnBind ( Android.Content.Intent intent ) : IBinder
intent Android.Content.Intent
return IBinder

OnServiceConnected() public method

This is called when we are connected to the MarketBillingService. This runs in the main UI thread.
public OnServiceConnected ( ComponentName name, IBinder service ) : void
name ComponentName
service IBinder
return void

OnServiceDisconnected() public method

This is called when we are disconnected from the MarketBillingService.
public OnServiceDisconnected ( ComponentName name ) : void
name ComponentName
return void

OnStart() public method

public OnStart ( Android.Content.Intent intent, int startId ) : void
intent Android.Content.Intent
startId int
return void

RequestPurchaseMethod() public method

Requests that the given item be offered to the user for purchase. When the purchase succeeds (or is canceled) the BillingReceiver receives an intent with the action Consts#ACTION_NOTIFY. Returns false if there was an error trying to connect to Android Market.
public RequestPurchaseMethod ( string productId, string itemType, string developerPayload ) : bool
productId string an identifier for the item being offered for purchase
itemType string Either Consts.ITEM_TYPE_INAPP or Consts.ITEM_TYPE_SUBSCRIPTION, indicating /// the type of item type support is being checked for.
developerPayload string a payload that is associated with a given /// purchase, if null, no payload is sent
return bool

RestoreTransactionsMethod() public method

Requests transaction information for all managed items. Call this only when the application is first installed or after a database wipe. Do NOT call this every time the application starts up.
public RestoreTransactionsMethod ( ) : bool
return bool

Unbind() public method

Unbinds from the MarketBillingService. Call this when the application terminates to avoid leaking a ServiceConnection.
public Unbind ( ) : void
return void