我正在使用 Android AccessibilityService 使用已在 api level 30 上添加的一些方法截屏,我想知道它是否适用于 api 低于 30 的方法
这是我的重写方法
@Override
public void takeScreenshot(int displayId, @NonNull Executor executor, @NonNull TakeScreenshotCallback callback) {
super.takeScreenshot(displayId, executor, callback);
}
这就是我调用 takeScreenshot 方法的地方,它通过 takeScreenshot CallBack 给了我结果
takeScreenshot(Display.DEFAULT_DISPLAY,
getApplicationContext().getMainExecutor(), new TakeScreenshotCallback() {
@RequiresApi(api = Build.VERSION_CODES.R)
@Override
public void onSuccess(@NonNull ScreenshotResult screenshotResult) {
Log.i("ScreenShotResult","onSuccess");
Bitmap bitmap = Bitmap.wrapHardwareBuffer(screenshotResult.getHardwareBuffer(),screenshotResult.getColorSpace());
AccessibilityUtils.saveImage(bitmap,getApplicationContext(),"WhatsappIntegration");
}
@Override
public void onFailure(int i) {
Log.i("ScreenShotResult","onFailure code is "+ i);
}
});
最佳答案
不幸的是,没有。
我尝试在低于 31 的 API 上使用它并收到以下错误。
这是我的 XML:
<accessibility-service
xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFeedbackType="feedbackAllMask"
android:notificationTimeout="100"
android:canRetrieveWindowContent="true"
android:canTakeScreenshot="true"/>
关于android - android accessibilityService 会在低于 30 的 api 上截屏吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68646933/