gaurav4sarma gaurav4sarma - 1 year ago 289
Android Question

Android : How to get larger profile pic from fb using firebaseAuth

I am using firebaseAuth to login user through FB. Here is the code

private FirebaseAuth mAuth;
private FirebaseAuth.AuthStateListener mAuthListener;
private CallbackManager mCallbackManager;

protected void onCreate(Bundle savedInstanceState) {

// Initialize Firebase Auth
mAuth = FirebaseAuth.getInstance();

mAuthListener = firebaseAuth -> {
FirebaseUser user = firebaseAuth.getCurrentUser();
if (user != null) {
// User is signed in
Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
} else {
// User is signed out
Log.d(TAG, "onAuthStateChanged:signed_out");

if (user != null) {
Log.d(TAG, "User details : " + user.getDisplayName() + user.getEmail() + "\n" + user.getPhotoUrl() + "\n"
+ user.getUid() + "\n" + user.getToken(true) + "\n" + user.getProviderId());

Issue is that the photo in i am get from using user.getPhotoUrl() is very small. I need a larger image and can't find a way to do that. Any help would be highly appreciated.
I have already tried this
Get larger facebook image through firebase login
but its not working although they are for swift i don't think the api should differ.

Answer Source

It is not possible to obtain a profile picture from Firebase that is larger than the one provided by getPhotoUrl(). However, the Facebook graph makes it pretty simple to get a user's profile picture in any size you want, as long as you have the user's Facebook ID.

String facebookUserId = "";
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
ImageView profilePicture = (ImageView) findViewById(;

// find the Facebook profile and get the user's id
for(UserInfo profile : user.getProviderData()) {
    // check if the provider id matches ""    
    if(profile.getProviderId().equals(getString(R.string.facebook_provider_id))) {
        facebookUserId = profile.getUid();

// construct the URL to the profile picture, with a custom height
// alternatively, use '?type=small|medium|large' instead of ?height=
String photoUrl = "" + facebookUserId + "/picture?height=500";

// (optional) use Picasso to download and show to image
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download