[英]How can you get a location in android when all location providers are disabled?
LocationManager has a method, getlastknownlocation. LocationManager有一个方法getlastknownlocation。 From the documentation this method: "Returns a Location indicating the data from the last known location fix obtained from the given provider. This can be done without starting the provider "
从文档中,此方法:“返回一个位置,该位置指示从给定提供程序获得的最新已知位置修复程序中的数据。 这可以在不启动提供程序的情况下完成 ”
However this method only returns a location if the provider is currently enabled. 但是,如果当前启用了提供程序,则此方法仅返回位置。
I'm a little confused by this, if this method can get a cached location without starting the provider, why would it only return a location if the provider is currently enabled? 我对此感到有些困惑,如果此方法可以在不启动提供程序的情况下获取缓存的位置,为什么仅在当前启用了提供程序的情况下才返回位置?
How can I guarantee a location, however inaccurate and outdated it may be, even if all providers are disabled? 即使所有提供商都被禁用,我如何保证一个位置,无论它有多准确和过时?
You can't. 你不能 If the user hasn't got any location providers enabled, you can't deliver a location.
如果用户未启用任何位置提供程序,则无法传递位置。 If the user hasn't enabled GPS and the user has no Internet connection, you can't get a network-based location (network-based location requires assistance from the server).
如果用户尚未启用GPS且用户没有Internet连接,则无法获得基于网络的位置(基于网络的位置需要服务器的协助)。
Sometimes you just can't tell the user where he is (or was). 有时您只是无法告诉用户他(或曾经)在哪里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.