=============== Problem description ====================
Because the mobile phone needs to regularly send data to the server, a new thread is added in the activity, and the thread regularly sends data. Therefore, I would like to ask a question. If the activity is overwritten by other programs, that is, when the activity is in the Stop State, will the thread still work?
============= Solution 1 ======================
Of course, services are used. If a component-based service is bound, the corresponding services will be recycled after the corresponding components are recycled. Therefore, you can call the service method to start a service. That is to say, do not bind a component to the service area. The component is only used to enable the Service, so that the system will not recycle it, unless the system forcibly recycles them, or explicitly calls the stopself () function.
============= Solution 2 ======================
The thread will die unless the process of the thread is dead. Your app exits, and the thread may still be running.
============= Solution 3 ======================
We recommend using service. Why thread?
============= Solution 4 ======================
The process does not die. The thread can exist.
Activity and thread Lifecycle