Reputation: 468
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.
Upvotes: 6
Views: 5536
Reputation: 468
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.
Upvotes: 16