我有一项服务,它通过注册 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 地图位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!