What is an ANR? What causes them and how can they be avoided?

ANR refers to Android’s infamous Application Not Responding dialog that apps can trigger when they spend too much time computing on the main thread.

Examples of tasks that can cause ANR’s include:

  • Uploading/loading data to/from the cloud
  • Saving/loading cached data to/from disk
  • Sorting, filtering and searching data

Worker threads offload long running task from UI thread.