NetworkStatsManager.QueryDetails Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Query network usage statistics details.
[Android.Runtime.Register("queryDetails", "(ILjava/lang/String;JJ)Landroid/app/usage/NetworkStats;", "GetQueryDetails_ILjava_lang_String_JJHandler", ApiSince=23)]
public virtual Android.App.Usage.NetworkStats? QueryDetails (Android.Net.ConnectivityType networkType, string? subscriberId, long startTime, long endTime);
[<Android.Runtime.Register("queryDetails", "(ILjava/lang/String;JJ)Landroid/app/usage/NetworkStats;", "GetQueryDetails_ILjava_lang_String_JJHandler", ApiSince=23)>]
abstract member QueryDetails : Android.Net.ConnectivityType * string * int64 * int64 -> Android.App.Usage.NetworkStats
override this.QueryDetails : Android.Net.ConnectivityType * string * int64 * int64 -> Android.App.Usage.NetworkStats
Parameters
- networkType
- ConnectivityType
As defined in ConnectivityManager
, e.g.
ConnectivityManager#TYPE_MOBILE
, ConnectivityManager#TYPE_WIFI
etc.
- subscriberId
- String
If applicable, the subscriber id of the network interface.
<p>Starting with API level 29, the subscriberId
is guarded by
additional restrictions. Calling apps that do not meet the new
requirements to access the subscriberId
can provide a null
value when querying for the mobile network type to receive usage
for all mobile networks. For additional details see TelephonyManager#getSubscriberId()
.
<p>Starting with API level 31, calling apps can provide a
subscriberId
with wifi network type to receive usage for
wifi networks which is under the given subscription if applicable.
Otherwise, pass null
when querying all wifi networks.
- startTime
- Int64
Start of period. Defined in terms of "Unix time", see
java.lang.System#currentTimeMillis
.
- endTime
- Int64
End of period. Defined in terms of "Unix time", see
java.lang.System#currentTimeMillis
.
Returns
Statistics object or null if permissions are insufficient or error happened during statistics collection.
- Attributes
Remarks
Query network usage statistics details. Result filtered to include only uids belonging to calling user. Result is aggregated over state but not aggregated over time, uid, tag, metered, nor roaming. This means buckets' start and end timestamps are going to be between 'startTime' and 'endTime' parameters. State is going to be NetworkStats.Bucket#STATE_ALL
, uid will vary, tag NetworkStats.Bucket#TAG_NONE
, default network is going to be NetworkStats.Bucket#DEFAULT_NETWORK_ALL
, metered is going to be NetworkStats.Bucket#METERED_ALL
, and roaming is going to be NetworkStats.Bucket#ROAMING_ALL
.
Only includes buckets that atomically occur in the inclusive time range. Doesn't interpolate across partial buckets. Since bucket length is in the order of hours, this method cannot be used to measure data usage on a fine grained time scale. This may take a long time, and apps should avoid calling this on their main thread.
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.