0

How can I send touch events to a particular app?! I found some tricks but device must be rooted!

There is some Apps that can do this and don't need system permission or rooted device!

Nobody knows how this is possible ?!

Jessica
  • 685
  • 1
  • 9
  • 23

2 Answers2

1

If I understand well, what you are looking for is be able to call onClick methods in application A, from application B.

If both apps are programmed by you, you can make a way around and in application A, create a parameter when passed through an intent performs the onClick method. So that when you call A from B you introduce in the intent an extra with that information.

If the application belongs to other party, you will need to do the rooting stuff, notice that you can call methods from other Activity if you don't declare the activity in your manifest...

Trebia Project.
  • 930
  • 2
  • 17
  • 36
0

If you can connect with a USB cable, you can use MonkeyRunner or ADB commands to do this.

For example, using a Jython script using MonkeyRunner, you can input touch events like this (slightly modified from their documentation):

#! /usr/bin/env monkeyrunner

import java

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice

# Connect and start application
device = MonkeyRunner.waitForConnection()
device.installPackage('myproject/bin/MyApplication.apk')
package = 'com.example.android.myapplication'
activity = 'com.example.android.myapplication.MainActivity'
runComponent = package + '/' + activity
device.startActivity(component=runComponent)

# Touch and drag
x, y = 100,100
duration = 0.5
numsteps = 20

device.touch(x, y, DOWN)
device.drag((x,y), (x+10,y+20), duration, numsteps)

With ADB this is even easier adb shell input tap x y

Btw, looks like this StackOverflow question has the ADB examples you are looking for, in case that works for you.

Community
  • 1
  • 1