<分区>
有没有办法让 Android 应用程序以编程方式与 USSD 对话框交互?该应用程序在 root 手机上运行,不会发布到谷歌商店(仅供内部使用)。
我知道我们可以读取 USSD 对话框的响应(使用辅助功能 hack)。但我在这里想要实现的是让 USSD 对话框打开并与之交互,就像普通用户使用软键盘与之交互一样。 谢谢。
<分区>
有没有办法让 Android 应用程序以编程方式与 USSD 对话框交互?该应用程序在 root 手机上运行,不会发布到谷歌商店(仅供内部使用)。
我知道我们可以读取 USSD 对话框的响应(使用辅助功能 hack)。但我在这里想要实现的是让 USSD 对话框打开并与之交互,就像普通用户使用软键盘与之交互一样。 谢谢。
最佳答案
在 onAccessibilityEvent 中,您需要先捕获输入字段,然后用您的文本填充它,然后单击“发送”(如@lewil ngah 所述)
AccessibilityNodeInfo source = event.getSource();
if (source != null) {
//capture the EditText simply by using FOCUS_INPUT (since the EditText has the focus), you can probably find it with the viewId input_field
AccessibilityNodeInfo inputNode = source.findFocus(AccessibilityNodeInfo.FOCUS_INPUT);
if (inputNode != null) {//prepare you text then fill it using ACTION_SET_TEXT
Bundle arguments = new Bundle();
arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE,"text to enter");
inputNode.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, arguments);
}
//"Click" the Send button
List<AccessibilityNodeInfo> list = source.findAccessibilityNodeInfosByText("Send");
for (AccessibilityNodeInfo node : list) {
node.performAction(AccessibilityNodeInfo.ACTION_CLICK);
}
}
关于Android - 以编程方式与 USSD 对话框交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35793378/