NetworkStats.Bucket

public static class NetworkStats.Bucket
extends Object

java.lang.Object
   ↳ 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

int DEFAULT_NETWORK_ALL

Combined usage for this network regardless of default network status.

int DEFAULT_NETWORK_NO

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

int DEFAULT_NETWORK_YES

Usage that occurs while this network is a default network.

int METERED_ALL

Combined usage across all metered states.

int METERED_NO

Usage that occurs on an unmetered network.

int METERED_YES

Usage that occurs on a metered network.

int ROAMING_ALL

Combined usage across all roaming states.

int ROAMING_NO

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

int ROAMING_YES

Usage that occurs on a roaming network.

int STATE_ALL

Combined usage across all states.

int STATE_DEFAULT

Usage not accounted for in any other state.

int STATE_FOREGROUND

Foreground usage.

int TAG_NONE

Special TAG value for total data across all tags

int UID_ALL

Special UID value for aggregate/unspecified.

int UID_REMOVED

Special UID value for removed apps.

int UID_TETHERING

Special UID value for data usage by tethering.

Public constructors

Bucket()

Public methods

int getDefaultNetworkStatus()

Default network status.

long getEndTimeStamp()

End timestamp of the bucket's time interval.

int getMetered()

Metered state.

int getRoaming()

Roaming state.

long getRxBytes()

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

long getRxPackets()

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

long getStartTimeStamp()

Start timestamp of the bucket's time interval.

int getState()

Usage state.

int getTag()

Tag of the bucket.

long getTxBytes()

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

long getTxPackets()

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

int getUid()

Key of the bucket.

Inherited methods

Constants

DEFAULT_NETWORK_ALL

Added in API level 28
public static final int DEFAULT_NETWORK_ALL

Combined usage for this network regardless of default network status.

Constant Value: -1 (0xffffffff)

DEFAULT_NETWORK_NO

Added in API level 28
public static final int DEFAULT_NETWORK_NO

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.

Constant Value: 1 (0x00000001)

DEFAULT_NETWORK_YES

Added in API level 28
public static final int DEFAULT_NETWORK_YES

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.

Constant Value: 2 (0x00000002)

METERED_ALL

Added in API level 26
public static final int METERED_ALL

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

Constant Value: -1 (0xffffffff)

METERED_NO

Added in API level 26
public static final int METERED_NO

Usage that occurs on an unmetered network.

Constant Value: 1 (0x00000001)

METERED_YES

Added in API level 26
public static final int METERED_YES

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.

Constant Value: 2 (0x00000002)

ROAMING_ALL

Added in API level 24
public static final int ROAMING_ALL

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

Constant Value: -1 (0xffffffff)

ROAMING_NO

Added in API level 24
public static final int ROAMING_NO

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.

Constant Value: 1 (0x00000001)

ROAMING_YES

Added in API level 24
public static final int ROAMING_YES

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.

Constant Value: 2 (0x00000002)

STATE_ALL

Added in API level 23
public static final int STATE_ALL

Combined usage across all states.

Constant Value: -1 (0xffffffff)

STATE_DEFAULT

Added in API level 23
public static final int STATE_DEFAULT

Usage not accounted for in any other state.

Constant Value: 1 (0x00000001)

STATE_FOREGROUND

Added in API level 23
public static final int STATE_FOREGROUND

Foreground usage.

Constant Value: 2 (0x00000002)

TAG_NONE

Added in API level 24
public static final int TAG_NONE

Special TAG value for total data across all tags

Constant Value: 0 (0x00000000)

UID_ALL

Added in API level 23
public static final int UID_ALL

Special UID value for aggregate/unspecified.

Constant Value: -1 (0xffffffff)

UID_REMOVED

Added in API level 23
public static final int UID_REMOVED

Special UID value for removed apps.

Constant Value: -4 (0xfffffffc)

UID_TETHERING

Added in API level 23
public static final int UID_TETHERING

Special UID value for data usage by tethering.

Constant Value: -5 (0xfffffffb)

Public constructors

Bucket

Added in API level 23
public Bucket ()

Public methods

getDefaultNetworkStatus

Added in API level 28
public int getDefaultNetworkStatus ()

Default network status. One of the following values:

Returns
int Value is DEFAULT_NETWORK_ALL, DEFAULT_NETWORK_NO, or DEFAULT_NETWORK_YES

getEndTimeStamp

Added in API level 23
public long getEndTimeStamp ()

End timestamp of the bucket's time interval. Defined in terms of "Unix time", see System.currentTimeMillis().

Returns
long End of interval.

getMetered

Added in API level 26
public int getMetered ()

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.

Returns
int Value is METERED_ALL, METERED_NO, or METERED_YES

getRoaming

Added in API level 24
public int getRoaming ()

Roaming state. One of the following values:

Returns
int Value is ROAMING_ALL, ROAMING_NO, or ROAMING_YES

getRxBytes

Added in API level 23
public long getRxBytes ()

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.

Returns
long Number of bytes.

getRxPackets

Added in API level 23
public long getRxPackets ()

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.

Returns
long Number of packets.

getStartTimeStamp

Added in API level 23
public long getStartTimeStamp ()

Start timestamp of the bucket's time interval. Defined in terms of "Unix time", see System.currentTimeMillis().

Returns
long Start of interval.

getState

Added in API level 23
public int getState ()

Usage state. One of the following values:

Returns
int Usage state. Value is STATE_ALL, STATE_DEFAULT, or STATE_FOREGROUND

getTag

Added in API level 24
public int getTag ()

Tag of the bucket.

Returns
int Bucket tag.

getTxBytes

Added in API level 23
public long getTxBytes ()

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.

Returns
long Number of bytes.

getTxPackets

Added in API level 23
public long getTxPackets ()

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.

Returns
long Number of packets.

getUid

Added in API level 23
public int getUid ()

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

Returns
int Bucket key.