前言

该异常触发的概率不大,很多Android猴子可能都没遇到过
但是真的出现的时候别不知道怎么解决

什么情况出现

界面跳转 intent 中的数据内容较多
Android调用系统裁减图片
批量插入大量数据到数据库(我是这种情况,一下主要针对批量插入数据库讲解)

系统源码

源码位置:android/frameworks/base/core/jni/android_util_Binder.cpp
是的你没看错,在以上三种传输中 大于200K就会报错

case FAILED_TRANSACTION: {            ALOGE("!!! FAILED BINDER TRANSACTION !!!  (parcel size = %d)", parcelSize);            const char* exceptionToThrow;            char msg[128];            // TransactionTooLargeException is a checked exception, only throw from certain methods.            // FIXME: Transaction too large is the most common reason for FAILED_TRANSACTION            //        but it is not the only one.  The Binder driver can return BR_FAILED_REPLY            //        for other reasons also, such as if the transaction is malformed or            //        refers to an FD that has been closed.  We should change the driver            //        to enable us to distinguish these cases in the future.            if (canThrowRemoteException && parcelSize > 200*1024) {    --------- 在这里是有判断的                  // bona fide large payload                exceptionToThrow = "android/os/TransactionTooLargeException";                snprintf(msg, sizeof(msg)-1, "data parcel size %d bytes", parcelSize);            } else {                // Heuristic: a payload smaller than this threshold "shouldn't" be too                // big, so it's probably some other, more subtle problem.  In practice                // it seems to always mean that the remote process died while the binder                // transaction was already in flight.                exceptionToThrow = (canThrowRemoteException)                        ? "android/os/DeadObjectException"                        : "java/lang/RuntimeException";                snprintf(msg, sizeof(msg)-1,                        "Transaction failed on small parcel; remote process probably died");            }            jniThrowException(env, exceptionToThrow, msg);        } break;

解决方案

intent 传递的数据过大 把大型的序列化集合或者Bitmap缓存 传递缓存路径即可
Android调用系统裁减图片 Bitmap 过大 这个时候只能通过MediaStore.EXTRA_OUTPUT设置裁减图片保存位置,只传递图片路径,不直接传bitmap对象。
批量插入大量数据到数据库 改成分多批 根据自己实际数据量 去衡量每次批量传入多少合适 比如要批量传入100000条数据 每张表的数据还特别多 可以以500条为一批 按批插入

更多相关文章

  1. android 加载大图长图失真或者不显示。
  2. Android显示gif格式图片
  3. Android训练课程(Android(安卓)Training) - 使用Volley传输网络
  4. Android自定义时间控件不可选择未来时间
  5. 关于Android(安卓)O系统短信拦截的流程
  6. 高亮的关键字
  7. Android(安卓)Adapter的那些事
  8. [置顶] Android仿人人客户端(v5.7.1)——应用主界面之左侧面板UI实
  9. Android数据共享机制ContentProvider

随机推荐

  1. android开发每日汇总【2011-10-31】
  2. Android的源代码结构
  3. Android(安卓)Fragment 实例
  4. Android(安卓)ActionBar 作为导航条的一
  5. Android有用代码片段(四)
  6. 关于相对布局RelativeLayout的各种属性介
  7. Android(安卓)EditText 限制输入数字和字
  8. Android中的界面组成
  9. android 7.0 系统关闭彩信过CTA测试的方
  10. TextView的drawable属性