Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the number of satellites from Location object

I'm using a GPS provider and LocationListener.onLocationChanged(Location location) to receive location fixes.
Documentation says, that Location.getExtras() contains next key/value pair:

satellites - the number of satellites used to derive the fix

but on practice I'm getting an empty extra object - there is no any data there.
Does it means that I'm getting the A-GPS fixes and not GPS?

like image 625
GetUsername Avatar asked Jul 05 '11 09:07

GetUsername


People also ask

How many satellites are minimum required to determine positions of any object on the surface of the earth?

It takes four GPS satellites to calculate a precise location on the Earth using the Global Positioning System: three to determine a position on the Earth, and one to adjust for the error in the receiver's clock.

How do satellites know location?

The locations of the satellites are determined using tracking from ground stations.

What is the least number of satellites should be received at the same time when using GNSS positioning technology?

A GNSS receiver needs a minimum of 4 satellites to be able to calculate its own position. Three satellites will determine latitude, longitude, and height. The fourth one synchronizes the receiver's internal clock.


1 Answers

To get the number of satellites used by the GPS engine you need to implement android.location.GpsStatus.Listener and implement its method onGpsStatusChanged().

Example...

public void onGpsStatusChanged(int event) {
    int satellites = 0;
    int satellitesInFix = 0;
    int timetofix = locationManager.getGpsStatus(null).getTimeToFirstFix();
    Log.i(TAG, "Time to first fix = " + timetofix);
    for (GpsSatellite sat : locationManager.getGpsStatus(null).getSatellites()) {
        if(sat.usedInFix()) {
            satellitesInFix++;              
        }
        satellites++;
    }
    Log.i(TAG, satellites + " Used In Last Fix ("+satellitesInFix+")"); 
}
like image 76
user1055212 Avatar answered Nov 15 '22 09:11

user1055212