If you want to inject touch events on android app without root:
you can use Instrumentation class,
https://developer.android.com/reference/android/app/Instrumentation.html
import android.app.Instrumentation;
public class MainActivity extends Activity {
Instrumentation m_Instrumentation;
public void onCreate(Bundle savedInstanceState) {
m_Instrumentation = new Instrumentation();
int x=0; //your x coord in screen.
int y=0; // your y coord in screen.
m_Instrumentation.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(),MotionEvent.ACTION_DOWN,x, y,0));
m_Instrumentation.sendPointerSync(MotionEvent.obtain(SystemClock.uptimeMillis(),
SystemClock.uptimeMillis(),MotionEvent.ACTION_UP,x, y,0));
}
}
This method obtains ACTION_DOWN and ACTION_UP event which injects an event on the current layout.
Note: if the injection of your coordinates (x,y) is outside of screen size, the app will crash.
This method injection works only inside app, if you want to inject touch events, you need a rooted device and inject events through adb command.