Manifest limits to only tablets but app is still available to Samsung Galaxy S2

霸气de小男生 提交于 2020-01-03 15:36:55

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/15361292/manifest-limits-to-only-tablets-but-app-is-still-available-to-samsung-galaxy-s2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!