Android 位置 : PendingIntent vs. LocationListener

标签 android service location android-pendingintent locationlistener

我很困惑何时应该使用 PendingIntent 和 LocationListener 来获取位置。如果我有一个始终保持 Activity 状态的服务,可以使用 LocationListeners 吗?

最佳答案

If the component needing location updates only needs updates when the component is around -- say, an activity -- I'd use the LocationListener approach.

If the component needing location updates specifically will not be around -- say, an IntentService -- I'd use the PendingIntent. You can't use the LocationListener in this case, since there is nothing in memory to be listening for locations.

来源:When is advised PendingIntent vs. LocationListener on requestLocationUpdates?

关于Android 位置 : PendingIntent vs. LocationListener,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9726457/

相关文章:

java - RadioButton.setChecked() 似乎不起作用

php - 使用 header() 将数据从一个 PHP 页面传递到另一个

python - 根据 WiFi 确定笔记本电脑的位置

android - 如何禁用 TabLayout 的点击效果?

java - 如何在android中调用时隐藏调用的号码

android - 如何在 Android 中完全加载 ImageView 时获取

windows - 如何让 Windows SCM 在失败时重新启动我的服务

android - 需要我的 android 应用程序的设计建议

android - Android : Application or Service for asynchronous updates? 中的 MVC

android - 我还能提高 GPS 精度吗?