In my app, I use a service to communicate with our server. The Service spawns several message queue threads to deal with tasks with different priorities.
This model has been used for about one year without big issues. However, recently, I found some time the onCreate
of my service class are called multiple times. onDestroy
is never called between two onCreate
calls. Therefore, I did not get chance to kill existing threads. Once this behavior happens, the service has duplicate threads inside.
The only thing I have changed is to run the service as foreground service is a user signs in the app. I am wondering whether foreground service cause the problem.
Any ideas?
stopSelf()
service then after automatically callonCreate()
multiple time callonCreate()
method – Colic