Skip to content

Instantly share code, notes, and snippets.

@GoMino
Created February 21, 2014 03:37
Show Gist options
  • Save GoMino/9128307 to your computer and use it in GitHub Desktop.
Save GoMino/9128307 to your computer and use it in GitHub Desktop.
Retrieving Entity from Google App Engine backend to Android App
public class EndpointsTask extends AsyncTask<Context, Integer, User> {
protected User doInBackground(Context... contexts) {
Userendpoint.Builder endpointBuilder = new Userendpoint.Builder(
AndroidHttp.newCompatibleTransport(),
new JacksonFactory(),
new HttpRequestInitializer() {
public void initialize(HttpRequest httpRequest) { }
});
Userendpoint endpoint = CloudEndpointUtils.updateBuilder(
endpointBuilder).build();
try {
String username = "INSERT_USERNAME_HERE_DUDE!";
User user = endpoint.getUser(username).execute();
} catch (Exception e) {
e.printStackTrace();
}
return user;
}
protected void onPostExecute(User user) {
//update your UI here
usernameTextView.setText(user.getUsername());
locationTextView.setText(user.getLocation());
ageTextView.setText(user.getAge());
occupationTextView.setText(user.getOccupation());
weightTextView.setText(user.getWeight());
genderTextView.setText(user.getGender());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment