美文网首页
TransactionTooLargeException

TransactionTooLargeException

作者: 陈萍儿Candy | 来源:发表于2020-08-26 21:24 被阅读0次

android.os.TransactionTooLargeException data parcel size 1807092 bytes
android.app.ActivityThread$StopInfo.run(ActivityThread.java:3803)


image.png

bundle中不能传太大的数据,bundle在一个进程中缓存大小是1M,被这个进程共享。超过/接近1M就会崩溃报上面的错
页面之间或者fragment传递的数据,不要太大,太大的可以存储本地,或者set方法,或者eventbus,等其他方法,不要放到bundle中。
onSaveInstanceState()方法也不能存储过多的数据

https://github.com/guardian/toolargetool 这个toolargetool可以检测你的项目中有哪些地方传的数据或者保存在bundle中的数据太大,有风险。

使用Bundle传递对象,首先要将其序列化,但是,在Android中要使用这种传递对象的方式需要用到Android Parcel机制,即,Android实现的轻量级的高效的对象序列化和反序列化机制。所以不能传大数据量的数据https://www.cnblogs.com/zhujiabin/p/5693564.html

targetSdkVersion在23及其以下只会有TransactionTooLargeException的警告,并不会导致crash。

targetSdkVersion在24及其以上会抛出TransactionTooLargeException导致crash,具体可查看7.0行为变更

相关文章

网友评论

      本文标题:TransactionTooLargeException

      本文链接:https://www.haomeiwen.com/subject/gbrjdktx.html