package com.example.sh04799.myapplication2;import android.app.Instrumentation;import android.util.Log;/** * Created by zhangwei on 2017/6/19. */public class CustomFuncManager {    private static CustomFuncManager mInstance;    // 模拟物理按键onKey事件    private Instrumentation   instrumentation = new Instrumentation();;    public static CustomFuncManager getInstance() {        if (mInstance == null) {            mInstance = new CustomFuncManager();        }        return mInstance;    }    public void sendKeyEvent(final int keyCode) {        Thread thread = new Thread(new Runnable() {            @Override            public void run() {                if (instrumentation != null) {                    instrumentation.sendKeyDownUpSync(keyCode);                } else {                    Log.d("zw", "instrumentation is null");                }            }        });        thread.start();    }}

更多相关文章

  1. android添加外部按键
  2. 隐藏Android下的虚拟按键
  3. Android交互体验必知:功能按键事件
  4. android:imeOptions 控制软键盘右下角按键
  5. Android面面观——Android事件处理下(按键、触摸屏和滚动球的一些
  6. Android 通过按键旋转屏幕
  7. android 实现模拟按键
  8. android沉浸式+虚拟按键+Fragment+CoordinatorLayout(1)
  9. android监听软键盘enter按键

随机推荐

  1. Python与苹果哲学的相似之处
  2. Tomcat就是这么简单(修订版)
  3. 聊聊Docker镜像
  4. FBI是如何攻破iPhone的?
  5. 快速尝试Python模块:try
  6. 微软Edge浏览器准备内置屏蔽广告功能
  7. 嗯,我来杭州了。
  8. 数据库两个神器索引和锁(修订版)
  9. 一个70后“大叔”的PMP学习考证之路
  10. 微软分析Pypi数据: 5月21日Python3战胜Py