Java 安卓-云存储不';行不通
我已经在我的应用程序中实现了云存储。该示例运行良好(使用我的软件包和密钥SHA,与控制台相同)。我用这个修改了示例代码。我有两个按钮 上传:Java 安卓-云存储不';行不通,java,android,google-app-engine,byte,google-cloud-storage,Java,Android,Google App Engine,Byte,Google Cloud Storage,我已经在我的应用程序中实现了云存储。该示例运行良好(使用我的软件包和密钥SHA,与控制台相同)。我用这个修改了示例代码。我有两个按钮 上传:保存到云 void saveToCloud() { //public int cLUN1 = 3; kl1 is the int stateKey (slot) ; bLUN1 the byte byte[] bLUN1 = String.valueOf(cLUN1).getBytes(); getAppStateCli
保存到云
void saveToCloud() {
//public int cLUN1 = 3; kl1 is the int stateKey (slot) ; bLUN1 the byte
byte[] bLUN1 = String.valueOf(cLUN1).getBytes();
getAppStateClient().updateStateImmediate(this, kl1, bLUN1);
void saveToDevice() {
//mint1 is the textview ; kl1 the slot to restore
getAppStateClient().loadState(this, kl1);
mint1.setText(" "+kl1);
下载:从云下载
void saveToCloud() {
//public int cLUN1 = 3; kl1 is the int stateKey (slot) ; bLUN1 the byte
byte[] bLUN1 = String.valueOf(cLUN1).getBytes();
getAppStateClient().updateStateImmediate(this, kl1, bLUN1);
void saveToDevice() {
//mint1 is the textview ; kl1 the slot to restore
getAppStateClient().loadState(this, kl1);
mint1.setText(" "+kl1);
从我的设备中,我收到始终为0作为TextView mint1的文本。为什么我没有得到正确的变量
编辑:解决方案
void saveToCloud() {
bLUN1 = String.valueOf(cLUN1).getBytes();
bLUN2 = String.valueOf(cLUN2).getBytes();
getAppStateClient().updateStateImmediate(this, key1, bLUN1);
getAppStateClient().updateStateImmediate(this, key2, bLUN2);
}
void loadFromCloud() {
mLoadingDialog.show();
getAppStateClient().loadState(this, key1);
getAppStateClient().loadState(this, key2);
}
我还编辑了onstateload
@Override
public void onStateLoaded(int statusCode, int stateKey, byte[] localData) {
mLoadingDialog.dismiss();
switch (statusCode) {
case AppStateClient.STATUS_OK:
mAlreadyLoadedState = true;
hideAlertBar();
mint1.setText(new String(bLUN1, charset));
mint2.setText(new String(bLUN2, charset));
break;
....
kl1是插槽id,而不是保存的数据。将使用保存的数据值调用您的
onStateLoaded
和onStateConflict
方法