Can two actions be performed simultaneously?
Not in the sense of what you expect. In Android operations, they are stored on the stack, only the top of the stack is displayed on the screen. While other activities that are not at the top are not necessarily completely βdeadβ, they are not alive enough to do the job for you.
Instead, you should make your server in the service.
source share