0

is it possible to have a service (A) which will launch an activity (B) and then periodically capture B's screen?

also, is it possible to send onTouch events from A to B?

basically, i'd like to make a bot which would use an application so i don't have to.

i guess it's not possible but had to ask.

2 Answers2

1

You can't do that across Activitys but you could create a view that held the Activity that you want to automate. Then periodically you can grab the ViewDecorator and do some processing on it and then inject touch events.

CaseyB
  • 24,780
  • 14
  • 77
  • 112
  • Ummm...really? I'm unconvinced that's even possible within your own application, and I am inferring that that OP as interested in controlling another application. – CommonsWare May 07 '10 at 20:09
  • yes, i'm interested in controlling another activity which is not mine. don't have the source code for it or anything. btw, can't find anything about ViewDecorator in android. – discoHR May 07 '10 at 22:58
0

Screen captures of apps which are not the current app are prevented in Android devices due to security considerations. As far as I know up until Android 4.3 you can only do this in these scenarios:

  • Your device is rooted
  • Your app is signed with the same signature of the system (Google apps)
  • With adb (debug environment): your device is connected via USB to a PC which is running adb shell commands, or either the USB is disconnected but you have started the native adb service in your device after each device reboot.

Some useful links:

How to programmatically take a screenshot in Android?

How to make a capture screen app on Android

http://code.google.com/p/android-screenshot-library/wiki/UserGuide

Community
  • 1
  • 1
Diana
  • 2,186
  • 1
  • 20
  • 31