【发布时间】:2015-07-10 06:27:33
【问题描述】:
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);
}
https://developers.google.com/games/services/android/savedgames
文档说必须在调用 writeSnaphot 之前获取对快照的引用。由于快照是一个接口,它不能用 new 创建。
如何获取对快照的引用?
谢谢!
附:我看到有一种方法可以通过按名称打开现有保存的游戏来获取引用,但是我想获得的引用是针对新快照的,目前没有现有快照,因此使用加载函数可能无法成功编写新快照。
【问题讨论】: