In my application, I have several images downloaded from the internet and when I click on those images, the images will be pass to an image viewer (a new activity). In term of memory usage, which is the best way to pass the images to image viewer by using intents? Should I pass the url of the images to the image viewer or pass the bitmaps instead?
Asked
Active
Viewed 65 times
2 Answers
1
If you have downloaded images, you must send the "Path" of image where it is downloaded using intent. From the path received, create a file and make a bitmap of that image.

Harish Vats
- 662
- 6
- 21
-
So you mean that it is better to send the path of the images instead of the whole bitmap? – Min Hou Lai Dec 02 '15 at 06:12
-
Yaa, passing a string is much better than passing bitmap. And what if your image size is large?? For more you can refer here: http://stackoverflow.com/questions/2459524/how-can-i-pass-a-bitmap-object-from-one-activity-to-another – Harish Vats Dec 02 '15 at 06:17
0
Actually, there are likely no difference in memory footprint. Bitmap
is passed through Intent
as Parcelable
, and you can dig into Android SDK source code to find out that only link to it is written.
On the other hand, it'll be safer to pass String
inside intent in terms of app lifecycle — if the app will be suspended, there can be issues with restoring bitmap from saved intent.

OleGG
- 8,589
- 1
- 28
- 34