private void showSavedGamesUI() {
   int maxNumberOfSavedGamesToShow = 5;
   Intent savedGamesIntent =
       Games.Snapshots.getSelectSnapshotIntent(
           mGoogleApiClient, "See My Saves", true, true, maxNumberOfSavedGamesToShow);
   startActivityForResult(savedGamesIntent, RC_SAVED_GAMES);
 }
  // [START write_snapshot]
  private PendingResult<Snapshots.CommitSnapshotResult> writeSnapshot(
      Snapshot snapshot, byte[] data, Bitmap coverImage, String desc) {

    // Set the data payload for the snapshot
    snapshot.getSnapshotContents().writeBytes(data);

    // Create the change operation
    SnapshotMetadataChange metadataChange =
        new SnapshotMetadataChange.Builder().setCoverImage(coverImage).setDescription(desc).build();

    // Commit the operation
    return Games.Snapshots.commitAndClose(mGoogleApiClient, snapshot, metadataChange);
  }
  /**
   * Conflict resolution for when Snapshots are opened. Must be run in an AsyncTask or in a
   * background thread,
   */
  Snapshot processSnapshotOpenResult(Snapshots.OpenSnapshotResult result, int retryCount) {
    Snapshot mResolvedSnapshot = null;
    retryCount++;

    int status = result.getStatus().getStatusCode();
    Log.i(TAG, "Save Result status: " + status);

    if (status == GamesStatusCodes.STATUS_OK) {
      return result.getSnapshot();
    } else if (status == GamesStatusCodes.STATUS_SNAPSHOT_CONTENTS_UNAVAILABLE) {
      return result.getSnapshot();
    } else if (status == GamesStatusCodes.STATUS_SNAPSHOT_CONFLICT) {
      Snapshot snapshot = result.getSnapshot();
      Snapshot conflictSnapshot = result.getConflictingSnapshot();

      // Resolve between conflicts by selecting the newest of the conflicting snapshots.
      mResolvedSnapshot = snapshot;

      if (snapshot.getMetadata().getLastModifiedTimestamp()
          < conflictSnapshot.getMetadata().getLastModifiedTimestamp()) {
        mResolvedSnapshot = conflictSnapshot;
      }

      Snapshots.OpenSnapshotResult resolveResult =
          Games.Snapshots.resolveConflict(
                  mGoogleApiClient, result.getConflictId(), mResolvedSnapshot)
              .await();

      if (retryCount < MAX_SNAPSHOT_RESOLVE_RETRIES) {
        // Recursively attempt again
        return processSnapshotOpenResult(resolveResult, retryCount);
      } else {
        // Failed, log error and show Toast to the user
        String message = "Could not resolve snapshot conflicts";
        Log.e(TAG, message);
        Toast.makeText(getBaseContext(), message, Toast.LENGTH_LONG).show();
      }
    }

    // Fail, return null.
    return null;
  }