2

While there are questions relevant to mine, none are quite answering them to the extent of what I was looking for. First off, is it possible to have a downloadable Android app that "runs on top of another app" that is, it emulates a pre-defined user input and doesn't have a traditional "gui." For example, (hypothetically) if I had an app that plays videos but is set to auto turn off the screen every 10 seconds, I would want an onTouch event every few seconds in order to prevent this. Nothing complicated, just touches, maybe a few swipes, and the other events that go along with them.

Secondly, if this is not a valid way to create an app "with no interface, just a pre-defined script, is there any other way that I could "inject" on-touch events into an app that isn't open-source?

EDIT: To be more specific, I'm looking at making a "quick" app helper, a sort of program that when activated, runs a pre-defined set of instructions that emulate user input at very high speed, so, think of an app that performs some activity (like swiping from object A to object B) and back REALLY fast. I'm also already looking at speed thresholds on different android devices to find a common (maximum) one that would work for all devices.

user1519665
  • 481
  • 4
  • 12
  • 1
    Take a look at the [UI/Application Exerciser Monkey](http://developer.android.com/tools/help/monkey.html) to see one way this might be done. You might also want to clarify your question to specify what it is you are really trying to do. Specifics help a lot. – Michael Hampton Jul 12 '12 at 04:57

1 Answers1

0

You want the android.app.Instrumentation class. This lets you send a wide variety of events to an application and monitor the results.

To use this class successfully, your app must have the INJECT_EVENTS permission and must be signed with the system signing key. This means you need to be working on a rooted device with your own custom firmware. You won't be able to do this with carrier-provided firwmare.

If your solution doesn't need to be an .apk, then you can try using monkeyrunner. This only requires that you are able to connect to the device with adb (i.e. USB debugging is enabled for the device).

Community
  • 1
  • 1
Michael Hampton
  • 8,754
  • 3
  • 47
  • 88