β

android.os.TransactionTooLargeException 异常

让我靠近你,我的宝贝 620 阅读

java.lang.RuntimeException: Adding window failed
        at android.view.ViewRootImpl.setView(ViewRootImpl.java:547)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:71)
        at android.widget.PopupWindow.invokePopup(PopupWindow.java:1023)
        at android.widget.PopupWindow.showAtLocation(PopupWindow.java:852)
        at android.widget.PopupWindow.showAtLocation(PopupWindow.java:816)
        at com.yunyue.weishangmother.view.PopPropertyWindow.showAsUp(PopPropertyWindow.java:810)
        at com.yunyue.weishangmother.activity.GoodsDetailActivity.onClick(GoodsDetailActivity.java:437)
        at android.view.View.performClick(View.java:4447)
        at android.view.View$PerformClick.run(View.java:18445)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5034)
        at java.lang.reflect.Method.invokeNative(Method.java)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:805)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:621)
        at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: android.os.TransactionTooLargeException
        at android.os.BinderProxy.transact(BinderProxy.java)
        at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:683)
        at android.view.ViewRootImpl.setView(ViewRootImpl.java:536)
        ... 18 more
android.os.TransactionTooLargeException
        at android.os.BinderProxy.transact(BinderProxy.java)
        at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:683)
        at android.view.ViewRootImpl.setView(ViewRootImpl.java:536)
        at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:259)
        at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:71)
        at android.widget.PopupWindow.invokePopup(PopupWindow.java:1023)
        at android.widget.PopupWindow.showAtLocation(PopupWindow.java:852)
        at android.widget.PopupWindow.showAtLocation(PopupWindow.java:816)
        at com.yunyue.weishangmother.view.PopPropertyWindow.showAsUp(PopPropertyWindow.java:810)

最近发现应用中常出现上述异常,引起此异常的地方主要集中两个方法,一个是显示PopWindow时;另一个是显示Dialog对话框。但上述问题,只在特定情况下才会出现。

网上查找原因,大部分归结于:
异常:Caused by: android.os.TransactionTooLargeException 导致原因是:Binder传输的数据太大 如果Binder的参数或返回值太大,不适合的事务缓冲区,然后调用将失败,并将被抛出TransactionTooLargeException。 解决方法:不要将大量数据传入Binder 参考:http://blog.csdn.net/philofly/article/details/17511919
即intent等传送数据时不能太大,貌似超过500k就会出现此异常。但是我自身应用并没有通过intent传递大数据,传递也至少JavaBean对象,数据量小。
发现一篇有用的分析文章:

http://stackoverflow.com/questions/11451393/what-to-do-on-transactiontoolargeexception/12809171#12809171"

比较有用,分析了各种可能引发此问题的状况;但仍未解决我的问题。


发表评论