public static final class

AppStateClient.Builder

extends Object
java.lang.Object
   ↳ com.google.android.gms.appstate.AppStateClient.Builder

Class Overview

Builder class for AppStateClient.

Summary

Public Constructors
AppStateClient.Builder(Context context, GooglePlayServicesClient.ConnectionCallbacks connectedListener, GooglePlayServicesClient.OnConnectionFailedListener connectionFailedListener)
Create a new Builder object to be used to build a corresponding AppStateClient object.
Public Methods
AppStateClient create()
Creates a new AppStateClient object to be used to communicate with the App State service, requesting all of the scopes passed in.
AppStateClient.Builder setAccountName(String accountName)
Specify an account name on the device that should be used.
AppStateClient.Builder setScopes(String... scopes)
Set the scopes to use when building the AppStateClient object.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public AppStateClient.Builder (Context context, GooglePlayServicesClient.ConnectionCallbacks connectedListener, GooglePlayServicesClient.OnConnectionFailedListener connectionFailedListener)

Create a new Builder object to be used to build a corresponding AppStateClient object.

Parameters
context The context to use for the connection.
connectedListener The listener where the results of the asynchronous connect() call are delivered.
connectionFailedListener The listener which will be notified if the connection attempt fails.

Public Methods

public AppStateClient create ()

Creates a new AppStateClient object to be used to communicate with the App State service, requesting all of the scopes passed in.

The object is not usable until after the asynchronous connect() method has been called and your listener's onConnected(Bundle) method is called. Note that the ConnectionCallbacks provided here will always receive callbacks before any subsequently registered connection listeners.

When your application is done using this client it must call disconnect(), even if the async result from connect() has not yet been delivered.

The typical pattern is to instantiate this object in your Activity's onCreate(Bundle) method and then call connect() in onStart() and disconnect() from onStop() regardless of the state.

Returns
  • The AppStateClient object.

public AppStateClient.Builder setAccountName (String accountName)

Specify an account name on the device that should be used. If this is never called, the client will use the current default account for Google Play services for this application.

Parameters
accountName The account name on the device that should be used by this AppStateClient. Must be non-null.
Returns
  • This Builder.

public AppStateClient.Builder setScopes (String... scopes)

Set the scopes to use when building the AppStateClient object.

The scope used by default is APP_STATE.

Parameters
scopes The OAuth scopes that your application is requesting access to (see Scopes for details).
Returns
  • This Builder.