Android上特定于设备的屏幕捕获 [英] Device specific screen capturing on android

查看:132
本文介绍了Android上特定于设备的屏幕捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们需要找到一种无需使用任何外部软件即可捕获Android屏幕的方法,该软件可以在无根电话上运行.

We need to find a way to capture Android screen, without using any external software, which will work on a non-rooted phone.

我的研究表明,没有办法做到这一点.无论如何,您都应该具有root权限,才能捕获设备的屏幕.

My research shows that there is no way to do that. In any way, you should have root permissions, to be able to capture device's screen.

然而,进一步的研究表明,有一种方法可以使有限数量的设备在没有root特权的情况下执行此操作.作为证明,我可以将以下应用程序带入Android市场:屏幕快照UX.

Further research, however, shows, that there is a way for limited number of devices, to do that, without having root privileges. As a proof I can bring following application on Android market: Screenshot UX.

它声称该应用不需要root权限即可在以下设备上捕获屏幕:

It claims, that app doesn't need root permissions for capturing screen on following devices:

  • 银河系(S,S2,...)
  • HTC手机(Sensation,...)
  • 摩托罗拉(Atrix,...).
  • LG Optimus系列(G2X,...)

有人说,Tegra设备也支持.

Some say, that Tegra devices support that also.

任何人都可以至少在特定设备上指出一些文档,因此我们至少可以支持HTC电话.

Could anyone point on some documentation, at least on specific devices, so we can at least support HTC phones, for example.

目前,我们正在尝试使用"/system/bin/screencap",但是在模拟器上没有成功. 是否可以在某些特定设备上拍摄屏幕快照只是意味着它们允许使用"/system/bin/screencap"或直接从/dev/graphics/fb0中读取?

For now we are trying to use "/system/bin/screencap", with no success on emulator though. Does availability of taking screenshots on some certain devices just means that they allow to use "/system/bin/screencap" or read directly from /dev/graphics/fb0?

还是他们提供了一些用于截取屏幕截图的API?

Or they give some API for taking screenshots?

谢谢.

推荐答案

屏幕捕获是android上一个古老且讨论最多的主题. 在过去的几年中,很少开发出一些主要选择:

Screen capturing is an old and much discussed topic on android. Over the last years few major options developed:

  1. 在有根设备上运行屏幕截图,但是您已经知道这一点.

  1. Running screencap on rooted devices, But you already know this.

运行屏幕截图并使用系统证书对应用程序进行标记:

Running screencap and siginging your application with system certificate:

具有READ_FRAME_BUFFER权限,但只有在将您的应用程序签名为系统应用程序时才能获得该权限.

There is a permission READ_FRAME_BUFFER but you only can obtain it when your apps are signed as system application.

  1. 使用各种ADB技巧,但是其中大多数都使用了截屏和AFAIK,需要您将设备连接到PC.

但是自Android 5以来,情况有所变化.

Android 5.0可让您添加屏幕捕获和屏幕共享 通过新的android.media.projection API为您的应用提供功能. 此功能很有用,例如,如果您要启用 视频会议应用程序中的屏幕共享.

Android 5.0 lets you add screen capturing and screen sharing capabilities to your app with the new android.media.projection APIs. This functionality is useful, for example, if you want to enable screen sharing in a video conferencing app.

新的createVirtualDisplay()方法可让您的应用捕获 主屏幕的内容(默认显示)进入Surface 对象,然后您的应用可以通过网络发送该对象.仅API 允许捕获非安全的屏幕内容,而不是系统音频.到 要开始抓屏,您的应用必须首先请求用户的 通过使用Intent启动屏幕捕获对话框来获得许可 通过createScreenCaptureIntent()方法获得.

The new createVirtualDisplay() method allows your app to capture the contents of the main screen (the default display) into a Surface object, which your app can then send across the network. The API only allows capturing non-secure screen content, and not system audio. To begin screen capturing, your app must first request the user’s permission by launching a screen capture dialog using an Intent obtained through the createScreenCaptureIntent() method.

您提到的设备已经过时,我怀疑它们是否已对android 5进行了正式更新,因此您只能选择第二个选项.

The devices you mentioned are quite old and I doubt that they got an official update to android 5, this leaves you with the 2nd option.

这篇关于Android上特定于设备的屏幕捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆