How many times has it happened to you that you use some Android application and get the message saying that the application is not responding? Why does this happen? We will explain! Pay attention to these points so you don't have the same thing happening with your application:
- Make sure nothing blocks your input (any intensive operation, especially network traffic).
- Don't perform long tasks on the main application thread.
- Don't perform long running operations in the onReceive() method for your broadcast receivers.
- Make use of the AsyncTask class as much as you can. Consider the use of ThreadPoolExecutor.
- Try using content loaders whenever it's possible.
- Avoid executing too many threads at the same time.
- If writing to filesystem, do it from a separate thread.
If it still happens that you have ANRs, or your application behaves...