Last active
July 20, 2020 10:34
-
-
Save bengongon97/0cdb1cd9c6530e266a1d4d8be50f693b to your computer and use it in GitHub Desktop.
SignOut and Related methods for AccountKit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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