-
Notifications
You must be signed in to change notification settings - Fork 1
Smart Lock For Passwords
Serhii Petrosyuk edited this page Apr 19, 2019
·
6 revisions
Build the SmartLock object
val smartLock = SmartLock.Builder(WeakReference(this))
.disableAutoSignIn()
.setAccountTypes(IdentityProviders.GOOGLE, IdentityProviders.FACEBOOK)
.build()
The requestCredentialAndAutoSignIn()
method returns the LiveData object with the AuthResult value type
smartLock.requestCredentialAndAutoSignIn()
.observe(this, Observer { authResult ->
if (it.isSuccess) {
// Do your stuff with the [authResult.account]
} else {
// Handle an error from the [authResult.exceptin]
}
})
Save the user's Credential by calling the saveCredentials()
method
smartLock.saveCredentials(credential)
.observe(this, Observer { status ->
// Do your stuff
})
The requestCredential()
returns the LiveData object with the CredentialRequestResult value type
smartLock.requestCredential()
.observe(this, Observer { credentialRequestResult ->
if (credentialRequestResult.status.isSuccess) {
// Do your stuff with the [credentialRequestResult.credential]
} else {
// Resolve the request result according to the [credentialRequestResult.status]
}
})
Delete the user's Credential by calling the deleteCredentials()
method
smartLock.deleteCredentials(credential)
.observe(this, Observer { status ->
// Do your stuff
})
this
represents the LifecycleOwner