本文主要是介绍笔记:配置遥控器按键事件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
全志H3平台
自己存放的源码路径:Z:\ceshi\luohuanai\h3_7_git\android\frameworks\base\services\core\java\com\android\server\policy在Android目录下,Java文件TvWindowManager.Java。修改switch中case事件,导入包和类,
id名为ir红外遥控的映射表
@Override
public int interceptKeyBeforeQueueing(KeyEvent event, int policyFlags) {
int keyCode = event.getKeyCode();
final boolean down = event.getAction() == KeyEvent.ACTION_DOWN;
Log.d(TAG,"key event key = " + KeyEvent.keyCodeToString(keyCode));
if(down){
switch(keyCode){
case KeyEvent.KEYCODE_SETTINGS:
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.android.tv.settings", "com.android.tv.settings.MainSettings"));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
break;
case KeyEvent.KEYCODE_BROWSER:
Intent intent4 = new Intent();
intent4.setComponent(new ComponentName("com.android.chrome", "org.chromium.chrome.browser.document.ChromeLauncherActivity"));
intent4.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent4);
break;
case KeyEvent.KEYCODE_PROG_RED:
Log.d(TAG,"key event red");
mHandler.post(mDisplayModeRunnable);
break;
case KeyEvent.KEYCODE_PROG_GREEN:
Log.d(TAG,"key event greed");
launchHomeFromHotKey();
break;
这篇关于笔记:配置遥控器按键事件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!