Manifest limits to only tablets but app is still a

2019-06-26 07:26发布

I want to run my app only in tablets. So I have declared below code in manifest file:

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

But when I connect my Samsung Galaxy S2 phone (hdpi 480x800), it still displays in Eclipse's Android device chooser.

I only want to support for 7" and 10" tablets. How can I do that?

2条回答
贼婆χ
2楼-- · 2019-06-26 07:54

You might want to take a look here.

The manifest restrictions you wrote are not exactly correct for this purpose:

Use this:

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

This describes your app’s screen-size support in two different ways:

It declares that the app does not support the screen size buckets “small”, “normal”, and “large”, which are traditionally not tablets

It declares that the app requires a screen size with a minimum usable area that is at least 600dp wide

The first technique is for devices that are running Android 3.1 or older, because those devices declare their size based on generalized screen size buckets. The requiresSmallestWidthDp attribute is for devices running Android 3.2 and newer, which added the capability for apps to specify their size requirements based on a minimum number of density-independent pixels. In this example, the app declares a minimum width requirement of 600dp, which generally implies a 7”-or-greater screen.

Your size choice might be different, of course, based on how well your design works on different screen sizes; for example, if your design works well only on screens that are 9” or larger, you might require a minimum width of 720dp.

The catch is that you must compile your application against Android 3.2 or higher in order to use the requiresSmallestWidthDp attribute. Older versions don’t understand this attribute and will raise a compile-time error. The safest thing to do is develop your app against the platform that matches the API level you’ve set for minSdkVersion. When you’re making final preparations to build your release candidate, change the build target to Android 3.2 and add the requiresSmallestWidthDp attribute. Android versions older than 3.2 simply ignore that XML attribute, so there’s no risk of a runtime failure.

查看更多
闹够了就滚
3楼-- · 2019-06-26 08:05

You can't filter the app from being installed on phones (via Eclipse, or if it's downloaded from an external source). This setting will restrict the app from being downloaded on phones from the Google Play Market.

查看更多
登录 后发表回答