Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Firebase存储和图像视图_Java_Android_Firebase_Bitmap_Firebase Storage - Fatal编程技术网

Java Firebase存储和图像视图

Java Firebase存储和图像视图,java,android,firebase,bitmap,firebase-storage,Java,Android,Firebase,Bitmap,Firebase Storage,我想从Firebase存储中获取图像,然后在图像视图中显示。我正在尝试此代码,但不起作用。我总是收到我的“错误”祝酒词。 应用程序正在打开,但我看不到我的JPEG **我找到了一种方法,但对我来说还不够 如果我从build gradle中删除'com.google.firebase:firebase auth:19.3.2',这段代码会正常工作。 我需要FirebaseAuth,因为我有用户登录和注销页面。 您知道Firebase存储和映像的另一种方式吗 谢谢你的帮助 private-Stor

我想从Firebase存储中获取图像,然后在图像视图中显示。我正在尝试此代码,但不起作用。我总是收到我的“错误”祝酒词。 应用程序正在打开,但我看不到我的JPEG

**我找到了一种方法,但对我来说还不够

如果我从build gradle中删除'com.google.firebase:firebase auth:19.3.2',这段代码会正常工作。 我需要FirebaseAuth,因为我有用户登录和注销页面。 您知道Firebase存储和映像的另一种方式吗

谢谢你的帮助

private-StorageReference mStorageReference;
图像视图图像视图;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_vardiya);
mStorageReference=FirebaseStorage.getInstance().getReference().child(“vardiyaandroid.jpeg”);
最终文件localfile;
试一试{
localfile=File.createTempFile(“vardiyaandroid”、“jpeg”);
mStorageReference.getFile(localfile).addOnSuccessListener(新的OnSuccessListener()){
@凌驾
成功时公共无效(FileDownloadTask.TaskSnapshot TaskSnapshot){
Toast.makeText(vardiya.this,“Resim Hazır”,Toast.LENGTH_LONG.show();
位图位图=BitmapFactory.decodeFile(localfile.getAbsolutePath());
(imageView=findviewbyd(R.id.imageView)).setImageBitmap(位图);
}
}).addOnFailureListener(新的OnFailureListener(){
@凌驾
public void onFailure(@NonNull异常e){
Toast.makeText(vardiya.this,“ERROR”,Toast.LENGTH_LONG.show();
}
});
}捕获(IOE异常){
e、 printStackTrace();
}
我发现我的错误

  • 您将更改此代码

    mStorageReference=FirebaseStorage.getInstance().getReference().child(“vardiyaandroid.jpeg”)

  • mStorageReference=FirebaseStorage.getInstance().getReferenceFromUrl(“gs://YOURAPPID.appspot.com/vardiyaandroid.jpeg”); StorageReference-PathReference=mStorageReference.child(“vardiyaandroid.jpeg”)


    确切的错误消息是什么?我没有收到错误消息。“错误”消息是我的toast消息。应用程序正在打开,但我没有看到我的jpeg。请将toast错误更改为:
    toast.makeText(vardiya.this,“错误:+e.getMessage(),toast.LENGTH\u LONG)。show();
    然后发布错误消息。E/StorageException:StorageException已发生。对象在位置不存在。代码:-13010 HttpResult:404
    private StorageReference mStorageReference;
    ImageView imageView;
    
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_vardiya);
    
    mStorageReference=FirebaseStorage.getInstance().getReference().child("vardiyaandroid.jpeg");
        final File localfile;
        try {
            localfile = File.createTempFile("vardiyaandroid","jpeg");
            mStorageReference.getFile(localfile).addOnSuccessListener(new OnSuccessListener<FileDownloadTask.TaskSnapshot>() {
                @Override
                public void onSuccess(FileDownloadTask.TaskSnapshot taskSnapshot) {
                    Toast.makeText(vardiya.this,"Resim Hazır",Toast.LENGTH_LONG).show();
                    Bitmap bitmap = BitmapFactory.decodeFile(localfile.getAbsolutePath());
                    (imageView=findViewById(R.id.imageView)).setImageBitmap(bitmap);
    
                }
            }).addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Toast.makeText(vardiya.this,"ERROR",Toast.LENGTH_LONG).show();
    
                }
            });
            
    
        } catch (IOException e) {
            e.printStackTrace();
        }
    
    and the storege rules must be this:
    
    
    
    rules_version = '2';
    service firebase.storage {
      match /b/{bucket}/o {
        match /{allPaths=**} {
          allow read, writ, auth: if true;
        }
      }
    }