다소 복잡 할 수 있지만 이미 Google에서는이 용도에 대해 Docs을 제공했습니다.
저장된 자격 증명을 요청하려면 자격 증명 API에 액세스하도록 구성된 GoogleApiClient
의 인스턴스를 만들어야합니다.
mCredentialsApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.enableAutoManage(this, this)
.addApi(Auth.CREDENTIALS_API)
.build();
CredentialRequest 개체는 자격 증명을 요청하려는 로그인 시스템을 지정합니다. 암호 기반 로그인에 setPasswordLoginSupported
방법을 사용하고 Google 로그인과 같은 통합 로그인 서비스에 대해 setAccountTypes()
방법을 사용하여 CredentialRequest
을 작성하십시오. 당신이 GoogleApiClient
및 CredentialRequest
객체를 생성 한 후
mCredentialRequest = new CredentialRequest.Builder()
.setPasswordLoginSupported(true)
.setAccountTypes(IdentityProviders.GOOGLE, IdentityProviders.TWITTER)
.build();
, 그들 앱 저장된 자격 증명을 요청하는 CredentialsApi.request()
메서드에 전달합니다.
Auth.CredentialsApi.request(mCredentialsClient, mCredentialRequest).setResultCallback(
new ResultCallback<CredentialRequestResult>() {
@Override
public void onResult(CredentialRequestResult credentialRequestResult) {
if (credentialRequestResult.getStatus().isSuccess()) {
// See "Handle successful credential requests"
onCredentialRetrieved(credentialRequestResult.getCredential());
} else {
// See "Handle unsuccessful and incomplete credential requests"
resolveResult(credentialRequestResult.getStatus());
}
}
});
자격증 명 요청에 성공하면 결과 자격 증명 개체를 사용하여 앱에 대한 사용자 로그인을 완료합니다. getAccountType()
메서드를 사용하여 검색된 자격 증명의 유형을 결정한 다음 적절한 로그인 프로세스를 완료하십시오.
private void onCredentialRetrieved(Credential credential) {
String accountType = credential.getAccountType();
if (accountType == null) {
// Sign the user in with information from the Credential.
signInWithPassword(credential.getId(), credential.getPassword());
} else if (accountType.equals(IdentityProviders.GOOGLE)) {
// The user has previously signed in with Google Sign-In. Silently
// sign in the user with the same ID.
// See https://developers.google.com/identity/sign-in/android/
GoogleSignInOptions gso =
new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, this)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.setAccountName(credential.getId())
.build();
OptionalPendingResult<GoogleSignInResult> opr =
Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
// ...
}
}
BLE 장치가 스마트 잠금 설정에서 신뢰할 수있는 장치로 추가 된 경우 전화기가 해당 BLE 장치와 연결될 때 자동으로 잠금이 해제됩니다. 당신이 찾고있는 것은 여전히 나에게 불분명하다. 이 점을 자세히 설명하고 내가 틀렸다면 어디든지 고쳐주십시오. –
당신이 옳습니다. 하지만 화면이 한 번 더 있습니다 (스 와이프 화면). 그 때, 화면을 스크롤하여 잠금 해제해야합니다. 나는 이것을 무시하고 싶다. Smartlock에는 그 옵션이 있다고 생각합니다 – Jame
이것을 확인하셨습니까? http : // stackoverflow.co.kr/questions/30246425/수신자 전환 서비스/30365638 # 30365638 –