How To Loop Or To Repeat Periodically Task In Android?
I am quite new to Android, and I am really wondering about is how to loop or to repeat periodically a task. In my program, I have UpdateLoc() that sends my gps location to my data
Solution 1:
You might want to look here: http://developer.android.com/reference/android/location/LocationListener.htmlhttp://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates(java.lang.String, long, float, android.location.LocationListener)
This will allow you to receive updates only after a particular amount of time has past.
Solution 2:
I believe you have two options in this case:
Service
- This will stay running in the background but use more battery.AlarmManager
- You can schedule a task to run in the future to briefly perform an update operation and should use less battery.
Post a Comment for "How To Loop Or To Repeat Periodically Task In Android?"