# ConfirmationOverlay

Artifact: [androidx.wear:wear](https://developer.android.com/jetpack/androidx/releases/wear) [View Source](https://cs.android.com/search?q=file:androidx/wear/widget/ConfirmationOverlay.java+class:androidx.wear.widget.ConfirmationOverlay) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

*** ** * ** ***


```
public class ConfirmationOverlay
```

<br />

*** ** * ** ***

Displays a full-screen confirmation animation with optional text and then hides it.

This is a lighter-weight version of `https://developer.android.com/reference/androidx/wear/activity/ConfirmationActivity` and should be preferred when constructed from an `https://developer.android.com/reference/android/app/Activity.html`.

Sample usage:

```
  // Defaults to SUCCESS_ANIMATION
  new ConfirmationOverlay().showOn(myActivity);

  new ConfirmationOverlay()
     .setType(ConfirmationOverlay.OPEN_ON_PHONE_ANIMATION)
     .setDuration(3000)
     .setMessage("Opening...")
     .setOnAnimationFinishedListener(new ConfirmationOverlay.OnAnimationFinishedListener() {
         @Override
         public void onAnimationFinished() {
             // Finished animating and the content view has been removed from myActivity.
         }
     }).showOn(myActivity);

  // Default duration is `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#DEFAULT_ANIMATION_DURATION_MS()`
  new ConfirmationOverlay()
     .setType(ConfirmationOverlay.FAILURE_ANIMATION)
     .setMessage("Failed")
     .setOnAnimationFinishedListener(new ConfirmationOverlay.OnAnimationFinishedListener() {
         @Override
         public void onAnimationFinished() {
             // Finished animating and the view has been removed from myView.getRootView().
         }
     }).showAbove(myView);
```

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OnAnimationFinishedListener` Interface for listeners to be notified when the `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` animation has finished and its `https://developer.android.com/reference/android/view/View.html` has been removed. |
| `@https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/androidx/annotation/IntDef(value = ) public annotation https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OverlayType` Types of animations to display in the overlay. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#DEFAULT_ANIMATION_DURATION_MS() = 1000` Default animation duration in ms. |
| `static final int` | `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#FAILURE_ANIMATION() = 1` `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OverlayType` indicating the failure overlay should be shown. |
| `static final int` | `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#OPEN_ON_PHONE_ANIMATION() = 2` `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OverlayType` indicating the "Open on Phone" animation overlay should be displayed. |
| `static final int` | `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#SUCCESS_ANIMATION() = 0` `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OverlayType` indicating the success animation overlay should be displayed. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#ConfirmationOverlay()()` |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setDuration(int)(int millis)` Sets the duration in milliseconds which controls how long the animation will be displayed. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `[setFinishedAnimationListener](https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setFinishedAnimationListener(androidx.wear.widget.ConfirmationOverlay.OnAnimationFinishedListener))( @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OnAnimationFinishedListener listener )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setOnAnimationFinishedListener(androidx.wear.widget.ConfirmationOverlay.OnAnimationFinishedListener)` instead. <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setMessage(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/CharSequence.html message)` Sets a message which will be displayed at the same time as the animation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `[setMessage](https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setMessage(java.lang.String))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html message)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setMessage(java.lang.CharSequence)` instead. <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setOnAnimationFinishedListener(androidx.wear.widget.ConfirmationOverlay.OnAnimationFinishedListener)( @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OnAnimationFinishedListener listener )` Sets the `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OnAnimationFinishedListener` which will be invoked once the overlay is no longer visible. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setType(int)(@https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OverlayType int type)` Sets the `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OverlayType` which controls which animation is displayed. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#showAbove(android.view.View)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html view)` Adds the overlay as a child of `view.getRootView()`, removing it when complete. |
| `void` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#showOn(android.app.Activity)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html activity)` Adds the overlay as a content view to the `activity`, removing it when complete. |

## Constants

### DEFAULT_ANIMATION_DURATION_MS

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
public static final int DEFAULT_ANIMATION_DURATION_MS = 1000
```

Default animation duration in ms.

### FAILURE_ANIMATION

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
public static final int FAILURE_ANIMATION = 1
```

`https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OverlayType` indicating the failure overlay should be shown. The icon associated with this type, unlike the others, does not animate.

### OPEN_ON_PHONE_ANIMATION

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
public static final int OPEN_ON_PHONE_ANIMATION = 2
```

`https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OverlayType` indicating the "Open on Phone" animation overlay should be displayed.

### SUCCESS_ANIMATION

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
public static final int SUCCESS_ANIMATION = 0
```

`https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OverlayType` indicating the success animation overlay should be displayed.

## Public constructors

### ConfirmationOverlay

Added in 1.1.0

```
public ConfirmationOverlay()
```

## Public methods

### setDuration

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
public @NonNull ConfirmationOverlay setDuration(int millis)
```

Sets the duration in milliseconds which controls how long the animation will be displayed. Default duration is `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#DEFAULT_ANIMATION_DURATION_MS()`.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `this` object for method chaining. |

### setFinishedAnimationListener

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
public @NonNull ConfirmationOverlay [setFinishedAnimationListener](https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setFinishedAnimationListener(androidx.wear.widget.ConfirmationOverlay.OnAnimationFinishedListener))(
    @Nullable ConfirmationOverlay.OnAnimationFinishedListener listener
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setOnAnimationFinishedListener(androidx.wear.widget.ConfirmationOverlay.OnAnimationFinishedListener)` instead.

Sets the `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OnAnimationFinishedListener` which will be invoked once the overlay is no longer visible.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `this` object for method chaining. |

### setMessage

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
public @NonNull ConfirmationOverlay setMessage(@NonNull CharSequence message)
```

Sets a message which will be displayed at the same time as the animation.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `this` object for method chaining. |

### setMessage

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0) Deprecated in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
public @NonNull ConfirmationOverlay [setMessage](https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setMessage(java.lang.String))(@NonNull String message)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay#setMessage(java.lang.CharSequence)` instead.

Sets a message which will be displayed at the same time as the animation.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `this` object for method chaining. |

### setOnAnimationFinishedListener

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
public @NonNull ConfirmationOverlay setOnAnimationFinishedListener(
    @Nullable ConfirmationOverlay.OnAnimationFinishedListener listener
)
```

Sets the `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OnAnimationFinishedListener` which will be invoked once the overlay is no longer visible.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `this` object for method chaining. |

### setType

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
public @NonNull ConfirmationOverlay setType(@ConfirmationOverlay.OverlayType int type)
```

Sets the `https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay.OverlayType` which controls which animation is displayed.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/widget/ConfirmationOverlay` | `this` object for method chaining. |

### showAbove

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
@MainThread
public void showAbove(@NonNull View view)
```

Adds the overlay as a child of `view.getRootView()`, removing it when complete. While it is shown, all touches will be intercepted to prevent accidental taps on obscured views.

### showOn

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/wear#1.1.0)

```
@MainThread
public void showOn(@NonNull Activity activity)
```

Adds the overlay as a content view to the `activity`, removing it when complete. While it is shown, all touches will be intercepted to prevent accidental taps on obscured views.