Answer the question
In order to leave comments, you need to log in
How to download image from firebase storage?
It is not possible to download the image into memory and load it into ImageView. Please help, I'm completely confused. Every time the app crashes , Here is the code:
Image_kyrs = (ImageView) findViewById(R.id.imageView);
FirebaseStorage storage = FirebaseStorage.getInstance();
StorageReference storageRef = storage.getReferenceFromUrl("gs://*******.appspot.com");
StorageReference pathReference = storageRef.child("scoin.png");
final long ONE_MEGABYTE = 1024 * 1024;
gsReference.getBytes(ONE_MEGABYTE).addOnSuccessListener(new OnSuccessListener<byte[]>() {
@Override
public void onSuccess(byte[] bytes) {
Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
Image_kyrs.setImageBitmap(bmp);
Toast toast = Toast.makeText(getApplicationContext(),
"Картинка скачалась!", Toast.LENGTH_SHORT);
toast.show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
Toast toast = Toast.makeText(getApplicationContext(),
"Ошибка!", Toast.LENGTH_SHORT);
toast.show();
}
});
}
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setImageBitmap(android.graphics.Bitmap)' on a null object reference
StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
StorageException has occurred.
User does not have permission to access this object.
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question