亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何檢索和顯示配置文件圖片 Android firebase?

如何檢索和顯示配置文件圖片 Android firebase?

aluckdog 2021-10-13 16:26:59
如何使用uid檢索和顯示當前用戶的個人資料圖片?我已經使用 uid 將圖像連接到用戶 uid,但不確定如何檢索和顯示。這就是我將它上傳到 Firebase 存儲的方式mProfilePic.setOnClickListener(new View.OnClickListener() {        @Override        public void onClick(View v) {            Intent intent = new Intent(Intent.ACTION_PICK);            intent.setType("image/*");            intent.setAction(Intent.ACTION_GET_CONTENT);            startActivityForResult(Intent.createChooser(intent, "Select Picture"), GALLERY_INTENT);        }    });我讓用戶從那里的手機存儲中單擊一個圖像視圖,并使用當前登錄的用戶 uid 上傳該圖像。FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) {    super.onActivityResult(requestCode, resultCode, data);    if(requestCode == GALLERY_INTENT && resultCode == RESULT_OK && data != null && data.getData() != null){        mainImageURI = data.getData();        try {            Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), mainImageURI);            mProfilePic.setImageBitmap(bitmap);            final ProgressDialog proDialog = new ProgressDialog(HomeActivity.this);            proDialog.setTitle("Uploading...");            proDialog.show();            String userUid = FirebaseAuth.getInstance().getCurrentUser().getUid();            UploadTask uploadTask = FirebaseStorage.getInstance().getReference().child("newFolder").child(userUid).putFile(mainImageURI);            uploadTask                    .addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {                        @Override                        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {                        }                    })                    .addOnFailureListener(new OnFailureListener() {                        @Override                        public void onFailure(@NonNull Exception e) {                        }                    })
查看完整描述

2 回答

?
弒天下

TA貢獻1818條經驗 獲得超8個贊

維護一個數據庫,您可以在其中根據 uid 保存圖像 url。然后使用該 url 從數據庫中檢索您的個人資料圖片


查看完整回答
反對 回復 2021-10-13
  • 2 回答
  • 0 關注
  • 199 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號