I've been working on an app to send sensor data via UDP. I have implemented a UDP client with an AsyncTask, and have created a Timer to execute this AsyncTask (send UDP packets) at a fixed interval.

However, I've noticed that there is intermittent lag in outputting udp packets, indicating that the scheduled executions are being held up at times. I've noticed that if I play with the UI (slide the notification bar up and down/have a notification pop up), the scheduled executions are held up.

This leads me to wonder if the Timer is indeed running on a background thread or not? The developer docs seem to indicate that it does, however it seems to get held up with UI events.

My code is below, perhaps there is an issue with my implementation? My app is currently listening for sensor data, and outputting accel in X direction via udp. I am receiving the packets on a simple python server.

// code omitted