Manisha
Manisha

Reputation: 109

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

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

Upvotes: 3

Views: 3524

Answers (2)

user370305
user370305

Reputation: 109237

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.

Upvotes: 2

Umesh
Umesh

Reputation: 4256

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

        }

  }

Upvotes: 2

Related Questions