让我的应用无法用于平板电脑

时间:2015-11-14 20:54:24

标签: android google-play android-manifest tablet

我是应用程序的新手(构建我的第一个)并且我想知道如何从我的Android清单中排除平板电脑以及如何使我的应用程序无法在Play商店下载(使用平板电脑时)

<manifest 
 android:versionCode="9"
android:versionName="0.2">
<uses-sdk android:minSdkVersion="16"
android:targetSdkVersion="16"/>

<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="480" />
    <!-- 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:screenDensity="480"
        android:screenSize="normal"/>
</compatible-screens>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

1 个答案:

答案 0 :(得分:1)

您可以将其添加到清单

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

         <!--Rest of the manifest-->

另外,要确定它是否是具有大屏幕的平板电脑,请使用此方法

public static boolean isTablet(Context context) {
return (context.getResources().getConfiguration().screenLayout
        & Configuration.SCREENLAYOUT_SIZE_MASK)
        >= Configuration.SCREENLAYOUT_SIZE_LARGE;

}