Android学习——systemUIService 类分析
来源:互联网 发布:男朋友短细的体验知乎 编辑:程序博客网 时间:2024/06/16 11:00
基于Android4.4 systemUIService.java 类分析
首先创建了并引用了一个类的数组mServices。数组类的成员均继承systemUI
private final Class<?>[] SERVICES = new Class[] { com.android.systemui.recent.Recents.class, // 最近应用 com.android.systemui.statusbar.SystemBars.class, // 系统状态栏 com.android.systemui.usb.StorageNotification.class, // storage存储通知 com.android.systemui.power.PowerUI.class, // 电量管理相关 com.android.systemui.media.RingtonePlayer.class, //铃声播放 com.android.systemui.settings.SettingsUI.class, // 设置相关 }; /** * Hold a reference on the stuff we start. */ private final SystemUI[] mServices = new SystemUI[SERVICES.length];
在onCreate() 中遍历数组中成员初始化并执行start()
public void onCreate() { HashMap<Class<?>, Object> components = new HashMap<Class<?>, Object>(); final int N = SERVICES.length; for (int i=0; i<N; i++) { Class<?> cl = SERVICES[i]; Log.d(TAG, "loading: " + cl); try { mServices[i] = (SystemUI)cl.newInstance(); } catch (IllegalAccessException ex) { throw new RuntimeException(ex); } catch (InstantiationException ex) { throw new RuntimeException(ex); } mServices[i].mContext = this; // mServices[i].mComponents = components; Log.d(TAG, "running: " + mServices[i]); mServices[i].start(); } }
同时在该类中重写onConfigurationChanged()方法并调用mServices数组中所有成员的onConfigurationChanged()方法,进而实现对 “相关事件改变” 执行对应的动作。
public void onConfigurationChanged(Configuration newConfig) { for (SystemUI ui: mServices) { ui.onConfigurationChanged(newConfig); } }
阅读全文
0 0
- Android学习——systemUIService 类分析
- Android学习——systemUIService 之PowerUI分析
- Android学习 ——SystemUIService之RingtonePlayer分析
- Android学习 ——SystemUIService之SettingsUI分析
- Android学习 ——SystemUIService之StorageNotification分析
- SystemUI源码分析一(SystemUIService的启动)
- Android学习——MediaScanner源码分析
- Android学习——MediaScanner源码分析
- Android zygote分析——学习笔记
- android学习日志—Handler源码分析
- android学习日志—AsyncTask源码分析
- Android内核学习笔记—Binder分析
- Android学习——Android RIL结构分析与移植
- Android群英传学习笔记——Android Scroll 分析
- Android群英传学习——第五章、Android Scroll分析
- Android学习笔记——LinearLayout源码分析
- Android init进程分析——学习笔记
- android安全学习之6—signapk分析
- linux下passwd命令设置修改用户密码
- .NET后台接收Json数据,序列化到指定实体类
- Maven常用插件
- Android 事件的分发机制
- Invalid bean definition with name 'connectionFactory' defined in
- Android学习——systemUIService 类分析
- Linux第二章作业
- vim配置及常用插件安装
- Excel在统计分析中的应用—第六章—抽样分布-小样本的抽样分布(F分布)
- Erlang keyfind多个值函数
- 初学者---第三方框架
- mysql如何开启慢查询
- log4j 史上最简单的配置
- php的memcache和memcached扩展区别