how to get current wifi connection info in android
<p>I'm trying to find if <code>scanResult</code> is the current connected wifi network.</p>

<p>here is my code</p>

<pre><code>public boolean IsCurrentConnectedWifi(ScanResult scanResult) 
{
    WifiManager mainWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    WifiInfo currentWifi = mainWifi.getConnectionInfo();
    if(currentWifi != null)
    {
        if(currentWifi.getSSID() != null) 
        {
            if(currentWifi.getSSID() == scanResult.SSID)
            return true;
        }
    }  
    return false;
}
</code></pre>

<p>I have no problem on getting scanresult.</p>

<p>Always I'm getting currentWifi is null.</p>

<p>Where am I wrong or Is there any alternative method to do this?</p>
