android - 以编程方式捕获整个屏幕
是否可以从 Android 应用程序代码中捕获整个屏幕?我正在为 Android 平台开发类似 VNC 的应用程序。
问候
Is it possible to capture the entire screen from Android application code? I'm developing an application like VNC for Android platform.
Regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为这取决于你想要捕捉什么。我确信您可以使用莫斯的方法从您自己的应用程序创建屏幕截图 - 即您自己渲染的东西。
然而,据我了解,出于安全原因,从其他视图、应用程序等捕获被设计为不可能的。这是为了避免应用程序能够从其他应用程序获取屏幕截图,这将很容易窃取敏感数据。
I think that depends on what you are trying to capture. I'm sure you can use Moss's method to create a screenshot from your own application - that is, something you render yourself.
As I understand it however, capturing from other views, apps, etc. is designed to be impossible for security reasons. This is to avoid apps being able to take screen shots from other apps, which would make it easy to steal sensitive data.
是的。您只需要创建一个画布并为其分配一个位图,然后绘制到该画布而不是您在 onDraw 方法中使用的画布,并将位图保存在 SD 卡上。
只是为了提醒您,如果您处理绘图,此方法将起作用,因此您应该使用自定义主屏幕来捕获您想要的内容。 (只需获取默认的 Android 主屏幕:D)。
yes it is. You just need to create a canvas and assign it a Bitmap, then draw to that canvas instead of the canvas you use in your onDraw method and save the bitmap on the SDcard for example.
Just to renind you that this method will work if you handle the drawing, so you should use a custom home screen for it to capture wether you want. (just get the default android home screen :D).
我没有个人经验,但这个开源项目听起来可能可以解决您的问题,或者为您提供有关使用哪个 API 的线索:
http://sourceforge.net/projects/ashot/
I don't have personal experience with it, but this open source project sounds like it might either solve your problem, or provide you clues as to which API to use:
http://sourceforge.net/projects/ashot/