Many of the actions above Android cannot be placed directly on the UI thread. When the UI thread is blocked for more than 5 seconds, the application will have an unresponsive dialog box. When this phenomenon occurs, it will directly affect the user experience. So we need to handle the asynchronous task or operation by means of the method. Here is a list of centralized and related processing methods:
First of all, we should think of using Thread+handler to implement a non-UI thread to update the UI interface, that is, when threads execute by sending a message to process and update the UI through handler. Another way is through the asynchronous task: Asynctask to the data processing, by inheriting Asynctask and rewriting the related methods, the more important is dobackground and Onpostexecutor rewrite. One is responsible for handling transactions, one is responsible for updating the interface.
Basically the first thing we think about is that these two methods are mentioned above, in fact there are two methods, one is through the service, the other is through the intentservice to deal with.
This article is from the "Android Learning Archive" blog, so be sure to keep this source http://renhui.blog.51cto.com/8943504/1536122