java.lang.Object | |||||
↳ | java.util.AbstractMap<K, V> | ||||
↳ | com.google.api.client.util.GenericData | ||||
↳ | com.google.api.client.json.GenericJson | ||||
↳ | com.kinvey.java.User<T extends com.kinvey.java.User> | ||||
↳ | com.kinvey.android.AbstractAsyncUser<T extends com.kinvey.java.User> |
![]() |
Maintains definitions of all asyncronous user operation methods, this class is meant to be extended.
Wraps theUser
public methods in asynchronous functionality using native Android AsyncTask.
This functionality can be accessed through the user()
convenience method.
Methods in this API use either KinveyUserCallback
for authentication, login, and
user creation, or the general-purpose KinveyClientCallback
used for User data retrieval,
updating, and management.
Login sample:
public void submit(View view) {
kinveyClient.user().login(mEditUserName.getText().toString(), mEditPassword.getText().toString(),
new KinveyUserCallback() {
public void onFailure(Throwable t) {
CharSequence text = "Wrong username or password.";
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
public void onSuccess(User u) {
CharSequence text = "Welcome back," + u.getUsername() + ".";
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
LoginActivity.this.startActivity(new Intent(LoginActivity.this,
SessionsActivity.class));
LoginActivity.this.finish();
}
});
}
Saving user data sample:
User user = kinveyClient.user();
user.put("fav_food", "bacon");
user.update(new KinveyClientCallback<User.Update>() {
public void onFailure(Throwable e) { ...
public void onSuccess(User u) { ... }
});
}
This class is not thread-safe.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
AbstractAsyncUser(AbstractClient client, Class<T> userClass, KinveyAuthRequest.Builder builder)
Base constructor requires the client instance and a
KinveyAuthRequest.Builder to be passed in. | |||||||||||
AbstractAsyncUser() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
create(String username, String password, KinveyClientCallback<T> callback)
Asynchronous method to create a new Kinvey User.
| ||||||||||
void |
delete(Boolean hardDelete, KinveyUserDeleteCallback callback)
Asynchronous Call to Delete the current user from the Kinvey backend
Constructs an asynchronous request to delete the current Kinvey user. | ||||||||||
void | getMICAccessToken(String token) | ||||||||||
void |
keepOfflineStorageOnLogout()
Set a flag to allow local offline storage to persist after calls to logout.
| ||||||||||
void |
login(KinveyClientCallback<T> callback)
Asynchronous implicit user login.
| ||||||||||
void |
login(String userid, String password, KinveyClientCallback<T> callback)
Asynchronous Kinvey user login.
| ||||||||||
void | loginAuthLink(String accessToken, String refreshToken, KinveyClientCallback<T> callback) | ||||||||||
void |
loginFacebook(String accessToken, KinveyClientCallback<T> callback)
Asynchronous Facebook login.
| ||||||||||
void |
loginGoogle(String accessToken, KinveyClientCallback<T> callback)
Asynchronous Google login.
| ||||||||||
void |
loginKinveyAuthToken(String userId, String authToken, KinveyClientCallback<T> callback)
Login to Kinvey services using a Kinvey user's _id and their valid Kinvey Auth Token.
| ||||||||||
void |
loginLinkedIn(String accessToken, String accessSecret, String consumerKey, String consumerSecret, KinveyClientCallback<T> callback)
Asynchronous Linked In login.
| ||||||||||
void |
loginMobileIdentity(String accessToken, KinveyUserCallback callback)
Login to Kinvey Service using Kinvey Mobile Identity Connect Service
| ||||||||||
void |
loginSalesForce(String accessToken, String clientid, String refreshToken, String id, KinveyClientCallback<T> callback)
Login to Kinvey Services using a Salesforce identity
| ||||||||||
void |
loginTwitter(String accessToken, String accessSecret, String consumerKey, String consumerSecret, KinveyClientCallback<T> callback)
Asynchronous Twitter login.
| ||||||||||
void |
loginWithAuthorizationCodeAPI(String username, String password, String redirectURI, KinveyUserCallback callback)
Login with the MIC service, using the oauth flow.
| ||||||||||
void |
loginWithAuthorizationCodeLoginPage(String redirectURI, KinveyMICCallback callback)
Login with the MIC service, using the oauth flow.
| ||||||||||
LogoutRequest |
logout()
Logs out the current user and clears the local sqllite3 storage
| ||||||||||
void | onOAuthCallbackRecieved(Intent intent) | ||||||||||
void |
resetPassword(String username, KinveyUserManagementCallback callback)
Asynchronous Call to initiate a Password Reset request
The reset password request initiates a server-side process to reset a user's password. | ||||||||||
<T> void |
retrieve(KinveyClientCallback<T> callback)
Asynchronous Call to Retrieve (refresh) the current user
Constructs an asynchronous request to refresh current user's data via the Kinvey back-end. | ||||||||||
void |
retrieve(Query q, KinveyListCallback<T> callback)
Asynchronous Call to Retrieve users via a Query
Constructs an asynchronous request to retrieve User objects via a Query. | ||||||||||
void |
retrieve(String[] resolves, KinveyClientCallback<T> callback)
Asynchronous call to retrive (refresh) the current user, and resolve KinveyReferences
Constructs an asynchronous request to refresh current user's data via the Kinvey back-end. | ||||||||||
void |
retrieve(Query query, String[] resolves, KinveyUserListCallback callback)
Asynchronous call to retrive (refresh) the users by query, and resolve KinveyReferences
Constructs an asynchronous request to retrieve User objects via a Query. | ||||||||||
void |
retrieveMetadata(KinveyClientCallback<T> callback)
Asynchronous Retrieve Metadata
Convenience method for retrieving user metadata and updating the current user with the metadata. | ||||||||||
void |
sendEmailVerification(KinveyUserManagementCallback callback)
Asynchronous Call to initiate an Email Verification request
The email verification request initiates a server-side process to verify a user's email. | ||||||||||
void |
update(User user, KinveyClientCallback<T> callback)
Asynchronous Call to Save a given user
Constructs an asynchronous request to save a provided Kinvey user. | ||||||||||
void |
update(KinveyClientCallback<T> callback)
Asynchronous Call to Save the current user
Constructs an asynchronous request to save the current Kinvey user. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Base constructor requires the client instance and a KinveyAuthRequest.Builder
to be passed in.
initializeRequest(com.kinvey.java.core.AbstractKinveyClientRequest)
is used to initialize all
requests constructed by this api.
client | instance of current client |
---|
NullPointerException | if the client parameter and KinveyAuthRequest.Builder is non-null |
---|
Asynchronous method to create a new Kinvey User.
Constructs an asynchronous request to create a Kinvey user with username and password, and returns the associated User object via a KinveyUserCallback. All metadata that is added to the user object prior to creating the user will be persisted to the Kinvey backend.
Sample Usage:
kinveyClient.user().put("State","MA");
kinveyClient.user().put("Age", 25);
kinveyClient.user().create(mEditUserName.getText().toString(), mEditPassword.getText().toString(),
new KinveyUserCallback() {
public void onFailure(Throwable t) {
CharSequence text = "Unable to create account.";
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
public void onSuccess(User u) {
CharSequence text = "Welcome " + u.getUsername() + ".";
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
}
});
}
username | username of the Kinvey User |
---|---|
password | password of the Kinvey user |
callback | KinveyUserCallback containing a new User instance.
|
Asynchronous Call to Delete the current user from the Kinvey backend
Constructs an asynchronous request to delete the current Kinvey user. The hardDelete flag determines whether the user is simply marked as inactive or completely erased from the Kinvey backend.
Sample Usage:
User user = kinveyClient.user();
user.delete(new KinveyUserDeleteCallback() {
public void onFailure(Throwable e) { ...
public void onSuccess(Void v) { ... }
});
}
hardDelete | Erases user from Kinvey backend if true; inactivates the user if false. |
---|---|
callback | KinveyUserDeleteCallback .
|
Set a flag to allow local offline storage to persist after calls to logout.
Only use this method if each device will have a guaranteed consistent user and there are no concerns about securityAsynchronous implicit user login.
Constructs an asynchronous request to log in an implicit (non-named) user and returns the associated User object via a KinveyUserCallback.
Sample Usage:
kinveyClient.user().login(new KinveyUserCallback() {
public void onFailure(Throwable t) { ...
public void onSuccess(User u) {
CharSequence text = "Welcome back!";
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
}
});
}
callback | KinveyUserCallback that returns a valid user object
|
---|
Asynchronous Kinvey user login.
Constructs an asynchronous request to log in a Kinvey user with username and password, and returns the associated User object via a KinveyUserCallback.
Sample Usage:
kinveyClient.user().login(mEditUserName.getText().toString(), mEditPassword.getText().toString(),
new KinveyUserCallback() {
public void onFailure(Throwable t) {
CharSequence text = "Wrong username or password.";
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
public void onSuccess(User u) {
CharSequence text = "Welcome back," + u.getUsername() + ".";
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
LoginActivity.this.startActivity(new Intent(LoginActivity.this,
SessionsActivity.class));
LoginActivity.this.finish();
}
});
}
userid | userID of the Kinvey User |
---|---|
password | password of the Kinvey user |
callback | KinveyUserCallback that returns a valid user object
|
Asynchronous Facebook login.
Constructs an asynchronous request to log in a Facebook user and returns the associated User object via a KinveyUserCallback. A valid Facebook access token must be obtained via the Facebook OAuth API and passed to this method.
Sample Usage:
kinveyClient.user().loginFacebook(accessToken, new KinveyUserCallback() { public void onFailure(Throwable e) { error(progressDialog, "Kinvey: " + e.getMessage()); Log.e(TAG, "failed Kinvey facebook login", e); } public void onSuccess(User u) { Log.d(TAG, "successfully logged in with facebook"); } });
accessToken | Facebook-generated access token. |
---|---|
callback | KinveyUserCallback that returns a valid user object
|
Asynchronous Google login.
Constructs an asynchronous request to log in a Google user and returns the associated User object via a KinveyUserCallback. A valid Google access token must be obtained via the Google OAuth API and passed to this method.
Sample Usage:
kinveyClient.user().loginGoogle(accessToken, new KinveyUserCallback() {
public void onFailure(Throwable e) {
error(progressDialog, "Kinvey: " + e.getMessage());
Log.e(TAG, "failed Kinvey facebook login", e);
public void onSuccess(User u) {
Log.d(TAG, "successfully logged in with facebook");
}
});
}
accessToken | Google-generated access token. |
---|---|
callback | KinveyUserCallback that contains a valid logged in user
|
Login to Kinvey services using a Kinvey user's _id and their valid Kinvey Auth Token. This method is provided to allow for cross-platform login, by reusing a session provided with another client library (or the REST api).
userId | the _id field of the user to login |
---|---|
authToken | a valid Kinvey Auth token |
callback | KinveyUserCallback that contains a valid logged in user |
IOException |
---|
Asynchronous Linked In login.
Constructs an asynchronous request to log in a Linked In user and returns the associated User object via a KinveyUserCallback. A valid Linked In access token, access secret, consumer key, and consumer secret must be obtained via the Linked In OAuth API and passed to this method.
Sample Usage:
kinveyClient.user().loginLinkedIn(accessToken, accessSecret, LINKEDIN_CONSUMER_KEY, LINKEDIN_CONSUMER_SECRET,
new KinveyUserCallback() {
public void onFailure(Throwable e) {
Log.e(TAG, "Failed Kinvey login", e)
;
public void onSuccess(User r) {
Log.e(TAG, "Successfully logged in via Linked In");
}
});
}
accessToken | Linked In-generated access token |
---|---|
accessSecret | Linked In-generated access secret |
consumerKey | Linked In supplied developer consumer key |
consumerSecret | Linked In supplied developer consumer secret |
callback | KinveyUserCallback that returns a valid user object
|
Login to Kinvey Service using Kinvey Mobile Identity Connect Service
accessToken | - a MIC access token |
---|---|
callback | - |
Login to Kinvey Services using a Salesforce identity
accessToken | - provided by salesforce, after successful login |
---|---|
clientid | - client id used by salesforce |
refreshToken | - provided by salesforce, after successful login |
id | - the salesforce id of the user |
callback | - KinveyUserCallback that contains a valid logged in user
|
Asynchronous Twitter login.
Constructs an asynchronous request to log in a Twitter user and returns the associated User object via a KinveyUserCallback. A valid Twitter access token, access secret, consumer key, and consumer secret must be obtained via the Twitter OAuth API and passed to this method.
Sample Usage:
kinveyClient.user().loginTwitter(accessToken, accessSecret, TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET,
new KinveyUserCallback() {
public void onFailure(Throwable e) {
Log.e(TAG, "Failed Kinvey login", e)
;
public void onSuccess(User r) {
Log.e(TAG, "Successfully logged in via Twitter");
}
});
}
accessToken | Twitter-generated access token |
---|---|
accessSecret | Twitter-generated access secret |
consumerKey | Twitter supplied developer consumer key |
consumerSecret | Twitter supplied developer consumer secret |
callback | KinveyUserCallback that returns a valid user object
|
Login with the MIC service, using the oauth flow. This method provides direct login, without rending a login page.
Login with the MIC service, using the oauth flow. This method provides a URL to render containing a login page.
Logs out the current user and clears the local sqllite3 storage
Asynchronous Call to initiate a Password Reset request
The reset password request initiates a server-side process to reset a user's password. Once executed, a success callback is initiated. The user is then emailed by the server to receive the password reset. The user's email address must be stored in a property named 'email' in the User collection.
Sample Usage:
kinveyClient.resetPassword(new KinveyClientCallback<User>() {
public void onFailure(Throwable e) { ...
public void onSuccess() { ... }
});
}
callback | KinveyUserManagementCallback
|
---|
Asynchronous Call to Retrieve (refresh) the current user
Constructs an asynchronous request to refresh current user's data via the Kinvey back-end.
Sample Usage:
User user = kinveyClient.user();
user.retrieve(new KinveyUserCallback() {
public void onFailure(Throwable e) { ...
public void onSuccess(User result) { ... }
});
}
callback | KinveyUserCallback containing a refreshed User instance. |
---|
Asynchronous Call to Retrieve users via a Query
Constructs an asynchronous request to retrieve User objects via a Query.
Sample Usage:
User user = kinveyClient.user();
user.retrieve(Query query, new KinveyUserListCallback() {
public void onFailure(Throwable e) { ...
public void onSuccess(User[] result) { ... }
});
}
callback | KinveyUserListCallback for retrieved users. |
---|
Asynchronous call to retrive (refresh) the current user, and resolve KinveyReferences
Constructs an asynchronous request to refresh current user's data via the Kinvey back-end.
Sample Usage:
User user = kinveyClient.user();
user.retrieve(new String[]{"myKinveyReferencedField"
, new KinveyUserCallback() {
public void onFailure(Throwable e) { ... }
public void onSuccess(User result) { ... }
});
}
resolves | an array of json keys maintaining KinveyReferences to be resolved |
---|---|
callback | KinveyUserCallback containing refreshed user instance
|
Asynchronous call to retrive (refresh) the users by query, and resolve KinveyReferences
Constructs an asynchronous request to retrieve User objects via a Query.
Sample Usage:
User user = kinveyClient.user();
user.retrieve(Query query, new String[]{"myKinveyReferenceField"
, new KinveyUserListCallback() {
public void onFailure(Throwable e) { ... }
public void onSuccess(User[] result) { ... }
});
}
query | the query to execute defining users to return |
---|---|
resolves | an array of json keys maintaining KinveyReferences to be resolved |
callback | KinveyUserListCallback containing an array of queried users
|
Asynchronous Retrieve Metadata
Convenience method for retrieving user metadata and updating the current user with the metadata. Used when initializing the client.
callback | KinveyUserCallback |
---|
Asynchronous Call to initiate an Email Verification request
The email verification request initiates a server-side process to verify a user's email. Once executed, a success callback is initiated. The user is then emailed by the server to receive the email verification. The user's email address must be stored in a property named 'email' in the User collection.
Sample Usage:
kinveyClient.sendEmailVerification(new KinveyClientCallback<User>() {
public void onFailure(Throwable e) { ...
public void onSuccess(Void result) { ... }
});
callback | KinveyUserManagementCallback
|
---|
Asynchronous Call to Save a given user
Constructs an asynchronous request to save a provided Kinvey user.
Ensure you have configured backend to allow for `Full` permissions on User edits through the console.Sample Usage:
kinveyClient.user().retrieve(new Query(), new KinveyUserListCallback(){
public void onFailure(Throwable e) { ...
public void onSuccess(User[] result) {
for (User u : result){
kinveyClient.User().update(u, new KinveyUserCallback() {
public void onFailure(Throwable e) { ... }
public void onSuccess(User result) { ... }
});
}
}
});
}
callback | KinveyUserCallback containing an updated User instance.
|
---|
Asynchronous Call to Save the current user
Constructs an asynchronous request to save the current Kinvey user.
Sample Usage:
User user = kinveyClient.user();
user.update(new KinveyUserCallback() {
public void onFailure(Throwable e) { ...
public void onSuccess(User result) { ... }
});
}
callback | KinveyUserCallback containing an updated User instance.
|
---|