通知栏定制化开发

关键类:
NotificationManger    NotificationManagerService   EnqueueNotificationRunnable  PostNotificationRunnable的处理  NotificationListeners
NotificationManger:
1)对smallicon的非空检验(Build.VERSION_CODES.LOLLIPOP_MR1以上版本),校验不通过报IllegalArgumentException("Invalid notification (no valid small icon),日志上有明显的提示,可以通过此条打印定位crash原因。
2)对LargeIcon压缩(若超过最大宽高MediaStyle(H:140dp W:280dp) BigPictureStyle(H:284dp W:416dp) 其他40dp),若未达到阀值则居中显示。

NotificationManagerService:
检验Caller是否合法(主要是针对多用户的非管理用户的限制)
参数是否合法(对nofiticaiton和packageName进行非空校验)
是否能被渲染(猜测是沉浸式状态栏相关设置,只有系统APP才可以设置)
保存通知状态(分为全局和根据Pakcagename区分的应用程序的)
校验ChannelId是否合法(ChannelId是否成功注册了)
封装Notification的相关信息到StatusBarNotification(实现Parcelable接口,用来给SystemUI传输数据)
创建NotificationRecord,用来保存framework层私有数据(也就是不发送给SystemUI的数据)和StatusBarNotification。简单理解就是所有的通知数据;
通知限制处理:
1):即时应用不允许发送通知;2):通知的刷新频率不能太快,并且进度条通知的进度不能大于或等于最大值;3):每个应用最多能同时存在50个通知

布局一:android:id/app_name_text图标旁文字  android:id/title  android:id/text
布局二:com.android.systemui:id/header_label(头标题)
android:id/app_name_text  android:id/time_divider  android:id/time   android:id/alerted_icon
android:id/title android:id/expand_button(扩展按钮)    android:id/title   com.android.systemui    android:id/action0
android:id/notification_header    android:id/app_ops(显示有几条信息)
com.android.systemui:id/notification_title(通知标题)  com.android.systemui:id/notification_text(通知信息)
清空所有通知:com.android.systemui:id/clear_all_port

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值