简体   繁体   English

限制Android应用程序仅适用于手机而非平板电脑

[英]Limit android app only for Mobile phones not tablet

I want my application available only for mobile phones not for tablet. 我希望我的应用程序仅适用于手机,而不适用于平板电脑。 Here is what i have done 这是我所做的

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="soulvant.golfclub">

<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" />
    <!-- all normal size screens -->
    <screen
        android:screenDensity="ldpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="mdpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="hdpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="large" />
</compatible-screens>


<uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" />

<!-- for Samsung badge -->
<uses-permission android:name="com.sec.android.provider.badge.permission.READ" />
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" />

<!-- for htc badge -->
<uses-permission android:name="com.htc.launcher.permission.READ_SETTINGS" />
<uses-permission android:name="com.htc.launcher.permission.UPDATE_SHORTCUT" />

<!-- for sony badge -->
<uses-permission android:name="com.sonyericsson.home.permission.BROADCAST_BADGE" />

<!-- for apex badge -->
<uses-permission android:name="com.anddoes.launcher.permission.UPDATE_COUNT" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />

<permission
    android:name="soulvant.golfclub.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="soulvant.golfclub.permission.C2D_MESSAGE" />

<!-- This app has permission to register and receive data message. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<!-- Network State Permissions to detect Internet status -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- Permission to vibrate -->
<uses-permission android:name="android.permission.VIBRATE" />

<application
    android:name=".utils.ApplicationClass"
    android:allowBackup="true"
    android:icon="@mipmap/launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:theme="@style/AppTheme"
    tools:node="replace">
    <meta-data
        android:name="DATABASE"
        android:value="aurous.db" />
    <meta-data
        android:name="VERSION"
        android:value="1" />
    <meta-data
        android:name="QUERY_LOG"
        android:value="true" />
    <meta-data
        android:name="DOMAIN_PACKAGE_NAME"
        android:value="soulvant.golfclub" />

    <activity
        android:name=".activities.SplashActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".activities.MainActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.ProsActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.ProsDetailActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.ProDetailRateOffer"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.NewsActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.NewsDetailActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.EventsActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.EventDetailActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.CourseActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.CourseDetailActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.FacilityAvailableActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.CourseRateoffActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.RestaurantActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.RestaurantMenu"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.RestaurantDetailActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.RestaurantRatesActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.HotelsActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.HotelDetailActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.HotelPackageActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.HotelWebsiteActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.ProshopActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.ProshopDetailActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.CoursesSlideshow"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.ProshopRateOfferActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.BrowserActivity"
        android:screenOrientation="portrait" />
    <activity
        android:name=".activities.AdvertisementActivity"
        android:screenOrientation="portrait" />

    <activity
        android:name=".activities.Advertisement"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.Translucent" />

    <receiver
        android:name="com.google.android.gms.gcm.GcmReceiver"
        android:exported="true"
        android:permission="com.google.android.c2dm.permission.SEND">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />

            <category android:name="soulvant.golfclub" />
        </intent-filter>
    </receiver>

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <!-- [START gcm_listener] -->
    <service
        android:name=".MyGcmListenerService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
        </intent-filter>
    </service>
    <!-- [END gcm_listener] -->
    <!-- [START instanceId_listener] -->
    <service
        android:name=".MyInstanceIDListenerService"
        android:exported="false">
        <intent-filter>
            <action android:name="com.google.android.gms.iid.InstanceID" />
        </intent-filter>
    </service>
    <!-- [END instanceId_listener] -->
    <service
        android:name=".RegistrationIntentService"
        android:exported="false" />
</application>

But when i uploaded it on playstore and tried to search on my samsung galaxy s4 it was not there is search result. 但是,当我将其上传到Playstore并尝试在我的三星s4上搜索时,没有搜索结果。

What i am doing wrong. 我做错了。

Android makes it easy to develop an app that runs well on a wide range of device screen sizes and form factors. Android使开发易于在各种设备屏幕尺寸和外形尺寸上良好运行的应用程序变得容易。 This broad compatibility works in your favor, since it helps you design a single app that you can distribute widely to all of your targeted devices. 这种广泛的兼容性对您有利,因为它可以帮助您设计一个可以广泛分发到所有目标设备的应用程序。 However, to give your users the best possible experience on each screen configuration — in particular on tablets — you need to optimize your layouts and other UI components for each targeted screen configuration. 但是,要在每种屏幕配置(尤其是在平板电脑上)上为用户提供最佳体验,您需要针对每种目标屏幕配置优化布局和其他UI组件。 On tablets, optimizing your UI lets you take full advantage of the additional screen available, such as to offer new features, present new content, or enhance the experience in other ways to deepen user engagement. 在平板电脑上,优化UI可以让您充分利用可用的其他屏幕,例如提供新功能,呈现新内容或以其他方式增强体验,以加深用户参与度。

Add this 加上这个

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

An application "supports" a given screen size if it resizes properly to fill the entire screen. 如果应用程序正确调整大小以填满整个屏幕,则它“支持”给定的屏幕大小。 Normal resizing applied by the system works well for most applications and you don't have to do any extra work to make your application work on screens larger than a handset device. 系统应用的常规大小调整对大多数应用程序都适用,并且您无需做任何额外的工作即可使您的应用程序在比手持设备更大的屏幕上运行。 However, it's often important that you optimize your application's UI for different screen sizes by providing alternative layout resources. 但是,通过提供替代布局资源来优化应用程序的UI以适合不同的屏幕尺寸通常很重要。 For instance, you might want to modify the layout of an activity when it is on a tablet compared to when running on a handset device. 例如,与在手持设备上运行时相比,您可能想要修改在平板电脑上的活动的布局。

Please read official Document's about Declare Support for Tablet Screens & supports-screens . 请阅读有关“ 声明支持平板电脑屏幕supports-screens”的官方文档。 I hope it will helps you . 希望对您有帮助。

If you do not specify a large screen size in manifest, it will not show up in tablet, so don't worry about that. 如果您未在清单中指定大屏幕尺寸,则它将不会显示在平板电脑中,因此不必担心。

在此处输入图片说明

So, now it wont show up for tablets in the play store unless you do something to show up in play store. 因此,除非您在Play商店中做一些展示,否则现在它不会在Play商店中出现在平板电脑上。

You stated your app doesn't show up on the Samsung galaxy s4 : 您表示您的应用程序未显示在Samsung galaxy s4

Your app has permissions that the samsung galaxy s4 cannot handle. 您的应用拥有三星银河s4无法处理的权限。 For example, if you try to access a camera on a device without a camera, then your app wont show up for that device. 例如,如果您尝试在没有摄像头的设备上访问摄像头,则您的应用不会针对该设备显示。 So, take a look at the permissions in the app you made, and look at the features of the s4, check which ones it cannot abide to. 因此,请查看您制作的应用程序中的权限,并查看s4的功能,然后检查它不能遵守的权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM