Making activity runs in background

You cannot really run an Activity on background! When an activity is not on foreground it gets to onStop and then the system could terminate it, to release resources, by onDestroy method! see Activity Lifecycle

In order to run on background you need to create a Service or IntentService

Checkout android javadoc about Services here and here or IntentService

and here is a third-party Android Service Tutorial

Edit: you may also need a communication between your service and your activity so you can get through that: Example: Communication between Activity and Service using Messaging


If you simply want your activity runs in back Try using

moveTaskToBack(true);