# Screenshot

Artifact: [androidx.test:runner](https://developer.android.com/jetpack/androidx/releases/test) [View Source](https://cs.android.com/search?q=file:androidx/test/runner/screenshot/Screenshot.java+class:androidx.test.runner.screenshot.Screenshot)

*** ** * ** ***


```
public final class Screenshot
```

<br />

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> use androidx.test.espresso.screenshot.captureToBitmap or androidx.test.core.app.DeviceCapture instead

The Screenshot instance provides methods to capture a `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` during instrumentation tests run on an android device.

The Screenshot instance keeps track of a set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s that will be passed to each `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` object when they are created during any test. These `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s are capable of processing the `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that was created.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot.ScreenShotException extends https://developer.android.com/reference/java/lang/RuntimeException.html` **This class is deprecated.** use androidx.test.espresso.screenshot.captureToBitmap or androidx.test.core.app.DeviceCapture instead <br /> |

| ### Public constructors |
|---|
| `[Screenshot](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#Screenshot())()` **This method is deprecated.** Deprecated in Java |

| ### Public methods |
|---|---|
| `static void` | `[addScreenCaptureProcessors](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#addScreenCaptureProcessors(java.util.Set<androidx.test.runner.screenshot.ScreenCaptureProcessor>))( https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor> screenCaptureProcessors )` **This method is deprecated.** Deprecated in Java |
| `static https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` | `[capture](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#capture())()` **This method is deprecated.** Deprecated in Java |
| `static https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` | `[capture](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#capture(android.app.Activity))(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/Activity.html activity)` **This method is deprecated.** Deprecated in Java |
| `static https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` | `[capture](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#capture(android.view.View))(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html view)` **This method is deprecated.** Deprecated in Java |
| `static void` | `[setScreenshotProcessors](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#setScreenshotProcessors(java.util.Set<androidx.test.runner.screenshot.ScreenCaptureProcessor>))( https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor> screenCaptureProcessors )` **This method is deprecated.** Deprecated in Java |

## Public constructors

### Screenshot

```
public [Screenshot](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#Screenshot())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

## Public methods

### addScreenCaptureProcessors

```
public static void [addScreenCaptureProcessors](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#addScreenCaptureProcessors(java.util.Set<androidx.test.runner.screenshot.ScreenCaptureProcessor>))(
    Set<ScreenCaptureProcessor> screenCaptureProcessors
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Adds the given set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s to the current set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s.

The current set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s will be passed to each `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that is created.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor> screenCaptureProcessors` | the set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s to add |

### capture

```
public static ScreenCapture [capture](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#capture())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Creates a `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that contains a `https://developer.android.com/reference/android/graphics/Bitmap.html` of the visible screen content.

The `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that is returned will also contain the set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s that have been set in this instance.

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` | a `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that contains the bitmap of the visible screen content. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if used on API below Build.VERSION_CODES.JELLY_BEAN_MR2 |
| `https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot.ScreenShotException` | If there was an error capturing the screenshot |

### capture

```
public static ScreenCapture [capture](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#capture(android.app.Activity))(@NonNull Activity activity)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Creates a `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that contains a `https://developer.android.com/reference/android/graphics/Bitmap.html` of the given activity's root `https://developer.android.com/reference/android/view/View.html` hierarchy content.

The `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that is returned will also contain the set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s that have been set in this instance.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/app/Activity.html activity` | the `https://developer.android.com/reference/android/app/Activity.html` who's root `https://developer.android.com/reference/android/view/View.html` will be used to create a `https://developer.android.com/reference/android/graphics/Bitmap.html` |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` | a `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that contains the bitmap of the given activity's root `https://developer.android.com/reference/android/view/View.html`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if given activity is null |
| `https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot.ScreenShotException` | If there was an error capturing the screenshot |

### capture

```
public static ScreenCapture [capture](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#capture(android.view.View))(@NonNull View view)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Creates a `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that contains a `https://developer.android.com/reference/android/graphics/Bitmap.html` of the given view's hierarchy content.

The `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that is returned will also contain the set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s that have been set in this instance.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/View.html view` | the `https://developer.android.com/reference/android/view/View.html` to create a `https://developer.android.com/reference/android/graphics/Bitmap.html` of |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` | `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that contains the bitmap of the given view's hierarchy content. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException.html` | if given view is null |
| `https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot.ScreenShotException` | If there was an error capturing the screenshot |

### setScreenshotProcessors

```
public static void [setScreenshotProcessors](https://developer.android.com/reference/androidx/test/runner/screenshot/Screenshot#setScreenshotProcessors(java.util.Set<androidx.test.runner.screenshot.ScreenCaptureProcessor>))(
    Set<ScreenCaptureProcessor> screenCaptureProcessors
)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Sets the current set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s to the given set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s.

The current set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s will be passed to each `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCapture` that is created.

| Parameters |
|---|---|
| `https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor> screenCaptureProcessors` | the set of `https://developer.android.com/reference/androidx/test/runner/screenshot/ScreenCaptureProcessor`s to use |