这里有一些关于捕获 Android 应用程序屏幕截图的问题。但是,我还没有找到关于如何使用 android SDK 或任何其他方法以编程方式截取屏幕截图的可靠解决方案。
所以我想我会再次问这个问题,希望我能找到一个好的解决方案,希望能够捕获全长图像,并将其保存到 SD 卡或类似的地方。
我感谢任何帮助
There are a few questions here on SO about capturing screenshots of an android application. However, I haven't found a solid solution on how to take a screenshot programatically using the android SDK or any other method.
So I thought I would ask this question again in the hopes that I can find a good solution, hopefully one that will allow capturing full length images that I can save to the SD card or somewhere similar.
I appreicate any help
发布评论
评论(4)
这不可能直接在设备/模拟器上实现,除非它已获得 root 权限。
这听起来像是 monkeyrunner。
This is not possible directly on the device/emulator, unless it is rooted.
This sounds like a job for monkeyrunner.
Monkeyrunner 工具可以通过一些 adb 命令为您完成这项工作,[python 脚本]
注意:调用此 jython 脚本文件
Monkeyrunner.bat <文件名>;
monkeyrunner tool can do the job for you with bit of adb command, [python script]
Note: call this jython script file
monkeyrunner.bat <file name>
您很可能会对这个答案不满意,但我见过的唯一答案涉及使用本机代码或执行本机命令。
编辑:
我以前没见过这个。你尝试过吗?:
http://code.google.com/p/android-screenshot-library/
Edit2:检查了该库,这也是一个糟糕的解决方案。要求您从 PC 启动该服务。所以我最初的答案仍然成立:)
Edit3:您应该能够通过执行类似的操作将视图保存为图像。您可能需要稍微调整一下,以便获得视图的宽度/高度。 (我正在膨胀布局,并在布局代码时指定宽度/高度)
You will most likely not be happy with this answer, but the only ones that I have seen involve using native code, or executing native commands.
Edit:
I hadn't seen this one before. Have you tried it?:
http://code.google.com/p/android-screenshot-library/
Edit2: Checked that library, and it also is a bad solution. Requires that you start the service from a pc. So my initial answer still holds :)
Edit3: You should be able to save a view as an image by doing something similar to this. You might need to tweek it a bit so that you get the width/height of the view. (I'm inflating layouts, and specify the width/height when I layout the code)
您可以查看 http://codaset.com/jens-riboe/droidatscreen/wiki (写在 http://blog.ribomation.com/2010/01/droidscreen/):这是一个使用
adb
捕获屏幕截图的 Java 库。我已经能够(费了很多功夫)修改源代码,让我自动捕获一系列定时的屏幕截图(我将其用于演示视频)。您可以在 http://pastebin.com/hX5rQsSR 中查看类结构
编辑:您可以调用它(之后捆绑所有要求)如下所示:
java -cp DroidScreen.jar --adb "" --device "" --prefix "" --interval
You can look at http://codaset.com/jens-riboe/droidatscreen/wiki (with a write up at http://blog.ribomation.com/2010/01/droidscreen/): this is a Java library that uses
adb
to capture a screen shots. I've been able to (with a lot of elbow grease) modify the source to let me automatically capture a timed series of screen shots (which I use for demo videos).You can see the class structure at http://pastebin.com/hX5rQsSR
EDIT: You'd invoke it (after bundling all the requirements) like this:
java -cp DroidScreen.jar --adb "" --device "" --prefix "" --interval