在Google Play上釋出過應用的開發者也許都遇到過這種情況。使用者抱怨說,用平闆電腦在Google Play上找不到你的應用,但是用手機上(或者其它的裝置)就可以找到。經過數小時苦苦尋一個合理的解釋,最後還是放棄了。
對,我們必須學會處理這個問題,終于,我找到了答案。
在應用中我們需要獲得一些權限,需要在清單檔案中注冊。但是,注冊了這些權限并不意味着你一定會在應用中使用它們。比如,你的應用可能用到GPS功能或者攝像頭功能,但是有沒有這個功能并不會阻礙使用者使用你的應用。隻需要在代碼中簡單地加上一條判斷語句就可以了,例如下面的代碼:
/** Check if this device has a camera */
private boolean checkCameraHardware(Context context)
{
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA))
{
// this device has a camera
return true;
}
else
// no camera on this device
return false;
}
然後,在AndroidManifest.xml檔案中添加一句話:
<uses-permission android:name="android.permission.CAMERA" />
但是也可能出現其它的情況,你要求的權限可能會影響Google Play的過濾規則。如果你要求一些硬體相關的權限,比如攝像頭,Google Play會認定你的應用需要這個基本的硬體功能,沒有這個功能的裝置就會過濾掉你的應用。
如果你想知道是什麼權限導緻Google Play過濾了你的應用,請看看下面這篇文章:
http://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions-features http://developer.android.com/guide/topics/manifest/uses-feature-element.htmlX7Xpermissions-features
如果你想想自己把握是否過濾,那你最好明确指定需要的硬體特性,使用
<uses-feature>
來聲明,這樣比讓Google Play自己去發現你的應用權限好得多。
<uses-feature
android:name="android.hardware.camera"
android:required="false"/>
android:name="android.hardware.camera.autofocus"
最後在Google Play上更新你的應用,問題就解決了。