1 在KeyEvent文件 中自定义键值
KeyEvent.KEYCODE_KEYLOCK
2 PhoneWindowManager 在方法public int interceptKeyTq()中加入
if(event.keycode == KeyEvent.KEYCODE_KEYLOCK && event.value != 0 ){
long when = System.currentTimeMillis();
if(!mTouchKeyLock){
mTouchKeyLock = true;
Context context = mContext;
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager =(NotificationManager)mContext.getSystemService(ns);
IntentFilter filter = new IntentFilter();
filter.addAction(LOCK_ACTION);
mContext.registerReceiver(mBroadcastReceiver,filter);
int icon = com.android.internal.R.drawable.stat_key_locked;
CharSequence tickerText = mContext.getResources().getString(com.android.internal.R.string.label_key_locked);
Notification notification = new Notification(icon, tickerText, when);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.flags = Notification.FLAG_AUTO_CANCEL | Notification.FLAG_NO_CLEAR;
CharSequence contentTitle = mContext.getResources().getString(com.android.internal.R.string.label_key_locked_name);
CharSequence contentText = mContext.getResources().getString(com.android.internal.R.string.label_key_unlocked);
Intent intent = new Intent();
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(LOCK_ACTION);
PendingIntent contentIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(KEY_LOCKED_ID, notification);
result &= ~ACTION_PASS_TO_USER;
return result;
} else {
mTouchKeyLock = false;
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager =(NotificationManager)mContext.getSystemService(ns);
mNotificationManager.cancel(KEY_LOCKED_ID);
result &= ~ACTION_PASS_TO_USER;
return result;
}
}
if(mTouchKeyLock){
if(event.keycode == KeyEvent.KEYCODE_MENU || event.keycode ==KeyEvent.KEYCODE_BACK
|| event.keycode ==KeyEvent.KEYCODE_SEARCH || event.keycode ==KeyEvent.KEYCODE_HOME){
result &= ~ACTION_PASS_TO_USER;
return result;
}
}
分享到:
相关推荐
EastSoft_触控按键芯片,DATASHEET/开发调试工具软件/按键/滑条/滑环源代码,入门级触摸IC开发完整资料.
TSM16C触控芯片 12键触控按键键盘板ALTIUM设计硬件原理图+PCB文件, 硬件2层板设计,大小为104mmx53mm,ALTIUM设计的工程文件,包括完整的原理图和PCB文件,已测试验证,可以做为你的设计参考。 主要器件型号列表...
HT45R38 触控按键在程控电源中的应用
本程序在MSP430F2013下使用的 电容式触控按键代码
行业分类-设备装置-背框具有触控按键的触控装置.zip
基于TSM16C触控芯片的12键触控按键键盘板设计资料 包含原理图及PCB文件
电子政务-一种电磁炉的触控按键装置.zip
电子政务-带有电容触控按键的电子阅读装置.zip
比亚迪BF76系列触控灵敏度调整指导书,提供触控灵敏度调整以及触控开启的说明。
电子政务-一种电磁炉的触控按键背光显示装置.zip
12键触控按键键盘ALTIUM设计硬件原理图+PCB+封装库文件,硬件2层板设计,大小为105mmx86mm,ALTIUM设计的工程文件,包括完整的原理图和PCB文件,已测试验证,可以做为你的设计参考。
基于CYPRESS 8C21X34系列电容式芯片的洗衣机触控按键设计方法及测试标准.pdf
Holtek新一代BS83xxxC系列Touch Flash MCU,除承袭BS83BxxA系列的优点以外,更全面提升MCU的抗干扰能力,可抵抗各式噪声的干扰,如:电源噪声、RF干扰、电源波动等,可应用于各式有按键需求如油烟机、电磁炉、微波炉...
单片机应用入门,触摸按键应用入门,小家电单片机应用
BS84B08A-3推出不久,Holtek再度推出新一代集成LED驱动器的Flash触控MCU BS84B06A-3,支持多6个触控按键,除了保有上一代的优点之外还比上一代触控MCU更省电,触控侦测的更新率更高,并且抗干扰的能力更好。...
行业分类-设备装置-具有触控板按键的键盘
HT45R38 是我公司开发的 8-bIT MCU,ROM 4K、RAM192Byte、29 个 I/O (注:QFP52 封 装只引出了 27 个 IO),12 通道电容/电阻型传感器输入。数字相框的显示屏为 TFT LCD 屏, 而液晶本身不能发光,需要背光源进行照明...
触控感应按键芯片vk36n5b规格书_v1.pdf
行业分类-设备装置-一种具有触控式按键的终端
赛元的IIC从机按键读取程序。