Added in API level 24

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 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 SystemHealth.takeMyUidSnapshot() method. The HealthStats object returned contains the statistics.

HealthStats
In order to be returned efficiently, the