這兩天發現我們的應用在Android Market 上,有的手機搜尋不到,原因是:
此應用只適用於具備相應功能的裝置
然後後面列出了許多硬體裝置的uses-feature
問題的原因是我們的應用中需要的許可權太多,導致沒有定義中提到的許可權的裝置無法搜尋到我們的應用。
經調查:我們的應用中並沒有使用到uses-feature標籤,那為什麼給出的提示會是“此應用只適用於具備相應功能的裝置”呢?
後來查了一下原因,在我們使用permission的時候,在需要某些硬體許可權的時候,其實已經隱含使用了uses-feature。
如下表:
Category |
This Permission... |
Implies This Feature Requirement |
Bluetooth |
BLUETOOTH |
android.hardware.bluetooth (See Special handling for Bluetooth feature for details.) |
BLUETOOTH_ADMIN |
android.hardware.bluetooth |
Camera |
CAMERA |
android.hardware.camera and
android.hardware.camera.autofocus |
Location |
ACCESS_MOCK_LOCATION |
android.hardware.location |
ACCESS_LOCATION_EXTRA_COMMANDS |
android.hardware.location |
INSTALL_LOCATION_PROVIDER |
android.hardware.location |
ACCESS_COARSE_LOCATION |
android.hardware.location.network and
android.hardware.location |
ACCESS_FINE_LOCATION |
android.hardware.location.gps and
android.hardware.location |
Microphone |
RECORD_AUDIO |
android.hardware.microphone |
Telephony |
CALL_PHONE |
android.hardware.telephony |
CALL_PRIVILEGED |
android.hardware.telephony |
MODIFY_PHONE_STATE |
android.hardware.telephony |
PROCESS_OUTGOING_CALLS |
android.hardware.telephony |
READ_SMS |
android.hardware.telephony |
RECEIVE_SMS |
android.hardware.telephony |
RECEIVE_MMS |
android.hardware.telephony |
RECEIVE_WAP_PUSH |
android.hardware.telephony |
SEND_SMS |
android.hardware.telephony |
WRITE_APN_SETTINGS |
android.hardware.telephony |
WRITE_SMS |
android.hardware.telephony |
Wifi |
ACCESS_WIFI_STATE |
android.hardware.wifi |
CHANGE_WIFI_STATE |
android.hardware.wifi |
CHANGE_WIFI_MULTICAST_STATE |
android.hardware.wifi |
這時我們又做了一下調查
我們的應用中有這樣一個feature,查看文檔後
- android.hardware.touchscreen
注釋為:
- applications require the android.hardware.touchscreen feature by default
可以修改:
- <uses-feature android:name="android.hardware.touchscreen" android:required="false" />
這樣我們就找到了問題的解決方案,即
- <uses-feature android:name="string" android:required="false" />
這樣就不會要求裝置必須具有該硬體裝置,這樣我們的應用程式就可以被更多的手機適配了。
本文出自 “雨軒印象” 部落格,請務必保留此出處http://zilla.blog.51cto.com/3095640/799727