0

我定义了 GPS 坐标。我创建了一个应用程序 onLocationChanged - 接收位置。这样可行。现在我想提高获取 kordinaty 和精度坐标的速度。

如何快速获取准确的 GPS 坐标?

4

2 回答 2

2

阅读 Reto Meiers “深入了解位置”:

http://android-developers.blogspot.de/2011/06/deep-dive-into-location.html

简短版:您得到的操作系统不会或多或少地为您提供

于 2012-09-28T09:22:46.303 回答
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) {
    }
}
于 2012-09-28T09:30:18.043 回答