I am new to Android and making my first real app and it uses the socket.io
Java Client for communicating with my Node.JS
server instance. I have recently discovered while testing that the OS can kill background apps whenever it feels necessary calling onSaveInstanceState()
on the active Activity
then when you switch back to the app it recreates the previous state using the Bundle
passed as an argument in the onCreate()
method.
So now that I know that, I need to implement a solution that would keep the app working as it should so I expect I will have to test a few solutions before I get the right one. And since it would be so time-consuming to just lock my screen and watch the server logs waiting for the
User disconnected
(which can take a lot of time for each try), I wondered if anyone here ever was in the same situation and figured a way to make the OS kill the app as soon as I lock the screen or hit the Volume Down button or something like that.