title: How to get unique id of WiFi in android?
body: <p>I can get a name of WiFi using the code String ssid = wifiInfo.getSSID(),
  but you know many WiFi have the same name such as "MyWiFi", I hope to get unique id of a WiFi, how can I do? Thanks!</p>
  
  <p>Tips:
  I hope to upload my file in my app only when I connect to my home WiFi named "MyWiFi", but in other place, there are many WiFi named "MyWiFi".</p>
  
  <pre><code>  if (intent.getAction().equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
          NetworkInfo networkInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
          if (networkInfo.isConnected()) {
              // Wifi is connected                
              WifiManager wifiManager = (WifiManager) context .getSystemService(Context.WIFI_SERVICE);
              WifiInfo wifiInfo = wifiManager.getConnectionInfo();
              String ssid = wifiInfo.getSSID();
  
              Toast.makeText(context, "OK " + ssid, Toast.LENGTH_LONG).show();
          }
      } else if(intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
          NetworkInfo networkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
          if(networkInfo.getType() == ConnectivityManager.TYPE_WIFI &amp;&amp; ! networkInfo.isConnected()) {
              Toast.makeText(context, "Wifi is disconnected: "+String.valueOf(networkInfo), Toast.LENGTH_LONG).show();
          }
      }
  </code></pre>