Android: Tenth chapter, silent laborer in the background--service, study notes

Source: Internet
Author: User

one, multi-threaded1) This chapter first introduces the multi-threaded programming of Android, which shows that if you want to modify the UI in a child thread, it must be implemented by handler, Message, MessageQueue, Looper, but it is too troublesome after all.2) and then give the Asynctask, by inheriting this class, you can directly modify the UI elements in his, a lot of convenience;
Second, the service1) First give the general method of service, such as Create OnCreate, start Onstartcommand, stop OnStop, destroy ondestroy;2, then explain how activity and service communicate, Here to use a binder and serviceconnection two abstract class, of course, the activity of Bindservice, Unbindservice method, 3) wiring to put forward the concept of front-desk service, this is really a lot of programs are now in use , in fact, the implementation is very simple, is the use of our system in the eighth chapter of the notification notification, and then call Setforeground (XXXX) to achieve; 4) immediately after Intentservice appeared; in fact, the beginning of the author raised a question, Do not be confused by the name of the background service, in fact, the service is running in the main thread, so if you do very time-consuming things in the main thread will be very card, will appear ANR, so we still have to consider the use of real background services, that is intentservice.


Finally, the author gives a complete example, in the example, the author does not use the Intentservice, but uses the Service+asynctask way, I can consider using Intentservice to rewrite This example later.




Android: Tenth chapter, silent laborer in the background--service, study notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.