开发者

capturing another activity's screen in android

开发者 https://www.devze.com 2022-12-29 19:21 出处:网络
is it possible to have a service (A) which will launch an activity开发者_运维技巧 (B) and then periodically capture B\'s screen?

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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号