Managing Network Changes on Android 7 Nougat

Is there a way to enable / disable the use of Wi-Fi or cellular networks on the Android phone N. I tried to add a broadcast receiver with the intent filter "android.net.conn.CONNECTIVITY_CHANGE" , but it is deprecated for N and higher.

+5
source share
1 answer

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 the helpful answer.

+15
source

Source: https://habr.com/ru/post/1258840/


All Articles