Android Services
So, you want your application to keep on running even if the user leaves your activities and start another application? Then tell android about it, and have your code continue to be executed by a service.
Lecture material
Recommended reading
The following chapters from the course book The Busy Coder's Guide to Android Development: