Notification 的 TransactionTooLargeException的问题
2017-11-27 16:33
513 查看
最近做一个需求,需要每隔五秒更新通知栏的ui,考虑的性能问题,notification不是每次都new然后再后台发现报了如下问题: android.os.TransactionTooLargeException at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(Binder.java:508) at android.service.notification.INotificationListener$Stub$Proxy.onNotificationPosted(INotificationListener.java:167) at com.android.server.notification.NotificationManagerService$NotificationListeners.notifyPosted(NotificationManagerService.java:3536) at com.android.server.notification.NotificationManagerService$NotificationListeners.access$5800(NotificationManagerService.java:3342) at com.android.server.notification.NotificationManagerService$NotificationListeners$2.run(NotificationManagerService.java:3450) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at com.android.server.SystemServer.run(SystemServer.java:417) at com.android.server.SystemServer.main(SystemServer.java:295) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1119) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:885)查看
setOnClickPendingIntent 的源码,发现
最终,系统是这么做的
** @param a The action to add*/private void addAction(Action a) {if (hasLandscapeAndPortraitLayouts()) {throw new RuntimeException("RemoteViews specifying separate landscape and portrait" +" layouts cannot be modified. Instead, fully configure the landscape and" +" portrait layouts individually before constructing the combined layout.");}if (mActions == null) {mActions = new ArrayList<Action>();}mActions.add(a);// update the memory usage statsa.updateMemoryUsageEstimate(mMemoryUsageCounter);}
mActions 没有考虑到add的内容是否重复。。。
所以,如果重复
setOnClickPendingIntent 的话,就会产生上面的bug,
解决方案
===================》notification 复用了一百次()之后,选择丢弃,重新new 一个,
while (flag) {index++;if (index%100==0){
//当到第一百次的时候重新init一个,之前的丢弃 initNotification();}else {addNotificaiton();}}
bug解决!
相关文章推荐
- 解决The content of the adapter has changed but ListView did not receive a notification的问题
- Notification 中PendingIntent 只打开最后一个Intent的问题
- 解决Notification不显示的问题:图标不设置,通知也不会显示
- android Notification分析——你可能遇到的各种问题
- android手机震动、提示音、播放系统音乐和研究7.0,6.0弹出Notification出现crash问题
- listview刷新点击,出现The content of the adapter has changed but ListView did not receive a notification问题
- 使用ORACLE 10.2G DBMS_CHANGE_NOTIFICATION 解决参数表的CACHE问题
- 关于Android Notification Bar icon setSmallIcon 显示为白板或白色的问题
- 使用Orientation Changed Notification遇到的问题及解决办法
- 在notification中使用remoteview遇到的问题
- 关于接收到推送下来的通知禁止声音和振动的问题 JPushInterface.setPushNotificationBuilder(1, builder);
- 魅族 Notification 遇到的奇葩问题
- 2012.4.9 :csocket Notification Sink 问题解决过程
- Android中notification点击进入新activity重复的问题
- Jenkins错误“editable email notification aborted due to exception”的问题解决
- IOS8 keyboardWillShow 在UIKeyboardWillShowNotification 调用两次 问题解决
- 关于重复接收NSNotificationCenter发送的通知的问题
- iOS升到8.2收不到推送问题的解决(You've implemented -[ application:didReceiveRemoteNotification:fetchCompletionH )
- android小问题: Notification通知栏 中用Intent传值无效
- 通知栏的问题(Notification)