How to get network state change on android? [duplicate]
问题 This question already has answers here : Android: Internet connectivity change listener (7 answers) Closed last year . I have broadcast receiver for "CONNECTIVITY_CHANGE". When I print the extra using this: intent.getExtras().toString() I can see that if I disable WIFI, I receive 2 network change. WIFI DISCONNECTED MOBILE CONNECTED However, when I try to use NetworkInfo networkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); It said, this API has been deprecated.