Background apps fall in two categories:
Cached apps which are not actually running but still loaded in RAM so that they can be resumed quickly. See How to find out which Android apps are in “Cached” state? for more details.
Let's learn how to investigate the state of background apps using WhatsRunning and PermissionManagerX.
These apps provide some kind of data to other apps when the latter need. For instance there's a system app named “Contacts Storage” (com.android.providers.contacts
) which provides contacts to other apps. So whenever you open an app like “Phone” or “WhatsApp” which needs contacts, the “Contacts Storage” app will automatically run in background.
In WhatsRunning you can type PROVIDER
in the top search bar to find all apps running because of being a content provider:
And the detail of the process:
Starting with Android 8, only system apps can start background services. For instance “SystemUIService” is always active since it manages user interface for us.
User apps are put in cached state even if they are running a background service. So they cannot perform any task.
Like in the case of Content Providers, some apps rely on other apps to perform some tasks. So the latter run background services whenever the former need.
Say you have My Location and AMap UnifiedNlp Backend apps installed on your device. Whenever you open the former, it binds to the latter as a client to fetch the location, and hence the latter runs a background service:
As soon as the clients unbind from the service, the service app is stopped and put into cached state.
If a user app needs to perform a persistent task in background, it runs a foreground service which shows a notification. For instance, WhatsRunning runs a foreground service to show Battery Stats and PermissionManagerX runs a foreground service for Permission Watcher:
You can see both services running in WhatsRunning:
Apps can request the operating system (using WorkManager, JobScheduler or AlarmManager) to run one-time or repeated tasks at a given interval or at a fixed time. Android starts these apps at the required time. Some of them may also wake up the device from sleep. Others may opt to run only when certain conditions meet, like battery fully charged, internet available etc. Once started, the apps may opt to hold Wake Lock and start a Foreground Service to run a long running task.
Apps like messengers and social media apps need to show notifications in realtime as soon as something new happens on the other side. So these apps use Google's Cloud Messaging (part of Google Play Services) to receive data from internet even when the device is sleeping or the apps are not running in foreground.
To get a list of such apps, you can use PermissionManagerX. Tap Exclusion Filters -> Disable Filters and on main screen type c2dm.permission.RECEIVE
in the top search bar:
Some apps are interested in certain events which occur on device e.g. when the device starts, or when the user changes the device language etc. A complete list of such events can be found here. So the apps register a Broadcast Receiver with the operating system. And whenever the requested event occurs, Android (starts and) notifies the app.
Related: