Я хочу вернуться myHighscores из Datastore: т.е .: Paul, 1200 Том, 1000 Кевин, 800GAE Чтение из Datastore
private void returnHighscores(HttpServletResponse resp, String game, int max) throws IOException {
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Key gameKey = KeyFactory.createKey("game", game);
Query query = new Query("highscore", gameKey);
query.addSort("points", Query.SortDirection.DESCENDING);
List<Entity> highscores = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(max));
for(Entity e : highscores) {
resp.getWriter().println(e.getProperty("name") + "," + e.getProperty("points"));
}
}
и он работает :)! Но когда я хочу прочитать возвращаемые Рекорды и добавьте строку в TextView с:
AndroidHttpClient client = AndroidHttpClient.newInstance("Mueckenfang");
HttpPost request = new HttpPost(HIGHSCORE_SERVER_BASE_URL + "?game=" + HIGHSCORESERVER_GAME_ID);
HttpResponse response = client.execute(request);
HttpEntity entity = response.getEntity();
InputStreamReader reader = new InputStreamReader(entity.getContent(), "utf-8");
int c = reader.read();
while (c > 0) {
highscores += (char) c;
c = reader.read();
}
TextView tv = (TextView) findViewById(R.id.highscoreTv);
tv.setText(highscores);
Я только получить HTML-код, как:
><html><head><meta http-euiv="content-type"content="text/html;charset=utf-8"><title>405 GTTP method POST is....
Но я хочу что-то, как Павел, 1200 Том, 1000 Кевином 800 и так далее
Thx за помощью, но вы могли бы написать мой метод так, как вы бы хотели? :) Я не знаю, куда вставить код ur! –
см. Мой обновленный ответ –
thx чувак его работает отлично сейчас! –