Skip to content

Most visited

Recently visited

navigation

TrafficStatsCompat

public final class TrafficStatsCompat
extends Object

java.lang.Object
   ↳ android.support.v4.net.TrafficStatsCompat


Helper for accessing features in TrafficStats introduced after API level 14 in a backwards compatible fashion.

Summary

Public methods

static void clearThreadStatsTag()

Clear active tag used when accounting Socket traffic originating from the current thread.

static int getThreadStatsTag()

Get the active tag used when accounting Socket traffic originating from the current thread.

static void incrementOperationCount(int operationCount)

Increment count of network operations performed under the accounting tag currently active on the calling thread.

static void incrementOperationCount(int tag, int operationCount)

Increment count of network operations performed under the given accounting tag.

static void setThreadStatsTag(int tag)

Set active tag to use when accounting Socket traffic originating from the current thread.

static void tagDatagramSocket(DatagramSocket socket)

Tag the given DatagramSocket with any statistics parameters active for the current thread.

static void tagSocket(Socket socket)

Tag the given Socket with any statistics parameters active for the current thread.

static void untagDatagramSocket(DatagramSocket socket)

Remove any statistics parameters from the given DatagramSocket.

static void untagSocket(Socket socket)

Remove any statistics parameters from the given Socket.

Inherited methods

From class java.lang.Object

Public methods

clearThreadStatsTag

void clearThreadStatsTag ()

Clear active tag used when accounting Socket traffic originating from the current thread.

getThreadStatsTag

int getThreadStatsTag ()

Get the active tag used when accounting Socket traffic originating from the current thread. Only one active tag per thread is supported. tagSocket(Socket).

Returns
int

incrementOperationCount

void incrementOperationCount (int operationCount)

Increment count of network operations performed under the accounting tag currently active on the calling thread. This can be used to derive bytes-per-operation.

Parameters
operationCount int: Number of operations to increment count by.

incrementOperationCount

void incrementOperationCount (int tag, 
                int operationCount)

Increment count of network operations performed under the given accounting tag. This can be used to derive bytes-per-operation.

Parameters
tag int: Accounting tag used in setThreadStatsTag(int).
operationCount int: Number of operations to increment count by.

setThreadStatsTag

void setThreadStatsTag (int tag)

Set active tag to use when accounting Socket traffic originating from the current thread. Only one active tag per thread is supported.

Changes only take effect during subsequent calls to tagSocket(Socket).

Tags between 0xFFFFFF00 and 0xFFFFFFFF are reserved and used internally by system services like DownloadManager when performing traffic on behalf of an application.

Parameters
tag int

tagDatagramSocket

void tagDatagramSocket (DatagramSocket socket)

Tag the given DatagramSocket with any statistics parameters active for the current thread. Subsequent calls always replace any existing parameters. When finished, call untagDatagramSocket(DatagramSocket) to remove statistics parameters.

Parameters
socket DatagramSocket
Throws
SocketException

See also:

tagSocket

void tagSocket (Socket socket)

Tag the given Socket with any statistics parameters active for the current thread. Subsequent calls always replace any existing parameters. When finished, call untagSocket(Socket) to remove statistics parameters.

Parameters
socket Socket
Throws
SocketException

See also:

untagDatagramSocket

void untagDatagramSocket (DatagramSocket socket)

Remove any statistics parameters from the given DatagramSocket.

Parameters
socket DatagramSocket
Throws
SocketException

untagSocket

void untagSocket (Socket socket)

Remove any statistics parameters from the given Socket.

Parameters
socket Socket
Throws
SocketException
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.