Logging In with the Android SDK

Once the Android SDK is initialized, you will be able to login using the TigerTextAccountManager.

Remember not to use the manager directly, but to leverage the instance as shown in the comments below.

...
// get username (String) and password(String) via input
...
public void doLogin(String username, String password) {
// Always get the manager through TT.getInstance() instead of TigerTextAccountManager.getInstance()
TigerTextAccountManager accountManager = TT.getInstance().getAccountManager();
accountManager.login("username", "password", new LoginResultCallback(this));
}
// Like most SDKs, TT's SDK holds strong references to the listeners,
// so get a weak reference to your components when necessary...
private static class LoginResultCallback implements LoginListener {
private WeakReference<Activity> weakLoginActivity;
public LoginResultCallback(Activity loginActivity) {
weakLoginActivity = new WeakReference(loginActivity);
}
@Override
public void onLoggedIn(User user, ValidationResponse validationResponse) {
Activity loginActivity = weakLoginActivity.get();
if (loginActivity == null) return;
// Handle logged in user
}
@Override
public void onLoginError(Throwable throwable) {
Activity loginActivity = weakLoginActivity.get();
if (loginActivity == null) return;
// Handle error
}
}

After logging in and before interacting further with the SDK, you will want to sync data with TigerText's backend. Syncing pulls down everything necessary for the account logged in to start interacting fully with the user's organizations, inbox, conversations, etc.

TT.getInstance().sync(new TT.SyncListener() {
@Override
public void onSyncComplete() {
// sync successful, continue using the sdk,
// at this point you can get all the conversations for this user
// (example available in the next sections)
}
@Override
public void onSyncFailed(Throwable throwable) {
// otherwise you will want to prompt the user to try and re-sync again
}
});