Hello there, is there a way in unity (Android) to have some code running on the background while you are not using the game?
Yes, you should create a native android Service that keeping running even after unity app was closed.
Not very easy. Interact with native code is not fun, and because the service will not access unity code after app get closed, you should move a lot of your game logic to java code or create a dll library where both unity and java code access.
And remember, background apps are the most undesired stuff for most of users