java.lang.Object | |
↳ | com.google.android.gms.appstate.AppStateManager |
Main public API entry point for the AppState APIs.
Nested Classes | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AppStateManager.StateConflictResult | Result retrieved from AppStateManager.StateResult when a conflict is detected while loading app
state. |
||||||||||||||||||||||||||||||||
AppStateManager.StateDeletedResult | Result delivered when app state data has been deleted. | ||||||||||||||||||||||||||||||||
AppStateManager.StateListResult | Result delivered when app state data has been loaded. | ||||||||||||||||||||||||||||||||
AppStateManager.StateLoadedResult | Result retrieved from AppStateManager.StateResult when app state data has been loaded successfully. |
||||||||||||||||||||||||||||||||
AppStateManager.StateResult | Result of an operation that could potentially generate a state conflict. |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
API | Token to pass to addApi(Api extends Api.ApiOptions.NotRequiredOptions>) to enable AppState features. |
||||||||||
SCOPE_APP_STATE | Scope for using the App State service. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Delete the state data for the current app.
| |||||||||||
Gets the maximum number of keys that an app can store data in simultaneously.
| |||||||||||
Gets the maximum app state size per state key in bytes.
| |||||||||||
Asynchronously lists all the saved states for the current app.
| |||||||||||
Asynchronously loads saved state for the current app.
| |||||||||||
Resolve a previously detected conflict in app state data.
| |||||||||||
Asynchronously signs the current user out.
| |||||||||||
Updates app state for the current app.
| |||||||||||
Updates app state for the current app.
|
[Expand]
Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Token to pass to addApi(Api extends Api.ApiOptions.NotRequiredOptions>)
to enable AppState features.
Delete the state data for the current app. This method will delete all data associated with the provided key, as well as removing the key itself.
Note that this API is not version safe. This means that it is possible to accidentally delete
a user's data using this API. For a version safe alternative, consider using
update(GoogleApiClient, int, byte[])
with null
data instead.
Required API: API
Required Scopes: SCOPE_APP_STATE
googleApiClient | The GoogleApiClient to service the call. |
---|---|
stateKey | The key to clear data for. Must be a non-negative integer less than
getMaxNumKeys(GoogleApiClient) . |
PendingResult
to access the data when available.
Gets the maximum number of keys that an app can store data in simultaneously.
If the service cannot be reached for some reason, this will return
STATUS_CLIENT_RECONNECT_REQUIRED
. In this case, no further
operations should be attempted until after the client has reconnected.
Required API: API
Required Scopes: SCOPE_APP_STATE
googleApiClient | The GoogleApiClient to service the call. |
---|
Gets the maximum app state size per state key in bytes. Guaranteed to be at least 256 KB. May increase in the future.
If the service cannot be reached for some reason, this will return
STATUS_CLIENT_RECONNECT_REQUIRED
. In this case, no further
operations should be attempted until after the client has reconnected.
Required API: API
Required Scopes: SCOPE_APP_STATE
googleApiClient | The GoogleApiClient to service the call. |
---|
Asynchronously lists all the saved states for the current app.
Required API: API
Required Scopes: SCOPE_APP_STATE
googleApiClient | The GoogleApiClient to service the call. |
---|
PendingResult
to access the data when available.
Asynchronously loads saved state for the current app.
Required API: API
Required Scopes: SCOPE_APP_STATE
googleApiClient | The GoogleApiClient to service the call. |
---|---|
stateKey | The key to load data for. Must be a non-negative integer less than
getMaxNumKeys(GoogleApiClient) . |
PendingResult
to access the data when available.
Resolve a previously detected conflict in app state data. Note that it is still possible to receive a conflict callback after this call. This will occur if data on the server continues to change. In this case, resolution should be retried until a successful status is returned.
The value of resolvedVersion
passed here must correspond to the value returned from
getResolvedVersion()
.
Required API: API
Required Scopes: SCOPE_APP_STATE
googleApiClient | The GoogleApiClient to service the call. |
---|---|
stateKey | The key to resolve data for. Must be a non-negative integer less than
getMaxNumKeys(GoogleApiClient) . |
resolvedVersion | Version code from previous onStateConflict call. |
resolvedData | Data to submit as the current data. null is a valid value here.
May be a maximum of getMaxStateSize(GoogleApiClient) bytes. |
PendingResult
to access the data when available.
Asynchronously signs the current user out.
Required API: API
Required Scopes: SCOPE_APP_STATE
googleApiClient | The GoogleApiClient to service the call. |
---|
PendingResult
to access the data when available.
Updates app state for the current app. The data provided here is developer-specified and can
be in any format appropriate for the app. This method updates the local copy of the app state
and syncs the changes to the server. If the local data conflicts with the data on the server,
this will be indicated the next time you call load(GoogleApiClient, int)
.
This is the fire-and-forget form of the API. Use this form if you don't need to know the
results of the operation immediately. For most applications, this will be the preferred API
to use. See updateImmediate(GoogleApiClient, int, byte[])
if you need the results
delivered to your application.
Required API: API
Required Scopes: SCOPE_APP_STATE
googleApiClient | The GoogleApiClient to service the call. |
---|---|
stateKey | The key to update data for. Must be a non-negative integer less than
getMaxNumKeys(GoogleApiClient) . |
data | The data to store. May be a maximum of getMaxStateSize(GoogleApiClient)
bytes.
|
Updates app state for the current app. The data provided here is developer-specified and can be in any format appropriate for the app. This method will attempt to update the data on the server immediately. The results of this operation will be returned via a PendingResult.
Required API: API
Required Scopes: SCOPE_APP_STATE
googleApiClient | The GoogleApiClient to service the call. |
---|---|
stateKey | The key to update data for. Must be a non-negative integer less than
getMaxNumKeys(GoogleApiClient) . |
data | The data to store. May be a maximum of getMaxStateSize(GoogleApiClient)
bytes. |
PendingResult
to access the data when available.