Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Constants](https://developer.android.com/reference/android/app/jank/AppJankStats#constants) \| [Ctors](https://developer.android.com/reference/android/app/jank/AppJankStats#pubctors) \| [Methods](https://developer.android.com/reference/android/app/jank/AppJankStats#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/jank/AppJankStats#inhmethods)

# AppJankStats

*** ** * ** ***

` public final class AppJankStats `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.jank.AppJankStats |

<br />

*** ** * ** ***

This class stores detailed jank statistics for an individual UI widget. These statistics provide performance insights for specific UI widget states by correlating the number of "Janky frames" with the total frames rendered while the widget is in that state. This class can be used by library widgets to provide the system with more detailed information about where jank is happening for diagnostic purposes.

## Summary

| ### Constants ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_CATEGORY_ANIMATION` UI elements that facilitate playing animations. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_CATEGORY_KEYBOARD` UI elements that facilitate displaying, hiding or interacting with keyboard. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_CATEGORY_MEDIA` UI elements that facilitate media playback. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_CATEGORY_NAVIGATION` UI elements that facilitate in-app navigation. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_CATEGORY_OTHER` UI elements that don't fall in one or any of the other categories. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_CATEGORY_SCROLL` UI elements that facilitate scrolling. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_CATEGORY_UNSPECIFIED` Used to indicate no widget category has been set. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_ANIMATING` Used to indicate the UI element is currently animating. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_DRAGGING` Used to indicate the UI element is currently being dragged. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_FLINGING` Used to indicate the UI element is currently being flung. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_NONE` Used to indicate the UI element currently has no state and is idle. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_PLAYBACK` Used to indicate the UI element is currently playing media. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_PREDICTIVE_BACK` Used to indicate predictive back navigation is currently being used |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_SCROLLING` Used to indicate the UI element is currently scrolling. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_SWIPING` Used to indicate the UI element is currently being swiped. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_TAPPING` Used to indicate the UI element is currently being tapped on, for example on a keyboard. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_UNSPECIFIED` Used to indicate no widget state has been set. |
| `https://developer.android.com/reference/java/lang/String` | `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_ZOOMING` Used to indicate the UI element is currently zooming. |

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/app/jank/AppJankStats#AppJankStats(int,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20long,%20long,%20android.app.jank.RelativeFrameTimeHistogram)(int appUid, https://developer.android.com/reference/java/lang/String widgetId, https://developer.android.com/reference/java/lang/String navigationComponent, https://developer.android.com/reference/java/lang/String widgetCategory, https://developer.android.com/reference/java/lang/String widgetState, long totalFrames, long jankyFrames, https://developer.android.com/reference/android/app/jank/RelativeFrameTimeHistogram relativeFrameTimeHistogram) ` Creates a new AppJankStats object. |

| ### Public methods ||
|---|---|
| ` long` | ` https://developer.android.com/reference/android/app/jank/AppJankStats#getJankyFrameCount()() ` Returns the number of frames that were determined to be janky for this stat. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/jank/AppJankStats#getNavigationComponent()() ` Returns the navigation component if it exists that this stat applies to. |
| ` https://developer.android.com/reference/android/app/jank/RelativeFrameTimeHistogram` | ` https://developer.android.com/reference/android/app/jank/AppJankStats#getRelativeFrameTimeHistogram()() ` Returns a Histogram containing relative frame times in millis grouped into predefined buckets. |
| ` long` | ` https://developer.android.com/reference/android/app/jank/AppJankStats#getTotalFrameCount()() ` Returns the total number of frames counted for this stat. |
| ` int` | ` https://developer.android.com/reference/android/app/jank/AppJankStats#getUid()() ` Returns the app uid. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/jank/AppJankStats#getWidgetCategory()() ` Returns the category that the widget's functionality generally falls into, or `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_CATEGORY_UNSPECIFIED` if no value was passed in. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/jank/AppJankStats#getWidgetId()() ` Returns the id of the widget that reported state changes. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/android/app/jank/AppJankStats#getWidgetState()() ` Returns the widget's state that was reported for this stat, or `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_UNSPECIFIED` if no value was passed in. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Constants

### WIDGET_CATEGORY_ANIMATION

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_CATEGORY_ANIMATION
```

UI elements that facilitate playing animations.

<br />

Constant Value: "animation"

### WIDGET_CATEGORY_KEYBOARD

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_CATEGORY_KEYBOARD
```

UI elements that facilitate displaying, hiding or interacting with keyboard.

<br />

Constant Value: "keyboard"

### WIDGET_CATEGORY_MEDIA

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_CATEGORY_MEDIA
```

UI elements that facilitate media playback.

<br />

Constant Value: "media"

### WIDGET_CATEGORY_NAVIGATION

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_CATEGORY_NAVIGATION
```

UI elements that facilitate in-app navigation.

<br />

Constant Value: "navigation"

### WIDGET_CATEGORY_OTHER

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_CATEGORY_OTHER
```

UI elements that don't fall in one or any of the other categories.

<br />

Constant Value: "other"

### WIDGET_CATEGORY_SCROLL

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_CATEGORY_SCROLL
```

UI elements that facilitate scrolling.

<br />

Constant Value: "scroll"

### WIDGET_CATEGORY_UNSPECIFIED

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_CATEGORY_UNSPECIFIED
```

Used to indicate no widget category has been set.

<br />

Constant Value: "unspecified"

### WIDGET_STATE_ANIMATING

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_STATE_ANIMATING
```

Used to indicate the UI element is currently animating.

<br />

Constant Value: "animating"

### WIDGET_STATE_DRAGGING

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_STATE_DRAGGING
```

Used to indicate the UI element is currently being dragged.

<br />

Constant Value: "dragging"

### WIDGET_STATE_FLINGING

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_STATE_FLINGING
```

Used to indicate the UI element is currently being flung.

<br />

Constant Value: "flinging"

### WIDGET_STATE_NONE

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_STATE_NONE
```

Used to indicate the UI element currently has no state and is idle.

<br />

Constant Value: "none"

### WIDGET_STATE_PLAYBACK

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_STATE_PLAYBACK
```

Used to indicate the UI element is currently playing media.

<br />

Constant Value: "playback"

### WIDGET_STATE_PREDICTIVE_BACK

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_STATE_PREDICTIVE_BACK
```

Used to indicate predictive back navigation is currently being used

<br />

Constant Value: "predictive_back"

### WIDGET_STATE_SCROLLING

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_STATE_SCROLLING
```

Used to indicate the UI element is currently scrolling.

<br />

Constant Value: "scrolling"

### WIDGET_STATE_SWIPING

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_STATE_SWIPING
```

Used to indicate the UI element is currently being swiped.

<br />

Constant Value: "swiping"

### WIDGET_STATE_TAPPING

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_STATE_TAPPING
```

Used to indicate the UI element is currently being tapped on, for example on a keyboard.

<br />

Constant Value: "tapping"

### WIDGET_STATE_UNSPECIFIED

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_STATE_UNSPECIFIED
```

Used to indicate no widget state has been set.

<br />

Constant Value: "unspecified"

### WIDGET_STATE_ZOOMING

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static final String WIDGET_STATE_ZOOMING
```

Used to indicate the UI element is currently zooming.

<br />

Constant Value: "zooming"

## Public constructors

### AppJankStats

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AppJankStats (int appUid, 
                String widgetId, 
                String navigationComponent, 
                String widgetCategory, 
                String widgetState, 
                long totalFrames, 
                long jankyFrames, 
                RelativeFrameTimeHistogram relativeFrameTimeHistogram)
```

Creates a new AppJankStats object.

<br />

| Parameters ||
|---|---|
| `appUid` | `int`: the Uid of the App that is collecting jank stats. <br /> |
| `widgetId` | `String`: the widget id that frames will be associated to. This value cannot be `null`. <br /> |
| `navigationComponent` | `String`: the intended navigation target within the activity, this could be a navigation destination, screen and/or pane. This value may be `null`. <br /> |
| `widgetCategory` | `String`: a category used to organize widgets in a structured way that indicates they serve a similar purpose or perform related functions. Must be prefixed with WIDGET_CATEGORY_ and have a suffix of one of the following:SCROLL, ANIMATION, MEDIA, NAVIGATION, KEYBOARD, OTHER or will be set to UNSPECIFIED if no value is passed. This value may be `null`. <br /> |
| `widgetState` | `String`: the state the widget was in while frames were counted. Must be prefixed with WIDGET_STATE_ and have a suffix of one of the following: NONE, SCROLLING, FLINGING, SWIPING, DRAGGING, ZOOMING, ANIMATING, PLAYBACK, TAPPING, PREDICTIVE_BACK or will be set to WIDGET_STATE_UNSPECIFIED if no value is passed. This value may be `null`. <br /> |
| `totalFrames` | `long`: the total number of frames that were counted for this stat. <br /> |
| `jankyFrames` | `long`: the total number of janky frames that were counted for this stat. <br /> |
| `relativeFrameTimeHistogram` | `RelativeFrameTimeHistogram`: the histogram with predefined buckets. See `https://developer.android.com/reference/android/app/jank/AppJankStats#getRelativeFrameTimeHistogram()` for details. This value cannot be `null`. <br /> |

## Public methods

### getJankyFrameCount

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getJankyFrameCount ()
```

Returns the number of frames that were determined to be janky for this stat.

<br />

| Returns ||
|---|---|
| `long` | the number of frames that were determined to be janky for this stat. <br /> |

### getNavigationComponent

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getNavigationComponent ()
```

Returns the navigation component if it exists that this stat applies to.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the navigation component if it exists that this stat applies to. This value may be `null`. <br /> |

### getRelativeFrameTimeHistogram

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public RelativeFrameTimeHistogram getRelativeFrameTimeHistogram ()
```

Returns a Histogram containing relative frame times in millis grouped into predefined buckets. See `https://developer.android.com/reference/android/app/jank/RelativeFrameTimeHistogram` for more information.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/app/jank/RelativeFrameTimeHistogram` | Histogram containing relative frame times in predefined buckets. This value cannot be null. <br /> |

### getTotalFrameCount

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public long getTotalFrameCount ()
```

Returns the total number of frames counted for this stat.

<br />

| Returns ||
|---|---|
| `long` | the total number of frames counted for this stat. <br /> |

### getUid

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int getUid ()
```

Returns the app uid.

<br />

| Returns ||
|---|---|
| `int` | the app uid. <br /> |

### getWidgetCategory

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getWidgetCategory ()
```

Returns the category that the widget's functionality generally falls into, or `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_CATEGORY_UNSPECIFIED` if no value was passed in.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the category that the widget's functionality generally falls into, this value cannot be null. <br /> |

### getWidgetId

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getWidgetId ()
```

Returns the id of the widget that reported state changes.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the id of the widget that reported state changes. This value cannot be null. <br /> |

### getWidgetState

Added in [API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getWidgetState ()
```

Returns the widget's state that was reported for this stat, or `https://developer.android.com/reference/android/app/jank/AppJankStats#WIDGET_STATE_UNSPECIFIED` if no value was passed in.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the widget's state that was reported for this stat. This value cannot be null. <br /> |