I am retrieving an image from my firebase database and setting it in an Image View. I am using the following code.
mStorageRef.child("Book_Photos/"+firstBook.bid).getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() { @Override public void onSuccess(Uri uri) { Toast.makeText(getApplicationContext(), "GET IMAGE SUCCESSFUL",Toast.LENGTH_LONG).show(); if(uri==null){ Toast.makeText(getApplicationContext(), "URI IS NULL",Toast.LENGTH_LONG).show(); } try { ImageView image2; image2=(ImageView)findViewById(R.id.imageView); image2.setImageURI(null); image2.setImageURI(uri); } catch (Exception e){ } } }).addOnFailureListener(new OnFailureListener() { @Override public void onFailure(@NonNull Exception exception) { Toast.makeText(getApplicationContext(), "GET IMAGE FAILED",Toast.LENGTH_LONG).show(); // Handle any errors } });
The image I am retrieving is not being set. The "GET IMAGE SUCCESSFUL" toast works. The "URI IS NULL" toast does not work. The command image2.setImageURI(null) works.
Just image2.setImageURI(uri) is not working.