如何使用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) { } })
添加回答
举报
0/150
提交
取消