How to check if a service is running on Android? -


How do I check that the background service is running (on android)?

I want an Android activity that toggles the state of the service - it gives me the power to turn it on if it is closed and closed.

I had only one problem, which was not earlier since my service was local, / P>

To toggle the state described (for the record), the service class has finished using a static field:

Here the hacked The solution proposed by:

If your client and server code are the same. Is a part of APK and you are bound to serve with a strong intention (a right service class specifying), you can simply set your service to a global variable when it is running that your client can check

We do not intentionally examine an API to see if the service is running, because when you are almost unsuccessful, when you want to do something like you end up with race conditions in your code

Comments