public
final
class
BackEvent
extends Object
| java.lang.Object | |
| ↳ | android.window.BackEvent |
Object used to report back gesture progress. Holds information about the touch event, swipe direction and the animation progress that predictive back animations should seek to.
Constants | |
|---|---|
int |
EDGE_LEFT
Indicates that the edge swipe starts from the left edge of the screen |
int |
EDGE_NONE
Indicates that the back event was not triggered by an edge swipe back gesture. |
int |
EDGE_RIGHT
Indicates that the edge swipe starts from the right edge of the screen |
Public constructors | |
|---|---|
BackEvent(float touchX, float touchY, float progress, int swipeEdge)
Creates a new |
|
BackEvent(float touchX, float touchY, float progress, int swipeEdge, long frameTimeMillis)
Creates a new |
|
Public methods | |
|---|---|
boolean
|
equals(Object other)
Indicates whether some other object is "equal to" this one. |
long
|
getFrameTimeMillis()
Returns the frameTime of the BackEvent in milliseconds. |
float
|
getProgress()
Returns a value between 0 and 1 on how far along the back gesture is. |
int
|
getSwipeEdge()
Returns the screen edge that the swipe starts from. |
float
|
getTouchX()
Returns the absolute X location of the touch point, or NaN if the event is from a button press. |
float
|
getTouchY()
Returns the absolute Y location of the touch point, or NaN if the event is from a button press. |
String
|
toString()
Returns a string representation of the object. |
Inherited methods | |
|---|---|
public static final int EDGE_LEFT
Indicates that the edge swipe starts from the left edge of the screen
Constant Value: 0 (0x00000000)
public static final int EDGE_NONE
Indicates that the back event was not triggered by an edge swipe back gesture. This applies to cases like using the back button in 3-button navigation or pressing a hardware back button.
Constant Value: 2 (0x00000002)
public static final int EDGE_RIGHT
Indicates that the edge swipe starts from the right edge of the screen
Constant Value: 1 (0x00000001)
public BackEvent (float touchX,
float touchY,
float progress,
int swipeEdge)Creates a new BackEvent instance with a frame time of 0.
touchXfloat: Absolute X location of the touch point of this event.touchYfloat: Absolute Y location of the touch point of this event.progressfloat: Value between 0 and 1 on how far along the back gesture is.swipeEdgeint: Indicates which edge the swipe starts from.
public BackEvent (float touchX,
float touchY,
float progress,
int swipeEdge,
long frameTimeMillis)Creates a new BackEvent instance.
touchXfloat: Absolute X location of the touch point of this event.touchYfloat: Absolute Y location of the touch point of this event.progressfloat: Value between 0 and 1 on how far along the back gesture is.swipeEdgeint: Indicates which edge the swipe starts from.
frameTimeMillislong: frame time of the back event.public boolean equals (Object other)
Indicates whether some other object is "equal to" this one.
The equals method implements an equivalence relation
on non-null object references:
x, x.equals(x) should return
true.
x and y, x.equals(y)
should return true if and only if
y.equals(x) returns true.
x, y, and z, if
x.equals(y) returns true and
y.equals(z) returns true, then
x.equals(z) should return true.
x and y, multiple invocations of
x.equals(y) consistently return true
or consistently return false, provided no
information used in equals comparisons on the
objects is modified.
x,
x.equals(null) should return false.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
| Parameters | |
|---|---|
other |
Object: the reference object with which to compare. |
| Returns | |
|---|---|
boolean |
true if this object is the same as the obj
argument; false otherwise. |
public long getFrameTimeMillis ()
Returns the frameTime of the BackEvent in milliseconds. Useful for calculating velocity.
| Returns | |
|---|---|
long |
|
public float getProgress ()
Returns a value between 0 and 1 on how far along the back gesture is. This value is driven by the horizontal location of the touch point, and should be used as the fraction to seek the predictive back animation with. Specifically,
| Returns | |
|---|---|
float |
Value is between 0.0f and 1.0f inclusive |
public int getSwipeEdge ()
Returns the screen edge that the swipe starts from.
intpublic float getTouchX ()
Returns the absolute X location of the touch point, or NaN if the event is from a button press.
| Returns | |
|---|---|
float |
|
public float getTouchY ()
Returns the absolute Y location of the touch point, or NaN if the event is from a button press.
| Returns | |
|---|---|
float |
|
public String toString ()
Returns a string representation of the object.
| Returns | |
|---|---|
String |
a string representation of the object. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-02-13 UTC.