我的 Delphi XE7 应用程序的 Android 屏幕截图

标签 android delphi screenshot firemonkey delphi-xe7

在我的 Android 手机上: 如何从我的 Delphi XE7 应用程序中同时按住右侧的待机键和主页按钮。 IE。访问这两个按钮以从我的应用程序内截取屏幕截图(到图片文件夹)?

最佳答案

在 API 级别 17 (Jelly Bean MR1) 及更高版本中,Android 的 com.android.uiautomator.core.UiDevice类有两个 takeScreenshot() 方法:

public boolean takeScreenshot (File storePath)

Take a screenshot of current window and store it as PNG Default scale of 1.0f (original size) and 90% quality is used The screenshot is adjusted per screen rotation

Parameters

storePath
where the PNG should be written to

Returns
true if screen shot is created successfully, false otherwise

public boolean takeScreenshot (File storePath, float scale, int quality)

Take a screenshot of current window and store it as PNG The screenshot is adjusted per screen rotation

Parameters

storePath
where the PNG should be written to

scale
scale the screenshot down if needed; 1.0f for original size

quality
quality of the PNG compression; range: 0-100

Returns
true if screen shot is created successfully, false otherwise

对于较旧的 Android 版本,没有屏幕截图 API,并且您无法模拟硬件按键来强制进行编程。尽管似乎有一些方法可以让 View 对象将自身渲染为 Bitmap 对象,然后您可以根据需要使用它们。

App Store 中有可以截屏的第三方应用,因此您也许可以使用 Intent 调用其中一个应用。

还有第三方截图库可用,例如Android Screenshot Library在 Google 代码上:

Android Screenshot Library (ASL) enables to programmatically capture screenshots from Android devices without requirement of having root access privileges. Instead, ASL utilizes a native service running in the background, started via the Android Debug Bridge (ADB) once per device boot.

关于我的 Delphi XE7 应用程序的 Android 屏幕截图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26722484/

相关文章:

java - Android apk 无法使用 PHP 检索超过 3g 的数据,在 wifi 上工作正常

java - 如何获取两个多点触控点的RawX和RawY

algorithm - 将帧转换为 NTSC 丢帧时间码

delphi - 使 2 个表格能够相互重叠?

google-maps - 谷歌地图图层可以导入tatukGis ViewerWnd吗

python - Pytesseract 不接受 pyautogui 屏幕截图、Windows、Python 3.6

android - android 中的 gcm 注册失败

java - 重启 Android 后自定义小部件中的 Android 持久可检查菜单

ios5 - 以编程方式截取屏幕截图 iOs 5

java - Selenium Webdriver 屏幕截图不显示驱动程序错误