Skip to content

Commit

Permalink
Update AbsWorkService.java
Browse files Browse the repository at this point in the history
  • Loading branch information
ShihooWang authored Mar 6, 2019
1 parent 185a253 commit f2c7841
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ protected int onStart(Intent intent, int flags, int startId) {

//业务逻辑: 实际使用时,根据需求,将这里更改为自定义的条件,判定服务应当启动还是停止 (任务是否需要运行)
if (shouldStopService) {
stopService(intent, flags, startId);
// 此处不比重复关闭服务。否则mConnection.mConnectedState的状态没有来得及改变,
// 再次unbindService(conn)服务会导致 Service not registered 异常抛出。 服务启动和关闭都需要耗时,段时间内不宜频繁开启和关闭。
// stopService(intent, flags, startId);
} else {
startService(intent, flags, startId);
}
Expand Down

0 comments on commit f2c7841

Please sign in to comment.