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端助力

相关推荐
Flynn Liang1 小时前
可观测性与成本治理:一次对话的 17 个观测点
java·langchain·可观测性·micrometer·langchain4j·token 成本·llm 监控
金銀銅鐵2 小时前
带您看懂字节码指令(三):同一行加法,为什么有四种指令
java·jvm
AI_Gump3 小时前
Harness篇|DeepSeek Harness 上手机:五条安卓移植路线与 App 内 Linux 拆解
android·linux·人工智能·智能手机·deepseek
文丑颜不良啊6 小时前
LeetCode2821~2840题目解析
java·leetcode
apcipot_rain6 小时前
C++转Java日记(10)
java·开发语言
简 洁 冬冬7 小时前
泛型方法写法全面辨析:从「能编译」到「能跑」到「能用」
java·泛型
LGL6030A7 小时前
Java学习历程31——初识Spring Boot
java·spring boot·学习
疯华整猫8 小时前
否决 Flutter 提案那天,我发现自己也说不清 Framework 管什么
android
Lansonli9 小时前
大数据Spark(八十八):Spark任务资源之Standalone集群测试
java·服务器·spark
budingxiaomoli9 小时前
Spring AOP
java·spring·java-ee