Created
February 21, 2014 03:37
-
-
Save GoMino/9128307 to your computer and use it in GitHub Desktop.
Retrieving Entity from Google App Engine backend to Android App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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