Reputation: 4620
I was trying to send some imageviews from one activity to the other,I have also seen other questions similar to this one and the suggestions regarding sending the ID of the imageview from one activity to the other,but in my case the difference is i am sending more than one imageviews,and also these imageviews are created dyamically from a Bigger imageview,
i.e I am creating 12 small imageviews from a bigger imageview by using
Bitmap resized=Bitmap.createBitmap(bmp, 0, 0, width, height);
in such a way that combination of all of them will give me back the original bigger imageview,
and want to pass them all to the next activity.
Hence i want some suggestions about the procedure i am following,and how can i do it in a better way.
Thanks !
Upvotes: 0
Views: 478
Reputation: 7035
I also required to implement similar case.
First of all you cannot send big bitmap objects through Intents. It crashes the application because Intents, I believe, have smaller capacity like 1mb.
You have following options:
1-Send image file paths through intent extras.
2-Save image file path in a static field and read it in other activity.
3-Save bitmap to the file and send its path using option (1,2) and delete the image file in new activity.
4-Put image bitmaps in a static arraylist of bitmaps and then read it in other activity.
5-Put image filenames in a static arraylist of strings and then read it in other activity.
Basically, you have to recreate them all in new activity or save them in a static field and read there afterwards.
Maybe you can implement more complicated solution like, if the application have sdcard write access then write it to file else save it in memory using static arraylist.
What I do is that, when PictureCallback is getting image data, I save it on sdcard and return the path to the other activities.
Upvotes: 1
Reputation: 5464
You should never, never ever send the bitmaps directly - just pass the URI or URL or Filename to the next Activity and load it from there...
Upvotes: 1