gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 15:58:05 25 4
gpt4 key购买 nike

在我的 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在谷歌代码上:

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com