Language

AccessibilityService.TakeScreenshotOfWindow Method

Definition

Takes a screenshot of the specified window and returns it via an AccessibilityService.ScreenshotResult.

[Android.Runtime.Register("takeScreenshotOfWindow", "(ILjava/util/concurrent/Executor;Landroid/accessibilityservice/AccessibilityService$TakeScreenshotCallback;)V", "GetTakeScreenshotOfWindow_ILjava_util_concurrent_Executor_Landroid_accessibilityservice_AccessibilityService_TakeScreenshotCallback_Handler", ApiSince=34)]
public virtual void TakeScreenshotOfWindow(int accessibilityWindowId, Java.Util.Concurrent.IExecutor executor, Android.AccessibilityServices.AccessibilityService.ITakeScreenshotCallback callback);
[<Android.Runtime.Register("takeScreenshotOfWindow", "(ILjava/util/concurrent/Executor;Landroid/accessibilityservice/AccessibilityService$TakeScreenshotCallback;)V", "GetTakeScreenshotOfWindow_ILjava_util_concurrent_Executor_Landroid_accessibilityservice_AccessibilityService_TakeScreenshotCallback_Handler", ApiSince=34)>]
abstract member TakeScreenshotOfWindow : int * Java.Util.Concurrent.IExecutor * Android.AccessibilityServices.AccessibilityService.ITakeScreenshotCallback -> unit
override this.TakeScreenshotOfWindow : int * Java.Util.Concurrent.IExecutor * Android.AccessibilityServices.AccessibilityService.ITakeScreenshotCallback -> unit

Parameters

accessibilityWindowId
Int32

The window id, from AccessibilityWindowInfo.getId().

executor
IExecutor

Executor on which to run the callback. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

callback
AccessibilityService.ITakeScreenshotCallback

The callback invoked when taking screenshot has succeeded or failed. See TakeScreenshotCallback for details. This value cannot be null.

Attributes

Remarks

Takes a screenshot of the specified window and returns it via an AccessibilityService.ScreenshotResult. You can use Bitmap.wrapHardwareBuffer to construct the bitmap from the ScreenshotResult's payload.

Note: In order to take screenshots your service has to declare the capability to take screenshot by setting the R.styleable.AccessibilityService_canTakeScreenshot property in its meta-data. For details refer to SERVICE_META_DATA.

Both this method and takeScreenshot(int, Executor, TakeScreenshotCallback) can be used for machine learning-based visual screen understanding. Use takeScreenshotOfWindow if your target window might be visually underneath an accessibility overlay (from your or another accessibility service) in order to capture the window contents without the screenshot being covered by the overlay contents drawn on the screen.

Android reference for android.accessibilityservice.AccessibilityService.takeScreenshotOfWindow.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to