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的xml文件中@、@android:type、@*、?、@+的含义和区别
  2. Android布局文件中常用的属性
  3. Android工具箱之文件目录
  4. android布局文件中各属性所代表的意义
  5. Android中资源文件的Shape使用总结
  6. 【魔幻塔防】60关配置文件
  7. 【魔幻塔防】80关配置文件
  8. 【魔幻塔防】128关配置文件

随机推荐

  1. Dagger2+Retrofit+RxJava
  2. Android打开系统设置界面
  3. 初学Android,数据存储之File存储(四十二)
  4. Android调节屏幕亮度分析源码
  5. Android(安卓)寮傛缃戠粶璇锋眰妗嗘灦-
  6. Android(安卓)Studio 中使用SVN注意事项
  7. Android(安卓)鏃ュ巻鎻愪緵鍣紙浜岋級
  8. android 关于程序升级问题
  9. Android(安卓)音乐播放器
  10. Android(安卓)自己制作的相册--效果还不