防止应用程序在Android平板电脑上运行

arj*_*oan 3 android manifest tablet google-play

我的项目支持单个apk用于手机和10英寸平板电脑.然而,手机和平板电脑的UI非常不同.我将在下周发布该应用程序,我希望该应用程序暂时仅供手机用户使用.由于测试未完成,平板电脑版本将被暂停.清单中的以下声明是否会阻止在10英寸平板电脑上安装/显示应用程序

<manifest ... >
    <supports-screens android:smallScreens="true"
                      android:normalScreens="true"
                      android:largeScreens="true"
                      android:xlargeScreens="false"/>
    ...
    <application ... >
        ...
    </application>
</manifest>
Run Code Online (Sandbox Code Playgroud)

对此的解决方案应该是:这将从10英寸(xLarge)平板电脑中过滤掉应用程序?

<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" />
    <!-- all large size screens -->
    <screen android:screenSize="large" android:screenDensity="ldpi" />
    <screen android:screenSize="large" android:screenDensity="mdpi" />
    <screen android:screenSize="large" android:screenDensity="hdpi" />
    <screen android:screenSize="large" android:screenDensity="xhdpi" />
</compatible-screens>
...
<application ... >
    ...
<application>
Run Code Online (Sandbox Code Playgroud)

Com*_*are 8

清单中的以下声明是否会阻止在10英寸平板电脑上安装/显示应用程序

不.使用该清单条目,您告诉Android允许您的应用在-xlarge设备上,Android会做一些额外的工作来尝试让您的UI拉伸以填满屏幕.

要阻止安装(并从Play商店列表中过滤掉),您需要使用<compatible-screens>.

  • @AbdulWahab:你的"最聪明的代码"不是有效的语法.答案包含"最聪明的代码",尽可能冗长.请参阅http://developer.android.com/guide/topics/manifest/compatible-screens-element.html底部的示例 (3认同)