How can I get current location on Android?
<p>I use this code for getting current location:</p>

<pre><code>LocationManager lm = (LocationManager) this
        .getSystemService(Context.LOCATION_SERVICE);
List&lt;String&gt; providers = lm.getProviders(true);

/*
 * Loop over the array backwards, and if you get an accurate location,
 * then break out the loop
 */
Location l = null;

for (int i = providers.size() - 1; i &gt;= 0; i--) {

    l = lm.getLastKnownLocation(providers.get(i));
    if (l != null)
        break;
}

if (l==null) {
    return;
}
Toast.makeText(this, String.valueOf(l.getLatitude()), Toast.LENGTH_LONG).show(); 
</code></pre>

<p>But I never see a latitude, because l is null always. My Manifest file contains ACCESS_FINE_LOCATION and INTERNET permissions. Where have I made mistake? </p>
