實現思路
- thread + handler
- 暴露唯一接口onHandleIntent給子類實現
- 消息隊列保證任務的順序性
- 巧妙的自動退出機制,其關鍵點
stopSelf(int startId), Stop the service if the most recent time it was started was <var>startId</var>.
onStartCommand(Intent intent, int flags, int startId), startId is A unique integer representing this specific request to start. Use with {@link #stopSelfResult(int)}.