[英]how to get current location using location services turned off
I use the following code to get Current Location from a Network provider turn off in my application: 我使用以下代码从应用程序中关闭网络提供商的“当前位置”:
LocationManager mgr = (LocationManager) getSystemService(LOCATION_SERVICE);
boolean network_enabled = mgr.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if(network_enabled){
Location location = mgr.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
This is expected from a Network provider. 可以从网络提供商处获得。 But the problem is: when location services turn on its return true and finally get current location.
但是问题是:当定位服务开启时,返回true并最终获得当前位置。 Suppose I turn off return false and get values 0.0,0.0.
假设我关闭return false并获得值0.0,0.0。
If any other way to get current location using network provider when location service turn off? 定位服务关闭时,是否还有其他方法可以使用网络提供商获取当前位置?
Use Fused Location API of Google. 使用Google的融合位置API。
https://developers.google.com/location-context/fused-location-provider/ https://developers.google.com/location-context/fused-location-provider/
It is more convenient. 比较方便。 It provide last known location.
它提供了最后的已知位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.