How to get the satellite count from the fused location api?

1.9k views Asked by At

I am using GoogleApiClient to request location update. I am getting the latitude, longitude, speed and other information. Along with this I want to get the satellite count also. How can I achieve this?

Please help me on this.

1

There are 1 answers

3
Murtaza Khursheed Hussain On

Here is the sample code to get the satellite count in use and in view

gpsStatus = locationManager.getGpsStatus (gpsStatus);
        Iterable<GpsSatellite> satellites = gpsStatus.getSatellites ();
        int sattInView = 0;
        int sattInUse = 0;
        if (satellites != null) {
            for (GpsSatellite gpsSatellite : satellites) {
                sattInView++;
                if (gpsSatellite.usedInFix ()) {
                    sattInUse++;
                }
            }
        }
        inView = String.valueOf (sattInView);
        inUse = String.valueOf (sattInUse);