Hot questions for Using Glide in android intent

Top 10 Java Open Source / Glide / android intent


I am beginner in android studio and i think it will be easy but also I am not getting that

How to share image from link ,i.e, without downloading the image just share on social media like whats app .I can download the image and then share and then delete that but I do not want to do that. I am using glide library to load the image in Image view and then when a user click on a button it will just share its image which is showing in image view and whose link i have and then come back to the app.

I am using Glide library for loading image.

Any help will be grateful.

Thanks in advance.


first you need to load image in glide(as you are using glide ) then you can share it to anywhere but image will be saved to storage

code to load image from glide (image is being saved to storage, you can delete it later)

                    .load(imagelink)   \\link of your image file (url)

                    .into(new SimpleTarget<Bitmap>(250, 250) {
                        public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {

                            Intent intent = new Intent(Intent.ACTION_SEND);
                            intent.putExtra(Intent.EXTRA_TEXT, "Hey view/download this image");
                            String path = MediaStore.Images.Media.insertImage(getContentResolver(), resource, "", null);

                            Uri screenshotUri = Uri.parse(path);

                            intent.putExtra(Intent.EXTRA_STREAM, screenshotUri);

                            startActivity(Intent.createChooser(intent, "Share image via..."));

                        public void onLoadFailed(Exception e, Drawable errorDrawable) {
                            Toast.makeText(getApplicationContext(), "Something went wrong", Toast.LENGTH_SHORT).show();

                            super.onLoadFailed(e, errorDrawable);

                        public void onLoadStarted(Drawable placeholder) {
                            Toast.makeText(getApplicationContext(), "Starting", Toast.LENGTH_SHORT).show();


If you want then delete that image from storage by adding some more code


I have already used Glide library to download an image, but I want to reuse that image in another activity without re downloading it again. How to do it?

I have tried to use .diskCacheStrategy(DiskCacheStrategy.ALL) but I didn't know what to do next..


I was expecting that I could pass it as an extra data to intent as an image not as URL


If you use .diskCacheStrategy(DiskCacheStrategy.ALL) it will download it first time only. Second time you load the image and use the same URL it will take it from Cache.

So just pass the URL to another Activity and use the same Glide code


I am using Glide to cache Images in an ImageView. Now I want to set the image in the ImageView as the wallpaper of the phone without using the WallpaperManager, because the WallpaperManager does not give the option to crop/pan the Image like the wallpaper setting of default gallery app does.

I want to set Wallpaper using:




but I don't know how to pass the Bitmap/drawable from the ImageView to that intent. Here's my code:

Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
            intent.setDataAndType(ContactsContract.Contacts.CONTENT_URI, "image/*");
            intent.putExtra("mimeType", "image/jpeg");
            intent.putExtra("image", imageView.getDrawingCache());
            startActivity(Intent.createChooser(intent, "Select Wallpaper"));

When I execute this code, I get a pull-up menu with installed galleries to select wallpaper. And when I choose one of them i get a Toast-

"Cannot load the image."

which is probably because I'm not passing any image to the Intent. Please Help, I've been searching for this for hours.

I found Similar questions here, here & here, but none of them worked for me.


So, as I've solved the problem, now I'm writing the solution here(in case anybody else needs it).

    myDir = new File(root + "/Wallpy/");     //this is the name of the containing folder
    final File imageFile = new File(myDir, "abcd.jpg");     //name of the image file
    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
                    intent.setDataAndType(Uri.fromFile(imageFile), "image/*");
                    startActivity(Intent.createChooser(intent, "Select Wallpaper"));

where, imageFile is the File that is needed to be set as wallpaper.


I'm trying to share GIF file. I want to share it via any social networking apps, I have a problem with file name. I don't how to get name file. This is my code:

llsetwallpapers.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // set as wallpapers
            lt.setText("Please Wait ...");
                    .into(new SimpleTarget<Bitmap>() {
                        public void onResourceReady(Bitmap resource, GlideAnimation<?super Bitmap> glideAnimation) {
                            File file = new File file = new File(getApplicationContext().getExternalCacheDir() , namefile)
                            Uri uri = Uri.fromFile(file);
                            Intent shareIntent = new Intent();
                            shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
                            startActivity(Intent.createChooser(shareIntent, "Share with"));


The problem you are trying to solve is discussed at github issues, where RĂ³bert Papp has provided an example implementation for sharing a file downloaded by Glide.

The key part for you - is to get a reference to the File. That can be done with downloadOnly():

    File file = Glide
                    .downloadOnly(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)

Having a File, you can use FileProvider API in order to share the file.