Target Android Phones Not Tablets

Screen size and density

Android devices come in a vast array of different screen sizes and screen densities. This makes it tricky to say “this app should only be available to phones” on the Google Play store.

Here is the most concise way I can find to achieve the desired result. Include the <compatible-screens> element in the AndroidManifest.xml file like this (my original gist here):

AndroidManifest.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<manifest>
<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="480" />
<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="480" />
</compatible-screens>
<!-- ... -->
<application>
<!-- ... -->
<application>
</manifest>

480 vs xxhdpi

The android:screenDensity="480" can also be written as android:screenDensity="xxhdpi" but depending on the min SDK version you are targeting, the xxhdpi may be unrecognised and cause a build failure. Fortunately, 480 has the same result because the standard quantised dpi for xxhdpi is 480.

xxxhdpi

I’ve seen xxxhdpi in the Android source but I’ve not seen a phone with the capability yet. I imagine this will have a standard quantised dpi of 640, so you will able to use this similar trick in future.

Now all you have to do is create the 100s of assets you need to actually support these screen densities.

What’s next? CastlemaineHDPI? (XXXX).