S
S
Sarclin2017-03-24 19:55:54
Java
Sarclin, 2017-03-24 19:55:54

How to start AlarmManager from foreground service?

I am writing an application in which the service constantly works in the background. There is an activity, but it is assumed that the user closes it for a long time. The essence of the problem: at some time, information comes from the server, which is processed by the background service. Having processed, it is necessary with the help of AlarmManager'a to put the task to be executed after some time. For example, an hour later, display an alert. I can't figure out how to do this, please help. I've known android for a week.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Grichenko, 2017-03-24
@Sarclin

The AlarmManager can just be a local variable. You only need it to "start" the alarm clock.

AlarmManager am = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
...

Further you work with it equally in any place.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question