Currently I am working on the Google's Saved Games integration into an Android app.
I am trying to create a new snapshot after the user requests new save. I implemented onActivityResult
as i found here:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
// requestCode and resultCode checks happen here, of course...
if (intent != null) {
if (intent.hasExtra(Snapshots.EXTRA_SNAPSHOT_METADATA)) {
// Load a snapshot.
SnapshotMetadata snapshotMetadata = intent.getParcelableExtra(Snapshots.EXTRA_SNAPSHOT_METADATA);
currentSaveName = snapshotMetadata.getUniqueName();
loadFromSnapshot(snapshotMetadata);
} else if (intent.hasExtra(Snapshots.EXTRA_SNAPSHOT_NEW)) {
// Create a new snapshot named with a unique string
// TODO: check for existing snapshot, for now, add garbage text.
String unique = new BigInteger(281, new Random()).toString(13);
currentSaveName = "snapshotTemp-" + unique;
saveSnapshot(null);
}
}
}
Obviously it is a good idea to check if a snapshot with the generated name already exists. How should I actually do it?