没有合适的资源?快使用搜索试试~ 我知道了~
首页android systemUI 学习资料
资源详情
资源评论
资源推荐
http://blog.csdn.net/andyhuabing/article/details/12851825
android SystemUI 流程分析
什么是 SystemUI?
对于 Phone 来说 SystemUI 指的是:StatusBar(状态栏)、NavigationBar(导航栏)。而对于
Tablet 或者是 TV 来说 SystemUI 指的是:
CombinedBar(包括了 StatusBar 和 NavigationBar)。
启动后 Phone 界面上的信号,蓝牙标志,Wifi 标志等等这些状态显示标志都会在
StatusBar 上显示。当我们的设备开机后,首先
需要给用户呈现的就是各种界面同时也包括了我们的 SystemUI,因此对于整个 Android 系
统来说,SystemUI 都有举足轻重的作用。
现在就从代码开始一步步的分析
1、启动流程
代码路径:fameworks/base/packages/SystemUI 建立工程导入到 eclipse 中代码具体图示:
先从
AndroidManifest.xml 看看有哪些东东,以前说过 android 中有四大组件,这里就有如下的
三大部分:
系统服务 Service :
SystemUIService
TakeScreenshotService
LoadAverageService
广播接收器 BroadcastReceive:
BootReceiver
Activity 应用:
USB 的挺多哟...
UsbStorageActivity
UsbConfirmActivity
UsbPermissionActivity
UsbStorageActivity
UsbAccessoryUriActivity
NetworkOverLimitActivity
<!-- started from ... somewhere -->
Nyandroid
具体定义请看 AndroidManifest.xml 文件,上面只是简单的列一下
先看第一个 Activity -- Nyandroid 这里做了什么呢?
就是网上传说中的 好多安卓机器人飞过去。。。。其中代码很简单,简单说一下动画效果
的代码:
[java] view plain copy print ?
1 <span style="font-size:14px">public class FlyingCat extends ImageView
{
2
3 public FlyingCat(Context context, AttributeSet as) {
4 super(context, as);
5 setImageResource(R.drawable.nyandroid_anim); // @@@
6
7 if (DEBUG) setBackgroundColor(0x80FF0000);
8 }
9 ...
10 }</span>
定义在 frameworks\base\packages\SystemUI\res\drawable\nyandroid_anim.xml
[html] view plain copy print ?
11 <span style="font-size:14px"><animation-list
12 xmlns:android="http://schemas.android.com/apk/res/android"
13 android:oneshot="false">
14 <item android:drawable="@drawable/nyandroid00"
android:duration="80" />
15 <item android:drawable="@drawable/nyandroid01"
android:duration="80" />
16 <item android:drawable="@drawable/nyandroid02"
android:duration="80" />
17 <item android:drawable="@drawable/nyandroid03"
android:duration="80" />
18 <item android:drawable="@drawable/nyandroid04"
android:duration="80" />
19 <item android:drawable="@drawable/nyandroid05"
android:duration="80" />
20 <item android:drawable="@drawable/nyandroid06"
android:duration="80" />
21 <item android:drawable="@drawable/nyandroid07"
android:duration="80" />
22 <item android:drawable="@drawable/nyandroid08"
android:duration="80" />
23 <item android:drawable="@drawable/nyandroid09"
android:duration="80" />
24 <item android:drawable="@drawable/nyandroid10"
android:duration="80" />
25 <item android:drawable="@drawable/nyandroid11"
android:duration="80" />
26 </animation-list></span>
相关图片在: frameworks\base\packages\SystemUI\res\drawable-nodpi 如图示:
然后再看最重要的服务:SystemUIService
一般来说,Service 启动一般由开机广播或者 StartService/BindService 这几种方式来启动。
既然这个 Service 是一个系统
服务,应该是由系统这边启动,那么看下 SystemServer.java ,果然发现如下启动代码:
[java] view plain copy print ?
27 <span style="font-size:14px">startSystemUi(contextF);
28
29 static final void startSystemUi(Context context) {
30 Intent intent = new Intent();
31 intent.setComponent(new ComponentName("com.android.systemui",
32 "com.android.systemui.SystemUIService"));
33 Slog.d(TAG, "Starting service: " + intent);
34 context.startService(intent);
35 }</span>
对于 Android 启动流程请看如下系统文章:
http://blog.csdn.net/andyhuabing/article/details/7346203 android 启动--深入理解 init 进程
http://blog.csdn.net/andyhuabing/article/details/7349986 android 启动--深入理解 zygote
http://blog.csdn.net/andyhuabing/article/details/7351691 android 启动--深入理解 zygote
(II)
http://blog.csdn.net/andyhuabing/article/details/7353910 android 启动--深入理解启动
HOME
那么就继续跟踪 SystemUIService 中代码:
[java] view plain copy print ?
36 <span style="font-size:14px">/**
37 * The class names of the stuff to start.
38 */
39 final Object[] SERVICES = new Object[] {
40 0, // system bar or status bar, filled in below.
41 com.android.systemui.power.PowerUI.class,
42 };
43
44 @Override
45 public void onCreate() {
46 // Pick status bar or system bar.
47 IWindowManager wm = IWindowManager.Stub.asInterface(
48 ServiceManager.getService(Context.WINDOW_SERVICE));
49 try {
50 SERVICES[0] = wm.canStatusBarHide()
51 ? R.string.config_statusBarComponent
52 : R.string.config_systemBarComponent;
53 } catch (RemoteException e) {
54 Slog.w(TAG, "Failing checking whether status bar can hide",
e);
55 }
56
57 final int N = SERVICES.length;
58 mServices = new SystemUI[N];
59 for (int i=0; i<N; i++) {
60 Class cl = chooseClass(SERVICES[i]);
61 Slog.d(TAG, "loading: " + cl);
62 try {
63 mServices[i] = (SystemUI)cl.newInstance();
64 } catch (IllegalAccessException ex) {
65 throw new RuntimeException(ex);
66 } catch (InstantiationException ex) {
67 throw new RuntimeException(ex);
68 }
69 mServices[i].mContext = this;
70 Slog.d(TAG, "running: " + mServices[i]);
71 mServices[i].start();
72 }
73 }</span>
在这代码中:[java] view plain copy print ?
74 <span style="font-size:14px">SERVICES[0] = wm.canStatusBarHide()
75 ? R.string.config_statusBarComponent
剩余27页未读,继续阅读
city_walker
- 粉丝: 6
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- 2023年中国辣条食品行业创新及消费需求洞察报告.pptx
- 2023年半导体行业20强品牌.pptx
- 2023年全球电力行业评论.pptx
- 2023年全球网络安全现状-劳动力资源和网络运营的全球发展新态势.pptx
- 毕业设计-基于单片机的液体密度检测系统设计.doc
- 家用清扫机器人设计.doc
- 基于VB+数据库SQL的教师信息管理系统设计与实现 计算机专业设计范文模板参考资料.pdf
- 官塘驿林场林防火(资源监管)“空天地人”四位一体监测系统方案.doc
- 基于专利语义表征的技术预见方法及其应用.docx
- 浅谈电子商务的现状及发展趋势学习总结.doc
- 基于单片机的智能仓库温湿度控制系统 (2).pdf
- 基于SSM框架知识产权管理系统 (2).pdf
- 9年终工作总结新年计划PPT模板.pptx
- Hytera海能达CH04L01 说明书.pdf
- 数据中心运维操作标准及流程.pdf
- 报告模板 -成本分析与报告培训之三.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论2