Android GPS定位精度问题
我正在android上开发gps跟踪应用程序。以下是我的代码体系结构:Android GPS定位精度问题,android,gps,tracking,Android,Gps,Tracking,我正在android上开发gps跟踪应用程序。以下是我的代码体系结构: BackgroundSyncService:用于获取位置更新的服务类。这里初始化了GoogleAppClient并实现了其他与位置相关的方法 AppRunCheckerReceiver:一个BroadcastReceiver类,它将检查myBackgroundSyncService是否在某个时间间隔内运行。如果它停止了,那么它就开始了 GpsEnableReceiver:如果gps状态发生变化,它将触发的广播接收器。它将检查
BackgroundSyncService
是否在某个时间间隔内运行。如果它停止了,那么它就开始了BackgroundSyncService
是否在某个时间间隔内运行。如果它停止了,那么它就开始了BackgroundSyncService
是否在某个时间间隔内运行。如果停止,则启动BackgroundSyncService
服务中,我使用以下方式初始化GoogleAppClient:
public void setLocationLocationRequest() {
try {
googleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(com.google.android.gms.location.LocationServices.API).build();
locationRequest = new LocationRequest();
locationRequest.setInterval(3000);
locationRequest.setFastestInterval(3000);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
googleApiClient.connect();
} catch (Exception e) {
}
这里的精度是定位请求。优先级是高精度,间隔是
locationRequest.setInterval(3000)
是GoogleAppClient实现代码
应用程序GPS信息部分包含经纬度和精度参数
我的发现:在onLocationChanged(Location-Location)
方法中,我通过以下方式检查Location对象的准确性:Location.getAccurance()
。在这里,如果精度小于50米,那么我接受它
在85%的案例中,它就像一个符咒。它从GPS向我发送准确的位置。但在15%的情况下,它会给我发送不准确的位置,比如超过300米
15%的设备是低成本的中国品牌移动设备
我的问题:
提前感谢你的帖子。同时也为糟糕的英语感到抱歉。+1了解相关描述。
我希望我们能为你的问题找到最好的答案,并且根据我所知,随着时间的推移,答案会变得更好1.这里不会只有一个正确答案 第一,(第二)
就GPS而言,在设备配置和精度方面,视线是一个重要因素。 虽然低成本的手机可以返回一个准确的位置和清晰的视线。您可以尝试多运行2个循环/等待以获得更高的精度 在最坏的情况下,您也可以尝试使用和GPS提供程序技术检索位置,该技术在15%的情况下作为备用方案,以进行比较并确保您使用的位置最准确。 把它当作 在大多数情况下,你会得到更好的电池性能,以及更多 通过使用定位服务API获得适当的精度
它们确实可以工作,但对于应用程序中接收到的位置,并不总是具有最高的准确度。如果有任何针对美国开发者的定位黑客,我们需要找到他们,也许是第5页的谷歌搜索结果:)或者从开源环境中获益。对我来说,最佳实践和安卓回购链接就足够了。您已经关注过类似的帖子
互联网与+
代码: 全球定位系统–>(全球定位系统)
new GoogleApiClient.Builder(context)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build()
public Location getLocation() {
try {
locationManager = (LocationManager) mContext
.getSystemService(LOCATION_SERVICE);
// getting GPS status
isGPSEnabled = locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
// getting network status
isNetworkEnabled = locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (!isGPSEnabled && !isNetworkEnabled) {
// no network provider is enabled
} else {
this.canGetLocation = true;
//here is the if-else change so code avoids falling into both loops
// if GPS Enabled get lat/long using GPS Services
if (isGPSEnabled) {
if (location == null) {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
Log.d("GPS", "GPS Enabled");
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
}
} else if (isNetworkEnabled) {
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
Log.d("Network", "Network Enabled");
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return location;
}