//KeyEvent.KEYCODE_MENU
//KeyEvent.KEYCODE_BACK
public static void sendKeyEvent(final int KeyCode) {
new Thread() { //不可在主線程中調用
public void run() {
try {
Instrumentation inst = new Instrumentation();
inst.sendKeyDownUpSync(KeyCode);
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();
}
android-代碼裏模擬發送按鍵
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
自定義ProgressDialog加載圖片
pengkv
2020-07-06 13:11:17
Android 開發中一些不得不知的坑(二)
阎楠
2020-07-04 17:48:09
Activity 切換運行模式後的意外情況
阎楠
2020-07-04 17:48:09
關於Android滑動衝突的解決方法(二)
阎楠
2020-07-04 17:48:09
android 2.3.4 在平板上開發遇到的問題
android_learn
2020-07-01 20:39:18
android 2.3 調整屏幕的默認超時時間
android_learn
2020-07-01 20:39:18
【android UI學習】QQ未讀消息粘性動畫
zkq49099
2020-06-29 23:29:44
【android UI學習】簡單炫酷Splash界面
zkq49099
2020-06-29 23:29:34
【android UI學習】貝塞爾曲線
zkq49099
2020-06-29 23:29:34
Android高手進階教程(五)之----Android 中LayoutInflater的使用! (轉)
windizual
2020-06-27 17:29:43
Android laucher總結(轉)
windizual
2020-06-27 17:29:43
Android Launcher View構架淺析(轉)
windizual
2020-06-27 17:29:43
RecyclerView線性佈局定義高度
叼毛爱学习
2020-06-27 09:00:10
24小時熱門文章
-
再談23種設計模式(3):行爲型模式(學習筆記)
-
Power Automate Desktop 安裝完,登錄後老是提示one driver 錯誤
-
微前端學習筆記(4):從微前端到微模塊之EMP與hel-micro方案探索
-
微前端學習筆記(1):微前端總體架構概述,從微服務發微
-
985 碩士程序員,空窗 4 個月沒有 Offer!
-
一文搞懂 Spring 循環依賴
-
賽博鬥地主——使用大語言模型扮演Agent智能體玩牌類遊戲。
-
VScode右鍵打開(添加到右鍵)
-
記一次 .NET某工控視覺自動化系統 卡死分析
-
WindowsServer--SQL Server搭建主從同步實現讀寫分離 - 事務性分發