防止应用在安卓平板电脑上运行

3

我的项目支持手机和10英寸平板电脑使用同一个apk。然而,手机和平板电脑的用户界面非常不同。我将在下周发布应用程序,并希望该应用程序目前仅对手机用户可用。由于测试尚未完成,平板电脑版本被搁置。 以下清单声明是否会防止应用程序安装/在10英寸平板电脑上显示?

在清单文件中加入以下声明是否可以防止应用程序在10英寸平板电脑上安装或显示:
<manifest ... >
    <supports-screens android:smallScreens="true"
                      android:normalScreens="true"
                      android:largeScreens="true"
                      android:xlargeScreens="false"/>
    ...
    <application ... >
        ...
    </application>
</manifest>

解决方法应该是:这将从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>

1个回答

8
以下的清单声明是否能防止应用程序在10英寸平板电脑上安装/显示?
不可以。有了这个清单条目,您告诉Android允许您的应用程序在-xlarge设备上运行,并且Android会进行一些额外的工作来尝试使您的UI拉伸以填充屏幕。
要阻止安装(并被从Play商店列表中过滤掉),您需要使用。

3
@AbdulWahab:你的“最聪明的代码”不是有效的语法。答案包含了“最聪明的代码”,尽管它可能很长。请参考http://developer.android.com/guide/topics/manifest/compatible-screens-element.html底部的示例。 - CommonsWare
实际上我正在处理位图,并将其适配到屏幕宽度,但在平板电脑上会抛出异常。 - Abdul Wahab
如果我的应用程序已经支持平板电脑,并且我不希望平板电脑更新到特定版本,这个方案是否可行? - geekoraul
@geekoraul:我不知道那是否可能。 - CommonsWare
如何确认行为? - geekoraul
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接