General topic questions
ANRs and main thread
EasyMost asked
Free section · general topics & algorithms
What causes ANRs, and how do you diagnose them?
Reveal model answer
ANRs happen when the main thread is blocked (~5s for input). Avoid disk/network on Main; use coroutines. Diagnose with ANR traces, StrictMode, and Systrace/Perfetto. Mention BroadcastReceiver and Service timeouts too.