Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android University - Week 5

Caren
December 05, 2018
210

Android University - Week 5

Caren

December 05, 2018
Tweet

Transcript

  1. Instagram - User can create a new account - User

    can log in / out - User can create a post with a photo and caption
  2. Why Do We Need Parse? We’ve been utilizing data from

    other developers (MovieDB, Twitter) Twitter
  3. Why Do We Need Parse? We’ve been utilizing data from

    other developers (MovieDB, Twitter) Wouldn’t it be cool if we started using our own data? OUR DATA!
  4. Why Do We Need Parse? We’ve been utilizing data from

    other developers (MovieDB, Twitter) Wouldn’t it be cool if we started using our own data? Parse allows us to get a backend up and running really fast OUR DATA!
  5. Instagram… with Parse! - User can create a new account

    - User can log in / out - User can create a post with a photo and caption
  6. // Create the ParseUser ParseUser user = new ParseUser(); //

    Set core properties user.setUsername("bob"); user.setPassword("bobspassword"); user.signUpInBackground(new SignUpCallback() { public void done(ParseException e) { if (e == null) { // Hooray! Let them use the app now. } else { e.getCode(); e.printStackTrace(); // Sign up didn't succeed. Look at the ParseException // to figure out what went wrong } } });
  7. // Create the ParseUser ParseUser user = new ParseUser(); //

    Set core properties user.setUsername("bob"); user.setPassword("bobspassword"); user.signUpInBackground(new SignUpCallback() { public void done(ParseException e) { if (e == null) { // Hooray! Let them use the app now. } else { e.getCode(); e.printStackTrace(); // Sign up didn't succeed. Look at the ParseException // to figure out what went wrong } } });
  8. // Create the ParseUser ParseUser user = new ParseUser(); //

    Set core properties user.setUsername("bob"); user.setPassword("bobspassword"); user.signUpInBackground(new SignUpCallback() { public void done(ParseException e) { if (e == null) { // Hooray! Let them use the app now. } else { e.getCode(); e.printStackTrace(); // Sign up didn't succeed. Look at the ParseException // to figure out what went wrong } } });
  9. // login user with username and password ParseUser.logInInBackground("bob", "bobspassword", new

    LogInCallback() { public void done(ParseUser user, ParseException e) { if (user != null) { // Hooray! The user is logged in. } else { // Signup failed. Look at the ParseException to see what happened. } } });
  10. // login user with username and password ParseUser.logInInBackground("bob", "bobspassword", new

    LogInCallback() { public void done(ParseUser user, ParseException e) { if (user != null) { // Hooray! The user is logged in. } else { // Signup failed. Look at the ParseException to see what happened. } } });
  11. @ParseClassName("Post") public class Post extends ParseObject { public Post() {

    super(); } // Constructor with core properties public Post(String description) { super(); setDescription(description); } public String getDescription() { return getString("description"); } // Use put to modify field values public void setDescription(String value) { put("description", value); } }
  12. @ParseClassName("Post") public class Post extends ParseObject { public Post() {

    super(); } // Constructor with core properties public Post(String description) { super(); setDescription(description); } public String getDescription() { return getString("description"); } // Use put to modify field values public void setDescription(String value) { put("description", value); } }
  13. @ParseClassName("Post") public class Post extends ParseObject { public Post() {

    super(); } // Constructor with core properties public Post(String description) { super(); setDescription(description); } public String getDescription() { return getString("description"); } // Use put to modify field values public void setDescription(String value) { put("description", value); } }
  14. @ParseClassName("Post") public class Post extends ParseObject { public Post() {

    super(); } // Constructor with core properties public Post(String description) { super(); setDescription(description); } public String getDescription() { return getString("description"); } // Use put to modify field values public void setDescription(String value) { put("description", value); } }
  15. Post post = new Post(); post.setDescription("It's laundry day"); // save

    the data asynchronously post.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { // the post was saved and uploaded to parse successfully! } else { // the post did not save successfully for some reason e.getCode(); } } });
  16. Post post = new Post(); post.setDescription("It's laundry day"); // save

    the data asynchronously post.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { // the post was saved and uploaded to parse successfully! } else { // the post did not save successfully for some reason e.getCode(); } } });
  17. Post post = new Post(); post.setDescription("It's laundry day"); // save

    the data asynchronously post.saveInBackground(new SaveCallback() { @Override public void done(ParseException e) { if (e == null) { // the post was saved and uploaded to parse successfully! } else { // the post did not save successfully for some reason e.getCode(); } } });
  18. In the next video.. • We’ll take a look at

    how to let users create posts with images
  19. Taking a Picture and Saving it Open Camera App Save

    the picture the user took Send the ‘post’ to our Parse server
  20. Taking a Picture and Saving it Open Camera App Save

    the picture the user took Send the ‘post’ to our Parse server
  21. Intents An Intent is Android’s way of saying it has

    an ‘intent’ to do something Android apps use these Intent objects to specify what it wants to happen (ie : start a new Activity)
  22. So far we’ve been utilizing explicit intents because we know

    exactly what we want to happen (for example: start a new Activity) Intents
  23. So far we’ve been utilizing explicit intents because we know

    exactly what we want to happen (for example: start a new Activity) Now we want to utilize implicit intents to let the user take a picture Intents
  24. So far we’ve been utilizing explicit intents because we know

    exactly what we want to happen (for example: start a new Activity) Now we want to utilize implicit intents to let the user take a picture
 - let’s Android search for all apps that are registered for the action we want to take Intents
  25. public void onLaunchCamera(View view) { // create Intent to take

    a picture and return to our app Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // pass in location where we want the image to be saved intent.putExtra(MediaStore.EXTRA_OUTPUT, uriToSaveImage); // Start the image capture intent to take photo startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); }
  26. public void onLaunchCamera(View view) { // create Intent to take

    a picture and return to our app Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // pass in location where we want the image to be saved intent.putExtra(MediaStore.EXTRA_OUTPUT, uriToSaveImage); // Start the image capture intent to take photo startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); }
  27. public void onLaunchCamera(View view) { // create Intent to take

    a picture and return to our app Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // pass in location where we want the image to be saved intent.putExtra(MediaStore.EXTRA_OUTPUT, uriToSaveImage); // Start the image capture intent to take photo startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); }
  28. public void onLaunchCamera(View view) { // create Intent to take

    a picture and return to our app Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // pass in location where we want the image to be saved intent.putExtra(MediaStore.EXTRA_OUTPUT, uriToSaveImage); // Start the image capture intent to take photo startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); }
  29. public void onLaunchCamera(View view) { // create Intent to take

    a picture and return to our app Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // pass in location where we want the image to be saved intent.putExtra(MediaStore.EXTRA_OUTPUT, uriToSaveImage); // Start the image capture intent to take photo startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE); }