我在我的應用程序使用行動後端入門,我能使用此代碼不斷地接收數據:當我的應用程序被激活行動後端處理在後臺連續查詢
CloudCallbackHandler<List<CloudEntity>> handler = new CloudCallbackHandler<List<CloudEntity>>() {
@Override
public void onComplete(List<CloudEntity> results) {
Logger.log(MainActivity.this, "onComplete");
}
@Override
public void onError(IOException e) {
Logger.log(MainActivity.this, e);
}
};
CloudQuery cq = new CloudQuery("Test");
cq.setLimit(50);
cq.setSort(CloudEntity.PROP_UPDATED_AT, Order.DESC);
cq.setScope(Scope.FUTURE_AND_PAST);
getCloudBackend().list(cq, handler);
這一切工作正常,但我想用此來通知用戶新的數據可用,當應用程序是而不是活動。
當我關閉應用程序(按回,不在家),我強制消息我的設備,我得到以下錯誤:
07-04 18:30:23.084: I/CloudBackend(31368): error:
07-04 18:30:23.084: I/CloudBackend(31368): com.google.api.client.googleapis.extensions.android.gms.auth.UserRecoverableAuthIOException
07-04 18:30:23.084: I/CloudBackend(31368): at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:222)
07-04 18:30:23.084: I/CloudBackend(31368): at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:836)
07-04 18:30:23.084: I/CloudBackend(31368): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:412)
07-04 18:30:23.084: I/CloudBackend(31368): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:345)
07-04 18:30:23.084: I/CloudBackend(31368): at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:463)
07-04 18:30:23.084: I/CloudBackend(31368): at com.myapp.cloudbackend.CloudBackend.list(CloudBackend.java:340)
07-04 18:30:23.084: I/CloudBackend(31368): at com.myapp.cloudbackend.CloudBackendAsync.access$8(CloudBackendAsync.java:1)
07-04 18:30:23.084: I/CloudBackend(31368): at com.myapp.cloudbackend.CloudBackendAsync$9.callBackend(CloudBackendAsync.java:283)
07-04 18:30:23.084: I/CloudBackend(31368): at com.myapp.cloudbackend.CloudBackendAsync$9.callBackend(CloudBackendAsync.java:1)
07-04 18:30:23.084: I/CloudBackend(31368): at com.myapp.cloudbackend.CloudBackendAsync$BackendCaller.run(CloudBackendAsync.java:429)
07-04 18:30:23.084: I/CloudBackend(31368): Caused by: com.google.android.gms.auth.UserRecoverableAuthException: AppDownloadRequired
07-04 18:30:23.084: I/CloudBackend(31368): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
07-04 18:30:23.084: I/CloudBackend(31368): at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
07-04 18:30:23.084: I/CloudBackend(31368): at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.getToken(GoogleAccountCredential.java:192)
07-04 18:30:23.084: I/CloudBackend(31368): at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:217)
07-04 18:30:23.084: I/CloudBackend(31368): ... 9 more
我如何能實現我想要什麼?