简体   繁体   中英

Is it possible to reliably detect which wifi network I'm on?

I am writing an android app and trying to figure out if there is a reliable way to determine when the phone is on a specific wifi network.

For example, I want to perform certain actions only when connected to the home wifi.

Does anyone know if it's possible?

Yes, there is a way for this on both, android and iOS/iPhone.

On Android, you need to use this method in the end: android.net.wifi.WifiInfo.getSSID

On iPhone it's a completely different world. You can find a good description of how to do it here: iPhone get SSID without private library

you can get the SSID of the current wifi-connection with :

WifiManager mng = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
String currentSSID = mng.getConnectionInfo().getSSID();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM