tv.ouya.console.api
Class OuyaFacade

java.lang.Object
  extended by tv.ouya.console.api.OuyaFacade
All Implemented Interfaces:
android.content.ServiceConnection

public class OuyaFacade
extends java.lang.Object
implements android.content.ServiceConnection

Entry point for the OUYA API. Applications should use the singleton instance.

Calls are asynchronous, so results are returned via client provided OuyaResponseListener objects.


Constructor Summary
protected OuyaFacade()
          Default constructor.
 
Method Summary
 boolean bindRequestHasBeenMade()
          Deprecated. 
static OuyaFacade getInstance()
          Returns the OuyaFacade singleton.
 void init(android.content.Context context, java.lang.String developerId)
          Initializes the facade.
 boolean isInitialized()
          Returns whether the OuyaFacade has been initialized.
 void onServiceConnected(android.content.ComponentName componentName, android.os.IBinder iBinder)
          Called when the service is connected.
 void onServiceDisconnected(android.content.ComponentName componentName)
          Called when the service is disconnected.
 void requestGamerUuid(OuyaResponseListener<java.lang.String> gamerUuidListener)
          Requests the current gamer's UUID.
 void requestProductList(java.util.List<tv.ouya.console.api.Purchasable> purchasables, OuyaResponseListener<java.util.ArrayList<tv.ouya.console.api.Product>> productListListener)
          Returns a list of Product objects that describe the products (including current price) associated with the specified list of Purchasables.
 void requestPurchase(tv.ouya.console.api.Purchasable purchasable, OuyaResponseListener<tv.ouya.console.api.Product> purchaseListener)
          Requests that the specified Purchasable be purchased on behalf of the current user.
 void requestReceipts(OuyaResponseListener<java.lang.String> receiptListListener)
          Requests receipts for all of the purchases that the current gamer has made from a particular vendor.
protected static void setInstance(OuyaFacade instance)
          Deprecated. 
 void shutdown()
          Shuts down the facade.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OuyaFacade

protected OuyaFacade()
Default constructor.

Protected in order to prevent anyone from accidently creating an OuyaFacade directly.

Method Detail

getInstance

public static OuyaFacade getInstance()
Returns the OuyaFacade singleton.

Returns:
The singleton.

setInstance

@Deprecated
protected static void setInstance(OuyaFacade instance)
Deprecated. 

This method is for testing only.


init

public void init(android.content.Context context,
                 java.lang.String developerId)
Initializes the facade. Should only be called once.

Parameters:
context - An Android Context object.
developerId - The developer UUID, which is obtained from the developer portal.

shutdown

public void shutdown()
Shuts down the facade.

Note: Call shutdown before the program exits. Otherwise, the internal BroadcastReceiver will be leaked.


isInitialized

public boolean isInitialized()
Returns whether the OuyaFacade has been initialized.

Returns:
true if the OuyaFacade has already been initialized; otherwise, false.

requestProductList

public void requestProductList(java.util.List<tv.ouya.console.api.Purchasable> purchasables,
                               OuyaResponseListener<java.util.ArrayList<tv.ouya.console.api.Product>> productListListener)
Returns a list of Product objects that describe the products (including current price) associated with the specified list of Purchasables.

Parameters:
purchasables - The Purchasable objects that identify the products to be returned.
productListListener - A listener object that will asynchronously receive the Products

requestPurchase

public void requestPurchase(tv.ouya.console.api.Purchasable purchasable,
                            OuyaResponseListener<tv.ouya.console.api.Product> purchaseListener)
Requests that the specified Purchasable be purchased on behalf of the current user.

The IAP client service is responsible for identifying the user and requesting credentials as appropriate, as well as providing all of the UI for the purchase flow. When purchases are successful, a Product object is returned that describes the product that was purchased.

Parameters:
purchasable - The Purchasable object that describes the item to be purchased.
purchaseListener - A listener object that will asynchronously receive the results of the purchase request

requestReceipts

public void requestReceipts(OuyaResponseListener<java.lang.String> receiptListListener)
Requests receipts for all of the purchases that the current gamer has made from a particular vendor.

Parameters:
receiptListListener - A listener object that will asynchronously receive the list of receipts for all purchases ever made by the gamer to whom the console is currently registered.

requestGamerUuid

public void requestGamerUuid(OuyaResponseListener<java.lang.String> gamerUuidListener)
Requests the current gamer's UUID.

Parameters:
gamerUuidListener - A listener object that will asynchronously receive the UUID of the gamer to whom the console is currently registered.

bindRequestHasBeenMade

@Deprecated
public boolean bindRequestHasBeenMade()
Deprecated. 

This method is used for testing only.


onServiceConnected

public void onServiceConnected(android.content.ComponentName componentName,
                               android.os.IBinder iBinder)
Called when the service is connected.

This is part of Android's ServiceConnection interface, and it is not client consumable.

Specified by:
onServiceConnected in interface android.content.ServiceConnection
Parameters:
componentName - The name of the service that has been connected.
iBinder - The IBinder object for that service.

onServiceDisconnected

public void onServiceDisconnected(android.content.ComponentName componentName)
Called when the service is disconnected.

This is part of Android's ServiceConnection interface, and it is not client consumable.

Specified by:
onServiceDisconnected in interface android.content.ServiceConnection
Parameters:
componentName - The name of the service that has been disconnected.


Copyright © 2012 OUYA, Inc. All Rights Reserved.