activity之间数据传递,数据量过大导致无法启动

来源:互联网 发布:淘宝网店模块 编辑:程序博客网 时间:2024/06/05 17:01

不知道各位开发童鞋有没有遇到过想把一个activity的集合传递到另一个activity的时候遇到TransactionTooLargeException异常,这是传输数据过大异常。安卓官方文档中提到The Binder transaction buffer has a limited fixed size, currently 1Mb, which is shared by all transactions in progress for the process. Consequently this exception can be thrown when there are many transactions in progress even when most of the individual transactions are of moderate size.即缓冲区最大1MB,并且这是该进程中所有正在进行中的传输对象所公用的。至于都有哪些传输对象、具体怎么分配,这个还不太清楚。可以肯定的是Activity之间使用Parcel传输数据是有大小限制的。

    那么如何解决这个问题呢?

    我采取的方式就是把需要传递的集合保存在application中,需要用的时候再去取这个集合,当然在退出的时候,要及时清空这个集合。

1 0
原创粉丝点击