@ParseClassName(value="_User") public class ParseUser extends ParseObject
ParseUser is a local representation of user data that can be saved and retrieved from
the Parse cloud.CREATOR, DEFAULT_PIN| Constructor and Description |
|---|
ParseUser()
Constructs a new ParseUser with no data in it.
|
| Modifier and Type | Method and Description |
|---|---|
static ParseUser |
become(java.lang.String sessionToken)
Authorize a user with a session token.
|
static <any> |
becomeInBackground(java.lang.String sessionToken)
Authorize a user with a session token.
|
static void |
becomeInBackground(java.lang.String sessionToken,
LogInCallback callback)
Authorize a user with a session token.
|
static void |
enableAutomaticUser()
Enables automatic creation of anonymous users.
|
static <any> |
enableRevocableSessionInBackground()
Enables revocable sessions.
|
ParseUser |
fetch()
Fetches this object with the data from the server.
|
ParseUser |
fetchIfNeeded()
If this
ParseObject has not been fetched (i.e. |
static java.lang.String |
getCurrentSessionToken() |
static <any> |
getCurrentSessionTokenAsync() |
static ParseUser |
getCurrentUser()
This retrieves the currently logged in ParseUser with a valid session, either from memory or
disk if necessary.
|
java.lang.String |
getEmail()
Retrieves the email address.
|
static ParseQuery<ParseUser> |
getQuery()
Constructs a query for
ParseUser. |
java.lang.String |
getSessionToken() |
java.lang.String |
getUsername()
Retrieves the username.
|
boolean |
isAuthenticated()
Whether the ParseUser has been authenticated on this device.
|
boolean |
isLinked(java.lang.String authType)
Indicates whether this user is linked with a third party authentication source.
|
boolean |
isNew()
Indicates whether this
ParseUser was created during this session through a call to
signUp() or by logging in with a linked service such as Facebook. |
<any> |
linkWithInBackground(java.lang.String authType,
java.util.Map<java.lang.String,java.lang.String> authData)
Links this user to a third party authentication source.
|
static ParseUser |
logIn(java.lang.String username,
java.lang.String password)
Logs in a user with a username and password.
|
static <any> |
logInInBackground(java.lang.String username,
java.lang.String password)
Logs in a user with a username and password.
|
static void |
logInInBackground(java.lang.String username,
java.lang.String password,
LogInCallback callback)
Logs in a user with a username and password.
|
static <any> |
logInWithInBackground(java.lang.String authType,
java.util.Map<java.lang.String,java.lang.String> authData)
Logs in a user with third party authentication credentials.
|
static void |
logOut()
Logs out the currently logged in user session.
|
static <any> |
logOutInBackground()
Logs out the currently logged in user session.
|
static void |
logOutInBackground(LogOutCallback callback)
Logs out the currently logged in user session.
|
protected void |
onRestoreInstanceState(android.os.Bundle savedState)
Called when unparceling this ParseObject.
|
protected void |
onSaveInstanceState(android.os.Bundle outState)
Called when parceling this ParseObject.
|
void |
put(java.lang.String key,
java.lang.Object value)
Add a key-value pair to this object.
|
static void |
registerAuthenticationCallback(java.lang.String authType,
AuthenticationCallback callback)
Registers a third party authentication callback.
|
void |
remove(java.lang.String key)
Removes a key from this object's data if it exists.
|
static void |
requestPasswordReset(java.lang.String email)
Requests a password reset email to be sent to the specified email address associated with the
user account.
|
static <any> |
requestPasswordResetInBackground(java.lang.String email)
Requests a password reset email to be sent in a background thread to the specified email
address associated with the user account.
|
static void |
requestPasswordResetInBackground(java.lang.String email,
RequestPasswordResetCallback callback)
Requests a password reset email to be sent in a background thread to the specified email
address associated with the user account.
|
void |
setEmail(java.lang.String email)
Sets the email address.
|
void |
setPassword(java.lang.String password)
Sets the password.
|
void |
setUsername(java.lang.String username)
Sets the username.
|
void |
signUp()
Signs up a new user.
|
<any> |
signUpInBackground()
Signs up a new user.
|
void |
signUpInBackground(SignUpCallback callback)
Signs up a new user.
|
<any> |
unlinkFromInBackground(java.lang.String authType)
Unlinks this user from a third party authentication source.
|
add, addAll, addAllUnique, addUnique, containsKey, create, create, createWithoutData, createWithoutData, delete, deleteAll, deleteAllInBackground, deleteAllInBackground, deleteEventually, deleteEventually, deleteInBackground, deleteInBackground, describeContents, fetchAll, fetchAllIfNeeded, fetchAllIfNeededInBackground, fetchAllIfNeededInBackground, fetchAllInBackground, fetchAllInBackground, fetchFromLocalDatastore, fetchFromLocalDatastoreInBackground, fetchIfNeededInBackground, fetchIfNeededInBackground, fetchInBackground, fetchInBackground, fromJSON, fromJSON, get, getACL, getBoolean, getBytes, getClassName, getCreatedAt, getDate, getDouble, getInt, getJSONArray, getJSONObject, getList, getLong, getMap, getNumber, getObjectId, getParseFile, getParseGeoPoint, getParseObject, getParsePolygon, getParseUser, getRelation, getString, getUpdatedAt, has, hasSameId, increment, increment, isDataAvailable, isDataAvailable, isDirty, isDirty, keySet, pin, pin, pinAll, pinAll, pinAllInBackground, pinAllInBackground, pinAllInBackground, pinAllInBackground, pinInBackground, pinInBackground, pinInBackground, pinInBackground, registerSubclass, removeAll, revert, revert, save, saveAll, saveAllInBackground, saveAllInBackground, saveEventually, saveEventually, saveInBackground, saveInBackground, setACL, setObjectId, unpin, unpin, unpinAll, unpinAll, unpinAll, unpinAll, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinAllInBackground, unpinInBackground, unpinInBackground, unpinInBackground, unpinInBackground, writeToParcelpublic ParseUser()
signUp() is called.public static ParseQuery<ParseUser> getQuery()
ParseUser.ParseQuery.getQuery(Class)public static <any> logInInBackground(java.lang.String username,
java.lang.String password)
getCurrentUser().
This is preferable to using logIn(java.lang.String, java.lang.String), unless your code is already running from a
background thread.username - The username to log in with.password - The password to log in with.public static ParseUser logIn(java.lang.String username, java.lang.String password) throws ParseException
getCurrentUser().
Typically, you should use logInInBackground(java.lang.String, java.lang.String) instead of this, unless you are managing
your own threading.username - The username to log in with.password - The password to log in with.ParseException - Throws an exception if the login was unsuccessful.public static void logInInBackground(java.lang.String username,
java.lang.String password,
LogInCallback callback)
getCurrentUser().
This is preferable to using logIn(java.lang.String, java.lang.String), unless your code is already running from a
background thread.username - The username to log in with.password - The password to log in with.callback - callback.done(user, e) is called when the login completes.public static <any> becomeInBackground(java.lang.String sessionToken)
getCurrentUser().
This is preferable to using become(java.lang.String), unless your code is already running from a
background thread.sessionToken - The session token to authorize with.public static ParseUser become(java.lang.String sessionToken) throws ParseException
getCurrentUser().
Typically, you should use becomeInBackground(java.lang.String) instead of this, unless you are managing
your own threading.sessionToken - The session token to authorize with.ParseException - Throws an exception if the authorization was unsuccessful.public static void becomeInBackground(java.lang.String sessionToken,
LogInCallback callback)
getCurrentUser().
This is preferable to using become(java.lang.String), unless your code is already running from a
background thread.sessionToken - The session token to authorize with.callback - callback.done(user, e) is called when the authorization completes.public static ParseUser getCurrentUser()
public static java.lang.String getCurrentSessionToken()
public static <any> getCurrentSessionTokenAsync()
public static <any> logOutInBackground()
getCurrentUser() will return null.
This is preferable to using logOut(), unless your code is already running from a
background thread.public static void logOutInBackground(LogOutCallback callback)
getCurrentUser() will return null.
This is preferable to using logOut(), unless your code is already running from a
background thread.public static void logOut()
getCurrentUser() will return null.
Typically, you should use logOutInBackground() instead of this, unless you are
managing your own threading.
Note:: Any errors in the log out flow will be swallowed due to
backward-compatibility reasons. Please use logOutInBackground() if you'd wish to
handle them.public static <any> requestPasswordResetInBackground(java.lang.String email)
requestPasswordReset(String), unless your code is already
running from a background thread.email - The email address associated with the user that forgot their password.public static void requestPasswordReset(java.lang.String email)
throws ParseException
requestPasswordResetInBackground(java.lang.String) instead of this, unless you
are managing your own threading.email - The email address associated with the user that forgot their password.ParseException - Throws an exception if the server is inaccessible, or if an account with that email
doesn't exist.public static void requestPasswordResetInBackground(java.lang.String email,
RequestPasswordResetCallback callback)
requestPasswordReset(String), unless your code is already
running from a background thread.email - The email address associated with the user that forgot their password.callback - callback.done(e) is called when the request completes.public static void registerAuthenticationCallback(java.lang.String authType,
AuthenticationCallback callback)
authType - The name of the third party authentication source.callback - The third party authentication callback to be registered.AuthenticationCallbackpublic static <any> logInWithInBackground(java.lang.String authType,
java.util.Map<java.lang.String,java.lang.String> authData)
authType - The name of the third party authentication source.authData - The user credentials of the third party authentication source.Task is resolved when logging in completes.AuthenticationCallbackpublic static void enableAutomaticUser()
getCurrentUser() will always have a value. The user will only be created on the server
once the user has been saved, or once an object with a relation to that user or an ACL that
refers to the user has been saved.
Note: ParseObject.saveEventually() will not work if an item being
saved has a relation to an automatic user that has never been saved.public static <any> enableRevocableSessionInBackground()
ParseSession APIs and do not have revocable sessions enabled in your application
settings on your parse server.
Upon successful completion of this Task, ParseSession APIs will be available
for use.Task that will resolve when enabling revocable sessionpublic boolean isAuthenticated()
public void remove(java.lang.String key)
ParseObjectremove in class ParseObjectkey - The key to remove.public java.lang.String getSessionToken()
public java.lang.String getUsername()
public void setUsername(java.lang.String username)
username - The username to set.public void setPassword(java.lang.String password)
password - The password to set.public java.lang.String getEmail()
public void setEmail(java.lang.String email)
email - The email address to set.public boolean isNew()
ParseUser was created during this session through a call to
signUp() or by logging in with a linked service such as Facebook.public void put(java.lang.String key,
java.lang.Object value)
ParseObjectcamelCaseLikeThis.put in class ParseObjectkey - Keys must be alphanumerical plus underscore, and start with a letter.value - Values may be numerical, String, JSONObject, JSONArray,
JSONObject.NULL, or other ParseObjects. value may not be null.public ParseUser fetch() throws ParseException
ParseObjectfetch in class ParseObjectParseObject that was fetched.ParseException - Throws an exception if the server is inaccessible.public <any> signUpInBackground()
ParseObject.save() for new ParseUsers. This
will create a new ParseUser on the server, and also persist the session on disk so that you can
access the user using getCurrentUser().
A username and password must be set before calling signUp.
This is preferable to using signUp(), unless your code is already running from a
background thread.public void signUp()
throws ParseException
ParseObject.save() for new ParseUsers. This
will create a new ParseUser on the server, and also persist the session on disk so that you can
access the user using getCurrentUser().
A username and password must be set before calling signUp.
Typically, you should use signUpInBackground() instead of this, unless you are managing
your own threading.ParseException - Throws an exception if the server is inaccessible, or if the username has already
been taken.public void signUpInBackground(SignUpCallback callback)
ParseObject.save() for new ParseUsers. This
will create a new ParseUser on the server, and also persist the session on disk so that you can
access the user using getCurrentUser().
A username and password must be set before calling signUp.
This is preferable to using signUp(), unless your code is already running from a
background thread.callback - callback.done(user, e) is called when the signUp completes.public ParseUser fetchIfNeeded() throws ParseException
ParseObjectParseObject has not been fetched (i.e. ParseObject.isDataAvailable() returns false),
fetches this object with the data from the server.fetchIfNeeded in class ParseObjectParseObject.ParseException - Throws an exception if the server is inaccessible.public boolean isLinked(java.lang.String authType)
authType - The name of the third party authentication source.true if linked, otherwise false.AuthenticationCallbackpublic <any> linkWithInBackground(java.lang.String authType,
java.util.Map<java.lang.String,java.lang.String> authData)
authType - The name of the third party authentication source.authData - The user credentials of the third party authentication source.Task is resolved when linking completes.AuthenticationCallbackpublic <any> unlinkFromInBackground(java.lang.String authType)
authType - The name of the third party authentication source.Task is resolved when unlinking completes.AuthenticationCallbackprotected void onSaveInstanceState(android.os.Bundle outState)
ParseObjectBundle and receive them later
ParseObject.onRestoreInstanceState(Bundle). Note that internal fields are already parceled by
the framework.onSaveInstanceState in class ParseObjectoutState - Bundle to host extra valuesprotected void onRestoreInstanceState(android.os.Bundle savedState)
ParseObjectBundle that were previously put
during ParseObject.onSaveInstanceState(Bundle). At this point the internal state is already
recovered.onRestoreInstanceState in class ParseObjectsavedState - Bundle to read the values from