Reputation: 97
I want to track GPS status in API 23 mobile, but the above method returing false
everytime.
My code:
LocationManager locationManager;
boolean isEnabled;
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
isEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
UPDATE :
I have both the permission in manifest.I have proper code to ask permmision also.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET"/>
# I have observed that if the location is turned on in app opeing the locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
is returning true, **but if I'm turning off location when app is opened and again turning on the location it is returning false. It is a big headache to get user current location. Also fused Location
is freezing.
Upvotes: 0
Views: 305