Reputation: 27
based on app id send latitude and longitude and time send to server and use of alram manager
Upvotes: 0
Views: 615
Reputation:
User AlarmManager
First Please check the Scheduling Repeating Alarms on android developer site.
and check the following answer here it explains how to run every 5 seconds.
finally check the following tutorial, it explains how to run a service(in your case to call the backend).
Hope that Helps.
Upvotes: 0
Reputation: 2737
Request Location updates using LocationManager.
NetworkListener listener = new NetworkListener()
locationManager.requestLocationUpdates (LocationManager.NETWORK_PROVIDER, 30000, 0, listener);
Inside Listener onLocationChanged u can write code to send lat, lng to php webservice.
class NetworkListener implements LocationListener{
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
double latitude = location.getLatitude();
double longitude = location.getLongitude();
// write code to send lat, lng to php webservice.
}
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: 3
Reputation: 1477
You can use timer task that will trigger after each 3 minutes. Please refer below code for that
final Handler handler = new Handler();
timer = new Timer();
TimerTask doAsynchronousTask = new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
public void run() {
/// send lat and long here to your server
}
});
}
};
timer.schedule(doAsynchronousTask, 0, 300000)
Upvotes: 0