1

There are a lot of answers about how to check if the device is connected on wifi or Data, using:

hasTransport(NetworkCapabilities.TRANSPORT_WIFI/TRANSPORT_CELLULAR) 

What is the current non-deprecated way to see if Wifi is enabled (not connected), like:

BluetoothAdapter.getDefaultAdapter().isEnabled

2 Answers2

0

The first answer does exactly what i need without deprecation warning: Checking Wi-Fi enabled or not on Android

  • A link only answer is not an answer. Best to include the link as comment or mark this question as duplicate – Zun Oct 29 '19 at 18:53
0
WifiManager.isWifiEnabled()

returns true if Wifi is enabled. link to doc


Another a good option is:

WifiManager.getWifiState()

returns an int: One of WIFI_STATE_DISABLED, WIFI_STATE_DISABLING, WIFI_STATE_ENABLED, WIFI_STATE_ENABLING, WIFI_STATE_UNKNOWN

link to doc

Vivek Vinodh
  • 114
  • 1
  • 13