Passing Cache Image from one Activity to another ActivityGlide : How to find if the image is already cached and use the cached version?How to control web page caching, across all browsers?How to save an Android Activity state using save instance state?Strange out of memory issue while loading an image to a Bitmap objectLazy load of images in ListViewFling gesture detection on grid layoutStop EditText from gaining focus at Activity startupHow do I pass data between Activities in Android application?Flash CS4 refuses to let goDisabling Chrome cache for website developmentHow to remove a particular image URL from disk cache in Glide?

Is it possible to 'live off the sea'

Why is one of Madera Municipal's runways labelled with only "R" on both sides?

Using a found spellbook as a Sorcerer-Wizard multiclass

An average heaven where everyone has sexless golden bodies and is bored

Why did Canadian English remain so close to standard U.S English?

PhD - Well known professor or well known school?

Watts vs. Volt Amps

Are there downsides to using std::string as a buffer?

Can the poison from Kingsmen be concocted?

Frame failure sudden death?

Dual boot macOS Catalina 10.15 and macOS Mojave 10.14

How do governments keep track of their issued currency?

Trapping Rain Water

Can a user sell my software (MIT license) without modification?

Genetic limitations to learn certain instruments

Implement Homestuck's Catenative Doomsday Dice Cascader

What's up with this leaf?

Why doesn't Adrian Toomes give up Spider-Man's identity?

Preventing Employees from either switching to Competitors or Opening Their Own Business

Payment instructions allegedly from HomeAway look fishy to me

Can an Aarakocra use a shield while flying?

Was there a priest on the Titanic who stayed on the ship giving confession to as many as he could?

How to project 3d image in the planes xy, xz, yz?

Using "subway" as name for London Underground?



Passing Cache Image from one Activity to another Activity


Glide : How to find if the image is already cached and use the cached version?How to control web page caching, across all browsers?How to save an Android Activity state using save instance state?Strange out of memory issue while loading an image to a Bitmap objectLazy load of images in ListViewFling gesture detection on grid layoutStop EditText from gaining focus at Activity startupHow do I pass data between Activities in Android application?Flash CS4 refuses to let goDisabling Chrome cache for website developmentHow to remove a particular image URL from disk cache in Glide?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I load an image from url into an imageview in Activity 1 (using glide). When I switch to activity 2 ,I disconnect my network connection and I'm required to load the same image in another imageview. How am I supposed to achieve this? Can this be done by using the image cached somewhere by glide?










share|improve this question



















  • 1





    this solution would be helpful stackoverflow.com/questions/32406489/…

    – Ajay Venugopal
    Sep 25 '17 at 6:27

















1















I load an image from url into an imageview in Activity 1 (using glide). When I switch to activity 2 ,I disconnect my network connection and I'm required to load the same image in another imageview. How am I supposed to achieve this? Can this be done by using the image cached somewhere by glide?










share|improve this question



















  • 1





    this solution would be helpful stackoverflow.com/questions/32406489/…

    – Ajay Venugopal
    Sep 25 '17 at 6:27













1












1








1


1






I load an image from url into an imageview in Activity 1 (using glide). When I switch to activity 2 ,I disconnect my network connection and I'm required to load the same image in another imageview. How am I supposed to achieve this? Can this be done by using the image cached somewhere by glide?










share|improve this question
















I load an image from url into an imageview in Activity 1 (using glide). When I switch to activity 2 ,I disconnect my network connection and I'm required to load the same image in another imageview. How am I supposed to achieve this? Can this be done by using the image cached somewhere by glide?







android caching android-glide






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 24 at 16:21









Zoe

15.2k85789




15.2k85789










asked Sep 25 '17 at 6:24









Uday KiranUday Kiran

112




112







  • 1





    this solution would be helpful stackoverflow.com/questions/32406489/…

    – Ajay Venugopal
    Sep 25 '17 at 6:27












  • 1





    this solution would be helpful stackoverflow.com/questions/32406489/…

    – Ajay Venugopal
    Sep 25 '17 at 6:27







1




1





this solution would be helpful stackoverflow.com/questions/32406489/…

– Ajay Venugopal
Sep 25 '17 at 6:27





this solution would be helpful stackoverflow.com/questions/32406489/…

– Ajay Venugopal
Sep 25 '17 at 6:27












3 Answers
3






active

oldest

votes


















1














In your Activity1



Convert ImageView to Bitmap



imageView.buildDrawingCache();
Bitmap bmp = imageView.getDrawingCache();

Intent intent = new Intent(this, Activity2.class);
intent.putExtra("img", bmp);


In Activity2



 Bitmap bitmap = (Bitmap) intent.getParcelableExtra("img");
imageView.setImageBitmap(bitmap);





share|improve this answer






























    0














    Instead of caching image using glide create your own cache folder and cache images into it.It can be easily accessible throughout the application



     Glide.with(yourImageView.getContext())
    .load("your url")
    .asBitmap()
    .placeholder(R.drawable.place_holder)
    .error(R.drawable.place_holder)
    .into(new SimpleTarget<Bitmap>()
    @Override
    public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition)

    //Create a folder for caching and add images from here


    );





    share|improve this answer






























      0














      I use this and this works for me:



      Add a OnClickListener like below:



       Glide.with(this)
      .load("URL HERE")
      .diskCacheStrategy(DiskCacheStrategy.ALL)
      .into(Image);

      Image.setOnClickListener(new View.OnClickListener()
      @Override
      public void onClick(View v)
      Intent intent= new Intent(context,FullScreenImage.class);
      intent.putExtra("image_url", "URL HERE" );
      startActivity(intent);

      );


      Then in the new Activity:



       public class FullScreenImage extends AppCompatActivity 


      ImageView myImage;
      String url = "";

      @Override
      protected void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_full_screen_image);

      url = getIntent().getStringExtra("image_url");

      myImage = findViewById(R.id.myImage);
      Glide.with(this).load(url)
      .placeholder(R.drawable.ic_image_send_24dp)
      .error(R.drawable.ic_image_send_24dp)
      .diskCacheStrategy(DiskCacheStrategy.ALL)
      .into(myImage);




      PS: Dont forget to use .diskCacheStrategy(DiskCacheStrategy.ALL) in both the activities while using glide.






      share|improve this answer























        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46398802%2fpassing-cache-image-from-one-activity-to-another-activity%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        1














        In your Activity1



        Convert ImageView to Bitmap



        imageView.buildDrawingCache();
        Bitmap bmp = imageView.getDrawingCache();

        Intent intent = new Intent(this, Activity2.class);
        intent.putExtra("img", bmp);


        In Activity2



         Bitmap bitmap = (Bitmap) intent.getParcelableExtra("img");
        imageView.setImageBitmap(bitmap);





        share|improve this answer



























          1














          In your Activity1



          Convert ImageView to Bitmap



          imageView.buildDrawingCache();
          Bitmap bmp = imageView.getDrawingCache();

          Intent intent = new Intent(this, Activity2.class);
          intent.putExtra("img", bmp);


          In Activity2



           Bitmap bitmap = (Bitmap) intent.getParcelableExtra("img");
          imageView.setImageBitmap(bitmap);





          share|improve this answer

























            1












            1








            1







            In your Activity1



            Convert ImageView to Bitmap



            imageView.buildDrawingCache();
            Bitmap bmp = imageView.getDrawingCache();

            Intent intent = new Intent(this, Activity2.class);
            intent.putExtra("img", bmp);


            In Activity2



             Bitmap bitmap = (Bitmap) intent.getParcelableExtra("img");
            imageView.setImageBitmap(bitmap);





            share|improve this answer













            In your Activity1



            Convert ImageView to Bitmap



            imageView.buildDrawingCache();
            Bitmap bmp = imageView.getDrawingCache();

            Intent intent = new Intent(this, Activity2.class);
            intent.putExtra("img", bmp);


            In Activity2



             Bitmap bitmap = (Bitmap) intent.getParcelableExtra("img");
            imageView.setImageBitmap(bitmap);






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Sep 25 '17 at 6:27









            vishal jangidvishal jangid

            1,998921




            1,998921























                0














                Instead of caching image using glide create your own cache folder and cache images into it.It can be easily accessible throughout the application



                 Glide.with(yourImageView.getContext())
                .load("your url")
                .asBitmap()
                .placeholder(R.drawable.place_holder)
                .error(R.drawable.place_holder)
                .into(new SimpleTarget<Bitmap>()
                @Override
                public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition)

                //Create a folder for caching and add images from here


                );





                share|improve this answer



























                  0














                  Instead of caching image using glide create your own cache folder and cache images into it.It can be easily accessible throughout the application



                   Glide.with(yourImageView.getContext())
                  .load("your url")
                  .asBitmap()
                  .placeholder(R.drawable.place_holder)
                  .error(R.drawable.place_holder)
                  .into(new SimpleTarget<Bitmap>()
                  @Override
                  public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition)

                  //Create a folder for caching and add images from here


                  );





                  share|improve this answer

























                    0












                    0








                    0







                    Instead of caching image using glide create your own cache folder and cache images into it.It can be easily accessible throughout the application



                     Glide.with(yourImageView.getContext())
                    .load("your url")
                    .asBitmap()
                    .placeholder(R.drawable.place_holder)
                    .error(R.drawable.place_holder)
                    .into(new SimpleTarget<Bitmap>()
                    @Override
                    public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition)

                    //Create a folder for caching and add images from here


                    );





                    share|improve this answer













                    Instead of caching image using glide create your own cache folder and cache images into it.It can be easily accessible throughout the application



                     Glide.with(yourImageView.getContext())
                    .load("your url")
                    .asBitmap()
                    .placeholder(R.drawable.place_holder)
                    .error(R.drawable.place_holder)
                    .into(new SimpleTarget<Bitmap>()
                    @Override
                    public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition)

                    //Create a folder for caching and add images from here


                    );






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Sep 25 '17 at 6:32









                    sharath kumarsharath kumar

                    3,0311616




                    3,0311616





















                        0














                        I use this and this works for me:



                        Add a OnClickListener like below:



                         Glide.with(this)
                        .load("URL HERE")
                        .diskCacheStrategy(DiskCacheStrategy.ALL)
                        .into(Image);

                        Image.setOnClickListener(new View.OnClickListener()
                        @Override
                        public void onClick(View v)
                        Intent intent= new Intent(context,FullScreenImage.class);
                        intent.putExtra("image_url", "URL HERE" );
                        startActivity(intent);

                        );


                        Then in the new Activity:



                         public class FullScreenImage extends AppCompatActivity 


                        ImageView myImage;
                        String url = "";

                        @Override
                        protected void onCreate(Bundle savedInstanceState)
                        super.onCreate(savedInstanceState);
                        setContentView(R.layout.activity_full_screen_image);

                        url = getIntent().getStringExtra("image_url");

                        myImage = findViewById(R.id.myImage);
                        Glide.with(this).load(url)
                        .placeholder(R.drawable.ic_image_send_24dp)
                        .error(R.drawable.ic_image_send_24dp)
                        .diskCacheStrategy(DiskCacheStrategy.ALL)
                        .into(myImage);




                        PS: Dont forget to use .diskCacheStrategy(DiskCacheStrategy.ALL) in both the activities while using glide.






                        share|improve this answer



























                          0














                          I use this and this works for me:



                          Add a OnClickListener like below:



                           Glide.with(this)
                          .load("URL HERE")
                          .diskCacheStrategy(DiskCacheStrategy.ALL)
                          .into(Image);

                          Image.setOnClickListener(new View.OnClickListener()
                          @Override
                          public void onClick(View v)
                          Intent intent= new Intent(context,FullScreenImage.class);
                          intent.putExtra("image_url", "URL HERE" );
                          startActivity(intent);

                          );


                          Then in the new Activity:



                           public class FullScreenImage extends AppCompatActivity 


                          ImageView myImage;
                          String url = "";

                          @Override
                          protected void onCreate(Bundle savedInstanceState)
                          super.onCreate(savedInstanceState);
                          setContentView(R.layout.activity_full_screen_image);

                          url = getIntent().getStringExtra("image_url");

                          myImage = findViewById(R.id.myImage);
                          Glide.with(this).load(url)
                          .placeholder(R.drawable.ic_image_send_24dp)
                          .error(R.drawable.ic_image_send_24dp)
                          .diskCacheStrategy(DiskCacheStrategy.ALL)
                          .into(myImage);




                          PS: Dont forget to use .diskCacheStrategy(DiskCacheStrategy.ALL) in both the activities while using glide.






                          share|improve this answer

























                            0












                            0








                            0







                            I use this and this works for me:



                            Add a OnClickListener like below:



                             Glide.with(this)
                            .load("URL HERE")
                            .diskCacheStrategy(DiskCacheStrategy.ALL)
                            .into(Image);

                            Image.setOnClickListener(new View.OnClickListener()
                            @Override
                            public void onClick(View v)
                            Intent intent= new Intent(context,FullScreenImage.class);
                            intent.putExtra("image_url", "URL HERE" );
                            startActivity(intent);

                            );


                            Then in the new Activity:



                             public class FullScreenImage extends AppCompatActivity 


                            ImageView myImage;
                            String url = "";

                            @Override
                            protected void onCreate(Bundle savedInstanceState)
                            super.onCreate(savedInstanceState);
                            setContentView(R.layout.activity_full_screen_image);

                            url = getIntent().getStringExtra("image_url");

                            myImage = findViewById(R.id.myImage);
                            Glide.with(this).load(url)
                            .placeholder(R.drawable.ic_image_send_24dp)
                            .error(R.drawable.ic_image_send_24dp)
                            .diskCacheStrategy(DiskCacheStrategy.ALL)
                            .into(myImage);




                            PS: Dont forget to use .diskCacheStrategy(DiskCacheStrategy.ALL) in both the activities while using glide.






                            share|improve this answer













                            I use this and this works for me:



                            Add a OnClickListener like below:



                             Glide.with(this)
                            .load("URL HERE")
                            .diskCacheStrategy(DiskCacheStrategy.ALL)
                            .into(Image);

                            Image.setOnClickListener(new View.OnClickListener()
                            @Override
                            public void onClick(View v)
                            Intent intent= new Intent(context,FullScreenImage.class);
                            intent.putExtra("image_url", "URL HERE" );
                            startActivity(intent);

                            );


                            Then in the new Activity:



                             public class FullScreenImage extends AppCompatActivity 


                            ImageView myImage;
                            String url = "";

                            @Override
                            protected void onCreate(Bundle savedInstanceState)
                            super.onCreate(savedInstanceState);
                            setContentView(R.layout.activity_full_screen_image);

                            url = getIntent().getStringExtra("image_url");

                            myImage = findViewById(R.id.myImage);
                            Glide.with(this).load(url)
                            .placeholder(R.drawable.ic_image_send_24dp)
                            .error(R.drawable.ic_image_send_24dp)
                            .diskCacheStrategy(DiskCacheStrategy.ALL)
                            .into(myImage);




                            PS: Dont forget to use .diskCacheStrategy(DiskCacheStrategy.ALL) in both the activities while using glide.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Aug 12 '18 at 17:42









                            Ashish YadavAshish Yadav

                            1841220




                            1841220



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46398802%2fpassing-cache-image-from-one-activity-to-another-activity%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                                Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript