An AsyncTask would make this clearer.