Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android位置:PendingEvent与LocationListener_Android_Service_Location_Android Pendingintent_Locationlistener - Fatal编程技术网

Android位置:PendingEvent与LocationListener

Android位置:PendingEvent与LocationListener,android,service,location,android-pendingintent,locationlistener,Android,Service,Location,Android Pendingintent,Locationlistener,我不知道什么时候应该使用PendingEvent和LocationListener来获取位置。如果我有一个始终保持活动状态的服务,那么使用LocationListeners可以吗 如果需要位置更新的组件只在组件存在时需要更新,比如说,一个活动,我会使用 位置侦听器方法 如果组件特别需要位置更新,则不会 比如说,一个意向服务,我会用吊挂帐篷。你 在这种情况下无法使用LocationListener,因为中没有任何内容 要侦听位置的内存 来源:我看到了这一点,我在服务中调用Looper.loop()

我不知道什么时候应该使用PendingEvent和LocationListener来获取位置。如果我有一个始终保持活动状态的服务,那么使用LocationListeners可以吗

如果需要位置更新的组件只在组件存在时需要更新,比如说,一个活动,我会使用 位置侦听器方法

如果组件特别需要位置更新,则不会 比如说,一个意向服务,我会用吊挂帐篷。你 在这种情况下无法使用LocationListener,因为中没有任何内容 要侦听位置的内存


来源:

我看到了这一点,我在服务中调用Looper.loop(),所以它应该仍然在内存中。我正在寻找使用其中一个的其他原因。