Android Status bar添加耳机图标
2014-10-24 13:29
387 查看
1. 将耳机资源图片文件stat_sys_headset.png放到android/frameworks/base/packages/SystemUI/res/drawable-nodpi/
2. 修改android/frameworks/base/core/res/res/values/config.xml
3. 修改android\frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\PhoneStatusBarPolicy.java
2. 修改android/frameworks/base/core/res/res/values/config.xml
<string-array name="config_statusBarIcons"> <item><xliff:g id="id">ime</xliff:g></item> <item><xliff:g id="id">volume</xliff:g></item> <span style="color:#3333ff;"><item><xliff:g id="id">headset</xliff:g></item></span> <item><xliff:g id="id">wifi</xliff:g></item> </string-array>
3. 修改android\frameworks\base\packages\SystemUI\src\com\android\systemui\statusbar\phone\PhoneStatusBarPolicy.java
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); } ......
//add start
<span style="color:#3333ff;"> else if (action.equals(Intent.ACTION_HEADSET_PLUG)) { updateHeadset(intent); }//zhanbing add end </span> }
public PhoneStatusBarPolicy(Context context) { mContext = context; mService = (StatusBarManager)context.getSystemService(Context.STATUS_BAR_SERVICE); // listen for broadcasts IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_ALARM_CHANGED); filter.addAction(TtyIntent.TTY_ENABLED_CHANGE_ACTION); ......
<span style="color:#3333ff;">filter.addAction(Intent.ACTION_HEADSET_PLUG);//zhanbing add </span> mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
......
<span style="color:#3333ff;">//headset zhanbing.li add mService.setIcon("headset", R.drawable.stat_sys_headset, 0, null); mService.setIconVisibility("headset", false); //zhanbing modify here end</span>
<span style="color:#000066;">//modify here start</span>
<span style="color:#000066;">private final void updateHeadset(Intent intent) { Slog.d(TAG, "updateHeadset: state=" + intent.getIntExtra("state", 0)); mService.setIconVisibility("headset", (intent.getIntExtra("state", 0) == 1)?true:false);</span>
<span style="color:#000066;">}</span>
<span style="color:#000066;">//modify here end</span>
相关文章推荐
- 在android系统SystemUI里面添加耳机图标的一点知识
- 为android添加耳机状态图标
- android实现添加耳机状态图标的方法
- 为android添加耳机状态图标
- 在android系统SystemUI里面添加耳机图标的一点知识
- 在android系统SystemUI里面添加耳机图标的一点知识
- 为android添加耳机状态图标
- Android4: Status bar or System UI
- android 在应用程序中添加快捷图标
- Android2.2 Luncher2扩展(仿Ipad DockBar、HTC预览图、批量添加快捷方式、启用3D效果等)
- 如何在android2.3下添加耳机在状态栏显示
- [Android 問題] How to Add Virtual Keys on Status Bar?
- android2.1状态栏显示耳机图标
- Android应用自动添加桌面图标
- Android Overlay 添加本地位置图标
- Android开发系列---UI篇---添加和消除通知栏图标
- android 状态栏添加图标的函数
- Android 为Activity屏幕的标题添加图标
- Android开发指南(38) —— Status Bar Notifications
- android下添加系统资源(图标)的问题