jeudi 13 août 2015

How to delete snapshot from Google Games in Android

Im implementing the snapshots from google games to my game, but i dont want to use the interface they use, I want to implement the open, update and delete gamedata in my game.

For the operations open and update i have no issue and everything works perfect, but for the delete operation I have a problem.

Based on the samples for open and update I managed to create a code that works but just halfway:

//get the snapshot
String snapshotName = "My_Snapshot_0";
Snapshots.OpenSnapshotResult open = Games.Snapshots.open(mGoogleApiClient, snapshotName, false).await();
if (!open.getStatus().isSuccess()) {
    Log.w(TAG, "Could not open Snapshot for update.");
    return false;
}
//delete the snapshot
Snapshots.DeleteSnapshotResult delete = (Snapshots.DeleteSnapshotResult)Games.Snapshots.delete(mGoogleApiClient, open.getSnapshot().getMetadata()).await();

if (!delete.getStatus().isSuccess()) {
    Log.w(TAG, "Failed to delete Snapshot.");
    return false;
}

This code its supposed to delete the snapshot My_Snapshot_0 and it even returns success, but if I try to recreate the snapshot (using the same name), an error is returned because it could not open the snapshot. This means the deleting process is missing something to work correctly.

After trying to recreate it and fail, if I do it again (repeat recreate process), then there is no error and the snapshot is created without any problem.

Its weird how the Games.Snapshots.delete uses an snapshot metadata instead of the snapshot.

The documentation says little about deleting and in the samples google provide there is no sample code for doing this correctly.

Thanks in advance!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire