Android:一个程序员的入门书外文翻译资料

 2022-07-11 03:07

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 devel

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


Android:一个程序员的入门书

1 什么是Android

1.1 主要技巧和思想

● 历史的嵌入式器件编程

● 开放手机联盟的解释

● 第一眼看到Android的主屏幕

可以这么说,暂时,传统的桌面应用程序开发者已经被惯坏了。这个不是说桌面应用程序开发比其他形式的开发很简单。总之,作为传统的桌面应用程序开发者,我们必须有能力创造出各种应用程序凡是我们能想象到的。包括我自己,因为我也是从做桌面程序开始的。

一方面已经使得桌面程序更容易理解就是我们已经有能力去跟桌面操作系统相互作用,因此,任何底部的硬件很自由的相互作用。这种类型独立自主的程序编制,然而,对于很小的开发者团体来说是不敢冒险的去搞手机发展这样浑浊的技术的。

注解:我提到两种不同的开发商在此讨论:传统的桌面应用程序开发,他们能在任何语言环境下工作,而且最终的产品和程序是用来运行“桌面”操作系统的;还有Android程序开发者,那些开发Android平台开发工具的JAVA程序开发人员。这不是说跟其他人比起来谁好谁坏。其实,区别目的仅仅在于想说明并比较Android桌面操作系统环境的开发风格,工具。

1.2 嵌入式器件编程的简要历史

有很长一段时间,手机的开发者由大的著名嵌入式的开发团队中的少数人组成,作为嵌入式设备的开发者。相对于桌面开发或者后续的网络开发,被视作更少“魅力”,而且嵌入式设备的开发通常因为硬件和操作系统而处于劣势。因为嵌入式设备的制造商们太小气,他们要保护他们硬件方面的秘密,所以他们给开发者们非常有限的库去运行当他们尝试去让一些特定的设备去相互作用。

嵌入设备与桌面系统显著不同的一部分是嵌入设备是个有特色的“芯片上的电脑”。例如:考虑你的标准电话遥控。这个并不是一个非常强大并且复杂性的技术。当任何的按钮被按下去,一个芯片解释一个信号以一种方式已经被编程进了这个设备。这个允许设备知道什么是从输入设备(键盘)来的需要。并且如何的响应这些命令(比如,打开电视机)。这个是一个简单的嵌入式设备的编程。总之,不管你相不相信,像这样的简单设备绝对的和早期的手机设备开发的根源有着紧密的联系。

大多数的嵌入式设备运行(有些仍然还在运行)在私有的操作系统。原因是选择创建一个私有的操作系统而不是用任何消费系统是产品的需要。简单的设备不需要非常健全和优化的操作系统。

作为一个产品的演化,更多复杂的嵌入式设备,如早期的PDA,家庭安全系统和GPS等。5年前某种程度上都转移标准的操作系统平台上。小的操作系统如Linux,甚至一个微软版本的嵌入式平台,已经在嵌入设备上变得普遍了。设备改革的这段时间里,手机从其他嵌入式设备中分支出去。走上了自己的轨道,这个分支是显而易见的当你去调查他们的体系结构。

在他们最初开始的时候,手机作为一个外围设备并且运行私有软件,而这些软件被制造商们所拥有和控制,而且几乎可以被认为是一个“关闭”的系统。习惯使用私有操作系统主要是制造商自己开发硬件,或者至少定义了开发的目的只是用来运行手机。最终的结果就是使开放成为不可能。现有的软件包或者解决方案会可靠的和他们的硬件交互。而且,制造商想要保护他们硬件的商业秘密。以防允许进入而发现设备软件的水准。所以风尚就是,而且大多数仍然是使用完全私有并且关闭的软件来运行他们的设备。任何人想为手机开发程序必须需要详尽的私有环境来运行软件的知识。而解决方案就是直接从制造商那里购买昂贵的开发工具。这就孤立了很多的“自制软件”的开发者。

注解:一个关于自制软件开发的文化包含了手机程序的开发。“自制软件”是指开发者通常不是工作在手机开发公司内,通常利用自己的时间在他们的设备上生产小的,一次性的产品。

另外,使手机开发无法出手的是硬件制造商对于“内存和需要”左右为难的解决方案。直到最近,手机才能执行比打出和接听电话,查找联系人,发送和接收短消息。不是今天“瑞士军刀”的技术。及时在2002年,在消费者的手上,带照相机的手机还是不多见。在1997年,小的应用程序如计算器和游戏爬进了手机内,但是强大的功能仍然是手机的拨号盘本身。手机还不想今天一样是一个多用途,多功能工具。没有人预见互联网浏览的需求,MP3播放,或者更多的是我们今天定制的功能。在1997年,手机制造商们没有预见消费者需要的是一个一体化的设备。但是,即使这个需求展现出来,设备内存和存储容量还是一个需要克服的大的障碍。更多的人可能想要他们的设备是一个多功能一体化的工具,但是制造商们不许跨越他们的障碍。

让问题变得简单,就要在任何的设备让内存来存储并运行程序,包括手机。手机作为一个设备,直到最近还没有足够多内存来执行“额外”的程序。在最近的两年里,内存的价格已经达到了非常低的水平。设备制造商们有足够的能力压低价格来包含更多的内存。很多的现在的手机标准内存已经超过了90年代中期电脑内存。于是,现在我们有需求,而且有内存。我们可以直接跳到为手机开发酷的应用程序了,对吗?不完全是这样。设备的制造商们仍然紧密的保护他们的操作系统。有一些在手机上开放JAVA为基础的小运行环境。更多的是不允许。即使允许运行JAVA应用程序但还是不允许进入核心的系统。而这些是桌面开发者习惯于拥有的。

1.3 开放手机联盟和Android

这个对于应用程序开发的障碍开始在2007年的11月份被打破,当Google在开放手机联盟下发布Android。开放手机联盟是一个硬件和软件开发者的集合,包括谷歌,NTT DoCoMo, Sprint Nextel和HTC。他们的目标是创建一个更多的开放手机环境。在开放联盟第一个被发布的产品就是移动设备操作系统Android。(更多关于开放手机联盟的信息,见:www.openhandsetalliance.com)。

对于这个Android的发布,谷歌使很多开发工具和向导成为可能来帮助在新

系统上可能的开发者。帮助系统,平台软件开发包(SDK),甚至一个开发者的论坛,可以在谷歌的Android的网站上找到,http://code.google.com/android.这个网站应该是你的起点,而且我极度推荐你去访问。

注解:谷歌为了推动这个新的Android操作系统,甚至为寻找新的Android程序而设立了1000万美元的奖金。

当手机运行Linux, Windows或者即使Palm OS的手机是很容易找到,如本文所述,没有硬件平台已经宣告可以来运行Android.HTC,LG电子,摩托罗拉和三星都是开发手机成员,在Android的发布下,我们希望在不久的将来有一些Android为基的设备。在2007年11月发布时,系统自身还仍旧是一个测试版的程序。这是个对开发者的好新闻因为它给了我们一个罕见的提前看到将来的设备和有机会来开始开发应用程序,而当硬件发布时就可以运行。

注解:这个策略明确的给了开放手机联盟一个大的优势,超越其它手机操作系统开发者。因为当第一代设备发布时会有数不尽的可用开发程序可以运行。

1.4 介绍Android

Android,作为一个系统,是一个运行在Linux2.6核心上的JAVA基础的操

作系统。系统是非常轻量型的而且全特性。

Android应用程序用JAVA开发而且很容易被放置到新的平台上。如果你没

有下载JAVA或者不确定那一个版本你需要,我在第二章详细列出了开发环境的

安装。其他Android的特点包括一个加速3-D图形引擎(基于硬件支持),被SQLite推动的数据库支持,和一个完整的网页浏览器。如果你熟悉JAVA编程或者是任何种类的OOP开发者,你可能使用程序用户接口(UI)开发-那就是,UI安置是直接在程序代码中有句柄的。Android,识别并许可UI开发,而且支持新生,XML为基础的UI布局。XMLUI布局对普通桌面开发者是一个非常新的概念。我会在本书的相关章节里描述XMLUI布局和程序化UI开发。

Android另一个更令人激动和关注的特点是因为它的样式,第三方应用程序---包括“自制的”---会和系统捆绑的有着同样的优先权。这是和大多数系统不同之处,但是给了嵌入式系统程序一个比由第三方开发者创建的线性优先权大的优先执行权。而且,每一个应用程序在虚拟计算机上以一个非常轻量的方式按照自己的线路执行。

除了大量的SDK和成型的类库可以用之外,对激动人心的特性对于Android的开发者来说是我们现在可以进入到操作系统可以进入的地方。也就是说,如果你要创建一个应用程序打一个电话,你已经进入到电话的拨号盘。加入你要创建一个应用程序来使用电话内部的GPS(如果安装了),你已经进入了。对于开发者创建动态和令人好奇的程序已经敞开大门。

Android的一些特征和上面这些可用的特点相同,谷歌已经非常迫切的奉送一些特性。Android的开发者可以将自己的应用程序和谷歌提供的如谷歌地图和无所不在的谷歌搜索绑在一起。假设你要写程序在谷歌地图上显示一个来电话者的的位置,或者你要储存一般的搜索结果到你的联系人中。在Android中,这个门已经完全打开。

2 应用程序:Hello World

2.1 主要技巧和思想

● 创建新的Android项目

● 用View工作

● 用一个TextView

● 修改main.xml文件

● 在Android虚拟机上运行一个应用程序

在这一章中,你将创建你的第一个Android活动,这一章从头到尾的检查应用程序的创建过程,我将给你们演示怎么去创建一个Android项目在Eclipese,在最初的文件里添加代码,并且在Android虚拟机上运行最终的应用程序,在Android环境下运行的最终结果的应用将是一个完全的功能项目

实际上,当你看到这一章,你将不止创建一个Android的活动,在计算机编程的传统规定中,你的第一个应用将是典型的Hello World!应用程序,所以在第一节的内容中你将创建一个标准的Hello World!应用程序,仅仅使用一个空白的背景和一个“Hello World!”文本。然后,为了让您更好的了解该语言,下一节详细的解释Android为了你的Hello World!应用程序自动的产生文件。在这个活动中你将创建两个重复的过程,每一个都是使用不同技术信息显示在屏幕上,而且你建创建两个不同版本的Hello World!应用程序将展示“Hello World!”信息的画面,这将给你一个很好的介绍关于Android的控制和内部的工作。

注解:你将经常看到“application”和“Activity”相互交换着应用,他们两个之间的不同就是应用程序可以有多个活动,但是一个应用程序必须至少有一个活动。你的应用程序的每一个窗口或者是屏幕就是一个分开的活动。因此,如果你创建了一个相当简单的应用程序仅仅使用了一个屏幕的数据(就像在这一章中的Hello World!应用程序),那就只有一个活动,在后来的章节里面你将创建许许多多的活动。

为了确保你可以完全很好的看到Android程序的整体,在第六章你将在Android软件开发包命令行编译在微软windows和Linux环境下同时创建这些应用程序。换句话说在这一章中包含了在Eclipse环境下创建项目的全过程。第六章也包含了利用命令行编译工具创建项目的

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


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

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

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