基于Android操作系统的游戏程序开发外文翻译资料

 2022-11-04 15:57:36

Beginning Android 2

Introducing the Android

Computing Platform

Computing continues to become more “personal,” increasingly accessible anytime,

anywhere. At the forefront of this development are handheld devices that are

transforming into computing platforms. Mobile phones are no longer just for talking—

they have been capable of carrying data and video for some time. Significantly, the

mobile device is becoming so capable of general-purpose computing that itrsquo;s destined

to become the next PC (Personal Computer). It is also anticipated that even a number of

traditional PC manufacturers such as ASUS, HP, and Dell will be producing devices of

various form factors based on the Android OS. The battle lines between operating

systems, computing platforms, programming languages, and development frameworks

are being shifted and reapplied to mobile devices.

We are also expecting a surge in mobile programming in the IT industry as more and

more IT applications start to offer mobile counterparts. To help you profit from this trend,

wersquo;ll show you how to use Java to write programs for devices that run on Googlersquo;s

Android Platform (http://developer.android.com/index.html), an open source platform

for mobile development. We are excited about Android because it is an advanced

platform that introduces a number of new paradigms in framework design (even with the

limitations of a mobile platform).

In this chapter, wersquo;ll provide an overview of Android and its SDK, give a brief overview of

key packages, introduce what we are going to cover in each chapter briefly, show you

how to take advantage of Android source code, and highlight the benefits of

programming for the Android Platform.

A New Platform for a New Personal Computer

The fact that hitherto dedicated devices such as mobile phones can now count

themselves among other venerable general-computing platforms is great news for

programmers (see Figure 1–1). This new trend makes mobile devices accessible through

general-purpose computing languages, which increases the range and market share for

mobile applications.

The Android SDK supports most of the Java Platform, Standard Edition (Java SE) except

for the Abstract Window Toolkit (AWT) and Swing. In place of AWT and Swing, Android

SDK has its own extensive modern UI framework. Because yoursquo;re programming your

applications in Java, you could expect that you need a Java Virtual Machine (JVM) that

is responsible for interpreting the runtime Java byte code. A JVM typically provides the

necessary optimization to help Java reach performance levels comparable to compiled

languages such as C and C . Android offers its own optimized JVM to run the

compiled Java class files in order to counter the handheld device limitations such as

memory, processor speed, and power. This virtual machine is called the Dalvik VM,

which wersquo;ll explore in a later section “Delving into the Dalvik VM.”

The familiarity and simplicity of the Java programming language coupled with Androidrsquo;s

extensive class library makes Android a compelling platform to write programs for.

History of Android

Let us look at how Android arrived on the Mobile OS landscape. Mobile phones use a

variety of operating systems such as Symbian OS, Microsoftrsquo;s Windows Mobile, Mobile

Linux, iPhone OS (based on Mac OS X), Moblin (from Intel), and many other proprietary

OSs. So far no single OS has become the de facto standard. The available APIs and

environments for developing mobile applications are too restrictive and seem to fall

behind when compared to desktop frameworks. This is where Google comes in. The

Android platform promised openness, affordability, open source code, and a high-end

development framework.

Google acquired the startup company Android Inc. in 2005 to start the development of

the Android Platform (see Figure 1–3). The key players at Android Inc. included Andy

Rubin, Rich Miner, Nick Sears, and Chris White.

In late 2007, a group of industry leaders came together around the Android Platform to

form the Open Handset Alliance (http://www.openhandsetalliance.com). Some of the

alliancersquo;s prominent members are as follows:

?Sprint Nextel

?T-Mobile

?Motorola

?Samsung

?Sony Ericsson

?Toshiba

?Vodafone

?Google

?Intel

?Texas Instruments

Part of the alliancersquo;s goal is to innovate rapidly and respond better to consumer needs,

and its first key outcome was the Android Platform. Android was designed to serve the

needs of mobile operators, handset manufacturers, and application developers. The

members have committed to release significant intellectual property through the open

source Apache License, Version 2.0.

NOTE: Handset manufacturers do not need to pay any licensing fees to load Android on their

handsets or devices.

The Android SDK was first issued as an “early look” release in November 2007. In

September 2008, T-Mobile announced the availability of T-Mobile G1, the first

smartphone based on the Android platform. A few days after that, Google announced

the availability of Android SDK Release Candidate 1.0. In October 2008, Google made

the source code of the Android platform available under Apachersquo;s open source license.

When Android was released, one of its key architectural goals was to allow applications

to interact with one another and reuse components from one another. This reuse not

only applies to services, but also to data and the user interface

剩余内容已隐藏,支付完成后下载完整资料


Android入门2

Android简介

运行平台

现在,编译的平台变得越来越独立,使得程序在任何时间、任何地点都容易被接受。Android开发的最底层是将手持设备转变为编译运行平台。手机的功能不再仅限于通话,现在手机已经能够携带数据和多媒体数据。值得注意的是,手机设备支持的功能越来越多,越来越丰富,看起来将会变成一种新的个人电脑。因而,众多传统的个人电脑制造商例如ASUS、HP和Dell 将会在Android操作系统的基础上生产形式多样的智能手机。而他们在操作系统、运行平台、编程语言和框架发展之间的战争迅速转移到智能手机设备上,并重演它们之间的战争。

随着越来越多的IT应用开始提供手机端配对接口,我们也在期待着一股手机编程的浪潮在IT行业中掀起。为了帮助你在这新的趋势中获益,我们将会向你展示如何使用java编写运行在谷歌的android平台上的程序,谷歌的Android平台(http://developer.android.com/index.html)是一个开源的手机开发平台。我们为Android的诞生感到高兴,因为它是一个新的先进的平台,即使它只能局限于一个手机平台,但它为框架设计引入了很多新的范例。

在这一章里面,我们将会对Android及其SDK进行总览,对android的主要的包进行简短的介绍和分析,并简短地介绍在接下来的章节中包括什么内容,向你展示如何利用Android源代码然后指出在android开发平台编程能带来哪些好处。

新的平台、新的“PC”

现在,像智能手机之类的专业设备能够将它们自身划分为和其他PC一样的常规的编译运行平台,这对于程序员来说这是一个好消息。这个新的趋势使得手机设备能够被多种编译语言接受,这提高了智能手机在市场中的广度和占有份额。

Android SDK支持除了Abstract Window Toolkit (AWT) 以及Swing之外绝大部分的java平台和Standard Edition(Java SE)。,Android SDK用自己的一个强大的、时髦的UI框架取代了AWT和Swing原有的位置。当你在使用java编写你的应用时,你可以想象到,你需要一个Java 虚拟机(JVM),JVM使得设备能够编译程序运行时产生的java字节码。一个JVM典型的功能就是提供一个必需的最优化的选择来帮助java在运行平台上达到能够与其他编译语言比如C和C 比肩的高度。为了抵消手持设备存在的例如,内存、处理器速度以及电池容量等局限性,Android提供了自己的最优的JVM来运行编译好的Java class文件。这个虚拟机被命名为Dalvik VM,在以后的“深入Dalvik VM”部分,我们将会深入探究这个虚拟机。

Android的历史

让我们一起来看看Android是如何着陆到手机操作系统上的。手机有很多操作系统,例如,塞班操作系统、微软的Windows Mobile、手机Linux系统、苹果的ios系统(基于Mac OS)、intel的Moblin以及其他很多私人的操作系统。直到现在,没有任何一个单一的操作系统成为实际上的标准系统。各个操作系统为开发手机应用所提供的APIs和开发环境有很大的局限性,与pc框架相比落后不少。这就是谷歌Android加入市场的背景。Android平台提供了开放的、承受能力强的、开源的、高端的开放框架。

谷歌在2005年启动Android Inc公司来开始研发Android平台。Android Inc中主要人员包括Andy Rubin, Rich Miner, Nick Sears,和Chris White.

在2007年,一个由工业领导者组成的小组聚到一起围绕Android平台建立了Open Handset Alliance(http://www.openhandsetalliance.com)。 alliance的一些卓越的成员如下所示:

?Sprint Nextel

?T-Mobile

?Motorola

?Samsung

?Sony Ericsson

?Toshiba

?Vodafone

?Google

?Intel

?Texas Instruments

Alliance的一部分目标是快速创新、更好地对用户的需求做出回应,它的第一个主要的成果就是Android平台。Android是为了服务手机操作者、手机厂商以及应用研发人员而设计的。Alliance的成员们承诺通过开源Apache许可证发布重要的知识产权。

注意:手机厂商在装载Android操作系统到它们的手机或者其他设备时并不需要支付任何的知识产权许可证的费用

Android SDK在2007年11月第一次发布了一个“early look”版本。2008年9月,T-Mobile公司宣布了第一台基于android平台的智能手机T-Mobile G1的诞生。几天之后,谷歌官方宣布,Android SDK版本Candidate 1.0可以使用。在2008年10月,谷歌通过开源Apache许可证开放了Android平台的源代码。当Android发布的时候,它的主要目标之一是允许应用之间进行交流,从另一个应用中复用组件。这种复用不仅仅适用于服务,还适用于数据和用户界面(UI)。结果,Android平台有不少关键的特征来让这种开发成为现实。我们将会在第3章深入探究这些特征。

由于其为了使用由网上资源提供的云计算模块而完全开发的功能以及为了提高用户体验而在手机上自带数据存储,Android也吸引了早期的关注。Android手机支持关系数据库也在早期采用中起了作用。

2008年接下来,谷歌发布了一个叫“Android Dev Phone1”的手持设备,它不用受手机连接网络的约束而可以独立运行android应用。这款设备(标价大约400美元)的目标是允许开发者在没有任何合同的情况下体验一款真正能够运行Android操作系统的设备。几乎在同一时间,谷歌还发布了一个bug补丁,1.1版本的操作系统是独立基于1.0版本的。在1.0和1.1版本发布时,Android并不支持软键盘,需要手机自带物理按键。2009年4月,谷歌发布的SDK1.5版本才修复了这个问题,此外SDK1.5还有一些新的功能,例如窗口小部件,先进的媒体记录功能、活动文件夹。(在第12章我们将会涉及活动文件夹,第13章则是关于窗口小部件)。

2009年9月,谷歌发布了1.6版本的Android操作系统,同时不到一个月,Android2.0也发布了,在2009年圣诞节前夕推动了一股Android设备的浪潮。这个版本引入了先进的搜索功能以及语音输入功能(我们将会在第15章学习语音输入的功能,在第14章学习搜索功能)。此外,这个版本还引进了手势识别和多点触控。这些我们都会在第16章进行学习。随着Android开始支持HTML 5,使用HTML 5给Android2.0带来了更多有趣的可能性。这些新的编程可能性将会在第17章学习。每天都有越来越多基于Android的应用发布,各种新类型的独立网上应用商店也是一样。这些应用商店和谷歌操作的网上Android市场一起,将会在第18章进行学习。在第19章,我们将会分析Android在手机市场中的优势地位。

深入Dalvik VM

作为Android不可或缺的一部分,为了实现低耗能手持设备谷歌花费了大量的时间在思考如何优化设计。手持设备在内存和速度上落后于桌面类似设备8到10年。它们的电源也有很大的限制,根据计算,一个手持设备的总RAM大约仅有64MB,而可以用于应用的大约仅有20MB。

注意:2008年后期发布的T-Mobile G1 手机,有192MB的RAM,一张1GB的SD卡以及一个528MHz的Qualcomm MSM7201A处理器。摩托罗拉在2009年后期发布的Droid,有256MB的RAM,一张16GB的micro SD卡以及一个550MHz的Arm Cortex处理器。相比之下最便宜的戴尔笔记本,有2.1GHz 的dual-cure处理器以及4GB的RAM。

手机运行需要的条件十分苛刻,需要手机设计师把一切做到最优化。如果你看过Android的包列表,你会发现它们是功能完全的,可扩展的。根据谷歌的数据,即使是使用最优化的JVM,这些系统库还是会占去10到20MB的内存。

这个问题导致谷歌在很多方面都重新访问了标准JVM接口。首先,Dalvik VM获取产生的java class文件并将它们结合成1个或更多Dalvik 可执行文件(.dex结尾文件)。这个过程从多个class文件中复用完全相同的信息,与传统的从.jar文件中获取相比有效地减少了一半的内存需求。比如,Android中浏览器的.dex文件大约是200k,然而相同的未压缩的.jar版本大约是500k。闹钟app的.dex文件大约是50k,而.jar版本大约是它的两倍。

其次,谷歌调整好了Dalvik VM中的垃圾收集器,但它在早期版本中选择忽略了一个JIT编译器。2.0版本的代码库中似乎有JIT编译器所需的资源,但是在最终版本中这种资源未被激活。当时有人预测这将会是未来版本的功能之一。公司能够证明这个选择是正确的因为Android很多的核心库包括图形库都被c和c 实现了。比如,java图形API实际上是使用JNI的本机代码周围的薄包装器类。类似的,Android提供了一个优化的基于C的本地库来使用SQLite数据库,但是这个库在一个高级java API中被压缩了。由于大多数的核心代码是C和C ,谷歌解释道:JIT编译器的影响没那么严重。

最后,Dalvik VM使用的是一个不同类型的集成代码产生器,它使用寄存器作为数据存储的主要单位而不是栈。谷歌希望能够最终结果减少30%的指令。我们应该指出最终在Dalvik VM中,Android系统中的可执行代码并不是基于java字节代码,而是.dex文件。这意味着你不能直接执行java字节码,你必须从java class文件开始,将它们转化为可连接的.dex文件。

这种方式扩展到其他Android SDK中。例如,Android SDK 广泛地使用XML来定义UI布局。然而,在这些XML文件加载到设备之前都要编译成为二进制文件。Android提供了特殊的机制来使用XML数据。

Android与Java ME相比

正如你所见,Android已经采用了全面、专注、集中的方式来实现它的移动平台的功能,超越了简单的基于JVM的解决方案。Android平台在一个包中就包含了你需要的一切:操作系统、设备驱动、核心库、JNI、最好的Dalvik VM以及java开发环境。保证开发人员在开发一个新的应用的时候,设备上的所有关键库都可用。

这种全面的方式不同于其他移动平台,例如,Java ME。在开始比较这两种方式之前,我们先来看一下关于Java ME的简要说明。图1-4以java多方面的处理配置展示了java的实用性。Java SE是与桌面和工作站的配置相匹配的。Java EE是为服务器配置而设计的。Java ME则是为适应小型设备而削弱的java版本。Java ME可以用两种配置。第一种配置被称为CDC(Connected Device Configuration)。Java ME中的CDC包含一个削弱版本的Java SE,其中只包含了很少的包,这些包中也只有很少的类,在这些类中,甚至连域和方法都很少。为了更进一步受限制的应用和设备,java定义了一个被称为CLDC(Connected Limited Device Configuration)的配置。对于不同的java参数可用的API在图1-5中做了对比。

安装在基础CDC和CLDC API顶部的任何可选择包被当做是使用JSR程序的标准的档案。每一个定义的档案都有一个额外的API供开发者使用。

注意:CLDC和CDC都可能支持一些Java SE之外的java API,而且它们的类名可能不是以java.*开头的。作为一个推论:如果你的一个java程序能够在桌面运行,但是不能保证它能够在只支持micro editions的设备上运行。

CLDC java平台被放置在一个专门的、被极大削减的JVM上,这个JVM被称为KVM(the

K Virtual Machine),它能够在一个内存仅有128k的设备上运行。ClDC能够运行MIDP(Mobile Information Device Profile)2.0下额外的API。这个API包含了很多javax.microedition.*下的包。其中主要的包是MIDlets,一个被称为“LCDUI”的UI包,游戏和多媒体。

CDC配置API在CLDC配置API的基础上增加了包括java.awt API ,java.net API,以及更多的安全API。在CDC顶部的额外档案可用使得编程人员可以使用javax.microedition.xlet API(Xlets代表应用在CDC中的参数)。在一个CDC参数顶部,你会发现你可以运行10个以上可选择包,包括蓝牙、多媒体API、嵌入式系统OpenGL(OpenGL ES) ,JAXP(java API for XML Processing)、JAXP-RPC、Java 2D、Swing、Java RMI(java Remote Method Invocation)、JDBC(java Data

剩余内容已隐藏,支付完成后下载完整资料


资料编号:[140554],资料为PDF文档或Word文档,PDF文档可免费转换为Word

您需要先支付 30元 才能查看全部内容!立即支付

课题毕业论文、外文翻译、任务书、文献综述、开题报告、程序设计、图纸设计等资料可联系客服协助查找。