in a single threaded environment • Long-running operations “block” the UI thread, causing lag / frustration / swearing • As of API 11, Android won’t allow networking operations on the UI thread
can be sent in message data bundle or as Intent extra • Custom objects must implement Serializeable or Parcelable interfaces to be sent • http://www.parcelabler.com/ to generate code
ResultReceiver or an event bus to send data to UI thread • Event Bus uses publisher/subscriber model, deliver events on bus to all subscribers • Popular event buses include EventBus (greenrobot) or Otto (Square)
into a Java interface and a series of async method calls • Built on top of OkHttp (Java networking) and Okio (java.io replacement) • http://square.github.io/retrofit/
void getPlayerList(@Path("id") int teamId, Callback<List<Player>> callback); } • Handle method callbacks SportsApiClient.getInstance().getPlayerList(teamId, new Callback<List<Player>>() { @Override public void success(List<Player> players, Response response) { // called on main thread, update UI... } @Override public void failure(RetrofitError error) { // uh oh, there was a problem... } });