Location Manager not obtaining GPS location properly
<p>i am supposed to obtain the current location of the user , for this i have implemented the following code:</p>

<pre><code>lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
ll = new mylocationlistener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, ll);
</code></pre>

<p>Here is my LocationListener class:</p>

<pre><code> private class mylocationlistener implements LocationListener {
    @Override
    public void onLocationChanged(Location location) {
        if (location != null) {
            Log.d("LOCATION CHANGED", location.getLatitude() + "");
            Log.d("LOCATION CHANGED", location.getLongitude() + "");
            lat = location.getLatitude();
            lng = location.getLongitude();
            Toast.makeText(NearActivity.this, "lng=" + lng + " lat=" + lat,
                    Toast.LENGTH_SHORT);
            showProgress();
        }
    }
</code></pre>

<p>The above code is not setting the variables lat and lng which are global variables. Why is the GPS not able to provide the cordinates? </p>

<p>Thank you in advance.</p>
