我在使用 Google Play 服务的 AppStateClient 时遇到问题。当我让下面的代码仅在一个设备上运行时,我会按预期进入 onStateLoaded - 但是当涉及另一台设备时,我总是会遇到冲突,而不会在数据中出现冲突
@Override
public void onSignInSucceeded() {
Log.i("", "StatCount" + playHelper.getAppStateClient().getMaxNumKeys());
playHelper.getAppStateClient().updateState(0, "test".getBytes());
playHelper.getAppStateClient().loadState(new OnStateLoadedListener() {
@Override
public void onStateLoaded(int i, int i2, byte[] bytes) {
Log.i("AppStateTest","load {" + new String(bytes) +"}");
}
@Override
public void onStateConflict(int i, String s, byte[] bytes, byte[] bytes2) {
Log.i("AppStateTest","conflict " + new String(bytes) +" <> " + new String(bytes2));
}
},0);
}
输出:
I/AppStateTest( 4173): conflict test <> test