2012-07-12 47 views
9

我希望我的應用程序訪問GPS /網絡位置,如果它們是可用的。 我不希望Google Play過濾掉沒有GPS /網絡定位器的設備。位置: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功能要求

- 許可* 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" />夠了嗎?

+0

它明確地說和強調「和」,所以我認爲你需要把所有的使用功能。 – 2012-07-12 17:34:21

回答

3

是的,您必須將它們全部包含在內,因爲權限存儲在API中。它們作爲字符串存儲在PackageManager class中。以你擔心的爲例,android.hardware.location。看看它是如何與你在Manifest中輸入的完全一樣的。 Google Play在過濾時會查找這些完全匹配的內容。所以android.hardware.location.gps實際上並不是android.hardware.location的孩子,它只是爲了組織而表現出來。