Android service lifecycle
I implemented a foreground service with notification for my application (music player) on Android. Everything works fine. I made a custom notification with buttons which can control music playback and it still continues even if I kill the main application. I can start/show it again by clicking the notification. The connection between the main program and the service is done using RemoteServices.
But after some time, the connection between my app and the service is lost. Even worse it seems that the service has a Java and C++ part which behave independently. So sometimes it happens that the C++ part closes but I can still see the notification.
I somehow need to control the life cycles of these components. What would be the best practice to do it?