如何从谷歌端点类提取列表到我的活动?

时间:2016-03-10 06:51:09

标签: android google-cloud-endpoints

端点类方法:

 @ApiMethod(name = "listRecords")
public List<ReplyRecord> listRecords(@Named("count") int count) {
    List<ReplyRecord> records = ofy().load().type(ReplyRecord.class).limit(count).list();
    return records;
}

在AsyncTask doInBackground中调用activity方法

regService.record(sf.getString("regId","0"),obj.getqId(),obj.getAnsId()).execute();
        Registration.ListRecords rr= regService.listRecords(20);

这不是对api方法的直接调用,因此我得到了一些 Registration.ListRecords 类型对象。我真的很困惑,请建议我直接输入列表类型的方法

1 个答案:

答案 0 :(得分:1)

你快到了。模型中的ListRecords对象基本上是一个请求,因此您还必须执行它并在完成后调用.getItems()以获得结果List

List<ReplyRecord> results = rr.execute().getItems();