I have a Service which is started from BroadcastReceiver when a new incoming call arrives. In that Service I start a new Thread and do all the work there. What happens if the Main Activity of my app is killed? I'm asking because I realised that in such a situation the Service's startID rises by one! Just like if the Service's onStartCommand() was called again or something like that. I'll give a short example:
Main Activityis running somewhere in the background, incoming call arrives,Servicestarts,stopSelf()is called by the user action,Serviceis destroyed.Main Activityis running, incoming call arrives,Servicestarts,Main Activityis killed by clearing Recent apps list,stopSelf()is called by the user action,Serviceis NOT destroyed becausestartIDs don't match.Main Activityis NOT running (killed by clearing Recent apps list), incoming call arrives,Servicestarts,stopSelf()is called by the user action,Serviceis destroyed.
That is very strange, because startID somehow changes its value when the Main Activity is killed. I use START_NOT_STICKY in my Service's onStartCommand() method so there is no way that Service is recreated with a new startID. Could someone explain this to me? What happens to the Service or the separate Thread where the service is running when Main Activity is killed? Thanks in advance!