public abstract class

AbstractAsyncUser

extends User<T extends User>
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>
Known Direct Subclasses

Class Overview

Maintains definitions of all asyncronous user operation methods, this class is meant to be extended.

Wraps the User 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.

Summary

[Expand]
Inherited Constants
From class com.kinvey.java.User
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 keepOfflineStorageOnLogout()
Set a flag to allow local offline storage to persist after calls to logout.
void login(String userid, String password, KinveyClientCallback<T> callback)
Asynchronous Kinvey user login.
void login(KinveyClientCallback<T> callback)
Asynchronous implicit 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.
LogoutRequest logout()
Logs out the current user and clears the local sqllite3 storage
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.

<T> 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
From class com.kinvey.java.User
From class com.google.api.client.json.GenericJson
From class com.google.api.client.util.GenericData
From class java.util.AbstractMap
From class java.lang.Object
From interface java.util.Map

Public Constructors

public AbstractAsyncUser (AbstractClient client, Class<T> userClass, KinveyAuthRequest.Builder builder)

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.

Parameters
client instance of current client
Throws
NullPointerException if the client parameter and KinveyAuthRequest.Builder is non-null

public AbstractAsyncUser ()

Public Methods

public void create (String username, String password, KinveyClientCallback<T> callback)

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();
    }
    });
    }
 

Parameters
username username of the Kinvey User
password password of the Kinvey user
callback KinveyUserCallback containing a new User instance.

public 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. 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) { ... }
    });
    }
 

Parameters
hardDelete Erases user from Kinvey backend if true; inactivates the user if false.
callback KinveyUserDeleteCallback.

public void keepOfflineStorageOnLogout ()

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 security

public void login (String userid, String password, KinveyClientCallback<T> callback)

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();
    }
    });
    }
 

Parameters
userid userID of the Kinvey User
password password of the Kinvey user
callback KinveyUserCallback that returns a valid user object

public void login (KinveyClientCallback<T> callback)

Asynchronous 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();
    }
    });
    }
 

Parameters
callback KinveyUserCallback that returns a valid user object

public void loginAuthLink (String accessToken, String refreshToken, KinveyClientCallback<T> callback)

public void loginFacebook (String accessToken, KinveyClientCallback<T> callback)

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");
     }
     });
 

Parameters
accessToken Facebook-generated access token.
callback KinveyUserCallback that returns a valid user object

public void loginGoogle (String accessToken, KinveyClientCallback<T> callback)

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");
     }
     });
     }
 

Parameters
accessToken Google-generated access token.
callback KinveyUserCallback that contains a valid logged in user

public 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. This method is provided to allow for cross-platform login, by reusing a session provided with another client library (or the REST api).

Parameters
userId the _id field of the user to login
authToken a valid Kinvey Auth token
callback KinveyUserCallback that contains a valid logged in user
Returns
  • a LoginRequest ready to be executed
Throws
IOException

public void loginLinkedIn (String accessToken, String accessSecret, String consumerKey, String consumerSecret, KinveyClientCallback<T> callback)

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");
    }
    });
    }

Parameters
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

public void loginMobileIdentity (String accessToken, KinveyUserCallback callback)

Login to Kinvey Service using Kinvey Mobile Identity Connect Service

Parameters
accessToken - a MIC access token
callback -

public void loginSalesForce (String accessToken, String clientid, String refreshToken, String id, KinveyClientCallback<T> callback)

Login to Kinvey Services using a Salesforce identity

Parameters
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

public void loginTwitter (String accessToken, String accessSecret, String consumerKey, String consumerSecret, KinveyClientCallback<T> callback)

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");
    }
    });
    }

Parameters
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

public LogoutRequest logout ()

Logs out the current user and clears the local sqllite3 storage

Returns
  • a Logout Request, ready to have *.execute() called

public 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. 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() { ... }
    });
    }
 

Parameters
callback KinveyUserManagementCallback

public 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.

Sample Usage:

     User user = kinveyClient.user();
     user.retrieve(new KinveyUserCallback() {
     public void onFailure(Throwable e) { ... 
     public void onSuccess(User result) { ... }
     });
     }
 

Parameters
callback KinveyUserCallback containing a refreshed User instance.

public 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.

Sample Usage:

 User user = kinveyClient.user();
    user.retrieve(Query query, new KinveyUserListCallback() {
    public void onFailure(Throwable e) { ... 
    public void onSuccess(User[] result) { ... }
    });
    }
 

Parameters
callback KinveyUserListCallback for retrieved users.

public 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.

Sample Usage:

     User user = kinveyClient.user();
     user.retrieve(new String[]{"myKinveyReferencedField", new KinveyUserCallback() {
     public void onFailure(Throwable e) { ... }
     public void onSuccess(User result) { ... }
     });
     }
 

Parameters
resolves an array of json keys maintaining KinveyReferences to be resolved
callback KinveyUserCallback containing refreshed user instance

public 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.

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) { ... }
    });
    }
 

Parameters
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

public void retrieveMetadata (KinveyClientCallback<T> callback)

Asynchronous Retrieve Metadata

Convenience method for retrieving user metadata and updating the current user with the metadata. Used when initializing the client.

Parameters
callback KinveyUserCallback

public 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. 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) { ... }
    });
 

Parameters
callback KinveyUserManagementCallback

public void update (User user, KinveyClientCallback<T> callback)

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) { ... }
     });
     }
     }
     });
     }
 

Parameters
callback KinveyUserCallback containing an updated User instance.

public void update (KinveyClientCallback<T> callback)

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) { ... }
     });
     }
 

Parameters
callback KinveyUserCallback containing an updated User instance.