to top
Android APIs
public class

TrafficStatsCompat

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

Class Overview

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

Summary

Public Constructors

? Examples
TrafficStatsCompat()
Public Methods

? Examples
static void clearThreadStatsTag()
Clear active tag used when accounting Socket traffic originating from the current thread.

? Examples
static int getThreadStatsTag()
Get the active tag used when accounting Socket traffic originating from the current thread.

? Examples
static void incrementOperationCount(int operationCount)
Increment count of network operations performed under the accounting tag currently active on the calling thread.

? Examples
static void incrementOperationCount(int tag, int operationCount)
Increment count of network operations performed under the given accounting tag.

? Examples
static void setThreadStatsTag(int tag)
Set active tag to use when accounting Socket traffic originating from the current thread.

? Examples
static void tagSocket( Socket socket)
Tag the given Socket with any statistics parameters active for the current thread.

? Examples
static void untagSocket( Socket socket)
Remove any statistics parameters from the given Socket.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public TrafficStatsCompat ()

Public Methods

public static void clearThreadStatsTag ()

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

public static 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).

public static 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 Number of operations to increment count by.

public static 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 Accounting tag used in setThreadStatsTag(int).
operationCount Number of operations to increment count by.

public static 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.

public static 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.

public static void untagSocket (Socket socket)

Remove any statistics parameters from the given Socket.

No examples for this method.
Frequently called with: [Clear]
Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License. The original page is available here.