废话少说,先总结:
1. Service 默认是在主线程(UI线程)运行的。
2. IntentService可以为我们开启一个独立的线程来工作。
注:IntentService必须开启一个无参的构造方法。
流程:构造方法--->onCreate---->onStartCommand--->onHandlerIntent--->onDestory;
3. 从onStartCommand方法中传数据到onHandlerIntent中排队执行。执行完之后,自动调用onDestory方法。
Demo下载地址:http://download.csdn.net/detail/wenquan125/7431333
参考:http://rainbow702.iteye.com/blog/1143286