0

In my android app, i'm playing with user location. Problem is I want to know whether GPS is locked or still it is trying to get i.e, is there flag or some method to know, the moment GPS is locked?

Sarweshkumar C R
  • 523
  • 1
  • 8
  • 19
  • 1
    I made some code that handles this: http://stackoverflow.com/questions/19365035/location-servise-gps-force-closed/19366773#19366773 – cYrixmorten Dec 19 '13 at 08:26

2 Answers2

0

http://developer.android.com/reference/android/location/GpsStatus.html

This might be what you're looking for.

George Daramouskas
  • 3,600
  • 3
  • 19
  • 50
0
    public class MyLocationListener implements LocationListener {

public void onLocationChanged(Location location) {
    if (location.getProvider().equals("gps")) {
        //FROM GPS
        if(isSearching){//GPS called first time after Enable
            isSearching=false;
        }
    } else {
        //FROM NETWORK

    }
}

public void onProviderDisabled(String provider) {

}

public void onProviderEnabled(String provider) {
    isSearching = true;
    // GPS IS SEARCHING
}

public void onStatusChanged(String provider, int status, Bundle extras) {
}

}

Raise a flag whenever the user enables the gps. OnLocationChanged is never called until the gps is fixed.

AabidMulani
  • 2,287
  • 1
  • 27
  • 47