Stay organized with collections
Save and categorize content based on your preferences.
NetworkStats
class NetworkStats : AutoCloseable
Class providing enumeration over buckets of network usage statistics. NetworkStats
objects are returned as results to various queries in NetworkStatsManager
.
Summary
Nested classes |
|
Buckets are the smallest elements of a query result.
|
Public methods |
Unit |
Closes the enumeration.
|
Boolean |
Fills the recycled bucket with data of the next bin in the enumeration.
|
Boolean |
Check if it is possible to ask for a next bucket in the enumeration.
|
Public methods
close
fun close(): Unit
Closes the enumeration. Call this method before this object gets out of scope.
Exceptions |
java.lang.Exception |
if this resource cannot be closed |
getNextBucket
fun getNextBucket(bucketOut: NetworkStats.Bucket?): Boolean
Fills the recycled bucket with data of the next bin in the enumeration.
Parameters |
bucketOut |
NetworkStats.Bucket?: Bucket to be filled with data. If null, the method does nothing and returning false. |
Return |
Boolean |
true if successfully filled the bucket, false otherwise. |
hasNextBucket
fun hasNextBucket(): Boolean
Check if it is possible to ask for a next bucket in the enumeration.
Return |
Boolean |
true if there is at least one more bucket. |
Protected methods
finalize
protected fun finalize(): Unit
Exceptions |
java.lang.Throwable |
the Exception raised by this method |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# NetworkStats\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nNetworkStats\n============\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/app/usage/NetworkStats \"View this page in Java\") \n\n```\nclass NetworkStats : AutoCloseable\n```\n\n|---|-------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.app.usage.NetworkStats](#) |\n\nClass providing enumeration over buckets of network usage statistics. [NetworkStats](#) objects are returned as results to various queries in [NetworkStatsManager](/reference/kotlin/android/app/usage/NetworkStatsManager).\n\nSummary\n-------\n\n| Nested classes ||\n|---|------------------------------------------------------------------------------------------------------------------------|\n| | [Bucket](/reference/kotlin/android/app/usage/NetworkStats.Bucket) Buckets are the smallest elements of a query result. |\n\n| Public methods ||\n|------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [close](#close())`()` Closes the enumeration. |\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [getNextBucket](#getNextBucket(android.app.usage.NetworkStats.Bucket))`(`bucketOut:` `[NetworkStats.Bucket](/reference/kotlin/android/app/usage/NetworkStats.Bucket)?`)` Fills the recycled bucket with data of the next bin in the enumeration. |\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [hasNextBucket](#hasNextBucket())`()` Check if it is possible to ask for a next bucket in the enumeration. |\n\n| Protected methods ||\n|------------------------------------------------------------------------------|------------------------------------|\n| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [finalize](#finalize())`()` \u003cbr /\u003e |\n\nPublic methods\n--------------\n\n### close\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun close(): Unit\n```\n\nCloses the enumeration. Call this method before this object gets out of scope.\n\n| Exceptions ||\n|-----------------------|-----------------------------------|\n| `java.lang.Exception` | if this resource cannot be closed |\n\n### getNextBucket\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun getNextBucket(bucketOut: NetworkStats.Bucket?): Boolean\n```\n\nFills the recycled bucket with data of the next bin in the enumeration.\n\n| Parameters ||\n|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `bucketOut` | [NetworkStats.Bucket](/reference/kotlin/android/app/usage/NetworkStats.Bucket)?: Bucket to be filled with data. If null, the method does nothing and returning false. |\n\n| Return ||\n|------------------------------------------------------------------------------------|----------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if successfully filled the bucket, false otherwise. |\n\n### hasNextBucket\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nfun hasNextBucket(): Boolean\n```\n\nCheck if it is possible to ask for a next bucket in the enumeration.\n\n| Return ||\n|------------------------------------------------------------------------------------|--------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | true if there is at least one more bucket. |\n\nProtected methods\n-----------------\n\n### finalize\n\nAdded in [API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nprotected fun finalize(): Unit\n```\n\n| Exceptions ||\n|-----------------------|---------------------------------------|\n| `java.lang.Throwable` | the `Exception` raised by this method |"]]