安卓:编程指南外文翻译资料

 2022-05-23 09:05

Android: A Programmerrsquo;s Guide

1 What Is Android

1.1 Key Skills amp; Concepts

● History of embedded device programming

● Explanation of Open Handset Alliance

● First look at the Android home screen

It can be said that, for a while, traditional desktop application developers have been spoiled. This is not to say that traditional desktop application development is easier than other forms of development. However, as traditional desktop application developers, we have had the ability to create almost any kind of application we can imagine. I am including myself in this grouping because I got my start in desktop programming.

One aspect that has made desktop programming more accessible is that we have had the ability to interact with the desktop operating system, and thus interact with any underlying hardware, pretty freely (or at least with minimal exceptions). This kind of freedom to program independently, however, has never really been available to the small group of programmers who dared to venture into the murky waters of cell phone development.

NOTE :I refer to two different kinds of developers in this discussion: traditional desktop application developers, who work in almost any language and whose end product, applications, are built to run on any “desktop” operating system; and Android developers, Java developers who develop for the Android platform. This is not for the purposes of saying one is by any means better or worse than the other. Rather, the distinction is made for purposes of comparing the development styles and tools of desktop operating system environments to the mobile operating system environment,

1.2 Brief History of Embedded Device Programming

For a long time, cell phone developers comprised a small sect of a slightly larger group of developers known as embedded device developers. Seen as a less “glamorous” sibling to desktop—and later web—development, embedded device development typically got the proverbial short end of the stick as far as hardware and operating system features, because embedded device manufacturers were notoriously stingy on feature support.

Embedded device manufacturers typically needed to guard their hardware secrets closely, so they gave embedded device developers few libraries to call when trying to interact with a specific device. Embedded devices differ from desktops in that an embedded device is typically a “computer on a chip.” For example, consider your standard television remote control; it is not really seen as an overwhelming achievement of technological complexity. When any button is pressed, a chip interprets the signal in a way that has been programmed into the device. This allows the device to know what to expect from the input device (key pad), and how to respond to those commands (for example, turn on the television). This is a simple form of embedded device programming. However, believe it or not, simple devices such as these are definitely related to the roots of early cell phone devices and development.

Most embedded devices ran (and in some cases still run) proprietary operating systems. The reason for choosing to create a proprietary operating system rather than use any consumer system was really a product of necessity. Simple devices did not need very robust and optimized operating systems.

As a product of device evolution, many of the more complex embedded devices, such as early PDAs, household security systems, and GPSs, moved to somewhat standardized operating system platforms about five years ago. Small-footprint operating systems such as Linux, or even an embedded version of Microsoft Windows, have become more prevalent on many embedded devices. Around this time in device evolution, cell phones branched from other embedded devices onto their own path. This branching is evident when you examine their architecture.

Nearly since their inception, cell phones have been fringe devices insofar as they run on proprietary software—software that is owned and controlled by the manufacturer, and is almost always considered to be a “closed” system. The practice of manufacturers using proprietary operating systems began more out of necessity than any other reason. That is, cell phone manufacturers typically used hardware that was completely developed in-house, or at least hardware that was specifically developed for the purposes of running cell phone equipment. As a result, there were no openly available, off-the-shelf software packages or solutions that would reliably interact with their hardware. Since the manufacturers also wanted to guard very closely their hardware trade secrets, some of which could be revealed by allowing access to the software level of the device, the common practice was, and in most cases still is, to use completely proprietary and closed software to run their devices. The downside to this is that anyone who wanted to develop applications for cell phones needed to have intimate knowledge of the proprietary environment within which it was to run. The solution was to purchase expensive development tools directly from the manufacturer. This isolated many of the “homebrew” developers.

NOTE:A growing culture of homebrew developers has embraced cell phone application development. The term “homebrew” refers to the fact that these developers typically do not work for a cell phone development company and generally produce small, one-off products on their own time.

Another, more compelling “necessity” that kept cell phone development out of the hands of the everyday developer was the hard

全文共18997字,剩余内容已隐藏,支付完成后下载完整资料


安卓:编程指南

1 什么是安卓

1.1 主要技能和思想

● 嵌入式设备编程的历史

● 开放式手机联盟解读

● 第一眼看到Android的主屏幕

可以这么说,暂时,传统的桌面开发者已经被宠坏了。这不是说传统的桌面应用程序开发比其他形式开发更简单。然而,作为一个传统的桌面应用开发者,凡是我们能想像到的各种应用程序,我们就一定要有能力去创造。包括我自己,因为我也是从做桌面编程开始的。

使桌面编程更容易访问的一个方面是,我们已经能够与桌面操作系统交互,从而可以自由地与底层硬件交互(至少很少有例外)。然而,这种独立编程的自由却从未真正被那些敢于冒险进入手机开发领域的程序员所利用。

注:在讨论中,我提到两种不同的开发人员:传统的桌面应用程序开发人员,他们几乎在任何语言中工作,其最终产品、应用程序都是建立在任何“桌面”操作系统上运行的;Android 开发人员和Java 开发人员都是为了Android平台开发的。这并不是为了说一种方法比另一种更好或更糟。相反,这是为了将桌面操作系统环境的开发风格和工具与移动操作系统环境进行比较的目的。

1.2 嵌入式设备编程简史

很长一段时间,手机开发者都是由一组稍大一点的开发者组成的,即嵌入式设备开发人员。在桌面和后期的Web开发中,作为一个不那么“迷人”的兄弟,嵌入式设备开发通常在硬件和操作系统特性上都是众所周知的,因为嵌入式设备制造商在功能支持方面非常吝啬。

嵌入式设备制造商通常需要密切保护自己的硬件机密,所以在尝试与特定设备交互时,他们给嵌入式设备开发人员很少的调用库。嵌入式设备与台式机不同之处在于,嵌入式设备通常是“芯片上的计算机”,例如,考虑您的标准电视遥控器;它并不是真正被视为技术复杂性的压倒性成就。当按下任何按钮时,一个芯片以编程的方式对信号进行解释。这允许设备知道输入设备(键盘)的期望,以及如何响应这些命令(例如,打开电视)。这是嵌入式设备编程的一种简单形式。不管你信不信,像这样的简单设备绝对与早期手机设备和发展的根源有关。 大多数嵌入式设备运行(在某些情况下仍然运行)专有操作系统。选择创建一个专有操作系统而不是使用任何消费系统的原因实际上是必然的产物。简单的设备不需要非常健壮和优化的操作系统。

作为设备进化的产物,许多更复杂的嵌入式设备,如在五年前,早期的PDAs,家庭安全系统,和GPSs搬到有所规范的操作系统平台。小型操作系统,如Linux,甚至是微软Windows的嵌入式版本,在许多嵌入式设备上已经变得越来越普遍。大约在这个时候,手机在设备进化中从其他嵌入式设备分支到了自己的轨道上。在检查其体系结构时,这种分支是显而易见的。

自创立之初,手机就一直是边缘设备,因为它们运行在由制造商拥有和控制的专有软件上,几乎总是被认为是一个“封闭”的系统。制造商使用专有操作系统的实践更多地出于必要而不是出于其他原因。也就是说,手机制造商通常使用完全在内部开发的硬件,或者至少是专门为运行手机设备而开发的硬件。因此,没有公开可用的现成软件包或着可靠地与硬件进行交互的解决方案。由于制造商也希望密切监视他们的硬件商业秘密,其中一些可以通过允许访问设备的软件级来揭示,通常的做法是,在大多数情况下仍然是,使用完全专有的和封闭的软件来运行它们的设备。这方面的缺点是,任何想开发手机应用程序的人都需要对其运行的专有环境有一个很好的了解。解决方案是直接从制造商那里购买昂贵的开发工具。这个隔离了许多“自制”的开发商。

注:不断增长的自制开发文化包括了手机应用开发。注:不断增长的自制开发文化包括了手机应用开发。“自制”是指这些开发人员在他们自己的时间里,通常不为手机开发公司工作,以及产生小的一次性的产品。

另一个使手机开发脱离日常开发者手中的更引人注目的“必要性”是硬件制造商解决“内存与需求”两难的问题。直到最近,手机只不过是执行和接收电话,跟踪联系人,可能发送和接收短信息,而不是今天“瑞士军刀”的技术。即使在2002年底,消费者手中也不常有带相机的手机。

直到1997,小应用程序如计算器和游戏(例如,俄罗斯方块)悄悄进入手机,但压倒一切的功能仍然是电话拨号器本身。手机还没有成为今天的多用途、多功能的工具。现在还没有人看到需要上网浏览,MP3播放,或任何我们今天习惯使用的功能。有可能1997的手机制造商没有完全意识到消费者对多功能设备的需求。然而,即使需要存在,设备存储器和存储容量的缺乏仍然是一个更大的障碍。越来越多的人可能希望他们的设备成为一个整体的工具,但制造商仍然不得不超越记忆障碍。

为了简单地解决这个问题,它需要内存来存储和运行任何设备上的应用程序,包括手机。手机,作为一种设备,直到最近还没有足够的可用内存,这将有助于列入“额外”的程序。在过去的两年里,内存的价格已经降到了很低的水平。设备制造商现在有能力以更低的价格存储更多的内存。现在许多手机的标准内存比上世纪90年代中期的普通电脑要多,所以,现在我们有了需要和内存,我们都可以跳进去,为全球手机开发的酷的应用程序,对吗?不完全。

设备制造商仍然密切监视运行在它们设备上的操作系统。而一些已经打开了的地步,他们将允许一些基于java的应用程序运行在手机上的一个小环境,很多都不允许这样做。即使是允许一些java程序运行的系统也不允许以标准的桌面开发人员习惯于那种途径进入“核心”系统。

1.3 开放式手机联盟和安卓系统

应用程序开发的这一障碍在2007十一月开始崩溃,当时谷歌在开放手机联盟发布了安卓系统。开放手机联盟是一组硬件和软件开发商,包括谷歌、NTT DoCoMo、Sprint Nextel和HTC,其目标是创建一个更开放的手机环境。手机联盟发布的第一个产品是移动设备操作系统Android。(关于开放手机联盟的更多信息见www.openhandsetalliance .com。)

随着Android的发布,谷歌提供了大量的开发工具和教程,以帮助潜在的开发人员进入新系统。帮助文件,该平台的软件开发工具包(SDK),甚至一个开发者社区可以在谷歌的Android网站被发现,http://code.google.com/android。这个网站应该是你的出发点,我强烈鼓励你访问这个网站。

注:谷歌在推广新的Android操作系统方面,甚至创造了价值1000万美元的寻找新的和令人兴奋的Android应用程序的竞争。

而手机运行Linux,Windows,甚至PalmOS都很容易找到,在撰写本文时,没有硬件平台已经宣布Android上运行。HTC、LG电子、摩托罗拉和三星都是开放式手机联盟的成员,在安卓系统已经发布的背景下,所以我们只能希望他们在不久的将来有几个安卓设备的计划。随着2007年11月发布,该系统本身仍然是软件测试版。这对开发人员来说是一个好消息,因为它让我们对未来的系统有了一个初步的了解,并有机会开始开发在硬件发布后运行的应用程序。

注意:这种策略显然使开放式手机联盟比其他手机操作系统开发人员具有很大的优势,因为可以立即为运行Android的第一台设备提供数量不尽的应用程序。

介绍Android

Android作为一个系统,是一个基于java的操作系统上运行的Linux 2.6内核。该系统非常轻巧,功能齐全。Android应用程序是用java开发的和可以很容易地移植到新的平台。如果你还没有下载java或者不确定你需要哪个版本,我将在2章详细的开发环境的安装。Android的其他功能还包括一个加速的三维图形引擎(基于硬件支持),采用SQLite数据库支持,和一个集成的Web浏览器。

如果你是熟悉java编程或是任何一种面向对象的开发人员,你可能过去曾做编程用户界面(UI)开发,那就是UI布局直接处理程序内的代码。Android在承认和允许编程UI开发的同时,也支持更新的基于XML的UI布局。对于一般的桌面开发人员来说,XML UI布局是一个相当新的概念。在本书的支持章节中,我将介绍XML UI布局和编程用户界面开发。

Android的一个更令人兴奋和吸引人的特点是,由于它的体系结构,第三方应用程序,包括那些“土生土长”的应用程序,与那些与核心系统捆绑的应用程序具有相同的系统优先级。这是与大多数系统的主要区别,这给嵌入式系统应用程序带来了比第三方开发者创建的线程优先级更高的执行优先级。此外,每个应用程序都使用一个非常轻量级的虚拟机在其自己的线程中执行。

除了我们可以开发的非常慷慨的SDK和完善的库之外,Android开发者最激动人心的特性是我们现在可以访问操作系统所能访问的任何东西。换句话说,如果你想创建一个应用程序拨打电话,您可以访问手机的拨号;如果你想创建一个应用程序,利用手机内置的GPS系统(如果装备),你可以访问它。开发人员创建动态的、有趣的应用程序的潜力现在已经打开了。

在上面的所有功能,可从Android的方程中获取,谷歌已经抛出一些非常诱人的自身特点。Android应用程序的开发人员将能够将他们的应用程序绑定到现有的谷歌产品中,例如谷歌地图和无所不在的谷歌搜索。假设你想写一个应用程序,它会提取一个谷歌地图,说明你的来电是从哪里来的,或者你想用你的联系人来存储常见的搜索结果。

第2章开始你的Android开发之旅。你将学习如何和为什么的使用特定的开发环境或集成开发环境(IDE),你会下载并安装java IDE Eclipse。

2 Android应用: 你好,世界

2.1 主要技能和概念

● 创建新的Android项目

● 视图的使用

● 使用 Text View

● 修改 the main.xml 文件

● 在Android模拟器上运行应用程序

在本章中,您将创建您的第一个Android活动。本章从开始到结束检查应用程序构建过程。我将向您展示如何在Eclipse中创建一个Android项目,向初始文件添加代码,并在Android模拟器中运行已完成的应用程序。生成的应用程序将是一个运行在Android环境中的功能完备的程序。

实际上,当您通过本章时,您将创建一个以上的Android活动。计算机编程传统决定了你的第一个应用程序是典型的Hello World!应用程序,所以在第一部分中,您将创建一个标准的Hello World!应用程序只是一个空白的背景和“Hello World”!“文本。然后,为了让您更好地了解该语言,下一节将详细讲解android为您的Hello World自动创建的文件!应用。您将创建此活动的两个迭代,每个迭代使用不同的技术将信息显示到屏幕上。您还将创建一个Hello World的两个不同版本!应用程序将显示一个提供“Hello World”的图像!“消息。这将让你很好地介绍Android的控制和内部工作。

注:您经常会看到“应用程序”和“活动”交替使用。两者之间的区别在于应用程序可以由多个活动组成,但是一个应用程序必须至少有一个活动。应用程序的每个“窗口”或屏幕都是单独的活动。因此,如果您创建一个相当简单的应用程序,只有一个数据屏幕(如Hello World),这将是一项活动。在以后的章节中,您将创建具有多种活动的应用程序。

为了确保您全面了解Android编程,在第6章中,您将在微软Windows和Linux的SDK命令行环境中创建这两个应用程序。换句话说,本章将介绍Eclipse中的创建过程,第6章将使用命令行工具覆盖创建过程。因此,在继续之前,您应该检查您的Eclipse环境是否正确配置。回顾第3章中为Android SDK设置路径声明的步骤。您还应该确保JRE是正确的在你的路径语句。

提示:如果您在尝试使用任何命令行示例时都有与配置相关的问题,请参考第2章和第3章中的配置步骤,并查看Android SDK文档。

原文和译文剩余内容已隐藏,您需要先支付 30元 才能查看原文和译文全部内容!立即支付

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