E
E
emigrantdd2014-10-23 19:18:14
Android
emigrantdd, 2014-10-23 19:18:14

How to change or update the service?

I need to change the interval when my service is already running. I thought the startService(intent) method would help change the service time interval, but doesn't work. Saw a similar implementation with Thread when the service is running in 2 threads, but don't know how it works, I can't figure out how to do it, for 3 days I can't find anything.
Here is my main service class that works and the second one where you will need to do the service update time.
I mean that the service is started, that is, the time at which the service is performed and the RepeatingAlarmService class wakes up. I can say simply, this interval is now written in the interval variable in this code below:

alarmManager.setRepeating(
                AlarmManager.ELAPSED_REALTIME_WAKEUP,
                SystemClock.elapsedRealtime() + FIRST_RUN,
                interval,
                pendingIntent);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Marat S, 2014-10-26
@aratj

Well, send an intent to the service.
catch on
public int onStartCommand(Intent intent, int flags, int startId)
kill your old alarm and create a new one with the right time.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question