問題描述
我有一項服務,它通過注冊 LocationManager.requestLocationUpdates
來接收位置.但是有些手機出現了一些問題.
I have a service which receives locations through registering a LocationManager.requestLocationUpdates
.
But there have been some issues on some phones.
當電池電量不足時,網絡位置提供程序會停止發(fā)送位置修復(此問題已在 這個 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.
但是,我發(fā)現(并且有人在上面的 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模板網!