简体   繁体   English

android-以编程方式捕获整个屏幕

[英]android - capture of the entire screen programatically

Is it possible to capture the entire screen from Android application code? 是否可以从Android应用程序代码捕获整个屏幕? I'm developing an application like VNC for Android platform. 我正在为Android平台开发类似VNC的应用程序。

Regards 问候

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. 我确定您可以使用Moss的方法从您自己的应用程序中创建屏幕截图-即您自己渲染的东西。

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. 这是为了避免应用程序能够从其他应用程序中截取屏幕快照,从而使窃取敏感数据变得容易。

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. 您只需要创建一个画布并为其分配一个位图,然后绘制到该画布而不是您在onDraw方法中使用的画布,然后将位图保存在SD卡上即可。

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). (只需获取默认的Android主屏幕:D)。

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: 我没有个人经验,但是这个开源项目听起来可能可以解决您的问题,或者为您提供有关使用哪种API的线索:
http://sourceforge.net/projects/ashot/ http://sourceforge.net/projects/ashot/

Screen capturing tool for Android handsets connected via USB to a desktop/laptop. 适用于通过USB连接到台式机/笔记本电脑的Android手机的屏幕捕获工具。 It is great for fullscreen presentations, product demos, automatic screen recording, or just a single screenshot. 它非常适合全屏演示,产品演示,自动屏幕录制或仅一个屏幕截图。 Without root. 没有root。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM