title: Get SSID when WIFI is connected
body: <p>I'm trying to get the SSID of the WIFI network when my android device is connected to WIFI.</p>
  
  <p>I've registered a BroadcastReceiver listening for <code>android.net.wifi.supplicant.CONNECTION_CHANGE</code> . I get the notification when WIFI is disconnected or reconnected. Unfortunately, I can't get the network's SSID.</p>
  
  <p>I'm using the following code to find the SSID:</p>
  
  <pre><code>WifiManager wifiManager = (WifiManager) context.getSystemService(context.WIFI_SERVICE);
  WifiInfo wifiInfo = wifiManager.getConnectionInfo();
  String ssid = wifiInfo.getSSID();
  </code></pre>
  
  <p>Instead of the SSID, I get the string <a href="http://code.google.com/p/android/issues/detail?id=43336"><code>&lt;unknown ssid&gt;</code></a> back.</p>
  
  <p>These are the permissions in the manifest (I've added ACCESS_NETWORK_STATE just to check, I don't actually need it)</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
  </code></pre>
  
  <p>Why does this happen? How can I get the actual SSID? Is the broadcast fired to early, before the connection is established? Is there another broadcast I should listen to? I'm only interested in WIFI connections, not 3G connections.</p>
  
  <p>Update: I just checked, <code>wifiInfo.getBSSID()</code> returns null.</p>