Device specific screen capturing on android

时光总嘲笑我的痴心妄想 提交于 2019-12-08 05:08:23

问题


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

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.

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.

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

  • Gallaxy series (S,S2,...)
  • HTC phones (Sensation, ...)
  • Motorola (Atrix, ...).
  • LG Optimus series (G2X, ...)

Some say, that Tegra devices support that also.

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

EDIT: 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?

Or they give some API for taking screenshots?

Thanks.


回答1:


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

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

  2. Running screencap and siginging your application with system certificate:

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

  1. Using all sort of ADB tricks, but most of them use screencap and AFAIK require you to have the device connected to a PC.

But Since Android 5 things have changed.

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.

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.

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.



来源:https://stackoverflow.com/questions/14242131/device-specific-screen-capturing-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!