Man*_*gde 21 android android-manifest android-screen android-screen-support
我开发了一个应用程序,现在我想限制平板电脑的应用程序.
表示应用程序不应在任何平板电脑上运行.为此我在Androidmenifest.XML文件中指定支持屏幕为:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abc.xyz"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="5"
android:targetSdkVersion="17"
android:maxSdkVersion="17" />
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="false"
android:xlargeScreens="false"
android:resizeable="true"
android:anyDensity="true" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:icon="@drawable/appicon"
android:label="@string/app_name"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:allowBackup="true" >
<activity
android:name="com.abc.xyz.activities.hello"
android:label="@string/title_activity_hello" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
现在的问题是:
应用程序在平板电脑上运行
android:largeScreens="false"
android:xlargeScreens="false"
Run Code Online (Sandbox Code Playgroud)
在宣布上述之后.
那我该怎么办 请建议我并指导我.
Sha*_*ley 38
这可以防止在平板电脑上访问,但允许使用新的密度存储区(xxhdpi和xxxhdpi),并避免在针对较低SDK编译的项目上出现错误.它应该是AndroidManifest.xml中<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" />
<screen android:screenSize="small" android:screenDensity="480" />
<screen android:screenSize="small" android:screenDensity="640" />
<!-- 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="480" />
<screen android:screenSize="normal" android:screenDensity="560" />
<screen android:screenSize="normal" android:screenDensity="640" />
</compatible-screens>
Run Code Online (Sandbox Code Playgroud)
更新8.8.2016 如果要支持密度为420的类似Nexus-5x的设备,请添加此行
<screen android:screenSize="normal" android:screenDensity="420" />
Run Code Online (Sandbox Code Playgroud)
Opt*_*dia 15
在您的清单中包括以下内容:
<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" />
<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" />
</compatible-screens>
</manifest>
Run Code Online (Sandbox Code Playgroud)
这会对你有所帮助.
Ren*_*ith 14
如果您想将应用程序限制为手机,请仅使用<compatible-screens>清单中的标记.就像这样
<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>
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅声明应用程序仅适用于手机
<supports-screens>如果要从平板电脑限制应用,则不应使用该标记.官方文件中明确提到了这一点
警告:如果您将该元素用于反向场景(当您的应用程序与较大屏幕不兼容时)并将较大的屏幕尺寸属性设置为"false",则Google Play等外部服务不会应用过滤.您的应用程序仍可用于更大的屏幕,但在运行时,它不会调整大小以适应屏幕.相反,系统将模拟手机屏幕大小(约320dp x 480dp;有关详细信息,请参阅屏幕兼容模式).如果您想阻止您的应用程序在较大的屏幕上下载,请使用,如上一节中有关声明应用程序仅适用于手机的讨论.
| 归档时间: |
|
| 查看次数: |
13851 次 |
| 最近记录: |