簡體   English   中英

Android XML,如何讓app只兼容手機和平板?

[英]Android XML, how to make app compatible only for phones and tablets?

我需要讓我的應用程序只兼容手機和平板電腦(特別是所有手機和平板電腦),我知道我必須在清單文件中聲明這一點,但不起作用。

這是我的嘗試:

<supports-screens
        android:smallScreens="true"
        android:normalScreens="true"
        android:largeScreens="true"
        android:xlargeScreens="false" />
<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" />
        <screen android:screenSize="small" android:screenDensity="xxhdpi" />
        <screen android:screenSize="small" android:screenDensity="xxxhdpi" />
        <!-- 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" />
        <screen android:screenSize="normal" android:screenDensity="xxhdpi" />
        <screen android:screenSize="normal" android:screenDensity="xxxhdpi" />
        <!-- all large size screens -->
        <screen android:screenSize="large" android:screenDensity="ldpi" />
        <screen android:screenSize="large" android:screenDensity="mdpi" />
        <screen android:screenSize="large" android:screenDensity="hdpi" />
        <screen android:screenSize="large" android:screenDensity="xhdpi" />
        <screen android:screenSize="large" android:screenDensity="xxhdpi" />
        <screen android:screenSize="large" android:screenDensity="xxxhdpi" />
    </compatible-screens>

通過對清單進行此編輯,該應用程序僅與手機和平板電腦兼容,但並非與所有手機和平板電腦兼容。 我怎樣才能使應用程序與所有這些兼容? 謝謝

刪除所有這些。 這些字段適用於您想要消除某些屏幕尺寸/類型的情況。 例如,如果您只想在小屏幕上工作。 如果你想處理所有事情,你根本就不要放任何東西——一切都是默認的。

現在在 Play 商店中,您可能仍然會看到一些您無法使用的設備。 這主要是由於您支持的 sdk 版本,這是預期的。 或者你的清單中的任何 require-feature 標志(只有當你絕對需要該功能才能工作時才應該存在)。

為了使應用程序僅與手機和平板電腦兼容(並以縱向模式運行),我的解決方案是在我的 Manifest.xml 文件中添加以下行:

    <uses-feature android:required="true" android:name="android.hardware.camera"/>
    <uses-feature android:required="true" android:name="android.hardware.camera.flash"/>
    <uses-feature android:required="true" android:name="android.hardware.touchscreen" />
    <uses-feature android:required="true" android:name="android.hardware.screen.portrait" />

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM