Implement an AsyncTask, the notorious wholesome API for background processing and returning values from the background.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/35154431-android-background-processing/lessons/24