打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
功能对应按键的改变

一、首先在android4.0\frameworks\base\data\keyboards\(qwerty.kl)Generic.kl文件中做如下改变:

key 59   HOME
key 60   FUNCTION_F2
key 61   FUNCTION_F3
key 62   FUNCTION_F4
key 63   FUNCTION_F5
key 64   EXPLORER
key 65   FUNCTION_F7
key 66   FUNCTION_F8
key 67   MENU
key 68   POWER             WAKE
key 87   FUNCTION_F11
key 88   FUNCTION_F9

 

这样F1键就是回到Home界面;

     F6键就是打开浏览器;

     F9键就是打开/关闭菜单;

     F10键就是关闭屏幕

二、然后修改android4.0\frameworks\base\policy\src\com\android\internal\policy\impl\PhoneWindowManager.java

在interceptKeyBeforeDispatching()方法的final boolean canceled = event.isCanceled();后面中 增加如下代码:

if ((keyCode == KeyEvent.KEYCODE_FUNCTION_F3) && !down) {
            //setDisplayOutput();
  Intent intent3 = new Intent();
  ComponentName cn3 = new ComponentName("com.cooliris.media", "com.cooliris.media.Gallery");
  intent3.setComponent(cn3);
  intent3.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent3.setAction("android.intent.action.MAIN");
  mContext.startActivity(intent3);
  }
  
        if ((keyCode == KeyEvent.KEYCODE_FUNCTION_F4) && !down) {
            //setDisplayOutput();
  Intent intent4 = new Intent();
  ComponentName cn4 = new ComponentName("com.android.camera", "com.android.camera.Camera");
  intent4.setComponent(cn4);
  intent4.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent4.setAction("android.intent.action.MAIN");
  mContext.startActivity(intent4);
  }
  
  if ((keyCode == KeyEvent.KEYCODE_FUNCTION_F5) && !down) {
            //setDisplayOutput();
  Intent intent5 = new Intent();
  ComponentName cn5 = new ComponentName("com.android.music", "com.android.music.MusicBrowserActivity");
  intent5.setComponent(cn5);
  intent5.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent5.setAction("android.intent.action.MAIN");
  mContext.startActivity(intent5);
  }
  
  if ((keyCode == KeyEvent.KEYCODE_FUNCTION_F7) && !down) {
            //setDisplayOutput();
  Intent intent7 = new Intent();
  ComponentName cn7 = new ComponentName("com.android.settings", "com.android.settings.Settings");
  intent7.setComponent(cn7);
  intent7.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent7.setAction("android.intent.action.MAIN");
  mContext.startActivity(intent7);
  }
  
  if ((keyCode == KeyEvent.KEYCODE_FUNCTION_F11) && !down) {
            //setDisplayOutput();
  Intent intent8 = new Intent();
  ComponentName cn8 = new ComponentName("com.android.calculator2", "com.android.calculator2.Calculator");
  intent8.setComponent(cn8);
  intent8.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent8.setAction("android.intent.action.MAIN");
  mContext.startActivity(intent8);
  }
  
  if ((keyCode == KeyEvent.KEYCODE_FUNCTION_F9) && !down) {
            //setDisplayOutput();
   WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
   if (wifiManager.isWifiEnabled()) {  
    wifiManager.setWifiEnabled(false);  
   } else {  
   wifiManager.setWifiEnabled(true);  
   }
  }
  
  if ((keyCode == KeyEvent.KEYCODE_FUNCTION_F8) && !down) {
            //setDisplayOutput();
  Intent intent11 = new Intent();
  ComponentName cn11 = new ComponentName("com.estrongs.android.pop", "com.estrongs.android.pop.view.FileExplorerActivity");
  intent11.setComponent(cn11);
  intent11.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent11.setAction("android.intent.action.MAIN");
  mContext.startActivity(intent11);
  }
 if ((keyCode == KeyEvent.KEYCODE_FUNCTION_F2) && !down){
   Intent intent2 = new Intent();
   ComponentName cn2 = new ComponentName("com.android.apkmanager", "com.android.apkmanager.MainActivity");
   intent2.setComponent(cn2);
   intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   intent2.setAction("android.intent.action.MAIN");
   mContext.startActivity(intent2);
  }

三、F1返回到home也可以如下定义

(KeyEvent在android4.0\frameworks\base\core\java\android\view\KeyEvent.java下面定义)

 在interceptKeyBeforeQueueing方法中switch (keyCode)添加

            case KeyEvent.KEYCODE_F1:{
                    Intent it = new Intent(Intent.ACTION_MAIN);                    
                    it.addCategory(Intent.CATEGORY_HOME);                   
                    it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);                    
                    mContext.startActivity(it);

          }
 

 

这样F3键就是打开相册;

    F4键就是打开照相机;

 F5键就是打开音乐;

   F7键就是打开设置;

  F11键就是打开计算器;

 F12键就是打开wifi;

F8键就是打开ES文件浏览器;

F2键就是打开APK安装器;

http://blog.csdn.net/zhangxu365/article/details/8566033

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
AppWidget的使用
Intent
intent打开外部程序、setClassName和 ComponentName 区别
Android应用自动添加桌面图标
android编程窗口(无标题,全屏)
Android使用Intent一键分享图片文字到腾讯、新浪、开心、人人等
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服