My phone is not moving, but GPS data still changing

 ̄綄美尐妖づ 提交于 2020-01-04 05:16:13

问题


I have a simple android code to send GPS location to a database periodically via a web service. For testing purpose I set the minTime to 2000ms.

lm=(LocationManager)getSystemService(Context.LOCATION_SERVICE);
ll=new SpeedoActionListener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,2000, 0,ll);

But...

  1. when my phone is not moving, still it inserts different longitude and latitude values to the database.
  2. Even I disabled GPS it sends different longitude latitude to the database untill I close the connection between my phone and the laptop.

Web service is hosted on IIS7 and my phone and laptop connected via wi-fi

Though my phone is not moving, why it sends different locations?

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

      }
}
}

回答1:


In low accuracy settings, data will receive from Wifi networks. Check Setting/Location/Use Wireless networks check box on your android phone.




回答2:


Android uses GPS when available, but does not rely only on GPS. The internals for when it uses what data sources is a complex subject, as described in the guide topic Obtaining User Location. The location changes may come, for instance, from the phone switching strategies to save battery life.




回答3:


GPS has inherent imprecision, so I would expect slight variations. I don't know why it would keep changing when you turn of GPS, though (as noted by the other answers, it's probably using an alternate source like WiFi triangulation).



来源:https://stackoverflow.com/questions/9858788/my-phone-is-not-moving-but-gps-data-still-changing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!