android google map current location not getting : <p>i am working on a google map activity. i am trying to get the current location.it works perfectly on emulator but not getting the current location on my phone. here is the code which i am using in my application...</p>

<pre><code>locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    provider = locationManager.getBestProvider(criteria, false);
    Location location = locationManager.getLastKnownLocation(provider);

    if (location != null) {
        double lat = (double) (location.getLatitude());
        double lng = (double) (location.getLongitude());

        Constants.lat = String.valueOf(lat);
        Constants.lng = String.valueOf(lng);
     }
</code></pre>

<p>Constants is the class where i have decalred the latitude and longitude static variables declared. This code is written in a function and it is call from onCreate method.I am getting null location everytime.I have declare below code also in manifestfile.</p>

<pre><code>     &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt;
     &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
</code></pre>

<p>Can anybody please help me ? Thanks . </p>
