在Service中onStartCommand(Intent intent, int flags, int startId)這三個參數的含義分別是,intent就是startService(Intent intent)中的intent;flags表明flags表示啓動服務的方式: 異步
Additional data about this start request. Currently either 0, START_FLAG_REDELIVERY, or START_FLAG_RETRY. this
START_FLAG_REDELIVERY: 若是你實現onStartCommand()來安排異步工做或者在另外一個線程中工做, 那麼你可能須要使用START_FLAG_REDELIVERY來 讓系統從新發送一個intent。這樣若是你的服務在處理它的時候被Kill掉, Intent不會丟失. 線程
START_FLAG_RETRY:表示服務以前被設爲START_STICKY,則會被傳入這個標記。 startId的值爲對這個service請求的activity或者其餘實體的編號,惟一。it