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

后端 未结 2 1714
南旧
南旧 2020-12-18 11:36

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

相关标签:
2条回答
  • 2020-12-18 12:10

    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
    
            }
    
      }
    
    0 讨论(0)
  • 2020-12-18 12:35

    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 讨论(0)
提交回复
热议问题