支持手机和平板手机,不支持平板电脑

Support phones and phablets, not tablets

我最近将我的应用程序上传到 Play 商店,它只支持 phones 和平板手机。 因此,根据 https://developer.android.com/guide/practices/screens-distribution.html

,我插入以下代码以仅支持 phones 和平板手机

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.xxx.yyy.permission.C2D_MESSAGE" />

    <compatible-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="420" />
      <screen android:screenSize="small" android:screenDensity="480" />
      <screen android:screenSize="small" android:screenDensity="560" />
      <screen android:screenSize="small" android:screenDensity="640" />
      <!-- 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="420" />
      <screen android:screenSize="normal" android:screenDensity="480" />
      <screen android:screenSize="normal" android:screenDensity="560" />
      <screen android:screenSize="normal" android:screenDensity="640" />
    </compatible-screens>

    <application android:name=".AppApplication" 
android:allowBackup="false" 
android:icon="@mipmap/ic_launcher" 
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" 
android:supportsRtl="true" 
android:theme="@style/AppTheme" 
android:largeHeap="true"/>

当 Samsung S8 尝试安装时,奇怪的事情开始出现。它将具有三种可能性。 华为Mate 9也有类似情况

  1. 能够找到应用并安装。
  2. 能够找到应用程序但显示错误“您的设备与此版本不兼容”。
  3. 根本找不到该应用程序。

我的问题是,我该如何解决这个问题? Google Play 控制台表示除了我上面提到的平板电脑外,所有设备都受支持。 还是与最近 phone 刚刚实施的 WQHD 相关?

已编辑: 只有升级到最新固件的用户才会出现此问题,这使得 phone 可以支持 WQHD。

您可以使用 <supports-screens> 而不是 <compatible-screens>,因为它不需要您指定您的应用程序支持的每个屏幕密度。

手机设备示例:

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

来源:

干杯。

已编辑更新为 ANDROID 奥利奥:

根据您的评论"EDITED: The problem occurs only to those who upgraded to latest firmware, which enables the phone to support WQHD."

可能的逻辑原因:问题是这些设备之前抑制了它们的真实屏幕(制造商/android os)分辨率,因此代码在所有设备上都按预期工作。

升级到新的 Android OS /Oreo 时出现问题,释放了设备的真正屏幕分辨率功能。

设置-显示-屏幕分辨率(有3个设置)

建议test/verification将分辨率调到最低。尝试安装/运行 应用程序。

参考:https://www.androidcentral.com/understanding-galaxy-s8s-display-resolution-options

目前这绝对不在您的代码控制范围内,因为它是对Android API 8.0 Oreo util 文档的全新升级,与此同时,您可以考虑将设备的最大分辨率包括在内或对用户进行培训。

除了@Khalid 的回答,使用<support-screens> 将启用屏幕兼容模式并让平板电脑用户能够下载。

这是不可避免的,因为 <compatible-screens> 无法区分使用户能够动态设置分辨率(HD+、FHD+ 和 WQHD+)的新版本 Android(或三星),并且无法真正确定屏幕密度.

为了解决这个问题,我在应用启动时添加了一个验证器来检查屏幕尺寸。

    public boolean checkUnsupportedSize() {
    int screenSize = this.getResources().getConfiguration().screenLayout &
            Configuration.SCREENLAYOUT_SIZE_MASK;

    switch(screenSize) {
        case Configuration.SCREENLAYOUT_SIZE_SMALL:
            return false;
        case Configuration.SCREENLAYOUT_SIZE_NORMAL:
            return false;
        default:
            return true;
    }
}

    if (checkUnsupportedSize()) {
    YourActivity.this.finish();
}

由于手机和平板手机总是使用 Small 和 Normal 的屏幕尺寸,我们可以区分其他屏幕尺寸并强制应用程序退出。

直到 Google Play 对手机、平板手机和平板电脑进行适当的过滤,这是我能想到的解决方法。

干杯。