Android为TV端助力 完全解析模拟遥控器按键

复制代码
public class VirturlKeyPadCtr {
    private static Instrumentation mInstrumentation;

    public static void RC_ConttrollerAction(final int keyValue) {

    /**
     * Wrapper-function taking a KeyCode. A complete KeyStroke is DOWN and UP
     * Action on a key!
     */
    public static void simulateKeystroke(int KeyCode) {
        if (mInstrumentation == null) {
            mInstrumentation = new Instrumentation();
        }
        mInstrumentation.sendKeyDownUpSync(KeyCode);
    }
}

写一个类工具类到时候方便调用

调用的时候直接

VirturlKeyPadCtr.simulateKeystroke(realCode);

传人的参数为你的遥控器的KEY值,比如返回键就是KeyEvent.KEYCODE_BACK

Android 为TV端助力

相关推荐
DevOpenClub34 分钟前
职教高考控制线 API:招生类别枚举、筛选与空分数含义
java·数据库·高考
露天赏雪2 小时前
第3篇:Sentinel熔断降级实战:大模型接口抖动时的服务兜底方案
java·开发语言·人工智能·spring boot·spring·servlet·sentinel
zhaoshuzhaoshu2 小时前
Android 系统启动与调试中的日志抓取方式全解析
android
天天被压力2 小时前
【A股分钟级高频数据完全手册 #06】北交所分钟级数据接口:京市股票Pro版最新分时
java·人工智能·python
天天被压力2 小时前
【A股分钟级高频数据完全手册 #05】指数历史分钟数据接口:Pro版沪深指数分时回放
java·人工智能·python
captain3762 小时前
▲统一功能——DispatcherServlet源码分析
java·spring·java-ee·log4j·maven
金銀銅鐵2 小时前
JDK 21 中 List.of 的实现细节:从 List12 到 ListN
java·后端·ai编程
雨声不在3 小时前
android 动画掉帧
android
在多学一点4 小时前
MYSQL第二次作业
android·数据库·mysql
yeccheng4 小时前
MySQL 索引超详解:从底层 B+ 树到面试高频考点
java·开发语言·jvm·mysql·面试