package com.sheep.gamegroup.util;

import android.app.Instrumentation;

/**
 * Created by realicing on 2018/11/8.
 * realicing@sina.com
 */
public class KeyEventUtil {
    public static void sendKeyDownUp(final int keyCode) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    // 创建一个Instrumentation对象
                    Instrumentation inst = new Instrumentation();
                    // 调用inst对象的按键模拟方法
                    inst.sendKeyDownUpSync(keyCode);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}
