位置: GPS/网络权限:如果可用则需要。

10

我希望我的应用程序可以访问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中指出:

- 权限ACCESS_COARSE_LOCATION意味着需要 android.hardware.location.networkandroid.hardware.location功能

- 权限ACCESS_FINE_LOCATION意味着需要 android.hardware.location.gpsandroid.hardware.location

我是否还需要添加以下内容: <uses-feature android:name="android.hardware.location.network" android:required="false" /><uses-feature android:name="android.hardware.location.gps" android:required="false" /> ?

为什么?

<uses-feature android:name="android.hardware.location" android:required="false" />不应该已经足够了吗?


它明确说明并强调了“和”,因此我认为您需要列出所有用途功能。 - Alex Curran
1个回答

3
是的,你必须全部包含这些权限,因为API中的权限存储方式。它们以字符串形式存储在PackageManager类中。以你关心的一个为例,android.hardware.location。看看这个字符串与你在清单中输入的内容完全相同。当过滤器匹配时,Google Play会寻找这些确切的匹配项。所以android.hardware.location.gps实际上不是android.hardware.location的子级,它只是为了组织而表现出来的。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接