Làm cách nào tôi có thể truy xuất ảnh của người dùng có độ phân giải khá có thể được sử dụng từ ứng dụng dành cho thiết bị di động? Tôi đã xem các hướng dẫn và tài liệu api và cách được đề xuất dường như sử dụng FirebaseUser#getPhotoUrl(). Tuy nhiên, điều này sẽ trả lại một url cho ảnh có độ phân giải 50x50 px, quá thấp để có thể hữu ích. Có cách nào để khách hàng yêu cầu ảnh có độ phân giải cao hơn của người dùng không? Tôi đã thử nghiệm các sdks của Đăng nhập Facebook và Đăng nhập bằng Google một cách riêng biệt và trong cả hai trường hợp, độ phân giải của ảnh cao hơn so với những gì Firebase Auth trả lại. Tại sao Autbase Firebase thay đổi độ phân giải ban đầu và làm thế nào tôi có thể buộc nó không làm điều đó? Cảm ơn.Xác thực Firebase của Android - Nhận Ảnh của Người dùng
7
A
Trả lời
1
Các bạn đã thử:
Uri xx = FirebaseAuth.getInstance().getCurrentUser().getPhotoUrl();
6
Bên onAuthStateChanged (@NonNull FirebaseAuth firebaseAuth)
Hãy thử Nếu bạn đăng nhập với Facebook:
if (!user.getProviderData().isEmpty() && user.getProviderData().size() > 1)
String URL = "https://graph.facebook.com/" + user.getProviderData().get(1).getUid() + "/picture?type=large";
4
Facebook và 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
Tôi đã thử điều này cho một phần facebook và thành công. Tôi chưa thử phần google. cảm ơn – Dika
Các vấn đề liên quan
- 1. Firebase setDisplayName của người dùng khi tạo người dùng Android
- 2. Xác thực người dùng Firebase trong python
- 3. Nhận vị trí của người dùng Android
- 4. Nhận địa chỉ email của người dùng bằng Twitter Đăng nhập đơn giản của Firebase
- 5. Android - Thẻ xác thực người dùng Firebase có hết hạn không?
- 6. C# Nhận hình ảnh của người dùng (Avatar)
- 7. Kiểm tra xem người dùng có được xác thực lần đầu tiên trong Xác thực Google Firebase trong Android
- 8. Chỉ nhận phương tiện của người dùng (ảnh) - Twitter API
- 9. Xác thực tính năng nhập của người dùng?
- 10. Xác thực Firebase Laravel
- 11. xác thực ldapjs (thiết lập đăng nhập của người dùng)
- 12. Android: Xác thực của Google
- 13. android: xác thực danh tính của người gửi ý định
- 14. Xác thực nhập của người dùng cho JOptionPane.showInputDialog
- 15. Xác thực và ủy quyền của người dùng WCF
- 16. Giao diện người dùng Firebase - Xác thực - Sử dụng bố cục riêng
- 17. Hộp thoại xác nhận SMS của Android
- 18. Cách nhận múi giờ của người dùng?
- 19. Firebase - Cách ghi/đọc dữ liệu cho mỗi người dùng sau khi xác thực
- 20. Xác thực Windows - Nhận tên người dùng hiện tại
- 21. Số lượng người dùng đang hoạt động không chính xác của Firebase Analytics
- 22. Xác thực người dùng Flask
- 23. tay người dùng xác thực
- 24. Cách xác thực lại người dùng trên Firebase với Nhà cung cấp Google?
- 25. Xác thực Firebase/Firechat với người dùng hoặc cơ sở dữ liệu Wordpress
- 26. Nhận xác thực người dùng AD objectGuid từ asp.net
- 27. firebase - được thông báo khi người dùng xác nhận email được gửi bằng sendEmailVerification
- 28. cách nhận người dùng hiện tại trên firebase
- 29. Xác thực người dùng Silverlight
- 30. Xác thực NodeJS với Firebase
Có, tôi có. Điều đó mang lại cho bạn một bức ảnh 50x50 px. – mobilekid