- Home /
Plugin Android service do not call onStartCommand when app is closed
I have an Android plugin that allows to send notifications among other things, using a sticky service, because I need to continue to run the service even if the application is closed.
I tested my service outside of Unity first and everything was working correctly. When closing my test application (by swiping it from the recent apps), I was getting log that my service was created again (passing by onCreate) and started again (passing by onStartCommand ).
When integrating my service in a Android plugin for my Unity project, the first initialization of my service was doing alright. But, when closing the application the same way, the onCreate method was called, but the onStartCommand was never called. Therefore, my service was not running when my Unity app had closed.
I wonder if this behaviour is linked to the fact that the AndroidJavaObject created in my Unity project to start my service was destroy when killing my Unity app or something like that.
If someone has experienced a similar situation, please let me know! Thanks.
Your answer
![](https://koobas.hobune.stream/wayback/20220612042213im_/https://answers.unity.com/themes/thub/images/avi.jpg)