Sending message to a Handler on a dead thread when getting a location from an IntentService

后端 未结 3 603
轻奢々
轻奢々 2020-12-01 01:44

My app needs location fixes on regular basis, even when the phone is not awake. To do this, I am using IntentService with the pattern generously provided by Commonsware. htt

3条回答
  •  隐瞒了意图╮
    2020-12-01 02:04

    You cannot safely register listeners from an IntentService, as the IntentService goes away as soon as onHandleIntent() (a.k.a., doWakefulWork()) completes. Instead, you will need to use a regular service, plus handle details like timeouts (e.g., the user is in a basement and cannot get a GPS signal).

提交回复
热议问题