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

# android.os.health

*** ** * ** ***

The android.os.health package contains a set of classes to provide data to track the system resources of applications.


Applications running in the background are responsible for a significant amount
of battery usage on a typical android device. There are several things that
applications can do in order to reduce their impact. For example, by using
`https://developer.android.com/reference/android/app/job/JobScheduler`, an application does not need
to independently monitor whether the network is available, whether the device is
plugged in, etc. In addition to being simpler to use, the application's
services are only started when the required conditions have been met. But even
when using the appropriate helper APIs, applications still can reduce their
footprint. This package provides more insight into what is going on behind the
scenes when an application is running.


Application data is tracked by which user id (uid) is using particular
resources. A snapshot of an application's measurements can be taken with the
`https://developer.android.com/reference/android/os/health/SystemHealthManager#takeMyUidSnapshot()`
method. The `https://developer.android.com/reference/android/os/health/HealthStats` object returned contains the
statistics.


**HealthStats**   

In order to be returned efficiently, the `https://developer.android.com/reference/android/os/health/HealthStats`
class uses a set of int keys to identify the data returned. The
`https://developer.android.com/reference/android/os/health/UidHealthStats`, `https://developer.android.com/reference/android/os/health/PidHealthStats`,
`https://developer.android.com/reference/android/os/health/PackageHealthStats` , `https://developer.android.com/reference/android/os/health/ProcessHealthStats`,
and `https://developer.android.com/reference/android/os/health/ServiceHealthStats` classes provide those constants.
Each `https://developer.android.com/reference/android/os/health/HealthStats` object will be associated with
exactly one of those classes. The object returned from
`https://developer.android.com/reference/android/os/health/SystemHealthManager#takeMyUidSnapshot()`
will be using the `https://developer.android.com/reference/android/os/health/UidHealthStats` keys, as it contains all
of the data available for that uid.


## Classes

|---|---|
| [HealthStats](https://developer.android.com/reference/android/os/health/HealthStats) | A HealthStats object contains system health data about an application. |
| [PackageHealthStats](https://developer.android.com/reference/android/os/health/PackageHealthStats) | Keys for `https://developer.android.com/reference/android/os/health/HealthStats` returned from `https://developer.android.com/reference/android/os/health/HealthStats#getStats(int)` with the `https://developer.android.com/reference/android/os/health/UidHealthStats#STATS_PACKAGES` key. |
| [PidHealthStats](https://developer.android.com/reference/android/os/health/PidHealthStats) | Keys for `https://developer.android.com/reference/android/os/health/HealthStats` returned from `https://developer.android.com/reference/android/os/health/HealthStats#getStats(int)` with the `https://developer.android.com/reference/android/os/health/UidHealthStats#STATS_PIDS` key. |
| [ProcessHealthStats](https://developer.android.com/reference/android/os/health/ProcessHealthStats) | Keys for `https://developer.android.com/reference/android/os/health/HealthStats` returned from `https://developer.android.com/reference/android/os/health/HealthStats#getStats(int)` with the `https://developer.android.com/reference/android/os/health/UidHealthStats#STATS_PROCESSES` key. |
| [ServiceHealthStats](https://developer.android.com/reference/android/os/health/ServiceHealthStats) | Keys for `https://developer.android.com/reference/android/os/health/HealthStats` returned from `https://developer.android.com/reference/android/os/health/HealthStats#getStats(int)` with the `https://developer.android.com/reference/android/os/health/PackageHealthStats#STATS_SERVICES` key. |
| [SystemHealthManager](https://developer.android.com/reference/android/os/health/SystemHealthManager) | Provides access to data about how various system resources are used by applications. |
| [TimerStat](https://developer.android.com/reference/android/os/health/TimerStat) | A TimerStat object stores a count and a time. |
| [UidHealthStats](https://developer.android.com/reference/android/os/health/UidHealthStats) | Keys for `https://developer.android.com/reference/android/os/health/HealthStats` returned from `https://developer.android.com/reference/android/os/health/SystemHealthManager#takeUidSnapshot(int)`, `https://developer.android.com/reference/android/os/health/SystemHealthManager#takeMyUidSnapshot()`, and `https://developer.android.com/reference/android/os/health/SystemHealthManager#takeUidSnapshots(int[])`. |

-

  ## Classes

  - [HealthStats](https://developer.android.com/reference/android/os/health/HealthStats)
  - [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)
  - [SystemHealthManager](https://developer.android.com/reference/android/os/health/SystemHealthManager)
  - [TimerStat](https://developer.android.com/reference/android/os/health/TimerStat)
  - [UidHealthStats](https://developer.android.com/reference/android/os/health/UidHealthStats)