Using Google Maps location without Activity(在没有活动的情况下使用 Google 地图位置)
问题描述
我有一项服务,它通过注册 LocationManager.requestLocationUpdates
来接收位置.但是有些手机出现了一些问题.
I have a service which receives locations through registering a LocationManager.requestLocationUpdates
.
But there have been some issues on some phones.
当电池电量不足时,网络位置提供程序会停止发送位置修复(此问题已在 这个 SO 问题).这不仅是我的应用程序的问题,而且其他应用程序也只是停止接收位置.即使手机已充电,问题仍然存在,直到完全重新启动.
When battery runs low, the network location provider stops sending location fixes (this problem is addressed in this SO question). It's not a only a problem with my app but also the other apps just stop receiving locations. Even when the phone is recharged the problem persists until the full reboot.
但是,我发现(并且有人在上面的 SO 问题中也提到过)Google 地图仍然不断接收位置更新 - 当我打开 Google 地图应用时,它会显示正确的位置和更新.
However, I found out (and someone also mentioned it in the SO question above) that Google Maps still keeps receiving location updates - when I open Google Maps app it shows the correct location and updates.
所以我正在考虑使用 Google Maps API 中的位置的解决方法.我完全没有使用 Maps API 的经验,但它似乎需要一个适当的 GUI (Activity) 应用程序才能使用.还是我错了?是否有可能使用 Google Maps API 甚至在服务内接收位置?
So I was thinking about a workaround of using locations from Google Maps API. I have absolutely no experience with the Maps API, but it seems that it needs a proper GUI (Activity) application to be used with. Or am I wrong? Is there a possibility to use Google Maps API to receive locations even within the Service?
推荐答案
鉴于可靠来源的一些广泛测试,我相信您可能需要考虑使用 Google Play 服务提供的 FusedLocationProvider.选择合适的功率标准等似乎让您头疼.
Given some extensive testing from a reliable source, I believe that you might want to consider using the FusedLocationProvider supplied with Google Play Services. It seems to take the headache out of choosing the appropriate power criteria and so on.
请注意,这将要求用户必须在其设备上安装 Google Play,因此 Kindle 等设备将无法使用.它还需要至少 Android 2.2.
Be aware that this will require that the user must have Google Play installed on their device, so Kindles and the like will be out of the picture. It also requires a minimum of Android 2.2.
有关 Google Play 服务提供的定位服务的更多信息,请参阅这里一个>.
Some more information about the location services provided by Google Play Services can be found here.
这篇关于在没有活动的情况下使用 Google 地图位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在没有活动的情况下使用 Google 地图位置
基础教程推荐
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01