好巧 , 报错也是因为Binder没有unBinder成功 , 与traceview的Binder耗时 , 以及systrace的GC耗时的信息都有千丝万缕的关系 , 也许就是问题的所在 , 接下来就是解决这个错误 , 并验证的时刻 。找到如下资料:
google Android Issue中有这个缺陷 , 缺陷详细信息在这里(Google Android Issue 2483) , Using getApplicationContext().bindService instead of just bindService on your activity solves the problem as it is using the higher level application context.先调用getApplicationContext()获取其所属的Activity的上下文环境才能正常bindService , 也就是在onCreate()方法中使用this.getApplicationContext().bindService([args…])就可以了,否则bindService将永远失败返回false 。
那么就看log找到对应的地方 , 我们发现绑定binder的地方是用的getContext().Binder(xxxx),解绑的地方是用的getActivity().unBinder(xxx),我们通通换成getActivity().getApplicationContext().binder(xxx) (unBinder),编译push验证 , 查看log如下:
Line 2240: 01-21 15:29:12.629 1167 1325 I ActivityManager: Displayed com.android.settings/.SubSettings: +2s672ms [aosp]
Android性能优化知识学习 , 获~可私信发送:“核心笔记”或“手册”即可获取!
五、文末成功优化了大约3秒的时间 , 虽然还感觉有卡顿 , 但是已经好很多 , 因为为了方便调试 , 编译的是userdebug版本 , 使用user版本后效果还有提升 , 算是能够过的去了!
更多性能优化(卡顿优化、UI优化、布局优化、稳定性优化、电量优化等)可前往私信哦 。
推荐阅读
- 港剧是tvb吗,港剧除了tvb还有啥-
- AMD|AMD游戏神U锐龙7 5800X3D再升级:免费解锁5%额外性能
- 安卓手机如何打开.null文件
- 电动车|小鹏P7出事故气囊未弹出 官方回应:事发后车门可解锁打开
- 奔驰|奔驰推出付费解锁后轮转向功能:4998元/年
- 一文读懂 Android 系统的源代码
- 原生javascript解锁恶心的CSDN强制关注才能阅读让文章自动展开
- 口红|5年磨一剑|优酷Android包瘦身治理思路全解
- 新飞冰箱触摸屏怎样解锁 新飞冰箱触摸屏如何解锁
- Pixel|第一款Android 13高端旗舰已在路上 谷歌Pixel 7 Pro参数曝光