android: Determine security type of wifi networks in range (without connecting to them)

I think you can find it in the source code of Settings.apk. First you should call wifiManager.getConfiguredNetworks() or wifiManager.getScanResults(), then use the two methods below: (find them in AccessPoint class “com.android.settings.wifi”): static int getSecurity(WifiConfiguration config) { if (config.allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { return SECURITY_PSK; } if (config.allowedKeyManagement.get(KeyMgmt.WPA_EAP) || config.allowedKeyManagement.get(KeyMgmt.IEEE8021X)) { return SECURITY_EAP; } return (config.wepKeys[0] != null) ? … Read more

How to programmatically connect to a WiFi network given the SSID and password

With iOS 11, Apple provided public API you can use to programmatically join a WiFi network without leaving your app. The class you’ll need to use is called NEHotspotConfiguration. To use it, you need to enable the Hotspot capability in your App Capabilities (Adding Capabilities). Quick working example : NEHotspotConfiguration *configuration = [[NEHotspotConfiguration alloc] initWithSSID:@“SSID-Name”]; … Read more

Get SSID when WIFI is connected

I listen for WifiManager.NETWORK_STATE_CHANGED_ACTION in a broadcast receiver if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) { NetworkInfo netInfo = intent.getParcelableExtra (WifiManager.EXTRA_NETWORK_INFO); if (ConnectivityManager.TYPE_WIFI == netInfo.getType ()) { … } } I check for netInfo.isConnected(). Then I am able to use WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); WifiInfo info = wifiManager.getConnectionInfo(); String ssid = info.getSSID(); UPDATE From android 8.0 onwards we wont … Read more

Wifi Connect-Disconnect Listener

Actually you’re checking for whether Wi-Fi is enabled, that doesn’t necessarily mean that it’s connected. It just means that Wi-Fi mode on the phone is enabled and able to connect to Wi-Fi networks. This is how I’m listening for actual Wi-Fi connections in my Broadcast Receiver: public class WifiReceiver extends BroadcastReceiver { @Override public void … Read more

Android turn On/Off WiFi HotSpot programmatically

Warning This method will not work beyond 5.0, it was a quite dated entry. Use the class below to change/check the Wifi hotspot setting: import android.content.*; import android.net.wifi.*; import java.lang.reflect.*; public class ApManager { //check whether wifi hotspot on or off public static boolean isApOn(Context context) { WifiManager wifimanager = (WifiManager) context.getSystemService(context.WIFI_SERVICE); try { Method … Read more