Reputation: 12222
when I use Thread.sleep()
for the delay in my app I get crash InterruptedException
.
I have to use Thread.sleep()
because I send Command to hardware and need to get data after 1 second.
can I use RX java for this problem? or other ways?
Upvotes: 1
Views: 876
Reputation: 4502
Yes you can replace Thread.sleep()
in RX java using delay
in Observable. Here how to do it:
Observable.delay(5000, TimeUnit.MILLISECONDS)
using interval
will do thing infinite time at the interval
of provided time.
Upvotes: 2
Reputation: 15423
Use interval
in RxJava
Observable.interval(1, TimeUnit.SECONDS)
Upvotes: 1