开发者

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

开发者 https://www.devze.com 2023-04-05 11:03 出处:网络
I want to send every 15minute updated latitude 开发者_开发问答and longitude of android device to php web service. How can i do this?Use an AlarmManager that starts a service every 15 minutes.

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


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

        }

  }


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消