سؤال

If there are two wifi networks in range that both have the same SSID, security type, and password, is there any available ID to distinguish between them? Is there a way to get that ID in android?

هل كانت مفيدة؟

المحلول

You can distinguish them through BSSID - if someone won't assign fixed MAC address they will have for sure different (unique) MAC addresses.

Also they can be on different channel. I think it's impossible if two networks have same SSID, same channel and same BSSID.

نصائح أخرى

You could try to extract the MAC address from the sending networks Router/AP. This address would be unique.

use getSubtype() .

Check out slide 9 here:

ConnectivityManager mConnectivity = null;
TelephonyManager mTelephony = null;
// Skip if no connection, or background data disabled
NetworkInfo info = mConnectivity.getActiveNetworkInfo();
if (info == null || !mConnectivity.getBackgroundDataSetting()) {
    return false;
}

// Only update if WiFi or 3G is connected and not roaming
int netType = info.getType();
int netSubtype = info.getSubtype();
if (netType == ConnectivityManager.TYPE_WIFI) {
    return info.isConnected();
} else if (netType == ConnectivityManager.TYPE_MOBILE
    && netSubtype == TelephonyManager.NETWORK_TYPE_UMTS
    && !mTelephony.isNetworkRoaming()) {
        return info.isConnected();
} else {
    return false;
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top