I have created an Android app to retrieve the location. I tried to use GPS_PROVIDER, it returned null.. But works smooth when i use NETWORK_PROVIDER.. Can any one help me fixing this?
Here is the code
Location location =
locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
The location turns null when i replace "NETWORK_PROVIDER" by "GPS_PROVIDER"..
I have added the following three permissions in manifest
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
There can be two reasons why your GPS location is null
setting menu => Location & Security => Check Use GPS Satellites.