0
如果用戶從帳戶選擇器登錄,我可以從靜音登錄中獲取詳細信息。 我想在沒有用戶輸入的情況下執行操作Android靜默登錄沒有用戶交互登錄帳戶經理中的Gmail帳戶
我試圖顯示用戶個人資料詳情,如個人資料圖片,從我的應用程序顯示,無需用戶輸入。通過在api中使用silentsign無聲登錄iam。
有沒有什麼辦法讓登入不從的AccountManager帳戶選擇,
private void silentSign() {
// Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
// startActivityForResult(signInIntent, RC_SIGN_IN);
OptionalPendingResult<GoogleSignInResult> pendingResult =
Auth.GoogleSignInApi.silentSignIn(mGoogleApiClient);
if (pendingResult.isDone()) {
// There's immediate result available.
handleSignInResult(pendingResult.get());
} else {
// There's no immediate result ready, displays some progress indicator and waits for the
// async callback.
// showProgressIndicator();
pendingResult.setResultCallback(new ResultCallback<GoogleSignInResult>() {
@Override
public void onResult(@NonNull GoogleSignInResult result) {
handleSignInResult(result);
// hideProgressIndicator();
}
});
}
private void handleSignInResult(GoogleSignInResult result) {
//If the login succeed
if (result.isSuccess()) {
//Getting google account
GoogleSignInAccount acct = result.getSignInAccount();
//Displaying name and email
textViewName.setText(acct.getDisplayName());
textViewEmail.setText(acct.getEmail());
textGivenName.setText(acct.getGivenName());
textFamilyName.setText(acct.getFamilyName());
textid.setText(acct.getId());
Uri photoUrl = acct.getPhotoUrl();
//Initializing image loader
imageLoader = CustomVolleyRequest.getInstance(this.getApplicationContext())
.getImageLoader();
imageLoader.get(acct.getPhotoUrl().toString(),
ImageLoader.getImageListener(profilePhoto,
R.mipmap.ic_launcher,
R.mipmap.ic_launcher));
//Loading image
profilePhoto.setImageURI(photoUrl);
} else {
//If login fails
Toast.makeText(this, "Login Failed", Toast.LENGTH_LONG).show();
}
}
我想顯示用戶gmail個人資料圖像,用戶名登錄在設備中的gmail帳戶(通過使用帳戶管理器我們將無法獲得用戶gmail配置文件圖像)。這些需要在應用程序啓動後顯示(如果有多個帳戶,沒有像gmail帳戶選擇器那樣的用戶交互) – Bhargavaroyal
按照要求,想要在我們的應用程序中顯示如下圖所示的用戶詳細信息:https:// www。 google.co.in/imgres?imgurl=https%3A%2F%2Fwww.androidheadlines.com%2Fwp-content%2Fuploads%2F2017%2F06%2FYouTube-for-Android-TV-New-4.jpg&imgrefurl=https%3A% 2F%2Fwww.androidheadlines.com%2F2017%2F06%2Fandroid-TV-YouTube上獲得-A-新外觀與 - 最新-update.html和文檔ID = YFuQTvqF6A3jnM&tbnid = n1xvchTuiu9vLM%3A&RET = 10ahUKEwiZtsKiu_nVAhXKo48KHUc_DuEQMwgmKAAwAA..i&W = 1366&H = 768&安全=關和客戶端= firefox-b-ab&bih = 681&biw = 1467&q = youtube%20android%20user%20profile&ved = 0ahUKEwiZtsKiu_nVAhXKo48KHUc_DuEQMwgmKAAwAA&iact = mrc&uact = 8 – Bhargavaroyal
因此,正如我所說的,你必須首先詢問權限,然後保存令牌。在下次你可以使用這個令牌並使用REST API或SDK獲取後, –