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

Android University - Week 5

7bf2baf0d8d5d7d96e6b67c5d567e3f9?s=47 Caren
December 05, 2018
200

Android University - Week 5

7bf2baf0d8d5d7d96e6b67c5d567e3f9?s=128

Caren

December 05, 2018
Tweet

Transcript

  1. Android University Week 5: Instagram with Parse

  2. Instagram

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

    can log in / out - User can create a post with a photo and caption
  4. None
  5. Instagram… with Parse!

  6. Why Do We Need Parse?

  7. Why Do We Need Parse? We’ve been utilizing data from

    other developers (MovieDB, Twitter) Twitter
  8. 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!
  9. 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!
  10. In the next video… We’ll take a closer look at

    how we’ll be utilizing Parse
  11. Using Parse

  12. None
  13. None
  14. None
  15. Instagram… with Parse! - User can create a new account

    - User can log in / out - User can create a post with a photo and caption
  16. // 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 } } });
  17. // 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 } } });
  18. // 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 } } });
  19. // 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. } } });
  20. // 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. } } });
  21. None
  22. None
  23. None
  24. @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); } }
  25. @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); } }
  26. @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); } }
  27. @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); } }
  28. 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(); } } });
  29. 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(); } } });
  30. 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(); } } });
  31. In the next video.. • We’ll take a look at

    how to let users create posts with images
  32. Taking a Picture and Saving it

  33. Taking a Picture and Saving it Open Camera App Save

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

    the picture the user took Send the ‘post’ to our Parse server
  35. 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)
  36. So far we’ve been utilizing explicit intents because we know

    exactly what we want to happen (for example: start a new Activity) Intents
  37. 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
  38. 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
  39. 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); }
  40. 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); }
  41. 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); }
  42. 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); }
  43. 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); }