Is there any way to handle wi-fi or cellular networks enable/disable on android N. I've tried to add broadcast receiver with intent-filter "android.net.conn.CONNECTIVITY_CHANGE"
, but it's deprecated for N and higher.
The network changes listener implementation for android N and high
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
registerReceiver(mNetworkReceiver,
new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
Many thanks to CommonsWare for useful answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With