AndroidManifest.xml 详解 (六) 之uses-sdk—— 译自《Beginning Android Games》

   我们要写入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).

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值