Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 1.0.0
belongs to Maven artifact androidx.core:core:1.0.0-rc01

TrafficStatsCompat

public final class TrafficStatsCompat
extends Object

java.lang.Object
   ↳ androidx.core.net.TrafficStatsCompat


Helper for accessing features in TrafficStats.

Summary

Public methods

static void clearThreadStatsTag()

This method was deprecated in API level 1.0.0. Use TrafficStats.clearThreadStatsTag() directly.

static int getThreadStatsTag()

This method was deprecated in API level 1.0.0. Use TrafficStats.getThreadStatsTag() directly.

static void incrementOperationCount(int operationCount)

This method was deprecated in API level 1.0.0. Use TrafficStats.incrementOperationCount(int) directly.

static void incrementOperationCount(int tag, int operationCount)

This method was deprecated in API level 1.0.0. Use TrafficStats.incrementOperationCount(int, int) directly.

static void setThreadStatsTag(int tag)

This method was deprecated in API level 1.0.0. Use TrafficStats.setThreadStatsTag(int) directly.

static void tagDatagramSocket(DatagramSocket socket)

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

static void tagSocket(Socket socket)

This method was deprecated in API level 1.0.0. Use TrafficStats.tagSocket(Socket) directly.

static void untagDatagramSocket(DatagramSocket socket)

Remove any statistics parameters from the given DatagramSocket.

static void untagSocket(Socket socket)

This method was deprecated in API level 1.0.0. Use TrafficStats.untagSocket(Socket) directly.

Inherited methods

Public methods

clearThreadStatsTag

added in version 1.0.0
public static void clearThreadStatsTag ()

This method was deprecated in API level 1.0.0.
Use TrafficStats.clearThreadStatsTag() directly.

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

getThreadStatsTag

added in version 1.0.0
public static int getThreadStatsTag ()

This method was deprecated in API level 1.0.0.
Use TrafficStats.getThreadStatsTag() directly.

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

added in version 1.0.0
public static void incrementOperationCount (int operationCount)

This method was deprecated in API level 1.0.0.
Use TrafficStats.incrementOperationCount(int) directly.

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

added in version 1.0.0
public static void incrementOperationCount (int tag, 
                int operationCount)

This method was deprecated in API level 1.0.0.
Use TrafficStats.incrementOperationCount(int, int) directly.

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

added in version 1.0.0
public static void setThreadStatsTag (int tag)

This method was deprecated in API level 1.0.0.
Use TrafficStats.setThreadStatsTag(int) directly.

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

added in version 1.0.0
public static 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

tagSocket

added in version 1.0.0
public static void tagSocket (Socket socket)

This method was deprecated in API level 1.0.0.
Use TrafficStats.tagSocket(Socket) directly.

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

untagDatagramSocket

added in version 1.0.0
public static void untagDatagramSocket (DatagramSocket socket)

Remove any statistics parameters from the given DatagramSocket.

Parameters
socket DatagramSocket

Throws
SocketException

untagSocket

added in version 1.0.0
public static void untagSocket (Socket socket)

This method was deprecated in API level 1.0.0.
Use TrafficStats.untagSocket(Socket) directly.

Remove any statistics parameters from the given Socket.

Parameters
socket Socket

Throws
SocketException