How to restrict app for tablet in Android?

会有一股神秘感。 提交于 2019-12-09 12:46:25

问题


i want to my app run only mobile device not in the

tablet 10 and 7 inch

. but my app is run on both tablet size .please help me out


回答1:


Yes as @OceanLife says you Should Go with compatible-screens or supports-screens.

but I would like to add Something here.

if you are using

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

then note what official compatible-screens documentation says:

if you want your application to be available only for large and xlarge screen devices, the element allows you to declare that your application does not support small and normal screen sizes. External services (such as Google Play) will filter your application accordingly. You can also use the element to declare whether the system should resize your application for different screen sizes.

So it will effect after you will upload your apk file to PlayStore. untill you will not get this feature affected.

Also see the Filters on Google Play document for more information about how Google Play filters applications using this and other manifest elements.

Hope it will Help.




回答2:


The google developer has very detail information on that so please check this link:
Distributing to Specific Screens

Quoting relevant parts below.

Handsets only:

Declaring an App is Only for Handsets

<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 ... >
        ...
    <application>
</manifest>

Tablets only:

Declaring an App is Only for Tablets

If you don't want your app to be used on handsets (perhaps your app truly makes sense only on a large screen) or you need time to optimize it for smaller screens, you can prevent small-screen devices from downloading your app by using the manifest element.

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



回答3:


Try to add this on your android manifest file

    <uses-sdk
android:minSdkVersion="6"
android:targetSdkVersion="8" />


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



回答4:


Try this :

You should use this attribute in your mainfest android:largestWidthLimitDp="enter mobile pixel value which above you want restrict."

 <supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:resizeable="true"
    android:largestWidthLimitDp="500"
    android:smallScreens="true"
    android:xlargeScreens="false" />



回答5:


By using Uses-Feature it seems you can restrict the app distribution to only Landscape screen devices "tablets and tablets like devices". Here is the code you will need in your manifest.xml:

          <uses-feature android:name="android.hardware.screen.landscape"
                      android:required="true"
          ></uses-feature>

Also use:

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


来源:https://stackoverflow.com/questions/14729410/how-to-restrict-app-for-tablet-in-android

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