Use the Background Service . Services are application components that can run in the background without user interaction. Good tutorial on ServiceAndroid from this .
You probably want to start the service when you start your own Activity, or you can register for system translations, such as BOOT_COMPLETEfor your service to work from boot.
However, your service runs without user knowledge - this is a bad idea, and it also drains the battery. You probably want to wake up the service with AlarmManager, perform processing, schedule the next restart, and exit.
source
share