-2

I want to do the alarm type task using rxjava. I'm already using rxjava interval operator but this asks for time interval I don't want to give time interval instead I want to repeat the function daily on 12:00 am.

This is my code for interval-based Rx Observable:

return Observable.interval(delay, TimeUnit.SECONDS).timeInterval()
                .flatMap((Function<Timed<Long>, ObservableSource<CustomTime.TimeTempBuilder>>) longTimed -> getDataManager().getTimeByDate(date));

Purpose: I have a foreground service running daily I have to show the notification at a specific time.

Nouman Ch
  • 4,023
  • 4
  • 29
  • 42

1 Answers1

2

You better not use rx for this. Instead take a look at JobScheduler or WorkManager. In case of use rxjava, your action won't be fired if main thread will be finished by system or user. But WorkManager API provides to you ability to configure a lot of options, including time, which indicated when system should start your job.

  • 1
    dear, I already have mentioned in the question that I'm using foreground service which is running 24/7 without any interruption. going with Rx looks better in my case. – Nouman Ch Aug 29 '18 at 08:07
  • 1
    `which is running 24/7 without any interruption.` what is the guarantee of this? You might need `evernote/android-job` or using AlarmManager manually. – EpicPandaForce Aug 29 '18 at 08:34
  • @EpicPandaForce there is no need in evernote/android-job, because of WorkManager is a standalone library – Bohdan Varchenko Aug 29 '18 at 10:07
  • @NoumanCh checkout this https://stackoverflow.com/questions/43048010/how-to-test-doze-mode-on-android – Bohdan Varchenko Aug 29 '18 at 10:08