DeviceCapture
public final class DeviceCapture
Summary
Public methods
takeScreenshot
public static final @NonNull Bitmap takeScreenshot()
Captures an image of the device's screen into a Bitmap.
This is essentially a wrapper for UIAutomation#takeScreenshot() that attempts to get a stable screenshot by forcing all the current application's root window views to redraw, and also handles cases where hardware renderer drawing is disabled.
This API is intended for use cases like debugging where an image of the entire screen is needed. For use cases where the image will be used for validation, its recommended to take a more isolated, targeted screenshot of a specific view or compose node. See androidx.test.core.view.captureToBitmap, androidx.test.espresso.screenshot.captureToBitmap and androidx.compose.ui.test.captureToImage.
This API does not support concurrent usage.
This API is currently experimental and subject to change or removal.
| Throws | |
|---|---|
IllegalStateException |
if called on the main thread. This is a limitation of connecting to UiAutomation, |