标签: android android-intent android-location android-pendingintent
假设我有一个app,并且在其活动中,我将注册pendingIntent并LocationManager每10分钟触发一次。
app
pendingIntent
LocationManager
就像在这个例子中: Android: How to get location information from intent bundle extras when using LocationManager.requestLocationUpdates()
如果用户关闭app,LocationManager仍然会继续pendingIntent吗?
这样,当我的应用未运行时,我可以从我的应用的BroadcastReciver(清单版本)调用此pendingIntent的通知。
BroadcastReciver
如果是,那么当实际清理了LocationManager后,手机重启后?
答案 0 :(得分:0)
如果您希望在应用退出后获得可靠的位置更新,请考虑使用AlarmManager(example)每10分钟唤醒一次设备。每次警报触发时注册并取消注册您的位置监听器,以便GPS可以在其他方式闲置。
AlarmManager
您可能还想使用WakefulIntentService之类的内容(请参阅here),以便在您的应用等待位置更新时设备保持唤醒状态。 Android会中断BroadcastReceiver的{{1}}方法,如果花费的时间太长且未持有onReceive()。
WakefulIntentService
BroadcastReceiver
onReceive()