Since applications still work in the background. I assume that you are really asking how you are doing applications in the background. The solution below will make your application run in the background after opening the application and after rebooting the system.
Below Ive added a link to a fully working example (in the form of an Android Studio project).
This question seems to go beyond the scope of Android docs, and there seems to be no comprehensive document for this. The information applies to several documents.
The following documents indirectly indicate how to do this: https://developer.android.com/reference/android/app/Service.html
https://developer.android.com/reference/android/content/BroadcastReceiver.html
https://developer.android.com/guide/components/bound-services.html
In order to properly use your usage requirements, an important part of this above document is carefully read: #Binder, #Messenger and components:
https://developer.android.com/guide/components/aidl.html
Here is a link to a fully working example (in Android Studio format): http://developersfound.com/BackgroundServiceDemo.zip
This project will start an action that is associated with the service; implementations of AIDL.
This project is also useful for redefinition for IPC purposes in different applications.
This project is also designed to automatically start when you restart Android (provided that the application was launched at least one after installation, and the application is not installed on the SD card).
When this application / project starts after a reboot, it dynamically uses a transparent view so that it looks as if no application was starting, but the linked application service starts cleanly.
This code is written in such a way that it is very easy to configure to simulate a scheduled service.
This project was developed in accordance with the above documents and subsequently is a clean solution.
However, there is part of this project that is not clean: I did not find a way to start the service on reboot without using Activity. If any of you guys reading this post have a clean way to do this, write a comment.