Language

TrafficStats.GetUidTxPackets(Int32) Method

Definition

Return number of packets transmitted by the given UID since device boot.

[Android.Runtime.Register("getUidTxPackets", "(I)J", "")]
public static long GetUidTxPackets(int uid);
[<Android.Runtime.Register("getUidTxPackets", "(I)J", "")>]
static member GetUidTxPackets : int -> int64

Parameters

uid
Int32

The Android UID whose traffic is requested.

Returns

The number of transmitted packets attributed to the UID since boot, or Unsupported if unavailable. Android 7.0 and later return Unsupported for other UIDs.

Attributes

Remarks

Return number of packets transmitted by the given UID since device boot. Counts packets across all network interfaces, and always increases monotonically since device boot. Statistics are measured at the network layer, so they include both TCP and UDP usage.

Before android.os.Build.VERSION_CODES#JELLY_BEAN_MR2, this may return #UNSUPPORTED on devices where statistics aren't available.

Starting in android.os.Build.VERSION_CODES#N this will only report traffic statistics for the calling UID. It will return #UNSUPPORTED for all other UIDs for privacy reasons. To access historical network statistics belonging to other UIDs, use NetworkStatsManager.

Java documentation for android.net.TrafficStats.getUidTxPackets(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

See also