android - 使用 picasso : out of memory exception 从 firebase 存储下载图像

标签 android android-recyclerview out-of-memory picasso android-bitmap

我正在开发一个需要从 firebase 后端下载图像的 android 应用程序,但是在我的 recyler View 中下载并显示 5 到 6 个图像后,抛出内存不足异常。

我使用了一个图像压缩库,每张图像的大小将近 300 到 400 KB。

I have added <application android:largeHeap="true" but still there is same issue

我的代码:

//Retriving image from picasso
            Picasso.Builder builder = new Picasso.Builder(c);
            builder.listener(new Picasso.Listener() {
                @Override
                public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
                    Toast.makeText(c,exception.getMessage(),Toast.LENGTH_LONG).show();
                }
            });
            Picasso pic = builder.build();
            pic.load(currentPost.getDownloadlinkDB()).into(((MyViewHolder_Image) holder).imageView, new Callback() {
                @Override
                public void onSuccess() {

                }

                @Override
                public void onError() {
                    Toast.makeText(c, "Problem in downloading image from server", Toast.LENGTH_SHORT).show();
                }
            });

异常快照 enter image description here

如何解决这个问题?

最佳答案

将此添加到您的 list 文件中。内部应用程序标签

<application
     android:largeHeap="true"

关于android - 使用 picasso : out of memory exception 从 firebase 存储下载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43224692/

相关文章:

android - 在代码中定义选择器

android - 在android上为多个工具栏设置菜单

android - RecyclerView 每隔几个项目都是一样的——可扩展项目

tensorflow - GPU上的Tensorflow OOM

java - 在 h2o 中加载大于内存大小的数据

android - 关于Android文档的说明

java - 未为 recyclerView 触发触摸事件 (onClickListener)

android - RecyclerView 与 GridLayoutManager 试图解决 wrap_content

.net - 当我达到 1GB 时出现 OutOfMemoryException

android - 我可以选择我的 Android 应用程序在运行时使用的 OpenGL 版本吗?