モバイルアプリから使用できる適切な解像度のユーザーの写真を取得するにはどうすればよいですか?私はガイドとapiドキュメントを見て、推奨される方法はFirebaseUser#getPhotoUrl()を使用するように見えました。しかしこれは、解像度が50x50ピクセルの写真にURLを返すので、役に立たない。クライアントがユーザーの高解像度の写真を要求する方法はありますか?私はFacebook LoginとGoogle Sign-inのSSDを別々にテストしましたが、いずれの場合もFirebase Authが返すものよりも写真の解像度が高いです。 Firebase Authが元の解像度を変更するのはなぜですか、それを強制しないのはなぜですか?ありがとう。Android Firebase認証 - ユーザーの写真を取得
7
A
答えて
1
は、あなたが試してみました:あなたがFacebookでログインしている場合
Uri xx = FirebaseAuth.getInstance().getCurrentUser().getPhotoUrl();
6
インサイドonAuthStateChangedを(@NonNull FirebaseAuth firebaseAuth)
は試してみてください。
if (!user.getProviderData().isEmpty() && user.getProviderData().size() > 1)
String URL = "https://graph.facebook.com/" + user.getProviderData().get(1).getUid() + "/picture?type=large";
4
FacebookとGoogleのPhotoURL:
User myUserDetails = new User();
myUserDetails.name = firebaseAuth.getCurrentUser().getDisplayName();
myUserDetails.email = firebaseAuth.getCurrentUser().getEmail();
String photoUrl = firebaseAuth.getCurrentUser().getPhotoUrl().toString();
for (UserInfo profile : firebaseAuth.getCurrentUser().getProviderData()) {
System.out.println(profile.getProviderId());
// check if the provider id matches "facebook.com"
if (profile.getProviderId().equals("facebook.com")) {
String facebookUserId = profile.getUid();
myUserDetails.sigin_provider = profile.getProviderId();
// construct the URL to the profile picture, with a custom height
// alternatively, use '?type=small|medium|large' instead of ?height=
photoUrl = "https://graph.facebook.com/" + facebookUserId + "/picture?height=500";
} else if (profile.getProviderId().equals("google.com")) {
myUserDetails.sigin_provider = profile.getProviderId();
((HomeActivity) getActivity()).loadGoogleUserDetails();
}
}
myUserDetails.profile_picture = photoUrl;
private static final int RC_SIGN_IN = 8888;
public void loadGoogleUserDetails() {
try {
// Configure sign-in to request the user's ID, email address, and basic profile. ID and
// basic profile are included in DEFAULT_SIGN_IN.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.build();
// Build a GoogleApiClient with access to GoogleSignIn.API and the options above.
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
System.out.println("onConnectionFailed");
}
})
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from
// GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
GoogleSignInAccount acct = result.getSignInAccount();
// Get account information
String PhotoUrl = acct.getPhotoUrl().toString();
}
}
}
+0
facebookの部分でこれを試してみました。私はまだGoogleの部分を試してみませんでした。ありがとう – Dika
関連する問題
- 1. firebase認証ユーザーの写真の写真のURLが返されます404
- 2. プロフィール写真のサイズでユーザーの写真を取得
- 3. Instagram:ユーザーとタグで写真を取得
- 4. Firebase:Facebookの写真URLを取得する[Android]
- 5. Twitterユーザー用のJSONを取得するユーザーの写真
- 6. firebase 3認証取得エラー
- 7. Google Classroomプロフィール写真の認証アクセス
- 8. Firebase Storageからすべての写真名を取得
- 9. アンドロイドFirebase - プロフィール写真
- 10. 認証firebase + androidのデータベースfirebase
- 11. Facebookの写真の写真アルバムを取得する
- 12. アルバム写真のメタデータ付き写真ファイルを取得
- 13. Firebaseから写真をアップロードして取得する
- 14. firebaseリアルタイムデータベース/ firebase認証用のAndroidユニークキー
- 15. instagramからすべてのユーザーの写真を取得
- 16. Facebook API PHPユーザーの "プロフィール写真"アルバムのIDを取得
- 17. Firebase Auth:Android:ユーザーのメールと写真を表示できません
- 18. Facebook - ページの写真を取得
- 19. 写真IDからFacebook写真を取得
- 20. Firebase認証:既存のユーザー
- 21. Firebase認証ユーザーの作成
- 22. Firebase Android認証エラー
- 23. Android:アップロード写真
- 24. セッションは写真とユーザー名を取得できません
- 25. Firebaseにユーザーの写真を保存する方法
- 26. Android - 撮影した写真のURLを取得する方法
- 27. Androidコンタクト写真の画像パスを取得する方法は?
- 28. 連絡先写真のファイルシステムパスを取得します。android
- 29. AndroidでのFirebase認証
- 30. facebook graph api壁の写真を取得
はい、あります。それはあなたに50x50ピクセルの写真を与えます。 – mobilekid