0

I am trying to show firebase image into the notification which requires a bitmap image to be shown. However i am getting exception. However i am able to show the same image using imageView using Glide library only. Here are the two codebase.

Code that loads the image correctly into imageView

private void DisplayImage () {
    FirebaseStorage storage = mFirebaseService.getFirebaseStorageInstance();

    getBitmapAsyncAndDoWork(mSpelling.getImagePath());
    // Reference to an image file in Cloud Storage
    StorageReference storageReference = storage.getReferenceFromUrl(mSpelling.getImagePath());

    // ImageView in your Activity
    ImageView imageView = findViewById(R.id.imageView);

    Glide.with(this).load(storageReference).into(imageView);
}

Code that runs into exception com.bumptech.glide.load.engine.GlideException: Failed to load resource

private void getBitmapAsyncAndDoWork(String imageUrl) {
    final Bitmap[] bitmap = {null};

    Glide.with(getApplicationContext())
            .asBitmap()
            .load(imageUrl)
            .addListener(new RequestListener<Bitmap>() {
                @Override
                public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
                    return false;
                }

                @Override
                public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
                    return false;
                }
            })
            .into(new CustomTarget<Bitmap>() {
                @Override
                public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {

                    bitmap[0] = resource;
                    // TODO Do some work: pass this bitmap
                }

                @Override
                public void onLoadCleared(@Nullable Drawable placeholder) {
                }
            });
}

Here are the exception details

enter image description here

Can someone please point out on what can be the issue while loading it as Bitmap?

Rajan Phatak
  • 524
  • 8
  • 24

0 Answers0