15. GCMの設定
com.google.cloud.backend.cor
e.Consts.javaを変更する
/**
* Set Project ID of your Google APIs Console Project.
*/
public static final String PROJECT_ID = "*** ENTER YOUR PROJECT ID ***";
/**
* Set Project Number of your Google APIs Console Project.
*/
public static final String PROJECT_NUMBER = "*** ENTER YOUR PROJECT NUMBER ***";
16. GCMの設定
/**
* Set Project ID of your Google APIs Console Project.
*/
public static final String PROJECT_ID = "sinuous-client-541";
/**
* Set Project Number of your Google APIs Console Project.
*/
public static final String PROJECT_NUMBER = "260486999232";
34. データの追加(Android)
// create a CloudEntity with the new post
CloudEntity newPost = new CloudEntity("Guestbook");
newPost.put("message", mMessageTxt.getText().toString());
// create a response handler that will receive the result or an error
CloudCallbackHandler<CloudEntity> handler = new
CloudCallbackHandler<CloudEntity>() {
@Override
public void onComplete(final CloudEntity result) {
mPosts.add(0, result);
updateGuestbookView();
mMessageTxt.setText("");
mMessageTxt.setEnabled(true);
mSendBtn.setEnabled(true);
}
@Override
public void onError(final IOException exception) {
handleEndpointException(exception);
}
};
35. 継続的クエリ(Android)
// create a response handler that will receive the result or an error
CloudCallbackHandler<List<CloudEntity>> handler =
new CloudCallbackHandler<List<CloudEntity>>() {
@Override
public void onComplete(List<CloudEntity> results) {
mAnnounceTxt.setText(R.string.announce_success);
mPosts = results;
animateArrival();
updateGuestbookView();
}
@Override
public void onError(IOException exception) {
mAnnounceTxt.setText(R.string.announce_fail);
animateArrival();
handleEndpointException(exception);
}
};
// execute the query with the handler
mProcessingFragment.getCloudBackend().listByKind(
"Guestbook", CloudEntity.PROP_CREATED_AT, Order.DESC, 50,
Scope.FUTURE_AND_PAST, handler);