【发布时间】:2010-11-08 18:20:04
【问题描述】:
从标题看很清楚,到目前为止我已经尝试了不同的坐标,但这里是一个例子:
telnet localhost <port>
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK
geo fix 46.498981 11.350230
OK
在 logcat 中我发现了这对夫妇:
46.491002 11.351833366666664
当我给出这个坐标时,我从我的类实现位置监听器(以及其他用于双重检查)的 logcat 中读取:
public class LocationService implements LocationListener {
private static final String TAG = "LocationService";
public LocationManager lmr = null;
private Navigation SystemService = null;
public LocationService(Navigation sservice) {
this.SystemService = sservice;
}
public void startLocationService() {
Log.d(TAG, "starting LocationService");
this.lmr = (LocationManager) this.SystemService
.getSystemService(Context.LOCATION_SERVICE);
this.lmr.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 5,
this);
}
public void stopLocationService() {
this.lmr.removeUpdates(this);
}
/*
* (non-Javadoc)
*
* @see
* android.location.LocationListener#onLocationChanged(android.location.
* Location)
*/
@Override
public void onLocationChanged(Location location) {
location = this.lmr.getLastKnownLocation(LocationManager.GPS_PROVIDER);
try {
// this code is used to make a location used from the server I am communicating with out of a android.location
eu.fbk.dycapo.models.Location loc = new eu.fbk.dycapo.models.Location();
Log.d(TAG, "longitude : " + location.getLongitude());
Log.d(TAG, "latitude : " + location.getLatitude());
loc.setGeorss_point(String.valueOf((double) location.getLongitude())
+ " " + String.valueOf((double) location.getLatitude()));
loc.setLeaves(Calendar.getInstance().getTime());
loc.setPoint(eu.fbk.dycapo.models.Location.POSI);
//send it to the server
LocationService.updatePosition(loc);
} catch (NullPointerException e) {
Log.e(TAG, e.getMessage());
e.printStackTrace();
}
}
/*
* (non-Javadoc)
*
* @see
* android.location.LocationListener#onProviderDisabled(java.lang.String)
*/
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see
* android.location.LocationListener#onProviderEnabled(java.lang.String)
*/
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see android.location.LocationListener#onStatusChanged(java.lang.String,
* int, android.os.Bundle)
*/
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
我认为某处可能有问题,但我不明白在哪里或为什么,因为我已经遵循 android 指南来实现位置侦听器 here。
谢谢
【问题讨论】: