NetworkStatsManager.RegisterUsageCallback 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.
Overloads
| Name | Description |
|---|---|
| RegisterUsageCallback(ConnectivityType, String, Int64, NetworkStatsManager+UsageCallback) |
Registers to receive notifications about data usage on specified networks. |
| RegisterUsageCallback(ConnectivityType, String, Int64, NetworkStatsManager+UsageCallback, Handler) |
Registers to receive notifications about data usage on specified networks. |
RegisterUsageCallback(ConnectivityType, String, Int64, NetworkStatsManager+UsageCallback)
Registers to receive notifications about data usage on specified networks.
[Android.Runtime.Register("registerUsageCallback", "(ILjava/lang/String;JLandroid/app/usage/NetworkStatsManager$UsageCallback;)V", "GetRegisterUsageCallback_ILjava_lang_String_JLandroid_app_usage_NetworkStatsManager_UsageCallback_Handler", ApiSince=24)]
public virtual void RegisterUsageCallback(Android.Net.ConnectivityType networkType, string? subscriberId, long thresholdBytes, Android.App.Usage.NetworkStatsManager.UsageCallback callback);
[<Android.Runtime.Register("registerUsageCallback", "(ILjava/lang/String;JLandroid/app/usage/NetworkStatsManager$UsageCallback;)V", "GetRegisterUsageCallback_ILjava_lang_String_JLandroid_app_usage_NetworkStatsManager_UsageCallback_Handler", ApiSince=24)>]
abstract member RegisterUsageCallback : Android.Net.ConnectivityType * string * int64 * Android.App.Usage.NetworkStatsManager.UsageCallback -> unit
override this.RegisterUsageCallback : Android.Net.ConnectivityType * string * int64 * Android.App.Usage.NetworkStatsManager.UsageCallback -> unit
Parameters
- networkType
- ConnectivityType
Type of network to monitor. Either ConnectivityManager.TYPE_MOBILE or ConnectivityManager.TYPE_WIFI.
- subscriberId
- String
If applicable, the subscriber id of the network interface. 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 registering for the mobile network type to receive notifications for all mobile networks. For additional details see TelephonyManager.getSubscriberId(). 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.
- thresholdBytes
- Int64
Threshold in bytes to be notified on.
- callback
- NetworkStatsManager.UsageCallback
The UsageCallback that the system will call when data usage has exceeded the specified threshold. This value cannot be null.
- Attributes
Remarks
Android reference for android.app.usage.NetworkStatsManager.registerUsageCallback.
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
RegisterUsageCallback(ConnectivityType, String, Int64, NetworkStatsManager+UsageCallback, Handler)
Registers to receive notifications about data usage on specified networks.
[Android.Runtime.Register("registerUsageCallback", "(ILjava/lang/String;JLandroid/app/usage/NetworkStatsManager$UsageCallback;Landroid/os/Handler;)V", "GetRegisterUsageCallback_ILjava_lang_String_JLandroid_app_usage_NetworkStatsManager_UsageCallback_Landroid_os_Handler_Handler", ApiSince=24)]
public virtual void RegisterUsageCallback(Android.Net.ConnectivityType networkType, string? subscriberId, long thresholdBytes, Android.App.Usage.NetworkStatsManager.UsageCallback callback, Android.OS.Handler? handler);
[<Android.Runtime.Register("registerUsageCallback", "(ILjava/lang/String;JLandroid/app/usage/NetworkStatsManager$UsageCallback;Landroid/os/Handler;)V", "GetRegisterUsageCallback_ILjava_lang_String_JLandroid_app_usage_NetworkStatsManager_UsageCallback_Landroid_os_Handler_Handler", ApiSince=24)>]
abstract member RegisterUsageCallback : Android.Net.ConnectivityType * string * int64 * Android.App.Usage.NetworkStatsManager.UsageCallback * Android.OS.Handler -> unit
override this.RegisterUsageCallback : Android.Net.ConnectivityType * string * int64 * Android.App.Usage.NetworkStatsManager.UsageCallback * Android.OS.Handler -> unit
Parameters
- networkType
- ConnectivityType
Type of network to monitor. Either ConnectivityManager.TYPE_MOBILE or ConnectivityManager.TYPE_WIFI.
- subscriberId
- String
If applicable, the subscriber id of the network interface. 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 registering for the mobile network type to receive notifications for all mobile networks. For additional details see TelephonyManager.getSubscriberId(). 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.
- thresholdBytes
- Int64
Threshold in bytes to be notified on.
- callback
- NetworkStatsManager.UsageCallback
The UsageCallback that the system will call when data usage has exceeded the specified threshold. This value cannot be null.
- handler
- Handler
to dispatch callback events through, otherwise if null it uses the calling thread.
- Attributes
Remarks
Android reference for android.app.usage.NetworkStatsManager.registerUsageCallback.
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.