# HealthStats

Added in[API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Methods](https://developer.android.com/reference/android/os/health/HealthStats#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/os/health/HealthStats#inhmethods)  

# HealthStats

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/os/health/HealthStats "View this page in Kotlin")\|Java

`
public


class
HealthStats
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.os.health.HealthStats |

<br />

*** ** * ** ***

A HealthStats object contains system health data about an application.

**Data Types**   
Each of the keys references data in one of five data types:

A**measurement** metric contains a single`long`value. That value may be a count, a time, or some other type of value. The unit for a measurement (COUNT, MS, etc) will always be in the name of the constant for the key to retrieve it. For example, the[UidHealthStats.MEASUREMENT_WIFI_TX_MS](https://developer.android.com/reference/android/os/health/UidHealthStats#MEASUREMENT_WIFI_TX_MS)value is the number of milliseconds (ms) that were spent transmitting on wifi by an application. The[UidHealthStats.MEASUREMENT_MOBILE_RX_PACKETS](https://developer.android.com/reference/android/os/health/UidHealthStats#MEASUREMENT_MOBILE_RX_PACKETS)measurement is the number of packets received on behalf of an application. The[UidHealthStats.MEASUREMENT_TOUCH_USER_ACTIVITY_COUNT](https://developer.android.com/reference/android/os/health/UidHealthStats#MEASUREMENT_TOUCH_USER_ACTIVITY_COUNT)measurement is the number of times the user touched the screen, causing the screen to stay awake.

A**timer** metric contains an`int`count and a`long`time, measured in milliseconds. Timers track how many times a resource was used, and the total duration for that usage. For example, the[UidHealthStats.TIMER_FLASHLIGHT](https://developer.android.com/reference/android/os/health/UidHealthStats#TIMER_FLASHLIGHT)timer tracks how many times the application turned on the flashlight, and for how many milliseconds total it kept it on.

A**measurement map** metric is a mapping of[String](https://developer.android.com/reference/java/lang/String)names to[Long](https://developer.android.com/reference/java/lang/Long)values. The names typically are application provided names. For example, the[PackageHealthStats.MEASUREMENTS_WAKEUP_ALARMS_COUNT](https://developer.android.com/reference/android/os/health/PackageHealthStats#MEASUREMENTS_WAKEUP_ALARMS_COUNT)measurement map is a mapping of the tag provided to the[AlarmManager](https://developer.android.com/reference/android/app/AlarmManager)when the alarm is scheduled.

A**timer map** metric is a mapping of[String](https://developer.android.com/reference/java/lang/String)names to[TimerStat](https://developer.android.com/reference/android/os/health/TimerStat)objects. The names are typically application provided names. For example, the[UidHealthStats.TIMERS_WAKELOCKS_PARTIAL](https://developer.android.com/reference/android/os/health/UidHealthStats#TIMERS_WAKELOCKS_PARTIAL)is a mapping of tag provided to the[PowerManager](https://developer.android.com/reference/android/os/PowerManager)when the wakelock is created to the number of times and for how long each wakelock was active.

Lastly, a**health stats** metric is a mapping of[String](https://developer.android.com/reference/java/lang/String)names to a recursive[HealthStats](https://developer.android.com/reference/android/os/health/HealthStats)object containing more detailed information. For example, the[UidHealthStats.STATS_PACKAGES](https://developer.android.com/reference/android/os/health/UidHealthStats#STATS_PACKAGES)metric is a mapping of the package names for each of the APKs sharing a uid to the information recorded for that apk. The returned HealthStats objects will each be associated with a different set of constants. For the HealthStats returned for UidHealthStats.STATS_PACKAGES, the keys come from the[PackageHealthStats](https://developer.android.com/reference/android/os/health/PackageHealthStats)class.

The keys that are available are subject to change, depending on what a particular device or software version is capable of recording. Applications must handle the absence of data without crashing.

## Summary

|                                                                                                                                                                                                             ### Public methods                                                                                                                                                                                                             ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[String](https://developer.android.com/reference/java/lang/String)                                                                                                                                                           | ` `[getDataType](https://developer.android.com/reference/android/os/health/HealthStats#getDataType())`() ` Get a name representing the contents of this object.                                           |
| ` long`                                                                                                                                                                                                                         | ` `[getMeasurement](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurement(int))`(int key) ` Get the measurement for the given key.                                         |
| ` int`                                                                                                                                                                                                                          | ` `[getMeasurementKeyAt](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurementKeyAt(int))`(int index) ` Get the key for the measurement at the given index.                |
| ` int`                                                                                                                                                                                                                          | ` `[getMeasurementKeyCount](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurementKeyCount())`() ` Get the number of measurement values in this object.                     |
| ` `[Map](https://developer.android.com/reference/java/util/Map)`<`[String](https://developer.android.com/reference/java/lang/String)`, `[Long](https://developer.android.com/reference/java/lang/Long)`>`                       | ` `[getMeasurements](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurements(int))`(int key) ` Get the measurements map for the given key.                                  |
| ` int`                                                                                                                                                                                                                          | ` `[getMeasurementsKeyAt](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurementsKeyAt(int))`(int index) ` Get the key for the measurement map at the given index.          |
| ` int`                                                                                                                                                                                                                          | ` `[getMeasurementsKeyCount](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurementsKeyCount())`() ` Get the number of measurement map values in this object.               |
| ` `[Map](https://developer.android.com/reference/java/util/Map)`<`[String](https://developer.android.com/reference/java/lang/String)`, `[HealthStats](https://developer.android.com/reference/android/os/health/HealthStats)`>` | ` `[getStats](https://developer.android.com/reference/android/os/health/HealthStats#getStats(int))`(int key) ` Get the HealthStats map for the given key.                                                 |
| ` int`                                                                                                                                                                                                                          | ` `[getStatsKeyAt](https://developer.android.com/reference/android/os/health/HealthStats#getStatsKeyAt(int))`(int index) ` Get the key for the timer at the given index.                                  |
| ` int`                                                                                                                                                                                                                          | ` `[getStatsKeyCount](https://developer.android.com/reference/android/os/health/HealthStats#getStatsKeyCount())`() ` Get the number of HealthStat map values in this object.                              |
| ` `[TimerStat](https://developer.android.com/reference/android/os/health/TimerStat)                                                                                                                                             | ` `[getTimer](https://developer.android.com/reference/android/os/health/HealthStats#getTimer(int))`(int key) ` Return a TimerStat object for the given key.                                               |
| ` int`                                                                                                                                                                                                                          | ` `[getTimerCount](https://developer.android.com/reference/android/os/health/HealthStats#getTimerCount(int))`(int key) ` Get the count for the timer for the given key.                                   |
| ` int`                                                                                                                                                                                                                          | ` `[getTimerKeyAt](https://developer.android.com/reference/android/os/health/HealthStats#getTimerKeyAt(int))`(int index) ` Get the key for the timer at the given index.                                  |
| ` int`                                                                                                                                                                                                                          | ` `[getTimerKeyCount](https://developer.android.com/reference/android/os/health/HealthStats#getTimerKeyCount())`() ` Get the number of timer values in this object.                                       |
| ` long`                                                                                                                                                                                                                         | ` `[getTimerTime](https://developer.android.com/reference/android/os/health/HealthStats#getTimerTime(int))`(int key) ` Get the time for the timer for the given key, in milliseconds.                     |
| ` `[Map](https://developer.android.com/reference/java/util/Map)`<`[String](https://developer.android.com/reference/java/lang/String)`, `[TimerStat](https://developer.android.com/reference/android/os/health/TimerStat)`>`     | ` `[getTimers](https://developer.android.com/reference/android/os/health/HealthStats#getTimers(int))`(int key) ` Get the TimerStat map for the given key.                                                 |
| ` int`                                                                                                                                                                                                                          | ` `[getTimersKeyAt](https://developer.android.com/reference/android/os/health/HealthStats#getTimersKeyAt(int))`(int index) ` Get the key for the timer map at the given index.                            |
| ` int`                                                                                                                                                                                                                          | ` `[getTimersKeyCount](https://developer.android.com/reference/android/os/health/HealthStats#getTimersKeyCount())`() ` Get the number of timer map values in this object.                                 |
| ` boolean`                                                                                                                                                                                                                      | ` `[hasMeasurement](https://developer.android.com/reference/android/os/health/HealthStats#hasMeasurement(int))`(int key) ` Return whether this object contains a measurement for the supplied key.        |
| ` boolean`                                                                                                                                                                                                                      | ` `[hasMeasurements](https://developer.android.com/reference/android/os/health/HealthStats#hasMeasurements(int))`(int key) ` Return whether this object contains a measurements map for the supplied key. |
| ` boolean`                                                                                                                                                                                                                      | ` `[hasStats](https://developer.android.com/reference/android/os/health/HealthStats#hasStats(int))`(int key) ` Return whether this object contains a HealthStats map for the supplied key.                |
| ` boolean`                                                                                                                                                                                                                      | ` `[hasTimer](https://developer.android.com/reference/android/os/health/HealthStats#hasTimer(int))`(int key) ` Return whether this object contains a TimerStat for the supplied key.                      |
| ` boolean`                                                                                                                                                                                                                      | ` `[hasTimers](https://developer.android.com/reference/android/os/health/HealthStats#hasTimers(int))`(int key) ` Return whether this object contains a timers map for the supplied key.                   |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](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 `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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`                                                                  | ` `[wait](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*.                                                                                             | ||

## Public methods

### getDataType

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

```
public String getDataType ()
```

Get a name representing the contents of this object.

<br />

|                                  Returns                                   ||
|--------------------------------------------------------------------|--------|
| [String](https://developer.android.com/reference/java/lang/String) | <br /> |

**See also:**

- [UidHealthStats](https://developer.android.com/reference/android/os/health/UidHealthStats)
- [PackageHealthStats](https://developer.android.com/reference/android/os/health/PackageHealthStats)
- [PidHealthStats](https://developer.android.com/reference/android/os/health/PidHealthStats)
- [ProcessHealthStats](https://developer.android.com/reference/android/os/health/ProcessHealthStats)
- [ServiceHealthStats](https://developer.android.com/reference/android/os/health/ServiceHealthStats)  

### getMeasurement

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

```
public long getMeasurement (int key)
```

Get the measurement for the given key.

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|    Returns     ||
|--------|--------|
| `long` | <br /> |

|                                                                        Throws                                                                         ||
|----------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) | When the key is not present in this object. |

**See also:**

- [hasMeasurement(int) To check if a value for the given key is present.](https://developer.android.com/reference/android/os/health/HealthStats#hasMeasurement(int))  

### getMeasurementKeyAt

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

```
public int getMeasurementKeyAt (int index)
```

Get the key for the measurement at the given index. Index must be between 0 and the result of[getMeasurementKeyCount()](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurementKeyCount()).

<br />

|      Parameters       ||
|---------|--------------|
| `index` | `int` <br /> |

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [getMeasurementKeyCount()](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurementKeyCount())  

### getMeasurementKeyCount

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

```
public int getMeasurementKeyCount ()
```

Get the number of measurement values in this object. Can be used to iterate through the available measurements.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [getMeasurementKeyAt(int)](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurementKeyAt(int))  

### getMeasurements

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

```
public Map<String, Long> getMeasurements (int key)
```

Get the measurements map for the given key.

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|                                                                                                    Returns                                                                                                     ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
| [Map](https://developer.android.com/reference/java/util/Map)`<`[String](https://developer.android.com/reference/java/lang/String)`, `[Long](https://developer.android.com/reference/java/lang/Long)`>` | <br /> |

|                                                                        Throws                                                                         ||
|----------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) | When the key is not present in this object. |

**See also:**

- [To check if a value for the given key is present.](https://developer.android.com/reference/android/os/health/HealthStats#hasMeasurements(int))  

### getMeasurementsKeyAt

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

```
public int getMeasurementsKeyAt (int index)
```

Get the key for the measurement map at the given index. Index must be between 0 and the result of[getMeasurementsKeyCount()](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurementsKeyCount()).

<br />

|      Parameters       ||
|---------|--------------|
| `index` | `int` <br /> |

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [getMeasurementsKeyCount()](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurementsKeyCount())  

### getMeasurementsKeyCount

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

```
public int getMeasurementsKeyCount ()
```

Get the number of measurement map values in this object. Can be used to iterate through the available measurement maps.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [getMeasurementsKeyAt(int)](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurementsKeyAt(int))  

### getStats

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

```
public Map<String, HealthStats> getStats (int key)
```

Get the HealthStats map for the given key.

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|                                                                                                               Returns                                                                                                                ||
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
| [Map](https://developer.android.com/reference/java/util/Map)`<`[String](https://developer.android.com/reference/java/lang/String)`, `[HealthStats](https://developer.android.com/reference/android/os/health/HealthStats)`>` | <br /> |

|                                                                        Throws                                                                         ||
|----------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) | When the key is not present in this object. |

**See also:**

- [hasStats(int) To check if a value for the given key is present.](https://developer.android.com/reference/android/os/health/HealthStats#hasStats(int))  

### getStatsKeyAt

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

```
public int getStatsKeyAt (int index)
```

Get the key for the timer at the given index. Index must be between 0 and the result of[getStatsKeyCount()](https://developer.android.com/reference/android/os/health/HealthStats#getStatsKeyCount()).

<br />

|      Parameters       ||
|---------|--------------|
| `index` | `int` <br /> |

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [getStatsKeyCount()](https://developer.android.com/reference/android/os/health/HealthStats#getStatsKeyCount())  

### getStatsKeyCount

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

```
public int getStatsKeyCount ()
```

Get the number of HealthStat map values in this object. Can be used to iterate through the available measurements.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [getMeasurementKeyAt(int)](https://developer.android.com/reference/android/os/health/HealthStats#getMeasurementKeyAt(int))  

### getTimer

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

```
public TimerStat getTimer (int key)
```

Return a TimerStat object for the given key. This will allocate a new[TimerStat](https://developer.android.com/reference/android/os/health/TimerStat)object, which may be wasteful. Instead, use[getTimerCount(int)](https://developer.android.com/reference/android/os/health/HealthStats#getTimerCount(int))and[getTimerTime(int)](https://developer.android.com/reference/android/os/health/HealthStats#getTimerTime(int)).

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|                                         Returns                                          ||
|----------------------------------------------------------------------------------|--------|
| [TimerStat](https://developer.android.com/reference/android/os/health/TimerStat) | <br /> |

|                                                                        Throws                                                                         ||
|----------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) | When the key is not present in this object. |

**See also:**

- [hasTimer(int) To check if a value for the given key is present.](https://developer.android.com/reference/android/os/health/HealthStats#hasTimer(int))  

### getTimerCount

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

```
public int getTimerCount (int key)
```

Get the count for the timer for the given key.

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|    Returns    ||
|-------|--------|
| `int` | <br /> |

|                                                                        Throws                                                                         ||
|----------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) | When the key is not present in this object. |

**See also:**

- [hasTimer(int) To check if a value for the given key is present.](https://developer.android.com/reference/android/os/health/HealthStats#hasTimer(int))  

### getTimerKeyAt

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

```
public int getTimerKeyAt (int index)
```

Get the key for the timer at the given index. Index must be between 0 and the result of[getTimerKeyCount()](https://developer.android.com/reference/android/os/health/HealthStats#getTimerKeyCount()).

<br />

|      Parameters       ||
|---------|--------------|
| `index` | `int` <br /> |

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [getTimerKeyCount()](https://developer.android.com/reference/android/os/health/HealthStats#getTimerKeyCount())  

### getTimerKeyCount

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

```
public int getTimerKeyCount ()
```

Get the number of timer values in this object. Can be used to iterate through the available timers.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [getTimerKeyAt(int)](https://developer.android.com/reference/android/os/health/HealthStats#getTimerKeyAt(int))  

### getTimerTime

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

```
public long getTimerTime (int key)
```

Get the time for the timer for the given key, in milliseconds.

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|    Returns     ||
|--------|--------|
| `long` | <br /> |

|                                                                        Throws                                                                         ||
|----------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) | When the key is not present in this object. |

**See also:**

- [hasTimer(int) To check if a value for the given key is present.](https://developer.android.com/reference/android/os/health/HealthStats#hasTimer(int))  

### getTimers

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

```
public Map<String, TimerStat> getTimers (int key)
```

Get the TimerStat map for the given key.

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|                                                                                                             Returns                                                                                                              ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
| [Map](https://developer.android.com/reference/java/util/Map)`<`[String](https://developer.android.com/reference/java/lang/String)`, `[TimerStat](https://developer.android.com/reference/android/os/health/TimerStat)`>` | <br /> |

|                                                                        Throws                                                                         ||
|----------------------------------------------------------------------------------------------------------|---------------------------------------------|
| [IndexOutOfBoundsException](https://developer.android.com/reference/java/lang/IndexOutOfBoundsException) | When the key is not present in this object. |

**See also:**

- [hasTimers(int) To check if a value for the given key is present.](https://developer.android.com/reference/android/os/health/HealthStats#hasTimers(int))  

### getTimersKeyAt

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

```
public int getTimersKeyAt (int index)
```

Get the key for the timer map at the given index. Index must be between 0 and the result of[getTimersKeyCount()](https://developer.android.com/reference/android/os/health/HealthStats#getTimersKeyCount()).

<br />

|      Parameters       ||
|---------|--------------|
| `index` | `int` <br /> |

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [getTimersKeyCount()](https://developer.android.com/reference/android/os/health/HealthStats#getTimersKeyCount())  

### getTimersKeyCount

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

```
public int getTimersKeyCount ()
```

Get the number of timer map values in this object. Can be used to iterate through the available timer maps.

<br />

|    Returns    ||
|-------|--------|
| `int` | <br /> |

**See also:**

- [getTimersKeyAt(int)](https://developer.android.com/reference/android/os/health/HealthStats#getTimersKeyAt(int))  

### hasMeasurement

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

```
public boolean hasMeasurement (int key)
```

Return whether this object contains a measurement for the supplied key.

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### hasMeasurements

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

```
public boolean hasMeasurements (int key)
```

Return whether this object contains a measurements map for the supplied key.

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### hasStats

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

```
public boolean hasStats (int key)
```

Return whether this object contains a HealthStats map for the supplied key.

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### hasTimer

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

```
public boolean hasTimer (int key)
```

Return whether this object contains a TimerStat for the supplied key.

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |

### hasTimers

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

```
public boolean hasTimers (int key)
```

Return whether this object contains a timers map for the supplied key.

<br />

|     Parameters      ||
|-------|--------------|
| `key` | `int` <br /> |

|      Returns      ||
|-----------|--------|
| `boolean` | <br /> |