【发布时间】:2013-12-14 17:25:24
【问题描述】:
在我使用 Google+ API 的 android 应用中,我可以使用以下代码编写“ReviewActivity”类型的时刻:
ItemScope rating = new ItemScope.Builder()
.setType("http://schema.org/Rating")
.setRatingValue(Float.toString(oeuvre.getRating()))
.setBestRating("5").setWorstRating("0").build();
ItemScope result = new ItemScope.Builder()
.setType("http://schema.org/Review").setName(titre)
.setUrl(urlfreebase)
.setDescription(oeuvre.getNomPeintre()).setReviewRating(rating)
.build();
ItemScope target = new ItemScope.Builder().setUrl(urlfreebase).build();
Moment moment = new Moment.Builder()
.setType("http://schemas.google.com/ReviewActivity")
.setTarget(target).setResult(result).build();
if (monPlusClient.isConnected()) {
monPlusClient.writeMoment(moment);
}
它的作品,我可以用我的桌面在我的 Google+ 个人资料中阅读它们。
当我加载时刻,在我的应用程序开始时,我也能够读取我的时刻,但我无法获得用户选择的评分值。
在我的听众中:
public void onMomentsLoaded(ConnectionResult status,
MomentBuffer momentBuffer, String nextPageToken, String updated) {
...
}
我收到了这个目标:
{"description":"Pablo Picasso","url":"https:\/\/developers.google.com\/+\/web\/snippet\/examples\/review","id":"https:\/\/developers.google.com\/+\/web\/snippet\/examples\/review","reviewRating":{"ratingValue":"4.0","worstRating":"0","bestRating":"5"},"name":"Le Pigeon aux petits pois"}
如您所见,评分设置正确:
"reviewRating":{"ratingValue":"4.0","worstRating":"0","bestRating":"5"}
但是当我尝试通过 API 阅读它时:
ItemScope res = m.getResult();
String titre = res.getName();
String desc = res.getDescription();
String streval = res.getRatingValue();
字符串 streval 始终为空
【问题讨论】:
标签: android google-api google-plus