我的手机是不动的,但GPS数据仍在变化 [英] My phone is not moving, but GPS data still changing

查看:270
本文介绍了我的手机是不动的,但GPS数据仍在变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的Andr​​oid code发送GPS定位到数据库通过Web服务定期。出于测试目的,我设置为minTime 2000毫秒。

 流明=(的LocationManager)getSystemService(Context.LOCATION_SERVICE);
LL =新Speed​​oActionListener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,2000,0,LL);

不过...


  1. 当我的手机是不动的,它仍然插入不同的经度和纬度值到数据库中。

  2. 即使我禁用GPS发送不同的经纬度到数据库中,直到我闭上我的手机和笔记本电脑之间的连接。

Web服务托管在IIS7和我的手机和笔记本电脑通过Wi-Fi连接。

虽然我的手机是不动的,为什么它会发送不同的位置?

 私有类Speed​​oActionListener实现LocationListener的
{    字符串结果= NULL;      @覆盖
      公共无效onLocationChanged(地点){          如果(位置!= NULL){
            LATI = location.getLatitude();            隆基= location.getLongitude();            字符串mylati = Double.toString(LATI);
            字符串mylongi = Double.toString(隆基);
            WebServiceCaller的obj =新WebServiceCaller();
            结果= obj.sendLocationData(mylongi,mylati);
            resultText =(的TextView)findViewById(R.id.result);
            resultText.setText(结果);
      }}      @覆盖
      公共无效onProviderDisabled(字符串提供商){
              // TODO自动生成方法存根      }      @覆盖
      公共无效onProviderEnabled(字符串提供商){
              // TODO自动生成方法存根      }      @覆盖
      公共无效onStatusChanged(字符串提供商,INT地位,捆绑演员){
              // TODO自动生成方法存根      }
}
}


解决方案

在低精度的设置,数据将收到来自WiFi网络。检查设置/位置/使用无线网络复选框您的Andr​​oid手机上。

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

      }
}
}

解决方案

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

这篇关于我的手机是不动的,但GPS数据仍在变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆