我有一个简单的Android代码,通过Web服务定期发送GPS位置到数据库.出于测试目的,我将minTime设置为2000ms.
lm=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
ll=new SpeedoActionListener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,2000, 0,ll);
Run Code Online (Sandbox Code Playgroud)
但...
网络服务托管在IIS7上,我的手机和笔记本电脑通过Wi-Fi连接
虽然我的手机没有移动,为什么它会发送不同的位置?
private class SpeedoActionListener implements LocationListener
{
String result=null;
@Override
public void onLocationChanged(Location location) {
if(location!=null) {
lati=location.getLatitude();
longi=location.getLongitude();
String mylati=Double.toString(lati);
String mylongi=Double.toString(longi);
WebServiceCaller obj=new WebServiceCaller();
result=obj.sendLocationData(mylongi, mylati);
resultText=(TextView)findViewById(R.id.result);
resultText.setText(result);
}
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
}
}
Run Code Online (Sandbox Code Playgroud)