How can i send latitude longitude of android device every 15minute to php web service

馋奶兔 提交于 2019-12-18 05:12:14

问题


I want to send every 15minute updated latitude and longitude of android device to php web service. How can i do this?


回答1:


Use an AlarmManager that starts a service every 15 minutes.

The service should include a class that implements a location listener.

follow this link - http://ukgupta.blogspot.com/2011_09_01_archive.html

  class GpsListener implements LocationListener{

        public void onLocationChanged(Location location) {
              // TODO Auto-generated method stub
              double latitude = location.getLatitude();
              double longitude = location.getLongitude();
              float speed = location.getSpeed();
              ...
        }

        public void onProviderDisabled(String provider) {
              // TODO Auto-generated method stub

        }

        public void onProviderEnabled(String provider) {
              // TODO Auto-generated method stub

        }
        public void onStatusChanged(String provider, int status, Bundle extras) {
              // TODO Auto-generated method stub

        }

  }



回答2:


For sending lat, long to webservice I think you can use either service or any thread in which you put the timer for every 15 minutes from device time and at that point just fetch the lat,long and send it to the your web service.

 locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);

from this method you get the update at specified time interval and frequency.

Here is the Android Location Manager link try it.



来源:https://stackoverflow.com/questions/7440470/how-can-i-send-latitude-longitude-of-android-device-every-15minute-to-php-web-se

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