In Android, I have an application with various actions and services. These actions are intended for direct interaction with the user, in which the user can change data, update data, enter data, whatever.
The application also has a (background) service, using data entered by the user (stock data). A regular service checks stock prices (for example, every 12 hours) and gives the user a notification if some conditions match.
However, as a user, I want to be able to change the settings for this service. I run the application and can enter the update interval in one of the applications that is stored in SharedPreference. I can change the value, for example, so that the service checks the stock data every 3 hours.
Should I restart the service? Since I understand the βservicesβ in the operating system, the service starts until it stops by an event. But if the service is not stopped, the service will not βnoticeβ that the update interval has changed! Thus, in my activity from my main application, I need a way to "restart" the service, so it checks stock prices for 3 hours, not 12 hours!
Any idea how to do this? A google search really didn't help. Maybe I was looking for the wrong keywords ...?
source
share