我目前正在构建一个简单的Android应用程序,它将信息发送到Azure移动服务。我正在使用本教程的以下示例代码。
mSClient = new MobileServiceClient(URL, KEY, context);
mSClient = getMSClient();
mSClient.getTable(MyClass.class).insert(form, new TableOperationCallback<MyClass>() {
public void onCompleted(MyClass entity, Exception exception, ServiceFilterResponse response) {
if (exception != null) {
Log.e("MSG", exception.getLocalizedMessage());
}
if (response != null) {
Log.e("MSG", response.getContent());
}
}
});
现在,我如何在onComplete方法中获取ServiceFilterResponse的响应,该方法需要一段时间才能获得并且MobileServiceClient已经完成了它的工作。 我如何等待将sqlite上的信息标记为已发送?
答案 0 :(得分:1)
调用回调时,表示插入操作已在服务器端完成。如果要在发送“插入”请求(基本上是HTTP POST请求)到操作完成的那一刻之间标记某些内容:正确
mSClient = new MobileServiceClient(URL, KEY, context);
mSClient = getMSClient();
mSClient.getTable(MyClass.class).insert(form, new TableOperationCallback<MyClass>() {
public void onCompleted(MyClass entity, Exception exception, ServiceFilterResponse response) {
if (exception != null) {
// here: tell sqlite that the insert request failed
Log.e("MSG", exception.getLocalizedMessage());
} else {
// here: tell sqlite that the insert request succeeded
Log.e("MSG", response.getContent());
}
}
});
// here: tell sqlite that the insert request was sent