Save image in onsaveinstatncestate: A heavy image downloaded from internet in onCreate() of an activity. Is it possible to save it in onSaveInstanceState() in case of configurationChanges?

Answer:  no, we have to use some static reference to it.

Description:
Generally configuration changes causes activity to get destroyed and recreated. So if you have downloaded heavy image from internet in onCreate() function, then there is a chance that it will be re downloaded in onCreate() one more time if user rotates the phone. To avoid this we can have a static reference to that image to avoid multiple downloads.

No comments:

Post a Comment