Displaying Google Plus User Profile Image in Android Application

I’m trying to display a profile picture of users registered in my application via Google+, but I don’t know how to do it. To get the image (and other information), google provides the code

@Override
public void onConnected() {
...
if (mPlusClient.getCurrentPerson() != null) {
    Person currentPerson = mPlusClient.getCurrentPerson();
    String personName = currentPerson.getDisplayName();
    String personPhoto = currentPerson.getImage();
    String personGooglePlusProfile = currentPerson.getUrl();
}
}

I know that usually I need to get any image that I want to display from res/drawable..., but I don’t know what to do with the value personPhoto(which somehow changes from type Stringto Imagewhen you paste the code in Eclipse.

+4
source share
2 answers

app/build.gradle:

dependencies {compile 'com.github.bumptech.glide:glide:3.8.0'}

:

private void updateUI(GoogleSignInAccount account) {
    if (account != null){
        text.setText("Sign in as :" +account.getDisplayName());
        email.setText(account.getEmail());
        String imgurl = account.getPhotoUrl().toString();
        Glide.with(this).load(imgurl).into(profile);
        sighIn.setVisibility(View.GONE);
        sighOut.setVisibility(View.VISIBLE);
    }
    else {
        text.setText("signOut");
        sighIn.setVisibility(View.VISIBLE);
        sighOut.setVisibility(View.GONE);
    }
}
+2

Source: https://habr.com/ru/post/1526275/


All Articles