0

I am trying to make an application that does a sort of auto scroll. The idea I have is to have a floating button (like the facebook chat head) with two buttons, one for scrolling down and one for scrolling up.

The problem I am facing is, I have no idea how to pass a touch/scroll event to the underlying screen. I had found this github gist: https://gist.github.com/oneyoung/a14c99856c3984263734 , it uses a Context to pass the movement to, but since I want it to pass it to the underlying screen my guess is the Context will change and this will no longer work.

Any thoughts on this or directions for me to look in are welcome, thanks in advance!

PS. Here is a screenshot to get an idea of what I currently have: https://i.stack.imgur.com/B2w3z.jpg

2 Answers2

0

send touch events to a device via adb

You can send touch events via shell to android. I think this is something similar to what you want.

Goodie123
  • 467
  • 4
  • 16
  • Yes, the phone needs to be plugged into a computer for this, not? And I want it to be standalone, no plugging of sorts. – tbreugelmans Jun 07 '20 at 10:25
  • I dont think you need it to be plugged in. you can just use the input utility to send events from your android app – Goodie123 Jun 09 '20 at 14:14
0

OK so, with the provided github gist, it is possible to send user input programmatically to your device. As for the Context, a Service is a Context in and of itself so you can just pass that as a parameter for the Input constructor in the onCreate method, like so:

public void onCreate() {
  super.onCreate();
  Input input = new Input(this);

But the problem lies with passing the input to the underlying screen. This is only possible with system permissions, meaning you would need root for this as it throws an error saying: W/System.err: Caused by: java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission