com.amazon.inapp.purchasing
Class PurchasingObserver

java.lang.Object
  extended by com.amazon.inapp.purchasing.PurchasingObserver
Direct Known Subclasses:
BasePurchasingObserver

public abstract class PurchasingObserver
extends java.lang.Object

Clients must subclass the PurchasingObserver and register an instance of their subclass with PurchasingManager.registerObserver(PurchasingObserver) before using other APIs in the PurchasingManager.

Your registered subclass of the PurchasingObserver will asynchronously receive callbacks when operations you initiate via methods in the PurchasingManager have completed.

For example, if you initiate a purchase with PurchasingManager.initiatePurchaseRequest(String) you will eventually receive a notification that the PurchaseResponse is available via the onPurchaseResponse(PurchaseResponse) method you have implemented.

Please be aware that the callbacks you implement here will be invoked on your UI thread. If you must perform any long-running tasks you should do them on another thread, possibly using an AsyncTask.

BasePurchasingObserver provides an implementation of this class that does nothing, allowing you to override just the methods you need.


Constructor Summary
PurchasingObserver(android.content.Context context)
          Creates a new PurchasingObserver that is associated with your Activity or Application Context.
 
Method Summary
abstract  void onGetUserIdResponse(GetUserIdResponse getUserIdResponse)
           This callback method allows you to be notified when a GetUserIdResponse is available for a request that was initiated previously via PurchasingManager.initiateGetUseridRequest().
abstract  void onItemDataResponse(ItemDataResponse itemDataResponse)
           This callback method allows you to be notified when an ItemDataResponse is available for a request that was initiated previously via PurchasingManager.initiateItemDataRequest(java.util.Set).
abstract  void onPurchaseResponse(PurchaseResponse purchaseResponse)
           This callback method allows you to be notified when a PurchaseResponse is available for a purchase that was initiated previously via PurchasingManager.initiatePurchaseRequest(String).
abstract  void onPurchaseUpdatesResponse(PurchaseUpdatesResponse purchaseUpdatesResponse)
           This callback method allows you to be notified when a PurchaseUpdatesResponse is available for a request that was initiated previously via PurchasingManager.initiatePurchaseUpdatesRequest(Offset).
abstract  void onSdkAvailable(boolean isSandboxMode)
           This is the first callback that will be invoked after you register your PurchasingObserver with the PurchasingManager, and will indicate whether the In-App SDK is running in sandbox mode (with test data) or production mode (with real data).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PurchasingObserver

public PurchasingObserver(android.content.Context context)
Creates a new PurchasingObserver that is associated with your Activity or Application Context.

Parameters:
context - The Activity or Application Context in which you are creating this PurchasingObserver
Method Detail

onSdkAvailable

public abstract void onSdkAvailable(boolean isSandboxMode)

This is the first callback that will be invoked after you register your PurchasingObserver with the PurchasingManager, and will indicate whether the In-App SDK is running in sandbox mode (with test data) or production mode (with real data).

Please be aware that this method will be invoked on your UI thread. If you must perform any long-running tasks in your implementation you should do them on another thread, possibly using an AsyncTask.

Parameters:
isSandboxMode - true if we are running in sandbox mode with test data, false if we're running in production mode with real data

onGetUserIdResponse

public abstract void onGetUserIdResponse(GetUserIdResponse getUserIdResponse)

This callback method allows you to be notified when a GetUserIdResponse is available for a request that was initiated previously via PurchasingManager.initiateGetUseridRequest().

Implement this method to be made aware of the ID of the currenlty logged in user. Note that this ID is specific to this application across all devices the user owns.

Please be aware that this method will be invoked on your UI thread. If you must perform any long-running tasks in your implementation you should do them on another thread, possibly using an AsyncTask.

Parameters:
getUserIdResponse - Indicates the application-specific ID of the currently logged in user

onPurchaseResponse

public abstract void onPurchaseResponse(PurchaseResponse purchaseResponse)

This callback method allows you to be notified when a PurchaseResponse is available for a purchase that was initiated previously via PurchasingManager.initiatePurchaseRequest(String).

Implement this method to update your application state, save purchase information to a database, send it to your developer server, etc.

Please be aware that this method will be invoked on your UI thread. If you must perform any long-running tasks in your implementation you should do them on another thread, possibly using an AsyncTask.

Parameters:
purchaseResponse - Indicates the status of the purchase operation and may contain a receipt

onItemDataResponse

public abstract void onItemDataResponse(ItemDataResponse itemDataResponse)

This callback method allows you to be notified when an ItemDataResponse is available for a request that was initiated previously via PurchasingManager.initiateItemDataRequest(java.util.Set).

Please be aware that this method will be invoked on your UI thread. If you must perform any long-running tasks in your implementation you should do them on another thread, possibly using an AsyncTask.

Parameters:
itemDataResponse - Provides access to item data and the status of the request

onPurchaseUpdatesResponse

public abstract void onPurchaseUpdatesResponse(PurchaseUpdatesResponse purchaseUpdatesResponse)

This callback method allows you to be notified when a PurchaseUpdatesResponse is available for a request that was initiated previously via PurchasingManager.initiatePurchaseUpdatesRequest(Offset).

Please be aware that this method will be invoked on your UI thread. If you must perform any long-running tasks in your implementation you should do them on another thread, possibly using an AsyncTask.

Parameters:
purchaseUpdatesResponse - Provides access to receipt data and the status of the request