我的图片文件夹未出现在图库中

时间:2017-05-08 18:27:35

标签: android imageview gallery

我试图从网址下载图片并将其保存在特殊文件夹中 是的我做到了,但我的图片文件夹没有出现在图库中,请提出任何解决此问题的建议。

llDownloadWallpaper.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // set as wallpapers
            lt.setText("Please Wait ...");
            lt.setTranslationY(100);
            lt.show();
            Glide.with(getApplication())
                    .load(url)
                    .asBitmap()
                    .toBytes(Bitmap.CompressFormat.JPEG, 80)
                    .into(new SimpleTarget<byte[]>() {
                        @Override public void onResourceReady(final byte[] resource, GlideAnimation<? super byte[]> glideAnimation) {
                            new AsyncTask<Void, Void, Void>() {
                                @Override protected Void doInBackground(Void... params) {
                                    File sdcard = Environment.getExternalStorageDirectory();
                                    File file = new File( sdcard+ "/ARTApp/"+"ART_"+System.currentTimeMillis()+".jpg");
                                    File dir = file.getParentFile();
                                    try {
                                        if (!dir.mkdirs() && (!dir.exists() || !dir.isDirectory())) {
                                            throw new IOException("Cannot ensure parent directory for file " + file);
                                        }
                                        BufferedOutputStream s = new BufferedOutputStream(new FileOutputStream(file));
                                        s.write(resource);
                                        s.flush();
                                        s.close();

                                    } catch (IOException e) {
                                        e.printStackTrace();
                                        lt.error();
                                    }
                                    return null;
                                }
                            }.execute();
                            lt.success();
                        }
                    })
            ;
        }
    });
}

0 个答案:

没有答案