PendingIntent产生以及响应

PendingIntent产生以及响应,第1张

PendingIntent
PendingIntent 将会发生的意图
主要有四种Activity、BroadcastReceiver、Service
Activity(BroadcastReceiver、Service类似只是在type不同)

PendingIntentRecord是IIntentSender的服务端
内部类Key(重写了equals,hashCode)保存从IIntentSender客户端传来的参数数据

在PendingIntent的getActivity(或Service,BroadcastReceiver),把参数封装在AMS中的mIntentSenderRecords属性中。
PendingIntent主要结合NotificationManager进行使用的。
分析一波NotificationManager
app端主要 使用的是NotificationManager(其他的管理器获取使用类似)

主要通过ContextImpljava

SystemServiceRegistry动态注册许多App端使用的各种Manager(ActivityManager,AlarmManager,NotificationManager)

在获取到NotificationManager,就已经实例化了。
Notification保存要执行的参数属性(pojo)
直接实例化或通过建造者模式实例化
参数

通过Notification封装了PendingIntent
NotificationManager通过notify把Notification发送到状态栏中

在NotificationManagerService的类中
联系点1
关注

NotificationListeners类是ManagedServices的子类
关注

ManagedServiceInfo类(pojo)存储信息,并使用service(IInterface )进行回调
关注属性

介绍完上面,接下来介绍如何启动状态栏PhoneStatusBar,BaeStatusBar,会 *** 作Nitiofication
首先从SystemServer#startOtherServices
然后通过AMS的

拉起SystemUIService把SytemUI的app启动

SystemUIApplicationjava

通过各个子类实现start()方法,执行各个子类定制的属性和逻辑关系
关注子类SystemBars类
SystemBarsjava且实现了ServiceMonitorCallbacks

在BaseStatusBar#start()
关注

//与上面分析的 联系点1 进行关联
// 当回调INotificationListener的方法,就会在这里具体执行
//间接调用NotificationListenerService的方法,子类在BaseStatusBar的内部NotificationListenerService重写
//又间接调用BaseStatusBar自己的方法,由子类再次PhoneStatusBar重写实现

关于Click事件监听
主要通过上面流程,把Notification拿出来,封装在View中,设置 点击相应PendingIntent
大功告成

PhoneStatusBarjava


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zz/13464158.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-08-12
下一篇 2023-08-12

发表评论

登录后才能评论

评论列表(0条)

保存