Subscribe Free

Join 2670+ others. No spamming.
I promise!

We are currently under high development. Follow us at github.

Looking for Python Tutorials?
Check these awesome tutorials



ReactiveX / RxAndroid


RxJava bindings for Android


RxAndroid: Reactive Extensions for Android

Android specific bindings for RxJava.

This module adds the minimum classes to RxJava that make writing reactive components in Android applications easy and hassle-free. More specifically, it provides a Scheduler that schedules on the main UI thread or any given Handler.


Since RxAndroid is part of the RxJava family the communication channels are similar:


compile 'io.reactivex:rxandroid:1.0.1'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
compile 'io.reactivex:rxjava:1.0.15'
  • RxAndroid:
  • RxJava:

Additional binaries and dependency information for can be found at


To build:

$ git clone
$ cd RxAndroid/
$ ./gradlew build

Futher details on building can be found on the RxJava Getting Started page of the wiki.

Sample usage

A sample project which provides runnable code examples that demonstrate uses of the classes in this project is available in the sample-app/ folder.

Observing on the UI thread

One of the most common operations when dealing with asynchronous tasks on Android is to observe the task's result or outcome on the main UI thread. Using vanilla Android, this would typically be accomplished with an AsyncTask. With RxJava instead you would declare your Observable to be observed on the main thread:

public class ReactiveFragment extends Fragment {
    public void onCreate(Bundle savedInstanceState) {
        Observable.just("one", "two", "three", "four", "five")
                .subscribe(/* an Observer */);

This will execute the Observable on a new thread, and emit results through onNext on the main UI thread.

Observing on arbitrary threads

The previous sample is merely a specialization of a more general concept, namely binding asynchronous communication to an Android message loop using the Handler class. In order to observe an Observable on an arbitrary thread, create a Handler bound to that thread and use the HandlerScheduler.from scheduler:

new Thread(new Runnable() {
    public void run() {
        final Handler handler = new Handler(); // bound to this thread
        Observable.just("one", "two", "three", "four", "five")
                .subscribe(/* an Observer */)

        // perform work, ...
}, "custom-thread-1").start();

This will execute the Observable on a new thread and emit results through onNext on "custom-thread-1". (This example is contrived since you could as well call observeOn(Schedulers.currentThread()) but it shall suffice to illustrate the idea.)

Bugs and Feedback

For bugs, feature requests, and discussion please use Github Issues. For general usage questions please use the mailing list or StackOverflow.


Copyright 2015 The RxAndroid authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.