Detect Service is running

canalrun

Well-Known Member
Licensed User
Longtime User
Hello,
I have an app where the user can optionally start a service that performs a check every 15 min. or so. After the first check the service uses StartServiceAt to wait for 15 min. then perform another check.

The user can exit the app leaving the service running.

Later when the user reenters the app I would like to check if the service is "running". The service may be actively performing its check or it may be waiting for 15 min. to perform the next check or and may not be running at all.

Is there a way I can check if the service is "running" – has been started and will periodically perform its check?

Thanks,
Barry.
 

Ohanian

Active Member
Licensed User
Longtime User
Hello,
I have an app where the user can optionally start a service that performs a check every 15 min. or so. After the first check the service uses StartServiceAt to wait for 15 min. then perform another check.

The user can exit the app leaving the service running.

Later when the user reenters the app I would like to check if the service is "running". The service may be actively performing its check or it may be waiting for 15 min. to perform the next check or and may not be running at all.

Is there a way I can check if the service is "running" – has been started and will periodically perform its check?

Thanks,
Barry.

Hi,

Here
 
Upvote 0

canalrun

Well-Known Member
Licensed User
Longtime User

Thanks,
I wrote a little test app to convince myself of the interaction between the Main Activity, a service, and IsPaused. I have attached that To this post.

I come from Windows – so I get the way things operate between Windows and Android confused.

If you run the app try playing around with looking at the output before the service is started, start the service and observe the output and the fact that SvcCntr continues to increment from its previous count if the app is paused using the Android Back button or closed using the Android Home button.

Forcing the application to Stop within Settings/Apps will also kill the service.

Everything seems to work as advertised and as expected.

Barry.
 

Attachments

  • SvcTst.zip
    141.9 KB · Views: 321
Upvote 0
Top