Stay organized with collections
Save and categorize content based on your preferences.
OnNetworkActiveListener
interface OnNetworkActiveListener
Callback for use with ConnectivityManager.addDefaultNetworkActiveListener
to find out when the system default network has gone in to a high power state.
Summary
Public methods |
abstract Unit |
Called on the main thread of the process to report that the current data network has become active, and it is now a good time to perform any pending network operations.
|
Public methods
onNetworkActive
abstract fun onNetworkActive(): Unit
Called on the main thread of the process to report that the current data network has become active, and it is now a good time to perform any pending network operations. Note that this listener only tells you when the network becomes active; if at any other time you want to know whether it is active (and thus okay to initiate network traffic), you can retrieve its instantaneous state with ConnectivityManager.isDefaultNetworkActive
.
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,["# ConnectivityManager.OnNetworkActiveListener\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nOnNetworkActiveListener\n=======================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/net/ConnectivityManager.OnNetworkActiveListener \"View this page in Java\") \n\n```\ninterface OnNetworkActiveListener\n```\n\n|--------------------------------------------------------------|\n| [android.net.ConnectivityManager.OnNetworkActiveListener](#) |\n\nCallback for use with [ConnectivityManager.addDefaultNetworkActiveListener](/reference/kotlin/android/net/ConnectivityManager#addDefaultNetworkActiveListener(android.net.ConnectivityManager.OnNetworkActiveListener)) to find out when the system default network has gone in to a high power state.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onNetworkActive](#onNetworkActive())`()` Called on the main thread of the process to report that the current data network has become active, and it is now a good time to perform any pending network operations. |\n\nPublic methods\n--------------\n\n### onNetworkActive\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun onNetworkActive(): Unit\n```\n\nCalled on the main thread of the process to report that the current data network has become active, and it is now a good time to perform any pending network operations. Note that this listener only tells you when the network becomes active; if at any other time you want to know whether it is active (and thus okay to initiate network traffic), you can retrieve its instantaneous state with [ConnectivityManager.isDefaultNetworkActive](/reference/kotlin/android/net/ConnectivityManager#isDefaultNetworkActive())."]]