Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何采取行动?单击延迟_Java_Android - Fatal编程技术网

Java 如何采取行动?单击延迟

Java 如何采取行动?单击延迟,java,android,Java,Android,我有行动的代码。有什么可以使我石化来解决这个问题吗。我想增加行动的延迟 private void performSmsAppMessage(final AccessibilityNodeInfo rootNode) { AccessibilityNodeInfo textNode = getNodeInfo(rootNode, waTextID); if (textNode == null || sendBlaster == null) return; Bundle t

我有行动的代码。有什么可以使我石化来解决这个问题吗。我想增加行动的延迟

private void performSmsAppMessage(final AccessibilityNodeInfo rootNode) {

    AccessibilityNodeInfo textNode = getNodeInfo(rootNode, waTextID);
    if (textNode == null || sendBlaster == null) return;
    Bundle textBundle = new Bundle();
    textBundle.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, sendBlaster);
    textNode.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, textBundle);
    AccessibilityNodeInfo buttonSend = getNodeInfo(rootNode, waSendID);

    if (buttonSend == null) return;
    buttonSend.performAction(AccessibilityNodeInfo.ACTION_CLICK);
    AccessibilityNodeInfo backButton = getNodeInfo(rootNode, waBackID);

    if (backButton != null) backButton.performAction(AccessibilityNodeInfo.ACTION_CLICK);

}

如果要延迟任何操作,请尝试以下操作:

new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
        //put you action here
    }
}, 1300); //milliseconds to delay, in this case 1.3 seconds

单击此代码按钮Send.performAction(AccessibilityNodeInfo.ACTION);