簡體   English   中英

無法在circleimageview中設置從Firebase當前用戶拍攝的照片Uri?

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

我正在使用Firebase身份驗證中的Userprofileupdaterequest設置配置文件pic Uri,成功設置並使用Firebase currentuser函數在另一個活動中進行了獲取,如下所示,但無法將其加載到圓圈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);

調試器報告,實際uri在uriString鍵中,這是我應該獲取的uri。

在此圖像中,你們可以看到實際數據在uriString鍵中,想要獲取我如何

對我來說,它可以與畢加索一起使用,但是有時候用戶圖像不存在。 對於這些情況,我使用默認圖像作為占位符和錯誤圖像:

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

在我的XML文件中:

<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"
     />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM