如何在Android中以编程方式获取设备热点SSID?

时间:2016-06-12 18:12:17

标签: java android android-networking

我很难找到找到hotspot ssid设备的方法,我找到的所有解决方案都返回了连接设备的Wi-Fi名称,而我想查找设备的热点名称创建

getting wifi name

public static String getWifiName(Context context) {
        WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        if (manager.isWifiEnabled()) {
            WifiInfo wifiInfo = manager.getConnectionInfo();
            if (wifiInfo != null) {
                NetworkInfo.DetailedState state = WifiInfo.getDetailedStateOf(wifiInfo.getSupplicantState());
                if (state == NetworkInfo.DetailedState.CONNECTED || state == NetworkInfo.DetailedState.OBTAINING_IPADDR) {
                    return wifiInfo.getSSID();
                }
            }
        }
        return null;
    }

0 个答案:

没有答案