pass a bitmap image from one activity to another

后端 未结 8 1611
清酒与你
清酒与你 2020-12-05 21:57

In my app i am displaying no.of images from gallery from where as soon as I select one image , the image should be sent to the new activity where the selected image will be

8条回答
  •  时光说笑
    2020-12-05 22:14

    IGP summed it up clearly, but in my opinion the most efficient way to do it is by passing the URI of the image to the next activity, instead of the Bitmap itself. I'm actually not sure if it's possible to pass whole Bitmaps (or, converted, ByteArrays) of data from one activity to another using Intents - I believe there is a limit as to how much data a Bundle can contain.

    Instead pass the reference you're using to display the image in the first activity. I assume you're using some kind of lazy loading? If not, I highly suggest you do. This way you can simply re-query for the Bitmap via the URI.

    However, I am able to get the images from gallery but as soon as I select one the application crashes

    I'm still puzzled as to how these kinds of problems reach SO. Check the logs, maybe you can figure it out on your own.

提交回复
热议问题