VoltAir
|
Helper class responsible for setting up the GoogleApiClient
object and managing its lifecycle for activities.
More...
Classes | |
class | SignInFailureReason |
Represents the reason for a sign-in failure. More... | |
interface | SignInListener |
Listener for sign-in success or failure events. More... | |
Public Member Functions | |
GooglePlayServicesHelper (Activity activity, int clientsToUse) | |
Constructs a GooglePlayServicesHelper, initially tied to activity . More... | |
void | setAutoSignIn (boolean autoSignIn) |
Sets whether or not the configuration should begin connecting automatically to the GoogleApiClient in onStart(). More... | |
int | getMaxForcedSignInAttempts () |
Returns the maximum number of times to automatically force sign-in flow on the user. More... | |
void | setMaxForcedSignInAttempts (int max) |
Sets the maximum number of times to automatically force sign-in flow on the user. More... | |
boolean | willForceSignInFlow () |
Returns whether or not the configuration will force sign in flow. More... | |
int | getSignInUserCancellations () |
Returns the number of times the user has canceled the sign-in flow in the life of the application. More... | |
void | resetSignInUserCancellations () |
Resets the counter of how many times the user has canceled the sign-in. More... | |
void | setShowErrorDialogs (boolean show) |
Sets whether or not to show error dialogs. More... | |
void | setGamesApiOptions (GoogleApiClient.ApiOptions options) |
Sets the options to pass when setting up the Games API client. More... | |
void | setAppStateApiOptions (GoogleApiClient.ApiOptions options) |
Sets the options to pass when setting up the AppState API client. More... | |
void | setPlusApiOptions (GoogleApiClient.ApiOptions options) |
Sets the options to pass when setting up the Plus API client. More... | |
GoogleApiClient | getApiClient () |
Returns the GoogleApiClient object. More... | |
boolean | isSignedIn () |
Returns whether or not the user (i.e. the GoogleApiClient ) is signed in. More... | |
boolean | isConnecting () |
Returns whether or not the GoogleApiClient is currently connecting. More... | |
boolean | hasSignInError () |
Returns whether or not there was a (non-recoverable) error during the sign-in process. More... | |
SignInFailureReason | getSignInError () |
Returns the error that happened during the sign-in process, null if no error occurred. More... | |
boolean | hasInvitation () |
Returns whether or not an invitation was in the connection bundle. More... | |
Invitation | getInvitation () |
Returns the invitation received in the connection bundle, or null if no invitation exists. More... | |
void | clearInvitation () |
Clears the invitation (if any) received in the connection bundle. More... | |
boolean | hasTurnBasedMatch () |
Returns whether or not a turn-based match was received in the connection bundle. More... | |
TurnBasedMatch | getTurnBasedMatch () |
Returns the turn-based match received in the connection bundle, or null if no turn-based match exists. More... | |
void | clearTurnBasedMatch () |
Clears the turn-based match (if any) received in the connection bundle. More... | |
boolean | hasRequests () |
Returns whether or not a list of game requests was received in the connection bundle. More... | |
ArrayList< GameRequest > | getRequests () |
Returns the list of game requests received in the connection bundle, or null if no requests exist. More... | |
void | clearRequests () |
Clears the list of game requests (if any) received in the connection bundle. More... | |
void | setup (SignInListener listener) |
Performs setup on this GooglePlayServicesHelper. More... | |
void | beginUserInitiatedSignIn () |
Starts a user-initiated sign-in flow. More... | |
void | signOut () |
Sign out and disconnect from the API clients used in the GoogleApiClient . More... | |
void | reconnect () |
Disconnects the GoogleApiClient client, then connects again. More... | |
void | onStart (Activity activity) |
Notifies this GooglePlayServicesHelper of the onStart activity lifecycle event. More... | |
void | onStop () |
Notifies this GooglePlayServicesHelper of the onStop activity lifecycle event. More... | |
void | onActivityResult (int requestCode, int responseCode, Intent data) |
Notifies this GooglePlayServicesHelper of the onActivityResult event. More... | |
void | onConnected (Bundle connectionHint) |
Called when a connection to the GoogleApiClient is successfully obtained. More... | |
void | onConnectionFailed (ConnectionResult result) |
Called when a connection attempt to the GoogleApiClient fails. More... | |
void | onConnectionSuspended (int cause) |
Called when a connection attempt to the GoogleApiClient is suspended due to falling into a temporarily disconnected state. More... | |
Static Public Attributes | |
static final int | CLIENT_NONE = 0x00 |
No clients. More... | |
static final int | CLIENT_GAMES = 0x01 |
Google Play Games client. More... | |
static final int | CLIENT_PLUS = 0x02 |
Google Plus client. More... | |
static final int | CLIENT_APPSTATE = 0x04 |
Google AppState client. More... | |
static final int | CLIENT_ALL = CLIENT_GAMES | CLIENT_PLUS | CLIENT_APPSTATE |
All clients supported by GooglePlayServicesHelper. More... | |
Helper class responsible for setting up the GoogleApiClient
object and managing its lifecycle for activities.
Activities should instantiate the class in their onCreate()
method and specify the requested clients (e.g. CLIENT_GAMES | CLIENT_APPSTATE
) during setup. Additionally, those activities should implement the SignInListener interface and register themselves as listeners for changes in sign-in status.
|
inline |
Constructs a GooglePlayServicesHelper, initially tied to activity
.
onCreate()
method of activity
. activity | Activity context to be used for the wrapped GoogleApiClient |
clientsToUse | Flags indicating which clients are requested |
|
inline |
Starts a user-initiated sign-in flow.
As a result of calling this method, authentication / consent dialogs may be displayed. At the end of the process, the registered SignInListener's methods will be called to indicate success or failure.
|
inline |
Clears the invitation (if any) received in the connection bundle.
|
inline |
Clears the list of game requests (if any) received in the connection bundle.
|
inline |
Clears the turn-based match (if any) received in the connection bundle.
|
inline |
Returns the GoogleApiClient object.
|
inline |
Returns the invitation received in the connection bundle, or null
if no invitation exists.
|
inline |
Returns the maximum number of times to automatically force sign-in flow on the user.
If a sign-in error occurred (e.g. user has not given permissions for sign-in), resolution (e.g. launching sign-in flow) will be forced up until getMaxForcedSignInFlowAttempts() times.
|
inline |
Returns the list of game requests received in the connection bundle, or null
if no requests exist.
|
inline |
Returns the error that happened during the sign-in process, null if no error occurred.
|
inline |
Returns the number of times the user has canceled the sign-in flow in the life of the application.
|
inline |
Returns the turn-based match received in the connection bundle, or null
if no turn-based match exists.
|
inline |
Returns whether or not an invitation was in the connection bundle.
|
inline |
Returns whether or not a list of game requests was received in the connection bundle.
|
inline |
Returns whether or not there was a (non-recoverable) error during the sign-in process.
|
inline |
Returns whether or not a turn-based match was received in the connection bundle.
|
inline |
Returns whether or not the GoogleApiClient
is currently connecting.
|
inline |
Returns whether or not the user (i.e. the GoogleApiClient
) is signed in.
|
inline |
Notifies this GooglePlayServicesHelper of the onActivityResult
event.
This method should be called from the onActivityResult
method in the activity context used to create this GooglePlayServicesHelper. If the activity result pertains to the sign-in process, then it is processesed appropriately, otherwise it is ignored.
requestCode | Identifier supplied when the activity was originally launched that is used to identify if this result pertains to the sign-in process |
responseCode | Status returned by the activity |
data | Intent which can be used to return result data to the caller |
|
inline |
Called when a connection to the GoogleApiClient
is successfully obtained.
connectionHint | Bundle of data provided to clients by Google Play Games Services, or null if no content is provided by the service |
|
inline |
Called when a connection attempt to the GoogleApiClient
fails.
result | ConnectionResult that can be used for resolving the sign-in error and / or deciding what sort of error occurred |
|
inline |
Called when a connection attempt to the GoogleApiClient
is suspended due to falling into a temporarily disconnected state.
cause | Code that identifies the reason for the disconnection |
|
inline |
Notifies this GooglePlayServicesHelper of the onStart
activity lifecycle event.
This method should be called from the onStart
method in activity
.
activity | Activity context to be used for the wrapped GoogleApiClient |
|
inline |
Notifies this GooglePlayServicesHelper of the onStop
activity lifecycle event.
This method should be called from the onStop
method in the activity context used to create this GooglePlayServicesHelper.
|
inline |
Disconnects the GoogleApiClient
client, then connects again.
|
inline |
Resets the counter of how many times the user has canceled the sign-in.
|
inline |
Sets the options to pass when setting up the AppState API client.
|
inline |
Sets whether or not the configuration should begin connecting automatically to the GoogleApiClient in onStart().
Auto sign-in occurs by default, so this method is used to disable auto sign-in.
autoSignIn | true to automatically connect to GoogleApiClient in onStart() |
|
inline |
Sets the options to pass when setting up the Games API client.
|
inline |
Sets the maximum number of times to automatically force sign-in flow on the user.
If set to 0, the user will not be forced through the sign-in flow automatically.
|
inline |
Sets the options to pass when setting up the Plus API client.
|
inline |
Sets whether or not to show error dialogs.
show | true to show error dialogs |
|
inline |
Performs setup on this GooglePlayServicesHelper.
Calling of this method will lead to the creation of the GoogleApiClient
.
onCreate()
method of the calling activity to ensure setup before onStart(). GoogleApiClient
. listener | SignInListener to be notified of sign-in events |
|
inline |
Sign out and disconnect from the API clients used in the GoogleApiClient
.
|
inline |
Returns whether or not the configuration will force sign in flow.
This is determined by two factors: having auto sign-in enabled and having not exceeded the maximum number of forced sign-in attempts.
|
static |
All clients supported by GooglePlayServicesHelper.
|
static |
Google AppState client.
|
static |
Google Play Games client.
|
static |
No clients.
|
static |
Google Plus client.