1. 将耳机资源图片文件stat_sys_headset.png放到android/frameworks/base/packages/SystemUI/res/drawable-nodpi/
2. 修改android/frameworks/base/core/res/res/values/config.xml

                ime          volume          headset          wifi      

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
            else if (action.equals(Intent.ACTION_HEADSET_PLUG)) {updateHeadset(intent);               }//zhanbing add end}


 

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);        ......
        filter.addAction(Intent.ACTION_HEADSET_PLUG);//zhanbing add        mContext.registerReceiver(mIntentReceiver, filter, null, mHandler);
        ......
        //headset zhanbing.li add        mService.setIcon("headset", R.drawable.stat_sys_headset, 0, null);        mService.setIconVisibility("headset", false);        //zhanbing modify here end
//modify here start
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);
}
//modify here end


 

更多相关文章

  1. Android(安卓)app设置全屏模式
  2. Android修改自己程序字体的方法详解
  3. android之4.0的系统主题style修改android:Theme.Holo.Light
  4. 修改android公共控件和后台服务
  5. Android(安卓)Studio系列(三)Version Control I 使用内置版本管理
  6. 【Android(安卓)文件管理】分区存储 ( 修改与删除图片文件 )
  7. android > 修改Android工程版本
  8. Android(安卓)Home's favorite.xml
  9. Android修改自己程序字体

随机推荐

  1. Android(安卓)app如何正确读写系统sys设
  2. 字节跳动屏幕适配方案解读
  3. Android(安卓)wifi 信号强度单位 dbm
  4. Android屏幕录制并转换gif
  5. android校园二手市场客户端+服务端源代码
  6. Android通过 SharedPreference 实现用户
  7. android widget 开发实例 : 桌面便签程序
  8. Android资源管理框架(Asset Manager)简要介
  9. 浏览器唤起App
  10. Android(安卓)常用的距离单位