2

I am wondering if it is possible to perform touch action with Android accessibility service on screen at position, e.g.:

Bundle arguments = new Bundle();
arguments.putInt(/*coord X*/, /*X value*/);
arguments.putInt(/*coord Y*/, /*Y value*/);
node.performAction(/*touch action*/, arguments);

Or, again if possible, record an action when user taps on a certain view / position.

Basically, I have to perform action over soft keyboard, when it pops up (external app does not have "Submit" button to perform ACTION_CLICK on it), but injecting events is not permitted due to security policies. Any idea? Thanks!

Oleg Novosad
  • 2,261
  • 1
  • 27
  • 28
  • is your code for onclick at specified bounds – v teja Jul 16 '18 at 06:47
  • Did you got a solution to this? – Narendra Pal Oct 17 '20 at 11:33
  • Having application as a system app can resolve this issue :) but I will not post an answer here so far as I the issue is obsolete so far for me. – Oleg Novosad Feb 08 '21 at 08:31
  • This question may help : [How can I reliably simulate touch events on Android without root (like Automate and Tasker)?](https://stackoverflow.com/questions/50775698/how-can-i-reliably-simulate-touch-events-on-android-without-root-like-automate) – Paul Lam Apr 25 '22 at 23:58

2 Answers2

1

You can not perform any action by position on the screen, you can only do on the nodes, but you can find which node is on your coordinates by recursively checking nodes position-on-the-screen with getBoundsInScreen.

It wouldn't work if it is OpenGL game, and you won't be able to perform the click on the precise location only on the node you found on that location.

Nikola Minoski
  • 416
  • 5
  • 7
1

//touch function

public void touchTo(int x, int y) {
    Path swipePath = new Path();
    swipePath.moveTo(x, y);
    swipePath.lineTo(x, y);
    GestureDescription.Builder gestureBuilder = new GestureDescription.Builder();
    gestureBuilder.addStroke(new GestureDescription.StrokeDescription(swipePath, 0, 50));
    dispatchGesture(gestureBuilder.build(), null, null);
}

// It working in my class SupporterService extends AccessibilityService.