我定义了GPS坐标。我已经创建了一个onLocationChanged应用程序 - 接收位置。这样可行。现在我想提高获得kordinaty和精度坐标的速度。
如何快速获得准确的GPS坐标?
答案 0 :(得分:2)
阅读Reto Meiers“深入到位置”:
http://android-developers.blogspot.de/2011/06/deep-dive-into-location.html
简短版本:你得到的操作系统不是或多或少提供
答案 1 :(得分:0)
我希望这可以帮助你,试试这个:
LocationManager mlocManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
LocationListener mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,
mlocListener);
public class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
loc.getLatitude();
loc.getLongitude();
Geocoder gcd = new Geocoder(getApplicationContext(),
Locale.getDefault());
try {
mAddresses = gcd.getFromLocation(loc.getLatitude(),
loc.getLongitude(), 1);
} catch (IOException e) {
}
String cityName = (mAddresses != null) ? mAddresses.get(0)
.getLocality() : TimeZone.getDefault().getID();
String countryName = (mAddresses != null) ? mAddresses.get(0)
.getCountryName() : Locale.getDefault().getDisplayCountry()
.toString();
mCurrentSpeed.setText(loc.getSpeed());
}
@Override
public void onProviderDisabled(String provider) {
Toast.makeText(getApplicationContext(), "Gps Disabled",
Toast.LENGTH_SHORT).show();
}
@Override
public void onProviderEnabled(String provider) {
Toast.makeText(getApplicationContext(), "Gps Enabled",
Toast.LENGTH_SHORT).show();
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}