博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android4.0 上定制状态栏
阅读量:4104 次
发布时间:2019-05-25

本文共 1911 字,大约阅读时间需要 6 分钟。

a)    代码在系统中的位置

status bar 的相关代码位于:frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar。
其中PhoneStatusBarPolicy类主要负责接收action动作。

frameworks\base\services\java\com\android\server

其他一些核心操作全部位于StatusBarManagerService类里面。

b)    在frameworks\base\core\res\res\values\config.xml中定义需要显示的Icon 的配置信息

 

c)  在frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\PhoneStatusBarPolicy.java 中初始化

       // Alarm clock

        mService.setIcon("alarm_clock", R.drawable.stat_sys_alarm, 0, null);
        mService.setIconVisibility("alarm_clock", false);

        // Sync state

        mService.setIcon("sync_active", R.drawable.stat_sys_sync, 0, null);
        mService.setIcon("sync_failing", R.drawable.stat_sys_sync_error, 0, null);
        mService.setIconVisibility("sync_active", false);
        mService.setIconVisibility("sync_failing", false);

 

d)  在frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\PhoneStatusBarPolicy.java 中注册相应的receiver 来接受intent

 private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (action.equals(Intent.ACTION_ALARM_CHANGED)) {
                updateAlarm(intent);
            }
            else if (action.equals(Intent.ACTION_SYNC_STATE_CHANGED)) {
                updateSyncState(intent);
            }
            else if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED) ||
                    action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
                updateBluetooth(intent);
            }
            else if (action.equals(AudioManager.RINGER_MODE_CHANGED_ACTION) ||
                    action.equals(AudioManager.VIBRATE_SETTING_CHANGED_ACTION)) {
                updateVolume();
            }
            else if (action.equals(TelephonyIntents.ACTION_SIM_STATE_CHANGED)) {
                updateSimState(intent);
            }
            else if (action.equals(TtyIntent.TTY_ENABLED_CHANGE_ACTION)) {
                updateTTY(intent);
            }
            // [SystemUI] Support "Headset icon". {
            else if (action.equals(Intent.ACTION_HEADSET_PLUG)) {
                updateHeadSet(intent);
            }
            // [SystemUI] Support "Headset icon". }
        }
    };

转载地址:http://prfsi.baihongyu.com/

你可能感兴趣的文章
AS3变量作用域问题
查看>>
#ifndef 在头文件中的作用
查看>>
FB安装技巧
查看>>
Lua4虚拟机运行概述
查看>>
C++中explicit关键字的作用
查看>>
AS3中Object与Dictionary的区别
查看>>
C++中的rand()函数
查看>>
SVN文件版本冲突解决方法
查看>>
map、hash_map、迭代器
查看>>
C++技巧
查看>>
STL迭代器简介
查看>>
AS3_MVC
查看>>
AS3_MVC解析
查看>>
关于C++中继承、重载、掩盖
查看>>
C++中的各种继承方式规则
查看>>
复制显示对象通用函数
查看>>
智能指针的原理及实现方案
查看>>
智能指针
查看>>
SWC和SWF文件比较
查看>>
深入理解Flash Player的应用程序域(Application Domains)(转载)
查看>>