Rxjava: rxjava2[2.1.8] delay Operation invalid when Turn off the screen for a while

Created on 30 Jul 2018  Â·  5Comments  Â·  Source: ReactiveX/RxJava

I used rxjava2[2.1.8] delay Operation in my Foreground Service 。Normal use ok, but when Turn off the screen for a while ,delay Operation cannot work,but the takeUntil Operation can use to cancel the invalid delay。my code:

  Observable.just(1).delay(downtime, TimeUnit.SECONDS)
            .doOnDispose({
                //valid all the time

            })
            .takeUntil(observable)
            .subscribe({
                request()
            })
2.x Android Question

All 5 comments

RxJava doesn't have any Android specific integration. If your code is not working in some tricky Android OS situations it usually means that you are doing something wrong with Android Sdk integration. In your case it could be one of the following:

  1. Your service is not ready for sporadic restarts from OS
  2. Your service doesn't aquire wake lock
  3. Consider using JobDcheduler to schedule some work instead of doing it with RxJava. JobScheduler will execute work even if your service/app is killed

RxAndroid

RxAndroid provides Android specific schedulers but have no effect on operators

Please ask such platform specific questions on StackOverflow.

thanks @TarasMazepa ,I'll refer to your ideas

Was this page helpful?
0 / 5 - 0 ratings