WHAT IS AN ANR? WHICH STRATEGIES CAN YOU USE TO AVOID IT?

Asked 23-Jan-2018
Viewed 633 times

0

WHAT IS AN ANR? WHICH STRATEGIES CAN YOU USE TO AVOID IT?


1 Answer


0

ANR (Application Not Responding)
An ANR (Application Not Responding) happens when some long operation takes more time in the "main" thread. To prevent from ANR you have to make long task on other threads.
WHAT IS AN ANR? WHICH STRATEGIES CAN YOU USE TO AVOID IT?
In our android app when UI threads are blocked for long duration of times then ANR (Application Not Responding) event is triggered. If your app is in the foreground state and any process is running for long duration of times then the system internally display a dialog to the user. The ANR dialog boxes give the message to the user to facially quit the app.
WHAT IS AN ANR? WHICH STRATEGIES CAN YOU USE TO AVOID IT?

When our UI component are updated on the main thread and process the user inputs, then causing frustration to the user in this case ANR create a problem.

Strategies to avoid ANR
When main thread is block while waiting for the child thread to complete our task then that cases you can’t call Thread.wait() or Thread.sleep() method for avoiding ANR. Instead of when child thread are blocked then main thread provide a handler for child threads to post back our competition.