At the core of many apps, there is a notion of user account management that lets users access their information in a secure manner. A specialized user class called ParseUser is available to automatically handles these kind of functionalities.
ParseUser is a subclass of the ParseObject, and has all the same features. All the methods that are on ParseObject also exist in ParseUser. The difference is that ParseUser has some special additions specific to user accounts.
Signing Up
importcom.parse.ParseException;importcom.parse.ParseUser;importcom.parse.SignUpCallback;publicvoidsignUpUser(String username,String password,String email){ParseUser user =newParseUser();user.setUsername(username);user.setPassword(password);user.setEmail(email);// other fields can be set just like with ParseObjectuser.put("phone","650-253-0000");user.signUpInBackground(newSignUpCallback() {publicvoiddone(ParseException e) {if (e ==null) {// Hooray! Let them use the app now. } else {// Sign up didn't succeed. Look at the ParseException// to figure out what went wrong } } });}
importcom.parse.LogInCallback;importcom.parse.ParseException;importcom.parse.ParseUser;publicvoidlogInUser(String username,String password){ParseUser.logInInBackground(username, password,newLogInCallback() {publicvoiddone(ParseUser user,ParseException e) {if (user !=null) {// Hooray! The user is logged in. } else {// Signup failed. Look at the ParseException to see what happened. } } });}
importcom.parse.ParseUser;publicvoidgetUser(){ParseUser currentUser =ParseUser.getCurrentUser();if (currentUser !=null) {// do stuff with the user } else {// show the signup or login screen }}