如何使用AccessibilityService模拟Android中的按键 [英] how to simulate key press in Android with AccessibilityService

查看:1486
本文介绍了如何使用AccessibilityService模拟Android中的按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写无障碍服务.我一直在尝试对应用程序进行一些自动搜索.我使用accessibilityservice action_paste填写EditText.然后,我需要模拟软键盘上的按键.但是我不知道该怎么做.你们可以帮我吗?

解决方案

您可以尝试Activity.dispatchKeyEvent(KeyEvent) 仪器中也有功能,但是这些功能主要用于测试. >

I am writing an accessibility service. I've been trying to do some auto search on an app. I uses the accessibilityservice action_paste to fill in the EditText. Then I need to simulate the key press on the soft keyboard. But I didn't find out how to. Can you guys help me out?

解决方案

You could try Activity.dispatchKeyEvent(KeyEvent) There are also functions in Instrumentation But those are mostly for testing.

这篇关于如何使用AccessibilityService模拟Android中的按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆