Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why 'xxhdpi' is not allowed value of screenDensity parameter in Manifest [Restricting tablets]

Why are xxhdpi and xxxhdpi not allowed values for screenDensity parameter of <screen> element in Manifest?

I'm trying to restrict usage of my app on tablets using the recommended solution from official Android Developers website - Declaring an App is Only for Handsets. I want to mark only small and normal screen sizes (with any density) as compatible:

<compatible-screens>
    <!-- all small size screens -->
    <screen
        android:screenDensity="ldpi"
        android:screenSize="small" />
    <screen
        android:screenDensity="mdpi"
        android:screenSize="small" />
    <screen
        android:screenDensity="hdpi"
        android:screenSize="small" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="small" />
    <!-- all normal size screens -->
    <screen
        android:screenDensity="ldpi"
        android:screenSize="normal" />
    <screen
        android:screenDensity="mdpi"
        android:screenSize="normal" />
    <screen
        android:screenDensity="hdpi"
        android:screenSize="normal" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="normal" />
</compatible-screens>

However, adding

    <screen
        android:screenDensity="xxhdpi"
        android:screenSize="normal" />

is not allowed. Doesn't compile with Error: String types not allowed (at 'screenDensity' with value 'xxhdpi'). The same happens for 'xxxhdpi'.

I found out that inserting integer for corresponding density (e.g. screenDensity="480") works, but I'm wondering why doesn't it allow string expressions for all existing density buckets?

like image 815
Marcel Bro Avatar asked Sep 29 '22 12:09

Marcel Bro


1 Answers

The android developer guide for screen density seems to agree with what you've experienced. It also mentions that for xxhdpi and higher you'll have to manually enter the dpi values. As to why, it doesn't really say...

http://developer.android.com/guide/topics/manifest/compatible-screens-element.html

Note: This attribute currently does not accept xxhdpi as a valid value, but you can instead specify 480 as the value, which is the approximate threshold for xhdpi screens.

like image 63
Jason Hu Avatar answered Oct 03 '22 06:10

Jason Hu