Suppose the device support both gps and glonass(support at the hardware level).
Now when I get location by the android.location API, is it possible to know the hardware where the location came from?
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener());
class LocationListener implement LocationListener(){
@Override
public void onLocationChanged(Location location) {
GPSStatus status=locationManager.getGpsStatus();
//check the PRN of the satellites from the status
//but how can be granted that the `status` object obtained here is exactly the same when it was used to calculate the location?
}
}
If we use the GPSStatus.Listener
like this:
class LocationListener implement LocationListener,GPSStatus.Listener(){
private GPSStatus status;
@Override
public void onLocationChanged(Location location) {
if(status!=null){
//status should be the GPSStatus before get this location
//check the PRN of the satellites from the status
//How it can be granted that the `onGpsStatusChanged` will be called before the `onLocationChanged` by the Android System?
}
}
public void onGpsStatusChanged(int event) {
status = locationManager.getGpsStatus(null);
}
}
The hardware the location came from is the GPS/GLONASS chip in your phone. The chip receives signals from satellites orbiting the earth.
GPS and GLONASS satellites are used in combination on devices that support this. To determine if GLONASS satellites were used to determine the location, you can either register a GpsStatusListener
or call LocationManager.getGpsStatus()
. Call getSatellites()
on the GpsStatus
object and call getPrn()
on each GpsSatellite
object in the returned list. If the value is between 65 and 88 and the usedInFix()
method returns true
the last position was calculated using a GLONASS satellite.
See http://developer.sonymobile.com/knowledge-base/technologies/glonass/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With