我注意到 Google Console 中报告了很多异常:
java.lang.RuntimeException:
at android.app.servertransaction.PendingTransactionActions$StopInfo.run (PendingTransactionActions.java:160)
at android.os.Handler.handleCallback (Handler.java:873)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:201)
at android.app.ActivityThread.main (ActivityThread.java:6815)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:873)
Caused by: android.os.TransactionTooLargeException:
at android.os.BinderProxy.transactNative (BinderProxy.java)
at android.os.BinderProxy.transact (BinderProxy.java:1131)
at android.app.IActivityManager$Stub$Proxy.activityStopped (IActivityManager.java:3973)
at android.app.servertransaction.PendingTransactionActions$StopInfo.run (PendingTransactionActions.java:144)
at android.os.Handler.handleCallback (Handler.java:873)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:201)
at android.app.ActivityThread.main (ActivityThread.java:6815)
at java.lang.reflect.Method.invoke (Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:873)
我试图弄清楚是什么引发了那个异常,但我做不到。我在源代码中唯一可疑的部分是我正在加载一个非常大的 json 文件(7MB),data
使用 GSON 将其解析为模型(对象),并将其通过处理程序传递给我的活动:
Message msg = new Message();
msg.what = Util.THREAD_DATA_GENERATED;
msg.obj = data;
handler.sendMessage(msg);
. . .
notifyHandler = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
Data data = (Data) msg.obj;
Manager.getInstance().setData(data);
showSelectTeamDialog();
return true;
}
});
当传递一个大尺寸的 msg.obj 参数时,这个处理程序可以抛出那个异常吗?