O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Toast notification

Showing a simple Toast notification is a much less involved process than handling state screens. Toast notification provides a very quick and snappy way of informing a user about certain events in the system.

We will use Toast notification to notify a user that the data couldn't be loaded from the Internet, but we will fall back to the saved data that's in the database--the offline mode.

Let's take a look at how that can be incorporated in the current flow:

Observable.interval(0, 5, TimeUnit.SECONDS)        .flatMap(                i -> Observable.<YahooStockResult>error(new RuntimeException("Oops"))        )        .subscribeOn(Schedulers.io())        .observeOn(AndroidSchedulers.mainThread())        .doOnError(error -> {            log("doOnError", "error");            Toast.makeText(this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required