简体   繁体   中英

How to know if an Android device is connected to a public wifi hotspot

I know if the device is connected or not to a wifi router. For security reasons I would like to know if that connection is a private one (one of those I have the password for, like Home, Work...) or if it is just a public open one without a password (library, airport...).

Is it possible?

Yes , you can check for particular wifi that it is a private one or public one. You can get all the list of available wifi and can get their BSSID,if any wifi connection have BSSID that means this on is private otherwise not.If you want code plz let me know.

Herei am providing you code to find list of all available wifi and their informations like BSSID,SSID etc. Here you can find that particular wifi is public or private.

create beans for wifi data named WifiDataBeans

public class WifiDataBeans {
public String ssid;
public String bssid;
public String compatibility;
public int freq;
public int level;}

and in you mainActivity

     WifiManager manager;
    public  ArrayList<WifiDataBeans> list = new ArrayList<WifiDataBeans>();

in onCreate()

        manager = (WifiManager) getSystemService(WIFI_SERVICE);

            List<ScanResult> results = manager.getScanResults();
                    for (int i = 0; i < results.size(); ++i) 
        {
            WifiDataBeans bean = new WifiDataBeans();
            bean.ssid = results.get(i).SSID;
            bean.bssid = results.get(i).BSSID;
            bean.compatibility = results.get(i).capabilities;
            bean.freq = results.get(i).frequency;
            bean.level = getPowerPercentage(results.get(i).level);
            list.add(bean);

        }

here you can check for all list of wifi BSSID,if they have that means private otherwise public.

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