简体   繁体   中英

can't set photo Uri which is taken from firebase current user in circleimageview.?

I'm setting up profile pic Uri using Userprofileupdaterequest in Firebase auth successfully set and fetched in another activity using Firebase currentuser function as below but couldn't load it in circle ImageView....

    mAuth = FirebaseAuth.getInstance();

    FirebaseUser user = mAuth.getCurrentUser();

    if (user == null) {
        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);

    } else {
        String name = user.getDisplayName();
        String email = user.getEmail();
        Uri photoUrl = user.getPhotoUrl();

        tv_username.setText(name);

        Picasso.with(Display.this)
                .load(photoUrl)
                .into(iv_profile);

        // Check if user's email is verified
        boolean emailVerified = user.isEmailVerified();
        String verified;
        if (emailVerified) {
            verified = "success";
        } else {
            verified = "not verified";
        }
        // The user's ID, unique to the Firebase project. Do NOT use this value to
        // authenticate with your backend server, if you have one. Use
        // FirebaseUser.getToken() instead.
        String uid = user.getUid();
        tv_display.setText(email);

        tv_email_verification.setText(verified);

debugger report,actual uri is in uriString key thats the uri i should fetch how can i do that..

在此图像中,你们可以看到实际数据在uriString键中,想要获取我如何

For me it's working with Picasso, but there are times when user image does not exist. For these cases, I used a default image as placeholder and error images:

Picasso.with(this)
        .load(photoUri)
        .placeholder(R.mipmap.ic_unknown_user) 
        .error(R.mipmap.ic_unknown_user)        
        .into(imgProfileImage);

And in my XML file:

<de.hdodenhof.circleimageview.CircleImageView
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/imgProfileImage"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:src="@mipmap/ic_usuario"
    app:border_color="#ffffff"
    app:border_width="2dp"
    android:layout_marginLeft="12dp"
    android:layout_marginStart="12dp"
    android:layout_marginTop="28dp"
     />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM