0

I passed image url form adapter and want to download image from url :

imageView = (ImageView) findViewById(R.id.image_view);
buttonDownload = (Button)findViewById(R.id.buttonDownload);

String strImage= String.valueOf(getIntent().getStringExtra("URL"));

Glide.with(this)
    .load(strImage)
    .into(imageView);

buttonDownload.setOnClickListener(new View.OnClickListener() {
    @Override
        public void onClick(View v) {
            //what to do
        }
    });
Mickaël Leger
  • 3,426
  • 2
  • 17
  • 36
Mu PK
  • 3
  • 4

2 Answers2

0

You can create custom callback within Glide for saving image after, like this:

Glide.with(context)
  .asBitmap()
  .load(url)
  .into(new Target<Bitmap>() {
     ...
});

You can set your target and get bitmap from it and then save it wherever you want it.

Check for more documentation on Glide official page: https://bumptech.github.io/glide/doc/getting-started.html

mmmatey
  • 666
  • 8
  • 15
0
public static void downloadFile(Context context,String file,String fileName)
{
    DownloadTask downloadTask = new DownloadTask(context,file,fileName);
    downloadTask.execute(file);
}