Mar 27, 2016 Make your phone easier to use with one hand, no root. XDA Forum App. The best way to access XDA on your phone. Help & Troubleshooting Where are the game save files located on Android? By sprunknwn. Galaxy Note 3 Q&A, Help & Troubleshooting. All I had to do was download Helium on both of my phones and the desktop program. The Saved Games service makes it possible to synchronize a player's game data across multiple devices. For example, if you have a game that runs on Android, you can use the Saved Games service to allow a player to start a game on their Android phone, and then continue playing on a. But, when it comes to Play Windows Games On Android, you have to use Windows Emulator For Android or there are multiple methods using which you can Play PC Games On Android For Free. But, if you are using Windows Emulator, then you have to install Windows Games on your Android Phone which will consume much time and Phones Battery.
This guide shows you how to implement saved games game using thesnapshots API provided by Google Play games services. The APIs can be found in thecom.google.android.gms.games.snapshot
and com.google.android.gms.games
packages.
If you haven't already done so, you might find it helpful to review theSaved Games game concepts.
To start using the snapshots API, your game must first obtain aSnapshotsClient
object. You can do this by calling theGames.getSnapshotsClient()
method and passing in theactivity and the GoogleSignInAccount
for the current player. To learn how toretrieve the player account information, seeSign-in in Android Games.
SnapshotsClient
class makes use of the Google Playservices Task
class to return results asynchronously. To learn more aboutusing tasks to manage threaded work, see theTasks API developer guide.The snapshots API relies on the Google Drive API for saved games storage. Toaccess the Drive API, your app must specify theDrive.SCOPE_APPFOLDER
scope when building the Google sign-in client.
Here’s an example of how to do this in theonResume()
method for your sign-in activity:
You can integrate the snapshots API wherever your game provides players withthe option to save or restore their progress. Your game might display such anoption at designated save/restore points or allow players to save or restoreprogress at any time.
Once players select the save/restore option in your game, your game canoptionally bring up a screen that prompts players to enter information for a new savedgame or to select an existing saved game to restore.
To simplify your development, the snapshots API provides a default saved games selection userinterface (UI) that you can use out-of-the-box. The saved games selection UI allows players tocreate a new saved game, view details about existing saved games, and load previous saved games.
To launch the default Saved Games UI:
SnapshotsClient.getSelectSnapshotIntent()
to get anIntent
for launching the defaultsaved games selection UI.startActivityForResult()
and pass in that Intent
.If the call is successful, the game displays the saved game selection UI, alongwith the options you specified.Here’s an example of how to launch the default saved games selection UI:
If the player selects to create a new saved game or load an existing saved game,the UI sends a request to Google Play games services. If the request is successful,Google Play games services returns information to create or restore the saved game throughthe onActivityResult()
callback. Your game can override this callback to check if any errors occurred during request.
The following code snippet shows a sample implementation ofonActivityResult()
:
To store content to a saved game:
SnapshotsClient.open()
. Then, retrieve the Snapshot
objectfrom the task's result by calling SnapshotsClient.DataOrConflict.getData()
.SnapshotContents
instance via SnapshotsClient.SnapshotConflict
.SnapshotContents.writeBytes()
to store the player's data in byte format.SnapshotsClient.commitAndClose()
to send your changes to Google's servers. In the method call,your game can optionally provide additional information to tell Google Play games services how topresent this saved game to players. This information is represented in a SnapshotMetaDataChange
object, which your game creates using SnapshotMetadataChange.Builder
.The following snippet shows how your game might commit changes to a saved game:
If the player's device is not connected to a network when your app callsSnapshotsClient.commitAndClose()
, Google Play games services stores the saved game data locally onthe device. Upon device re-connection, Google Play games services syncs the locally cached saved gamechanges to Google's servers.
To retrieve saved games for the currently signed-in player:
SnapshotsClient.open()
. Then, retrieve the Snapshot
objectfrom the task's result by calling SnapshotsClient.DataOrConflict.getData()
. Alternatively, yourgame can also retrieve a specific snapshot through the saved games selection UI, as described inDisplaying Saved Games.SnapshotContents
instance via SnapshotsClient.SnapshotConflict
.SnapshotContents.readFully()
to read the contents of the snapshot.The following snippet shows how you might load a specific saved game:
When using the snapshots API in your game, it is possible for multipledevices to perform reads and writes on the same saved game. In the event that adevice temporarily loses its network connection and later reconnects, this mightcause data conflicts whereby the saved game stored on a player's local deviceis out-of-sync with the remote version stored in Google's servers.
The snapshots API provides a conflict resolution mechanism that presents bothsets of conflicting saved games at read-time and lets you implement a resolutionstrategy that is appropriate for your game.
When Google Play games services detects a data conflict, theSnapshotsClient.DataOrConflict.isConflict()
method returns a value of true
In this event, theSnapshotsClient.SnapshotConflict
class provides two versions of the saved game:
Your game must decide how to resolve the conflict by picking one of theprovided versions or merging the data of the two saved game versions.
To detect and resolve saved game conflicts:
SnapshotsClient.open()
. The task result contains a SnapshotsClient.DataOrConflict
class.SnapshotsClient.DataOrConflict.isConflict()
method. If the result is true, you have aconflict to resolve.SnapshotsClient.DataOrConflict.getConflict()
to retrieve aSnaphotsClient.snapshotConflict
instance.SnapshotsClient.SnapshotConflict.getConflictId()
to retrieve the conflict ID that uniquelyidentifies the detected conflict. Your game needs this value to send a conflict resolution requestlater.SnapshotsClient.SnapshotConflict.getConflictingSnapshot()
to get the local version.SnapshotsClient.SnapshotConflict.getSnapshot()
to get the server version.SnapshotsClient.resolveConflict()
method.The following snippet shows and example of how your game might handle a saved game conflict byselecting the most recently modified saved game as the final version to save:
If you want to merge data from multiple saved games or modify an existing Snapshot
to save to the server as the resolved final version, follow these steps:
SnapshotsClient.open()
.SnapshotsClient.SnapshotConflict.getResolutionSnapshotsContent()
to get a newSnapshotContents
object.SnapshotsClient.SnapshotConflict.getConflictingSnapshot()
andSnapshotsClient.SnapshotConflict.getSnapshot()
into the SnapshotContents
object from theprevious step.SnapshotMetadataChange
instance if there are any changes to the metadatafields.SnapshotsClient.resolveConflict()
. In your method call, pass inSnapshotsClient.SnapshotConflict.getConflictId()
as the first argument, and theSnapshotMetadataChange
and SnapshotContents
objects that you modified earlier as the second andthird arguments respectively.SnapshotsClient.resolveConflict()
call is successful, the API stores the Snapshot
object to the server and attempts to open the Snapshot object on your local device.SnapshotsClient.DataOrConflict.isConflict()
returns true
. In thiscase, your game should return to step 2 and repeat the steps to modify the snapshot untilconflicts are resolved.SnapshotsClient.DataOrConflict.isConflict()
returns false
andthe Snapshot
object is open for your game to modify.The Saved Games service gives you a convenient way to saveyour players' game progression to Google's servers. Your game can retrieve thesaved game data to allow returning players to continue a game at their lastsave point from any device.
The Saved Games service makes it possible to synchronize a player's game dataacross multiple devices. For example, if you have a game thatruns on Android, you can use the Saved Games service toallow a player to start a game on their Android phone, and thencontinue playing on a tablet without losing any of their progress. This servicecan also be used to ensure that a player's game playcontinues from where it left off even if their device is lost, destroyed, ortraded in for a newer model.
Note: Before using the Saved Games service, you must firstenable it in theGoogle Play Console.To learn how to implement saved games for your platform, seeClient implementations.
A saved game consists of two parts:
A game can write an arbitrary number of Saved Games for a single player,subject to user quota, so there is no hard requirement to restrictplayers to a single save file.
The Saved Games service provides a visual user experience in addition topersistence features. You are strongly encouraged to associate representativeimages with corresponding save files. If you are using the default Saved Gameslist user interface (UI) provides by the Play Games SDK in your game, the UIwill display these cover images. The cover images may also appear in theGoogle Play Games app.
You can provide a short text description of the content of a particular savedgame. This description is directly displayed to players and should summarizethe state that the saved game represents; for example, “Fighting the Goblinsin the Dark Woods”.
Developers are not charged for any saved game data that’s stored in the cloud.Instead, this data is counted against the player’s Google Drive quota - younever have to worry about it. The only quota that game developers need to careabout is their Google Drive API quota.
All Saved Games are stored in your players' Google Drive Application DataFolder. This folder can only be read and written by your game - it cannot beviewed or modified by other developers’ games, so there is additional protectionagainst data corruption. In addition, Saved Games are insulated from directtampering by players so they cannot modify individual Saved Games.
Your game can still read and write to a saved game when the player's device isoffline, but will not be able to sync with Google Play games services untilnetwork connectivity is established. Once reconnected, Google Play games servicesasynchronously updates the saved game data on Google's servers.
When using the Saved Games service, your game may encounter conflicts whenattempting to save data. These conflicts can occur when a user is running morethan one instance of your application on different devices or computers. Yourapplication must be able to resolve these conflicts in a way that provides thebest user experience.
Typically, data conflicts occur when an instance of your application is unableto reach the Saved Games service while attempting to load data or save it. Ingeneral, the best way to avoid data conflicts is to always load the latest datafrom the service when your application starts up or resumes, and save data tothe service with reasonable frequency. However, it is not always possible toavoid data conflicts. Your application should make every effort to handleconflicts such that your users' data is preserved and that they have a goodexperience.
Google Play games services currently enforce size limits on binary data and coverimage sizes of 3 MB and 800 KB respectively.
The structured metadata for a saved game contains these these properties:
Property | Description |
---|---|
ID | A unique string generated by Google Play games services for this saved game. Use this ID to refer to the saved game in your game clients. |
Name | A developer-supplied short name for the saved game, for example 'Save slot 1' or 'PlayerName_Save1'. This is not shown to players. |
Description | A developer-supplied description of the saved game. |
Last modified | Timestamp in milliseconds generated by Google Play games services for when the saved game was last updated. |
Played time | A developer-supplied time (in milliseconds) to display on the saved game. This value should represent how long the player has played the corresponding save game. For example, a played time value of 3600000 will be displayed by Google Play games services as '1 hr'. |
Cover image | This is an optional, developer-supplied property that contains information about the cover image. |
To learn how to implement Saved Games for your platform, see the following resources: