-1

I am trying to make my service emulate tap input, but it isn't working.

My main activity already called

try {

            Runtime.getRuntime().exec("su");

        } catch (IOException e) {

            e.printStackTrace();

        }

My service checks if a toggle button is clicked I want to call

try {

                Runtime.getRuntime().exec("input tap" + Main.xValue.toString() + Main.yValue.toString());

            } catch (IOException e) {

                e.printStackTrace();

            }

But to no success, could someone explain why?

user192198
  • 11
  • 4
  • flagged as off-topic because it's asking for debugging slaves. – max Feb 07 '15 at 23:16
  • Possible duplicate of [How to simulate touch from background service with sendevent or other way?](https://stackoverflow.com/questions/14928197/how-to-simulate-touch-from-background-service-with-sendevent-or-other-way) – alijandro Oct 24 '18 at 07:37

1 Answers1

1

As an example lets say: Main.xValue.toString() = 10 Main.yValue.toString() = 20

So according to your code, the line :

"input tap" + Main.xValue.toString() + Main.yValue.toString()

will be "input tap1020"

but you expect "input tap 10 20" !

try :

try {
     Runtime.getRuntime().exec("su -c input tap " + Main.xValue.toString() + " " + Main.yValue.toString());
} catch (IOException e) {
     e.printStackTrace();
}
paulmelnikow
  • 16,895
  • 8
  • 63
  • 114