I would like to know if the following is possible. I have a foreground service that runs even if the app is killed and it is started with application context. Is it possible to capture static variables inside that application context and keep them alive as long as the service is alive even when the application is killed?
Can you write to a static variable? Sure. But the foreground service itself can eventually be killed, you can't assume it will run forever.