Passing android Bitmap Data within activity using Intent in Android

前端 未结 7 1664
梦如初夏
梦如初夏 2020-11-22 09:36

I hava a Bitmap variable named bmp in Activity1 , and I want to send the bitmap to Activity2

Following is the code I use to pass it with the intent.

7条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 09:48

    Sometimes, the bitmap might be too large for encode&decode or pass as a byte array in the intent. This can cause either OOM or a bad UI experience.

    I suggest to consider putting the bitmap into a static variable of the new activity (the one that uses it) which will carefully be null when you no longer need it (meaning in onDestroy but only if "isChangingConfigurations" returns false).

提交回复
热议问题