Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot get satellite count Android

Tags:

java

android

gps

I cannot seem to get the satellite count when using the geo fix command though the adb.

The geo fix help reads:

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 geo location to trigger OnLocationChanged to execute:

geo fix -106.1221 52.1311 514 5

In the OnlocationChanged:

Location newestloc = loc; 
Bundle sats = newestloc.getExtras();
int satcount = 0;
satcount = sats.getInt("satellites");

However whenever I call satcount, I always get 0. is the number of satellites being passed through the geo fix not counted?

Are there any other methods to getting the number satellites that are currently seen by the phone's GPS?

Edit: I have also tried the following code as well:

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 at minimally return 1 every time I get a fix, but it never changes from 0.

like image 670
Sorean Avatar asked Mar 04 '11 18:03

Sorean


2 Answers

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

try getSatellites()

What type of phone are you testing with? Have you tried checking what lbstest mode returns? Could be that the phone itself is not picking up any satellites.

like image 162
Nayan Jain Avatar answered Sep 30 '22 04:09

Nayan Jain


There seems to be a bug in Android's handling of the geo fix command in some Versions. You might want to try geo fix -106.1221 52.1311 514 5 12, where the number 5 is ignored on some Implementations and the 12 is taken as the number of satellites. So the actual syntax on flawed systems would be

geo fix <longitude> <latitude> [<altitude> [<dummy> <satellites>]]
like image 22
Name Avatar answered Sep 30 '22 05:09

Name