background preloader

Async

Facebook Twitter

RxJava and Android: error handling. This is a follow-up to a post titled Using RxJava with Android.

RxJava and Android: error handling

If you’re not familiar with RxJava, I recommend reading it before you continue. If you’re working with async processes, transparent error handling is a must for adequate user experience. Using RxJava with Android. If you’re into Android (and Java) development, there is a good chance you’ve already heard about RxJava, which is a Java implementation of Reactive Extensions developed by Netflix.

Using RxJava with Android

Reactive Extensions is a library to compose asynchronous and event-based programs using observable collections and LINQ-style query operators, quoted from the corresponding MSDN site. Netflix made the library available for the public on Github, supporting Java 6 or newer, making it available to use with Android apps as well. This post is the first in a series about RxJava and Android. It is a tutorial, which will show you how to build a REST API client in Android with RxJava observables (and based on Square’s Retrofit).

Let’s start the example with adding the required libraries to your project. Using AsyncTask with progress dialogs and device rotation. Android AsyncTasks during a screen rotation, Part I. During development of the Android Recipe Distiller app, I ran into a subtle issue around the usage of the AsyncTask class.

Android AsyncTasks during a screen rotation, Part I

It ended up being a little trickier than I thought it would be to perform the relatively mundane task of bringing up a progress dialog and making a webservice call in the background. This first part goes over some of the suggested solutions and the next post will go over what I ended up implementing. My initial implementation started with the AsyncTask as an inner class of the Activity.

A progress dialog was created in onPreExecute, the web service call made in doInBackground, and then the dialog was dismissed in onPostExecute. This was all well and good until you tried rotating the screen at which point the app would crash.