Added in API level 23

Bucket


class Bucket
kotlin.Any
   ↳ android.app.usage.NetworkStats.Bucket

Buckets are the smallest elements of a query result. As some dimensions of a result may be aggregated (e.g. time or state) some values may be equal across all buckets.

Summary

Constants
static Int

Combined usage for this network regardless of default network status.

static Int

Usage that occurs while this network is not a default network.

static Int

Usage that occurs while this network is a default network.

static Int

Combined usage across all metered states.

static Int

Usage that occurs on an unmetered network.

static Int

Usage that occurs on a metered network.

static Int

Combined usage across all roaming states.

static Int

Usage that occurs on a home, non-roaming network.

static Int

Usage that occurs on a roaming network.

static Int

Combined usage across all states.

static Int

Usage not accounted for in any other state.

static Int

Foreground usage.

static Int

Special TAG value for total data across all tags

static Int

Special UID value for aggregate/unspecified.

static Int

Special UID value for removed apps.

static Int

Special UID value for data usage by tethering.

Public constructors

Public methods
open Int

Default network status.

open Long

End timestamp of the bucket's time interval.

open Int

Metered state.

open Int

Roaming state.

open Long

Number of bytes received during the bucket's time interval.

open Long

Number of packets received during the bucket's time interval.

open Long

Start timestamp of the bucket's time interval.

open Int

Usage state.

open Int

Tag of the bucket.

open Long

Number of bytes transmitted during the bucket's time interval.

open Long

Number of packets transmitted during the bucket's time interval.

open Int

Key of the bucket.

Constants

DEFAULT_NETWORK_ALL

Added in API level 28
static val DEFAULT_NETWORK_ALL: Int

Combined usage for this network regardless of default network status.

Value: -1

DEFAULT_NETWORK_NO

Added in API level 28
static val DEFAULT_NETWORK_NO: Int

Usage that occurs while this network is not a default network.

This implies that the app responsible for this usage requested that it occur on a specific network different from the one(s) the system would have selected for it.

Value: 1

DEFAULT_NETWORK_YES

Added in API level 28
static val DEFAULT_NETWORK_YES: Int

Usage that occurs while this network is a default network.

This implies that the app either did not select a specific network for this usage, or it selected a network that the system could have selected for app traffic.

Value: 2

METERED_ALL

Added in API level 26
static val METERED_ALL: Int

Combined usage across all metered states. Covers metered and unmetered usage.

Value: -1

METERED_NO

Added in API level 26
static val METERED_NO: Int

Usage that occurs on an unmetered network.

Value: 1

METERED_YES

Added in API level 26
static val METERED_YES: Int

Usage that occurs on a metered network.

A network is classified as metered when the user is sensitive to heavy data usage on that connection.

Value: 2

ROAMING_ALL

Added in API level 24
static val ROAMING_ALL: Int

Combined usage across all roaming states. Covers both roaming and non-roaming usage.

Value: -1

ROAMING_NO

Added in API level 24
static val ROAMING_NO: Int

Usage that occurs on a home, non-roaming network.

Any cellular usage in this bucket was incurred while the device was connected to a tower owned or operated by the user's wireless carrier, or a tower that the user's wireless carrier has indicated should be treated as a home network regardless.

This is also the default value for network types that do not support roaming.

Value: 1

ROAMING_YES

Added in API level 24
static val ROAMING_YES: Int

Usage that occurs on a roaming network.

Any cellular usage in this bucket as incurred while the device was roaming on another carrier's network, for which additional charges may apply.

Value: 2

STATE_ALL

Added in API level 23
static val STATE_ALL: Int

Combined usage across all states.

Value: -1

STATE_DEFAULT

Added in API level 23
static val STATE_DEFAULT: Int

Usage not accounted for in any other state.

Value: 1

STATE_FOREGROUND

Added in API level 23
static val STATE_FOREGROUND: Int

Foreground usage.

Value: 2

TAG_NONE

Added in API level 24
static val TAG_NONE: Int

Special TAG value for total data across all tags

Value: 0

UID_ALL

Added in API level 23
static val UID_ALL: Int

Special UID value for aggregate/unspecified.

Value: -1

UID_REMOVED

Added in API level 23
static val UID_REMOVED: Int

Special UID value for removed apps.

Value: -4

UID_TETHERING

Added in API level 23
static val UID_TETHERING: Int

Special UID value for data usage by tethering.

Value: -5

Public constructors

Bucket

Added in API level 23
Bucket()

Public methods

getEndTimeStamp

Added in API level 23
open fun getEndTimeStamp(): Long

End timestamp of the bucket's time interval. Defined in terms of "Unix time", see java.lang.System#currentTimeMillis.

Return
Long End of interval.

getMetered

Added in API level 26
open fun getMetered(): Int

Metered state. One of the following values:

A network is classified as metered when the user is sensitive to heavy data usage on that connection. Apps may warn before using these networks for large downloads. The metered state can be set by the user within data usage network restrictions.

Return
Int Value is android.app.usage.NetworkStats.Bucket#METERED_ALL, android.app.usage.NetworkStats.Bucket#METERED_NO, or android.app.usage.NetworkStats.Bucket#METERED_YES

getRxBytes

Added in API level 23
open fun getRxBytes(): Long

Number of bytes received during the bucket's time interval. Statistics are measured at the network layer, so they include both TCP and UDP usage.

Return
Long Number of bytes.

getRxPackets

Added in API level 23
open fun getRxPackets(): Long

Number of packets received during the bucket's time interval. Statistics are measured at the network layer, so they include both TCP and UDP usage.

Return
Long Number of packets.

getStartTimeStamp

Added in API level 23
open fun getStartTimeStamp(): Long

Start timestamp of the bucket's time interval. Defined in terms of "Unix time", see java.lang.System#currentTimeMillis.

Return
Long Start of interval.

getTag

Added in API level 24
open fun getTag(): Int

Tag of the bucket.

Return
Int Bucket tag.

getTxBytes

Added in API level 23
open fun getTxBytes(): Long

Number of bytes transmitted during the bucket's time interval. Statistics are measured at the network layer, so they include both TCP and UDP usage.

Return
Long Number of bytes.

getTxPackets

Added in API level 23
open fun getTxPackets(): Long

Number of packets transmitted during the bucket's time interval. Statistics are measured at the network layer, so they include both TCP and UDP usage.

Return
Long Number of packets.

getUid

Added in API level 23
open fun getUid(): Int

Key of the bucket. Usually an app uid or one of the following special values:

Return
Int Bucket key.