based on app id send latitude and longitude and time send to server and use of alram manager
Asked
Active
Viewed 607 times
0
-
U can set time interval to 3 minutes using location manager and request location updates. Now inside onLocationChanged() u can call php webservice and send the updated lat,lng. – kevz Dec 23 '15 at 05:46
-
2What did you try so far? Whats the problem you are stuck with? – Abhijit Annaldas Dec 23 '15 at 05:46
-
Possible duplicate of [How can i send latitude longitude of android device every 15minute to php web service](http://stackoverflow.com/questions/7440470/how-can-i-send-latitude-longitude-of-android-device-every-15minute-to-php-web-se) – Abhijit Annaldas Dec 23 '15 at 05:47
-
1You need to use alrmmanager to trigger every 3 minutes – Madhu Dec 23 '15 at 05:49
-
okay pls send the code – mounika Dec 23 '15 at 05:49
-
Okay ,thaks for reply – mounika Dec 23 '15 at 06:51
3 Answers
3
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 } }
0
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)

Anjali Tripathi
- 1,477
- 9
- 28
0
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.

Community
- 1
- 1