2011-10-29 113 views
3

我的應用專爲手機設計,但是當我嘗試將應用上傳到市場時,它顯示我的應用對平板電腦(xlarge)也可見。如果從平板電腦訪問,我故意不希望我的應用在市場上展示。如何讓我的Android應用僅適用於手機?

我試着玩minSdkVersion和targetVersion支持和元素。

我也使用

<manifest ... > 
    <compatible-screens> 
     <!-- all small size screens --> 
     <screen android:screenSize="small" android:screenDensity="ldpi" /> 
     <screen android:screenSize="small" android:screenDensity="mdpi" /> 
     <screen android:screenSize="small" android:screenDensity="hdpi" /> 
     <screen android:screenSize="small" android:screenDensity="xhdpi" /> 
     <!-- all normal size screens --> 
     <screen android:screenSize="normal" android:screenDensity="ldpi" /> 
     <screen android:screenSize="normal" android:screenDensity="mdpi" /> 
     <screen android:screenSize="normal" android:screenDensity="hdpi" /> 
     <screen android:screenSize="normal" android:screenDensity="xhdpi" /> 
    </compatible-screens> 
    ... 
    <application ... > 
     ... 
    <application> 
</manifest> 

嘗試,但我得到一個錯誤:

Multiple annotations found at this line:
- error: No resource identifier found for attribute 'screenDensity' in package
'android'
- error: No resource identifier found for attribute 'screenSize' in package
'android'

我缺少什麼?

回答

4

您應該使用market filters來指定您的應用程序確實需要的那些東西。如果設備需要爲手機,請添加<uses-feature android:name="android.hardware.telephony"/>

通過指定兼容屏幕尺寸來過濾平板電腦是沒有意義的。有關硬件功能列表,請參見<uses-feature>。不要僅僅爲了過濾而添加元素,清單應該指定應用程序爲了工作而需要的內容。

+0

考慮到平板電腦沒有電話服務,使用此過濾器將有所幫助。但我的應用程序不需要任何硬件配置就可以運行。我的應用程序非常專門針對手機(從小到大的設備)完成,因此我不希望負面評論,因爲應用程序在平板電腦中無法按預期運行。 – sku

+0

您發佈的XML在這裏工作正常,您的項目構建目標是什麼? – user999717

+0

它是10 ... 被引入9 ... – sku

0

我真的不知道這是否是去了解它的正確方法。但是,我遇到過這種情況,並將其用於我的應用中,以確保平板電腦用戶無法在其設備上訪問此應用。

//verify the android version running on the phone/device 
int currentDeviceVersion = android.os.Build.VERSION.SDK_INT; 

//since tablets would be running HoneyComb or higher 
if (currentDeviceVersion >= android.os.Build.VERSION_CODES.HONEYCOMB){ 
    // display message that app is not supported for android honeycomb and above 
    // End (finish) app 
} 
+0

這可能會在設備下載並安裝應用程序後生效。我需要一些過濾器才能使應用程序對平板電腦隱身。 – sku

+2

不,不要這樣做。像Galaxy Nexus這樣的手機新設備將無法使用您的應用。 – kabuko

+0

@kabuko - +1有效點! – Abhijit

0

通過查看播放控制檯的設備目錄,您需要指定更多的screenDensity值。 (見下文,截至今日)我認爲在設備目錄中總會看到新值出現的風險。所以你應該不斷監測你的應用不支持的設備數量。

<!-- Exclude Tablets --> 
<compatible-screens> 
    <!-- all small size screens --> 
    <screen android:screenSize="small" android:screenDensity="ldpi" /> 
    <screen android:screenSize="small" android:screenDensity="mdpi" /> 
    <screen android:screenSize="small" android:screenDensity="hdpi" /> 
    <screen android:screenSize="small" android:screenDensity="xhdpi" /> 
    <screen android:screenSize="small" android:screenDensity="xxhdpi" /> 
    <screen android:screenSize="small" android:screenDensity="xxxhdpi" /> 
    <screen android:screenSize="small" android:screenDensity="213" /> 
    <screen android:screenSize="small" android:screenDensity="280" /> 
    <screen android:screenSize="small" android:screenDensity="360" /> 
    <screen android:screenSize="small" android:screenDensity="400" /> 
    <screen android:screenSize="small" android:screenDensity="420" /> 
    <screen android:screenSize="small" android:screenDensity="480" /> 
    <screen android:screenSize="small" android:screenDensity="560" /> 
    <!-- all normal size screens --> 
    <screen android:screenSize="normal" android:screenDensity="ldpi" /> 
    <screen android:screenSize="normal" android:screenDensity="mdpi" /> 
    <screen android:screenSize="normal" android:screenDensity="hdpi" /> 
    <screen android:screenSize="normal" android:screenDensity="xhdpi" /> 
    <screen android:screenSize="normal" android:screenDensity="xxhdpi" /> 
    <screen android:screenSize="normal" android:screenDensity="xxxhdpi" /> 
    <screen android:screenSize="normal" android:screenDensity="213" /> 
    <screen android:screenSize="normal" android:screenDensity="280" /> 
    <screen android:screenSize="normal" android:screenDensity="360" /> 
    <screen android:screenSize="normal" android:screenDensity="400" /> 
    <screen android:screenSize="normal" android:screenDensity="420" /> 
    <screen android:screenSize="normal" android:screenDensity="480" /> 
    <screen android:screenSize="normal" android:screenDensity="560" /> 
</compatible-screens> 
相關問題