問題描述
我正在使用 Fused Location Provider 在我的應用程序.根據 Fused Location Provided 文檔,它使用所有可用資源(例如 Wifi、GPS、手機信號塔等)來優化位置.
I'm using Fused Location Provider for location updates in my app. According to Fused Location Provided documentation, it uses all available resources (e.g. Wifi, GPS, Cell tower, etc..) to optimize location.
但我想知道,有沒有辦法在位置更新接收器中檢測到當前位置更新來自 GPS 提供商或網絡提供商?
But i want to know, is there any way to detect that current location update is from GPS Provider or Network provider, in Location update receiver ?
推薦答案
你可以通過location.getProvider()
從你獲取的位置查看位置提供者.
You can check the location provider by location.getProvider()
from the location you are getting.
無論您使用的是融合位置 api 還是以前的 API,您都將從 locationManager.getLastKnownLocation
或 LocationServices.FusedLocationApi.getLastLocation
獲取位置,并從您可以獲取的位置location.getProvider
Either you are using fused location api or a previous one, you will get the location from locationManager.getLastKnownLocation
or LocationServices.FusedLocationApi.getLastLocation
and from location you can get provider by location.getProvider
這篇關于如何檢測位置提供者?GPS 或網絡提供商的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!