FAILED BINDER TRANSACTION while passing Bitmap from one activity to another

后端 未结 2 1281
再見小時候
再見小時候 2020-12-18 15:22

I want to pass a image as a bitmap from one activity to another. And i want to know whether it is possible to do like that.

Sending Activity

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-18 15:48

    You can use a global class with a static bitmap object in it, something like this:

    public class Global { static Bitmap img; }

    Before stating the activity by intent, assign your bitmap to this Global class attribute:

    Global.img = your_bitmap_img;

    After starting your activity, you can get back your bitmap by:

    bitmap_in_new_activity = Global.img;

    I know global variables are too dangerous for debugging but this technique helps us to transfer large data from one activity to another.The binder transaction buffer has a limited fixed size, currently 1Mb regardless of your device capabilities or your app.

提交回复
热议问题