2016-05-23 11 views
7

मैं उपयोगकर्ता के फोटो को सभ्य रिज़ॉल्यूशन के साथ कैसे प्राप्त कर सकता हूं जिसका उपयोग मोबाइल ऐप से किया जा सकता है? मैंने गाइड और एपीआई दस्तावेज़ों को देखा और अनुशंसित तरीका FirebaseUser#getPhotoUrl() का उपयोग करना प्रतीत होता था। हालांकि यह संकल्प 50x50 पीएक्स के साथ एक फोटो को यूआरएल देता है, जो उपयोगी होने के लिए बहुत कम है। क्या क्लाइंट के उपयोगकर्ता की उच्च रेज फोटो का अनुरोध करने का कोई तरीका है? मैंने फेसबुक लॉगिन और Google साइन-इन के अलग-अलग परीक्षणों का परीक्षण किया है, और दोनों मामलों में फ़ोटो के संकल्प फ़ायरबेस एथ वापस देता है उससे अधिक हैं। फायरबेस एथ मूल संकल्प क्यों बदलता है और मैं इसे कैसे करने के लिए मजबूर कर सकता हूं? धन्यवाद।एंड्रॉइड फायरबेस एथ - उपयोगकर्ता का फोटो प्राप्त करें

उत्तर

1

आप की कोशिश की है:

Uri xx = FirebaseAuth.getInstance().getCurrentUser().getPhotoUrl(); 
+0

हाँ, मेरे पास है। यह आपको 50x50 पीएक्स फोटो देता है। – mobilekid

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

फेसबुक और गूगल 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

मैंने फेसबुक भाग के लिए यह कोशिश की और सफल हुआ। मैंने अभी तक Google भाग की कोशिश नहीं की है। धन्यवाद – Dika

संबंधित मुद्दे