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();
}
}
android 模拟物理按键
最新推荐文章于 2024-10-29 23:18:12 发布