假设设备支持gps和glonass(在硬件级别支持).
现在,当我通过android.location API获取位置时,是否可以知道位置来自哪里的硬件?
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?
}
}
Run Code Online (Sandbox Code Playgroud)
如果我们使用GPSStatus.Listener这样的:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
位置来自的硬件是手机中的GPS/GLONASS芯片.芯片从绕地球轨道运行的卫星接收信号.
GPS和GLONASS卫星在支持此功能的设备上组合使用.要确定GLONASS卫星是否用于确定位置,您可以注册GpsStatusListener或拨打电话LocationManager.getGpsStatus().调用getSatellites()上GpsStatus对象,然后调用getPrn()每一个上GpsSatellite返回列表中的对象.如果该值介于65和88之间,并且该usedInFix()方法返回true,则使用GLONASS卫星计算最后位置.
见http://developer.sonymobile.com/knowledge-base/technologies/glonass/
| 归档时间: |
|
| 查看次数: |
3173 次 |
| 最近记录: |