【问题标题】:Make android app not availble for tablets使 Android 应用程序不适用于平板电脑
【发布时间】:2013-03-10 23:45:31
【问题描述】:

我正在 Play 商店中发布我的应用,但我不希望它可用于平板电脑。 我怎样才能做到这一点?

我不想在 android 的开发者控制台中手动排除每一个平板电脑,但我确实需要我的应用程序只能在智能手机上运行。

编辑: 我按照你的建议做了,但结果如下:

为了进一步解释:我需要我的应用程序在普通人称为智能手机的设备上运行,而不是在普通人称为平板电脑的设备上运行......例如它必须在“Galaxy Note 2”上运行,但不能在“Galaxy Tab”上运行

已解决感谢@CommonsWare:

我必须在清单中设置以下标签:

<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="9"/>

和:

<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>

然后执行以下操作: 右键项目->属性->android->选择大于8的目标

【问题讨论】:

  • 这是为什么呢? (另外,请定义“平板电脑”)
  • 如果原因是您的应用程序需要电话语音通话访问权限,请注意某些平板电脑可以支持语音通话(例如,我有一个 ViewSonic ViewPad 7",它基本上只是一部超大手机)。
  • 如果你不想包含平板电脑,我想知道你为什么还要写 元素。?
  • 不要以编程方式进行。只需在 Google Play Concole 中排除一些设备即可。

标签: android tablet


【解决方案1】:

http://developer.android.com/guide/practices/screens-distribution.html#FilteringHansetApps

...您可以使用该元素根据屏幕尺寸和密度的组合来管理应用程序的分布。 Google Play 等外部服务使用此信息对您的应用程序进行过滤,以便只有具有您声明兼容的屏幕配置的设备才能下载您的应用程序。

来自该页面的示例&lt;compatible-screens&gt; 元素:

<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>

不过,我建议同时添加密度为xxhdpi 的线条,因为此类设备现已上市(Droid DNA、Xperia Z、HTC Butterfly 等)。


更新

首先,关于您的构建错误,如果您阅读the documentation for the &lt;compatible-screens&gt; element,您会注意到它是在 API 级别 9 中添加的,并且出于某种奇怪的原因,您的构建目标设置得比这更早。

第二,关于:

我需要我的应用程序在普通人称为智能手机的设备上运行,而不是在普通人称为平板电脑的设备上运行......例如它必须在“Galaxy Note 2”上运行,但不能在“Galaxy Tab”上运行

这是不可能的,仅仅是因为您没有具体定义自己所做的事情并且不希望您的应用发布。

地球上有大约 80 亿“正常人”。欢迎您采访他们每个人,并询问他们对 Galaxy Note 2 的看法。有人会说是电话。有人会说是平板电脑。有些人会说“平板手机”,这不会有用。有些人会把你赶出他们的家,声称你带了一些发光的恶魔进入他们中间(这也没有用,如果他们手边有石头可以扔,可能会很痛苦)。

如果在未来的某个时间点,您对自己的设备要做什么和不希望发货有一个科学的定义,请提出一个新的 StackOverflow 问题。我所说的“科学定义”是指一种算法,它可以被所有设备上的所有人普遍应用,以确定你在做什么和不希望你的应用在什么地方。

(请注意,“所有人”是指那些可能认为你是恶魔贩子的人)

例如:

  • “我想在所有具有电话功能的设备上发货,无论屏幕大小如何”

  • “我想在所有屏幕尺寸小于最小边的几英寸的设备上发货:

【讨论】:

  • 你是对的(并且做了一个非常搞笑的回答。诚实!)。我需要运送小于 6 英寸的设备。现在我有: 但它仍然给我与我发布的图片相同的错误!
  • @aveschini:您需要将 构建目标 设置为 API 级别 9 或更高。在 Eclipse 中,即在 Project > Properties > Android 中。
  • 我只需要添加以下内容:
  • @CommonsWare 似乎 xxhdpi 的值对于 screenDensity 是不允许的,即使是 targetSdkVersion="19" ...从我在 SO 上找到的内容来看,我们必须使用 480对吗?
  • @AlexAndro:你必须使用480 而不是xxhdpi。
【解决方案2】:

在清单文件中使用支持屏幕标记是方法错误。始终使用&lt;compatible-screens&gt; 使您的应用无法在平板电脑上使用。

<supports-screens 
    android:smallScreens="true"
    android:normalScreens="true" 
    android:largeScreens="false"
    android:xlargeScreens="false"
    android:resizeable="false" />

注意

如果您将元素用于上述场景 (当您的应用程序与大屏幕不兼容时)并设置 较大的屏幕尺寸属性为“假”,然后是外部服务 例如 Google Play 不应用过滤。您的申请将 仍然可以在更大的屏幕上使用,但是当它运行时,它不会 调整大小以适应屏幕。相反,系统将模拟手机 屏幕尺寸(约 320dp x 480dp;请参阅屏幕兼容模式了解 更多信息)。如果您想阻止您的应用程序被 下载到更大的屏幕上,按照 @CommonsWare 的建议使用。

使用标签排除您的应用程序以在平板电脑上运行。

<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>

【讨论】:

  • 这行不通。 Android 仍会将应用程序发布到更大屏幕的设备上,并将应用自己的算法来扩展 UI。
  • 正如另一个线程中所述,此解决方案取决于“平板电脑”的定义,这可能不是 aveschini 想要的。
  • @CommonsWare 感谢您的宝贵建议。
  • 'android:resizeable' 此属性已弃用。来自developer.android.com/guide/topics/manifest/…
【解决方案3】:

对于刚接触线程的人,请使用

<uses-feature android:name="android.hardware.telephony" required="true"/>

来源 (https://paramsen.github.io/exclude-tablets/)

【讨论】:

    【解决方案4】:

    您可以尝试为 3g 或 4g 服务添加某种检查。这将排除大多数但可能不是所有平板电脑。

    【讨论】:

    • idk 我们应该如何处理这个答案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多