# NavigationEvent

Artifact: [androidx.navigationevent:navigationevent](https://developer.android.com/jetpack/androidx/releases/navigationevent) [View Source](https://cs.android.com/search?q=file:androidx/navigationevent/NavigationEvent.kt+class:androidx.navigationevent.NavigationEvent) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigationevent#1.0.0)

*** ** * ** ***


```
public final class NavigationEvent
```

<br />

*** ** * ** ***

Represents a system navigation event, such as a predictive back gesture or a back button press.

This class standardizes various platform signals (e.g., touch gestures, key events) into a single, consistent format. This allows handlers like `https://developer.android.com/reference/androidx/navigationevent/NavigationEventDispatcher` to process navigation actions uniformly without needing to know the specific source of the event.

Note that not all parameters apply to every type of navigation event. For example, `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#touchX()` and `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#touchY()` are only relevant for gesture-based navigation.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler` |   |
| `https://developer.android.com/reference/androidx/navigationevent/NavigationEventDispatcher` |   |

## Summary

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#EDGE_LEFT() = 0` Indicates the navigation gesture originates from the left edge of the screen. |
| `static final int` | `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#EDGE_NONE() = 2` Indicates the navigation event was not caused by an edge swipe. |
| `static final int` | `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#EDGE_RIGHT() = 1` Indicates the navigation gesture originates from the right edge of the screen. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#NavigationEvent(kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Long)( int swipeEdge, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 1.0) float progress, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float touchX, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float touchY, long frameTimeMillis )` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final long` | `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#getFrameTimeMillis()()` The timestamp in milliseconds when this navigation event occurred. |
| `final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 1.0) float` | `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#getProgress()()` A normalized value from `0.0F` to `1.0F` indicating how far the navigation action has progressed. |
| `final int` | `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#getSwipeEdge()()` Indicates which screen edge a swipe-based navigation gesture originates from. |
| `final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float` | `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#getTouchX()()` The absolute X coordinate of the touch point for this event, in pixels, in the coordinate space of the screen. |
| `final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float` | `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#getTouchY()()` The absolute Y coordinate of the touch point for this event, in pixels, in the coordinate space of the screen. |
| `int` | `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#toString()()` |

| ### Extension functions |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/window/BackEvent.html` | `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 34) https://developer.android.com/reference/androidx/navigationevent/NavigationEventKt.https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#(androidx.navigationevent.NavigationEvent).toBackEvent()(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent receiver)` |

## Constants

### EDGE_LEFT

```
public static final int EDGE_LEFT = 0
```

Indicates the navigation gesture originates from the left edge of the screen.

### EDGE_NONE

```
public static final int EDGE_NONE = 2
```

Indicates the navigation event was not caused by an edge swipe. This applies to actions like a 3-button navigation press or a hardware back button event.

### EDGE_RIGHT

```
public static final int EDGE_RIGHT = 1
```

Indicates the navigation gesture originates from the right edge of the screen.

## Public constructors

### NavigationEvent

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

```
public NavigationEvent(
    int swipeEdge,
    @FloatRange(from = 0.0, to = 1.0) float progress,
    @FloatRange(from = 0.0) float touchX,
    @FloatRange(from = 0.0) float touchY,
    long frameTimeMillis
)
```

## Public methods

### equals

```
public boolean equals(Object other)
```

### getFrameTimeMillis

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

```
public final long getFrameTimeMillis()
```

The timestamp in milliseconds when this navigation event occurred. This is useful for synchronizing animations or for debugging event sequences.

### getProgress

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

```
public final @FloatRange(from = 0.0, to = 1.0) float getProgress()
```

A normalized value from `0.0F` to `1.0F` indicating how far the navigation action has progressed.

For continuous gestures like a swipe, this value will update incrementally. For discrete actions like a button press, a single event with `progress` of `0.0F` may be sent when the action starts, followed by a completion signal.

### getSwipeEdge

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

```
public final int getSwipeEdge()
```

Indicates which screen edge a swipe-based navigation gesture originates from. For non-swipe events, this will be `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent#EDGE_NONE()`.

Value is one of the following:

- `0`
- `1`
- `2`

<br />

### getTouchX

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

```
public final @FloatRange(from = 0.0) float getTouchX()
```

The absolute X coordinate of the touch point for this event, in pixels, in the coordinate space of the screen. For events not triggered by a touch gesture (e.g., a key press), this will be `0.0F`.

### getTouchY

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

```
public final @FloatRange(from = 0.0) float getTouchY()
```

The absolute Y coordinate of the touch point for this event, in pixels, in the coordinate space of the screen. For events not triggered by a touch gesture (e.g., a key press), this will be `0.0F`.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```

## Extension functions

### NavigationEventKt.toBackEvent

Artifact: [androidx.navigationevent:navigationevent](https://developer.android.com/jetpack/androidx/releases/navigationevent) [View Source](https://cs.android.com/search?q=file:androidx/navigationevent/NavigationEvent.android.kt+function:toBackEvent)

```
@RequiresApi(value = 34)
public final @NonNull BackEvent NavigationEventKt.toBackEvent(@NonNull NavigationEvent receiver)
```