gpt4 book ai didi

android - 如何从 firebase 获取 url 图片并将其保存在字符串中?

转载 作者:行者123 更新时间:2023-11-29 23:15:52 25 4
gpt4 key购买 nike

如何从以下位置获取字符串 url:

StorageReference file_path = mStorageReference.child("Posts_images")
.child(currentUser + ".jpg");
file_path.putFile(pickedImageUri).addOnCompleteListener(new OnCompleteListener <UploadTask.TaskSnapshot>() {
@Override
public void onComplete(@NonNull Task<UploadTask.TaskSnapshot> task) {
if (task.isSuccessful()) {
//
String msg = getString(R.string.imageUploadSuccessfully);
Toast.makeText(AddPost_Activity.this, msg, Toast.LENGTH_SHORT).show();
finish();
}

最佳答案

你需要用到这个

 .addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
if (downloadUri != null) {
String photoStringUrl = downloadUri.toString();
}
}
}
});

关于android - 如何从 firebase 获取 url 图片并将其保存在字符串中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55388216/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com