【问题标题】:Location: GPS/network permissions: wanted if available位置:GPS/网络权限:如果可用,需要
【发布时间】:2012-07-12 12:32:17
【问题描述】:

我希望我的应用程序能够访问 GPS/网络位置(如果它们可用)。 我不希望 Google Play 过滤掉没有 GPS/网络定位器的设备。

我应该怎么做?

目前我的清单上有这个:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-feature android:name="android.hardware.location" android:required="false" />

但是,我不确定这是否足够,因为http://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions-features 声明:

-permission ACCESS_COARSE_LOCATION 暗示 android.hardware.location.networkandroid.hardware.location 功能要求

-permission *ACCESS_FINE_LOCATION 暗示 android.hardware.location.gpsandroid.hardware.location

我是否也必须添加 &lt;uses-feature android:name="android.hardware.location.network" android:required="false" /&gt;&lt;uses-feature android:name="android.hardware.location.gps" android:required="false" /&gt; ?

为什么?

&lt;uses-feature android:name="android.hardware.location" android:required="false" /&gt; 还不够吗?

【问题讨论】:

  • 它明确地说并强调了“和”,所以我认为你需要把所有的使用特征都写进去。

标签: android android-permissions


【解决方案1】:

是的,由于权限在 API 中的存储方式,您必须将它们全部包含在内。它们作为字符串存储在PackageManager class 中。以您关心的android.hardware.location 为例。看看字符串与您在清单中键入的内容完全相同。 Google Play 在过滤时会查找这些完全匹配的内容。所以android.hardware.location.gps 实际上并不是android.hardware.location 的子代,只是为了组织而这样表示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-10-07
    • 2014-12-24
    • 2016-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-29
    • 2013-12-11
    相关资源
    最近更新 更多