本文介绍了我什么时候需要android.hardware.location.gps和android.hardware.location.network?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌正在通过电子邮件告知Android位置权限的变化:
$ b

我正在使用融合定位提供商,定位API 21,并使用 ACCESS_FINE_LOCATION 。我并不特别关心GPS是否可用,只报告最准确的位置。


  • 根据第一句话,我想我不需要做任何改变。

  • 基于第二个引号,我想我需要 android.hardware.location.gps android .hardware.location.network 。或者这只适用于 LocationManager 而不是融合地点?



我是否需要 android.hardware.location.gps android.hardware.location.network 或不是?第二个引号告诉你,你需要 android.hardware.location.network code>或 android.hardware.location.gps ,如果您特别需要其中一个或其他位置提供商。



如果你想通过GPS更新,你需要 android.hardware.location.gps
如果您想通过WiFi和蜂窝网络进行更新,您需要 android.hardware.location.network



如果您需要网络和GPS更新,则应包含< uses-feature> 元素。



如果您不指定,您的设备可能安装在没有提供商的设备上。例如,它可能安装在没有GPS,蜂窝网络或Wi-Fi芯片的设备上。换句话说,获取位置需要网络位置功能或GPS功能。如果您没有声明您的应用程序需要一个或另一个,您可能根本不会获得位置更新。



API 21 vs 20及以下

strong>



请注意,以上仅适用于API 21及更高版本。
在API 21之前,请求 ACCESS_COARSE_LOCATION 权限意味着 location.network 功能,当请求 ACCESS_FINE_LOCATION 暗示 location.gps 功能(请参阅)。



现在唯一的变化是,对于API 21+,任何请求 ACCESS_FINE_LOCATION 的应用程序即将可用于安装在设备上没有GPS。如果您的应用程序以前认为GPS可用(并且需要GPS),则需要确保您具有 android.hardware.location.gps 的明确请求。



Google表示,网络位置提供商现在已经够好了,因此可以实现更好的位置。


Google is informing by email of changes to the Android location permissions:

From the Android Developers Help Center

I am using the fused location provider, targeting API 21, and using ACCESS_FINE_LOCATION. I don't specifically care whether GPS is available, only that the most accurate location is reported.

  • Based on the first quotation, I think I do not have to make any changes.
  • Based on the second quotation, I think I need both android.hardware.location.gps and android.hardware.location.network. Or is this only for LocationManager and not fused location?

Do I need android.hardware.location.gps and android.hardware.location.network or not?

解决方案

The second quotation is telling you that you need either android.hardware.location.network or android.hardware.location.gps, if you specifically need one or the other location provider.

If you want updates via GPS, you need android.hardware.location.gps.If you want updates via the WiFi and cellular networks, you need android.hardware.location.network.

If you want updates from both the network and GPS, you should include both <uses-feature> elements.

If you don't specify either, your device may be installed on devices without that provider. For example, it may be installed on a device without a GPS, cellular network, or Wi-Fi chip.

In other words, getting location requires either the network location feature or the GPS feature. If you don't declare that your application needs one or the other, you may not get location updates at all.

API 21 vs 20 and below

Note that the above is only true for API 21 and above.Prior to API 21, requesting the ACCESS_COARSE_LOCATION permission implied the location.network feature, wheras requesting ACCESS_FINE_LOCATION implied the location.gps feature (see <uses-feature>).

The only change right now is that, for API 21+, any app requesting ACCESS_FINE_LOCATION will soon be available to install on devices without GPS. If your app previously assumed GPS was available (and needs GPS), you need to make sure you have the explicit request for android.hardware.location.gps.

Google says that network location providers are now good enough for a fine location, thus, the change.

这篇关于我什么时候需要android.hardware.location.gps和android.hardware.location.network?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-18 07:01
查看更多