java.lang.Object | |
↳ | com.google.android.gms.plus.PlusClient |
The main entry point for Google+ integration.
Use the PlusClient after the asynchronous connect()
method
has been called and your listener's
onConnected(android.os.Bundle)
method is called.
When your app is done using PlusClient, call disconnect()
, even if the async
result from connect()
has not yet been delivered.
You should instantiate this object in your Activity's onCreate(Bundle)
method and then
call connect()
in onStart()
and disconnect()
in
onStop()
, regardless of the state.
Nested Classes | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PlusClient.Builder | Builder to configure a PlusClient for communicating with the Google+ APIs. |
||||||||||||||||||||||||||||||||
PlusClient.OnAccessRevokedListener | Listener interface for when the token revocation request has completed. | ||||||||||||||||||||||||||||||||
PlusClient.OnMomentsLoadedListener | Listener interface for when moments are loaded. | ||||||||||||||||||||||||||||||||
PlusClient.OnPeopleLoadedListener | Listener interface for when a collection of people are loaded. | ||||||||||||||||||||||||||||||||
PlusClient.OrderBy | Constants to declare the order to return people in. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Remove the default account set in Google Play services for your app.
| |||||||||||
Connects the client to Google Play services.
| |||||||||||
Closes the connection to Google Play services.
| |||||||||||
Gets the account name resolved by Google Play services.
| |||||||||||
Returns profile information for the current user.
| |||||||||||
Checks if the client is currently connected to the service, so that
requests to other methods will succeed.
| |||||||||||
Checks if the client is attempting to connect to the service.
| |||||||||||
Returns true if the specified listener is currently registered to
receive connection events.
| |||||||||||
Returns true if the specified listener is currently registered to
receive connection failed events.
| |||||||||||
List all of the moments for a particular user.
| |||||||||||
List all of the moments for the currently signed-in user.
| |||||||||||
Loads a list of specified people.
| |||||||||||
Helper method for
loadPeople(PlusClient.OnPeopleLoadedListener, java.util.Collection) . | |||||||||||
Loads the list of visible people in the user's circles.
| |||||||||||
Loads the list of visible people in the user's circles.
| |||||||||||
Registers a listener to receive connection events from this
GooglePlayServicesClient . | |||||||||||
Registers a listener to receive connection failed events from this
GooglePlayServicesClient . | |||||||||||
Delete a moment.
| |||||||||||
Revokes access given to the current application.
| |||||||||||
Removes a connection listener from this
GooglePlayServicesClient . | |||||||||||
Removes a connection failed listener from the
GooglePlayServicesClient . | |||||||||||
Writes a moment.
|
[Expand]
Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||||||||||||||||||||||||
From interface
com.google.android.gms.common.GooglePlayServicesClient
|
Remove the default account set in Google Play services for your app.
Subsequent calls to connect()
will return a resolution intent
that will let the user select a different account.
revokeAccessAndDisconnect(PlusClient.OnAccessRevokedListener)
.
Connects the client to Google Play services. This method returns immediately, and connects to
the service in the background. If the connection is successful,
onConnected(Bundle)
is called. On a
failure, onConnectionFailed(ConnectionResult)
is called.
Closes the connection to Google Play services. No calls can be made on this object after calling this method.
Gets the account name resolved by Google Play services. The permission
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
must be declared in your AndroidManifest.xml
to use this method.
SecurityException | If your app doesn't have the
GET_ACCOUNTS permission.
|
---|
Returns profile information for the current user. For more information, see: https://developers.google.com/+/api/latest/people/get.
This method requires the OAuth 2.0 scope PLUS_PROFILE
or
PLUS_LOGIN
specified in the PlusClient.Builder
.
This method can return null
if the required scopes weren't specified in the
PlusClient.Builder
, or if there was a network error while connecting.
null
otherwise.
Checks if the client is currently connected to the service, so that requests to other methods will succeed. Applications should guard client actions caused by the user with a call to this method.
Checks if the client is attempting to connect to the service.
Returns true if the specified listener is currently registered to receive connection events.
listener | The listener to check for. |
---|
Returns true if the specified listener is currently registered to receive connection failed events.
listener | The listener to check for. |
---|
List all of the moments for a particular user. For more information, see https://developers.google.com/+/api/latest/moments/list.
This method requires the PLUS_LOGIN
OAuth 2.0 scope specified in the PlusClient.Builder
.
listener | The PlusClient.OnMomentsLoadedListener to receive a callback when the moments
are loaded. |
---|---|
maxResults | The maximum number of moments to include in the response, which is used for paging. For any response, the actual number returned might be less than the specified maxResults. |
pageToken | The continuation token, which is used to page through large result sets. To get the next page of results, set this parameter to the value of nextPageToken from the previous response. |
targetUrl | Only moments containing this targetUrl will be returned. |
type | Only moments of this type will be returned. |
userId | The ID of the user to get moments for. The special value "me" can be used to indicate the authenticated user. |
List all of the moments for the currently signed-in user. For more information, see https://developers.google.com/+/api/latest/moments/list.
This method requires the PLUS_LOGIN
OAuth 2.0 scope specified in the PlusClient.Builder
.
listener | The PlusClient.OnMomentsLoadedListener to receive a callback when the moments
are loaded.
|
---|
Loads a list of specified people.
This call returns all information in Person
, but only for the people
specified and for data that is public in their profiles.
This method requires the PLUS_LOGIN
OAuth 2.0 scope specified in the PlusClient.Builder
listener | The PlusClient.OnPeopleLoadedListener to receive a callback when the people
are loaded. |
---|---|
personIds | The ids of people to load. This should match the user id that would be sent to https://developers.google.com/+/api/latest/people/get |
Helper method for
loadPeople(PlusClient.OnPeopleLoadedListener, java.util.Collection)
.
Loads the list of visible people in the user's circles. For more information, see: https://developers.google.com/+/api/latest/people/list.
Each Person
will contain the id
, displayName
,
image
, objectType
, and url
fields populated.
To retrieve additional profile data, use the loadPeople(PlusClient.OnPeopleLoadedListener, String...)
method.
This method requires the PLUS_LOGIN
OAuth 2.0 scope specified in the PlusClient.Builder
listener | The PlusClient.OnPeopleLoadedListener to receive a callback when the people
are loaded.
|
---|
Loads the list of visible people in the user's circles. For more information, see: https://developers.google.com/+/api/latest/people/list.
Each Person
will contain the id
, displayName
,
image
, objectType
, and url
fields populated.
To retrieve additional profile data, use the loadPeople(PlusClient.OnPeopleLoadedListener, String...)
method.
This method requires the PLUS_LOGIN
OAuth 2.0 scope specified in the PlusClient.Builder
listener | The PlusClient.OnPeopleLoadedListener to receive a callback when the people
are loaded. |
---|---|
orderBy | The order to return people in. Valid values are:
|
Registers a listener to receive connection events from this GooglePlayServicesClient
.
If the service is already connected, the listener's onConnected(Bundle)
method will be called immediately. Applications should balance calls to this method with
calls to unregisterConnectionCallbacks(ConnectionCallbacks)
to avoid leaking
resources.
If the specified listener is already registered to receive connection events, this
method will not add a duplicate entry for the same listener, but will
still call the listener's onConnected(Bundle)
method if currently
connected.
Note that the order of messages received here may not be stable, so clients should not rely on the order that multiple listeners receive events in.
listener | the listener where the results of the asynchronous connect() call are
delivered.
|
---|
Registers a listener to receive connection failed events from this
GooglePlayServicesClient
. Unlike registerConnectionCallbacks(GooglePlayServicesClient.ConnectionCallbacks)
, if the service
is not already connected, the listener's
onConnectionFailed(ConnectionResult)
method will not be called immediately.
Applications should balance calls to this method with calls to
unregisterConnectionFailedListener(OnConnectionFailedListener)
to avoid leaking
resources.
If the specified listener is already registered to receive connection failed events, this method will not add a duplicate entry for the same listener.
Note that the order of messages received here may not be stable, so clients should not rely on the order that multiple listeners receive events in.
listener | the listener where the results of the asynchronous connect() call are
delivered.
|
---|
Delete a moment. For more information, see https://developers.google.com/+/api/latest/moments/remove.
This method requires the PLUS_LOGIN
OAuth 2.0 scope specified in the PlusClient.Builder
.
momentId | The ID of the moment to delete. |
---|
Revokes access given to the current application.
listener | The PlusClient.OnAccessRevokedListener to receive a callback when the token
is revoked.
|
---|
Removes a connection listener from this GooglePlayServicesClient
. Note that removing
a listener does not generate any callbacks.
If the specified listener is not currently registered to receive connection events, this method will have no effect.
listener | the listener to unregister. |
---|
Removes a connection failed listener from the GooglePlayServicesClient
.
Note that removing a listener does not generate any callbacks.
If the specified listener is not currently registered to receive connection failed events, this method will have no effect.
listener | the listener to unregister. |
---|
Writes a moment. For more information, see https://developers.google.com/+/api/latest/moments/insert.
This is a fire-and-forget method that writes the user's moment asynchronously. If there is
a network error, Google Play services attempts to send the request again when the device
comes back online. Requests can fail if there are problems with the account or format of
specified in moment
. To debug, run adb logcat
in a terminal and find errors
related to moments in the output.
This method requires the PLUS_LOGIN
OAuth 2.0 scope specified in the PlusClient.Builder
.
moment | The moment description. |
---|