Sr. Android Developer Question:
Tell us what is an ANR? What are some measures you can take to avoid ANR?

Answer:
ANR stands for ‘Application Not Responding’. This dialogue is displayed if the main thread in the application has been unresponsive for a long time and in the following conditions:
☛ When there is no response to an input event after 5 seconds.
☛ When a broadcast receiver is not done executing within 10 seconds.
Following measures can be taken to avoid ANR:
► To avoid ANR, an app should perform a lengthy database or networking operations in separate threads.
► One technique is to create a child thread to prevent the Android system from concluding a code that has been unresponsive for a long period of time. Most of the actual workings of the codes can be placed within the child thread to ensure that the main thread runs with minimal unresponsive time.
► For background task-intensive apps, you can alleviate pressure from the UI thread by using the IntentService.
☛ When there is no response to an input event after 5 seconds.
☛ When a broadcast receiver is not done executing within 10 seconds.
Following measures can be taken to avoid ANR:
► To avoid ANR, an app should perform a lengthy database or networking operations in separate threads.
► One technique is to create a child thread to prevent the Android system from concluding a code that has been unresponsive for a long period of time. Most of the actual workings of the codes can be placed within the child thread to ensure that the main thread runs with minimal unresponsive time.
► For background task-intensive apps, you can alleviate pressure from the UI thread by using the IntentService.
Previous Question | Next Question |
Tell me what is APK format? | Explain me what are the features of Android? |