Link to home
Start Free TrialLog in
Avatar of Jorge Paulino
Jorge PaulinoFlag for Portugal

asked on

Get running Intent Service

Hi,

I'm creating an android application that will do a task in a specific time (defined by the user). For this I'm using an Intent Service.

The the problem is if the user closes the application (example: using back button) then I cannot get the the running service to shutdown it, to read information from it (to update my activity when the application opens), etc.

Is this the better approach?

Is there any way to get the running service (intent service)?

Thanks
jpaulino
Avatar of girionis
girionis
Flag of Greece image

When the user closes your activity the onStop() method of the activity is called (or the onPause(), depending on what made the activity stop). So you could implement your code in one of these two methods.
Avatar of Jorge Paulino

ASKER

Thanks for the reply.

But the second time the user presses the back button it destroys the activity and the next time it opens, it starts  a new instance.

What I want to achieve is to check if the service is already running. If not, then start a new one, if it's running, then get the state of the timer, selected options, etc, and event shutdown the service (if the user wants it).
ASKER CERTIFIED SOLUTION
Avatar of girionis
girionis
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial