It seems I canβt count the number of satellites when using the geo fix command, although adb.
Location Fix:
geo fix <longitude> <latitude> [<altitude> [<satellites>]] allows you to send a simple GPS fix to the emulated system The parameters are: <longitude> longitude, in decimal degrees <latitude> latitude, in decimal degrees <altitude> optional altitude in meters <satellites> number of satellites being tracked (1-12)
I use the following command to set the geolocation to run OnLocationChanged to execute:
geo fix -106.1221 52.1311 514 5
In OnlocationChanged:
Location newestloc = loc; Bundle sats = newestloc.getExtras(); int satcount = 0; satcount = sats.getInt("satellites");
However, whenever I call satcount, I always get 0. Does the number of satellites passing through the geo patch not count?
Are there any other ways to get the number of satellites that are currently displayed by the GPS phone?
Edit: I also tried the following code:
GpsStatus gpsstat = mlocManager.getGpsStatus(null); Iterable sats = gpsstat.getSatellites(); Iterator satI = sats.iterator(); int count = 0; while(satI.hasNext()){ GpsSatellite gpssatellite = (GpsSatellite) satI.next(); if (gpssatellite.usedInFix()){ count++; } }
This should minimally return 1 every time I get a fix, but it never changes from 0.
java android gps
Sorean
source share