Skip to content

Instantly share code, notes, and snippets.

@bengongon97
Last active July 20, 2020 10:34
Show Gist options
  • Save bengongon97/0cdb1cd9c6530e266a1d4d8be50f693b to your computer and use it in GitHub Desktop.
Save bengongon97/0cdb1cd9c6530e266a1d4d8be50f693b to your computer and use it in GitHub Desktop.
SignOut and Related methods for AccountKit
//FROM HERE...
binding.signOutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
signOutFromAccount();
}
});
//...TO HERE, SHOULD BE INSIDE ONCREATE() METHOD. A SIMPLE FUNCTION CALL.
//THIS IS A CUSTOM METHOD
private void signOutFromAccount() {
// service indicates the HuaweiIdAuthService instance generated using the getService method during the sign-in authorization.
Task<Void> signOutTask = service.signOut();
signOutTask.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(Task<Void> task) {
// Processing after the sign-out.
Intent i = new Intent(MainActivity.this, LoginActivity.class);
Toast.makeText(MainActivity.this, "You have successfully signed out!", Toast.LENGTH_SHORT).show();
startActivity(i);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment