I need to develop a feature that is required checking Wi-Fi settings state 'ON' or 'OFF' even if not connected to a WiFi network on Android! I need to display a pop up!
public static boolean CheckWifiConnection(Context context) {
ConnectivityManager conMgr = (ConnectivityManager) context.getSystemService (Context.CONNECTIVITY_SERVICE);
return conMgr.getActiveNetworkInfo() != null
&& conMgr.getActiveNetworkInfo().isAvailable();
}
For an example: Think I am in a bus, I have turned on the WiFi. It is not connected to a wifi network, because there is no WiFi router near by. So How can my app knows wifi is on or off.