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

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

How to connect android wifi to adhoc wifi?

You are correct that this is currently not natively supported in Android, although Google has been saying it will be coming ever since Android was officially launched. While not natively supported, the hardware on every android device released to date do support it. It is just disabled in software, and you would need to enable … 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

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

How to calculate distance from Wifi router using Signal Strength?

FSPL depends on two parameters: First is the frequency of radio signals;Second is the wireless transmission distance. The following formula can reflect the relationship between them. FSPL (dB) = 20log10(d) + 20log10(f) + K d = distance f = frequency K= constant that depends on the units used for d and f If d is … Read more