0

GPS プロバイダーを使用して現在地を取得しようとしました。

  • しかし、私が知る限り、それは適切に機能していません。Network プロバイダーの場合、サテライトの値ではなく、Tower の値を返します。
  • ここに、GPS プロバイダーに関連するコード サンプルをいくつか添付しました。

LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 500.0f,this);

public void onLocationChanged(Location location) {
    if (location != null) {
        double lat = location.getLatitude();
        double lng = location.getLongitude();
        String currentLocation = "Lat: " + lat + " Lng: " + lng;
        txted.setText(currentLocation);
        p = new GeoPoint((int) lat * 1000000, (int) lng * 1000000);
        mc.animateTo(p);
    }
}

public void onProviderDisabled(String provider) {
    // required for interface, not used
}

public void onProviderEnabled(String provider) {
    // required for interface, not used
}

public void onStatusChanged(String provider, int status, Bundle extras) {
    // required for interface, not used
}
4

2 に答える 2

0

これを試して

lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0,this);

後で、要件に従って更新を取得します。

于 2012-12-27T16:44:20.797 に答える
0

「GPS 衛星を使用する」が有効になっていることを確認し、[設定] -> [場所とセキュリティ] -> [GPS 衛星を使用] に移動します。

于 2012-12-27T15:20:27.590 に答える