Идея состоит в том, что я сохраняю имя пользователя и пароль в приложении 1.
suspend fun signUp(username: String, password: String): SignUpResult {
return try {
credentialManager.createCredential(
context = context,
request = CreatePasswordRequest(
id = username,
password = password
)
)
SignUpResult.Success(username)
} catch (e: Exception) {
e.printStackTrace()
SignUpResult.Failure
}
}
Затем каким-то образом получите эти учетные данные в приложении 2 и предложите пользователю их использовать.
suspend fun signIn(): SignInResult {
return try {
val credentialResponse = credentialManager.getCredential(
context = context,
request = GetCredentialRequest(
credentialOptions = listOf(GetPasswordOption())
)
)
val credential = credentialResponse.credential as? PasswordCredential
?: return SignInResult.Failure
SignInResult.Success(credential.id)
} catch (e: Exception) {
e.printStackTrace()
SignInResult.Failure
}
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... al-manager