打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
AndroidManifest.xml 详解 (六) 之uses

   我们要写入manifest文件的最后一个元素就是<uses-sdk>。它是<manifest>的子元素。在第二章创建Hello World项目的时候,在New Android Project对话框中,通过指定Android SDK 的最小版本,我们已经使用了<uses-sdk>元素。

 

   但是我们怎么在<manifest>中指定它呢?这有个例子:

 

   <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="9"/>

 

   和我们在第二章中讨论的一样,每一个Android SDK 版本号都对应一个整形数字。<uses-sdk>指定了我们应用所支持的最低Android SDK版本号,和我们应用所使用的版本号。

 

    <uses-sdk> 元素允许配置我们的应用,一个低版本的android sdk开发,而能够在最新的android系统上运行(向上兼容)。一个突出的例子就是多点触控APIs,多点触控在SDK 5(Android 2.0)或以上版本才能够被支持。当我们在Eclipse中设置Android 项目的时候,我们使用build target来选择支持多点触控的Android 版本——举个例子,SDK 5或更高(我通常设置成最新的版本,在我写这本书的时候是SDK 9)。如果我们想让我们的游戏在安装有SDK 3(Android 1.5)的系统的设备上运行,我们就可以和刚才的例子一样,在manifest文件中指定minSdkVersion属性。当然,使用高版本开发时,我们必须小心别去使用那些在低版本中不可用的API,比如说高版本SDK兼容安装了1.5系统的设备。如果设备安装了高版本的系统,那么我们就可以很好的使用更新的APIs了。

 

    前面的配置说明已经可以适用于大多数的游戏开发(除非你不能为一个更高版本的APIs提供独立的代码路径,而在这种情况下你会希望设置minSdkVersion为你实际支持的最低的SDK版本)

 

终于完结了。

最近看到第7章 OpenGL ES的内容。~所以接下来翻译会和第七章有关。

书中有一个最简单的Android游戏框架。。。虽然小但是能学到很多东西..感觉是libgdx的迷你版本(此书作者是libgdx框架的开发者之一~)

我会把源码上传。

 

 

最后附上原文:

The <uses-sdk> Element


The last element we’ll put in our manifest file is the <uses-sdk> element. It is a child of
the <manifest> element. We implicitly defined this element when we created our Hello
World project in Chapter 2 when we specified the minimum SDK version in the New
Android Project dialog. So what does this element do? Here’s an example:


<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="9"/>


As we discussed in Chapter 2, each Android version has an integer assigned, also
known as an SDK version. The <uses-sdk> element specifies what minimum version our
application supports and what the target version of our application is. 


This element allows us to deploy an application that uses APIs that are only available in
newer versions to devices that have a lower version installed. One prominent example
would be the multitouch APIs, which are supported from SDK version 5 (Android 2.0)
onward. When we set up our Android project in Eclipse, we use a build target that
supports that API—for example, SDK version 5 or higher (I usually set it to the latest
SDK version, which is 9 at the time of writing). If we want our game to run on devices
with SDK version 3 (Android 1.5) as well, we specify the minSdkVersion as before in the
manifest file. Of course we must be careful not to use any APIs that are not available on
the lower version, at least on a 1.5 device. On a device with a higher version, we can use
the newer APIs as well.


The preceding configuration is usually fine for most games (unless you can’t provide a
separate fallback code path for the higher-version APIs, in which case you will want to
set the minSdkVersion attribute to the minimum SDK version you actually support).

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Android中build target,minSdkVersion,targetSdkVersio...
android:targetSdkVersion相关
一个 android 项目中解决画面模糊问题的小结
android:minSdkVersion 之我见
android工程有红×没错误解决办法 .
API级别 和 sdk版本
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服