




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、外 文 翻 译原文来源 android a programmers guide中文翻译 安卓程序员指南 androida programmers guidej.f. dimarzionew york chicago san franciscolisbon london madrid mexico citymilan new delhi san juanseoul singapore sydney torontoabout the authorj.f. dimarzio is a developer with over 15 years ofexperience in networking an
2、d application developmentand is the author of seven books on computing technologies.he has become a leading resource in the fields of itconsulting and development. he lives in central florida.about the technical editorgilbert l. polo is a software developer with over 20years of experience working in
3、 the telecommunications,financial, and, most recently, educational industries. hehas programmed in various languages including c, c+,java, and c#.chapter1what is android?key skills & conceptsl history of embedded device programmingl explanation of open handset alliancel first look at the android hom
4、e 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 c
5、reate 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
6、 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.notei refer to two different k
7、inds 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 th
8、e 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, android.brief history of embedded device programming
9、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 desktopand later webdevelopment, embedded device development typically got the proverbial short end of the stick as far as
10、 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 wit
11、h 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 chi
12、p 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
13、 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 consume
14、r 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
15、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 bra
16、nching is evident when you examine their architecture.nearly since their inception, cell phones have been fringe devices insofar as they run on proprietary softwaresoftware that is owned and controlled by the manufacturer, and is almost always considered to be a “closed” system. the practice of manu
17、facturers 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
18、 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 o
19、f 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 wh
20、ich it was to run. the solution was to purchase expensive development tools directly from the manufacturer. this isolated many of the “homebrew” developers.notea growing culture of homebrew developers has embraced cell phone application development. the term “homebrew” refers to the fact that these
21、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 hardware manufacturers solution to the “memor
22、y versus need” dilemma. until recently, cell phones did little more than execute and receive phone calls, track your contacts, and possibly send and receive short text messages; not really the “swiss army knives” of technology they are today. even as late as 2002, cell phones with cameras were not c
23、ommonly found in the hands of consumers.by 1997, small applications such as calculators and games (tetris, for example) crept their way onto cell phones, but the overwhelming function was still that of a phone dialer itself. cell phones had not yet become the multiuse, multifunction personal tools t
24、hey are today. no one yet saw the need for internet browsing, mp3 playing, or any of the multitudes of functions we are accustomed to using today. it is possible that the cell phone manufacturers of 1997 did not fully perceive the need consumers would have for an all-in-one device. however, even if
25、the need was present, a lack of device memory and storage capacity was an even bigger obstacle to overcome. more people may have wanted their devices to be all-in-one tools, but manufacturers still had to climb the memory hurdle.to put the problem simply, it takes memory to store and run application
26、s on any device, cell phones included. cell phones, as a device, until recently did not have the amount of memory available to them that would facilitate the inclusion of “extra” programs. within the last two years, the price of memory has reached very low levels.device manufacturers now have the ab
27、ility to include more memory at lower prices. many cell phones now have more standard memory than the average pc had in the mid-1990s. so, now that we have the need, and the memory, we can all jump in and develop cool applications for cell phones around the world, right? not exactly.device manufactu
28、rers still closely guard the operating systems that run on their devices. while a few have opened up to the point where they will allow some java-based applications to run within a small environment on the phone, many do not allow this. even the systems that do allow some java apps to run do not all
29、ow the kind of access to the “core” system that standard desktop developers are accustomed to having.open handset alliance and androidthis barrier to application development began to crumble in november of 2007 when google, under the open handset alliance, released android. the open handset alliance
30、 is a group of hardware and software developers, including google, ntt docomo, sprint nextel, and htc, whose goal is to create a more open cell phone environment.the first product to be released under the alliance is the mobile device operating system, android. (for more information about the open h
31、andset alliance, see.) with the release of android, google made available a host of development tools and tutorials to aid would-be developers onto the new system. help files, the platform software development kit (sdk), and even a developers community can be found at googles android website, this s
32、ite should be your starting point, and i highly encourage you to visit the site.notegoogle, in promoting the new android operating system, even went as far as to create a $10 million contest looking for new and exciting android applications.while cell phones running linux, windows, and even palmos a
33、re easy to find, as of this writing, no hardware platforms have been announced for android to run on. htc, lgelectronics, motorola, and samsung are members of the open handset alliance, under which android has been released, so we can only hope that they have plans for a few android-based devices in
34、 the near future. with its release in november 2007, the system itself is still in a software-only beta. this is good news for developers because it gives us a rare advance look at a future system and a chance to begin developing applications that will run as soon as the hardware is released. noteth
35、is strategy clearly gives the open handset alliance a big advantage over other cell phone operating system developers, because there could be an uncountable number of applications available immediately for the first devices released to run android.introduction to androidandroid, as a system, is a ja
36、va-based operating system that runs on the linux 2.6 kernel. the system is very lightweight and full featured. figure 1-1 shows the unmodified android home screen.figure 1-1 the current android home screen as seen on the android emulatorandroid applications are developed using java and can be ported
37、 rather easily to the new platform. if you have not yet downloaded java or are unsure about which version you need, i detail the installation of the development environment in chapter 2. other features of android include an accelerated 3-d graphics engine (based on hardware support), database suppor
38、t powered by sqlite, and an integrated web browser.if you are familiar with java programming or are an oop developer of any sort, you are likely used to programmatic user interface (ui) developmentthat is, ui placement which is handled directly within the program code. android, while recognizing and
39、 allowing for programmatic ui development, also supports the newer, xml-based ui layout. xmlui layout is a fairly new concept to the average desktop developer. i will cover both the xml ui layout and the programmatic ui development in the supporting chapters of this book.one of the more exciting and
40、 compelling features of android is that, because of its architecture, third-party applicationsincluding those that are “home grown”are executed with the same system priority as those that are bundled with the core system.this is a major departure from most systems, which give embedded system apps a
41、greater execution priority than the thread priority available to apps created by third-party developers. also, each application is executed within its own thread using a very lightweight virtual machine.aside from the very generous sdk and the well-formed libraries that are available to us to develo
42、p with, the most exciting feature for android developers is that we now have access to anything the operating system has access to. in other words, if you want to create an application that dials the phone, you have access to the phones dialer; if you want to create an application that utilizes the
43、phones internal gps (if equipped), you have access to it. the potential for developers to create dynamic and intriguing applications is now wide open.on top of all the features that are available from the android side of the equation, google has thrown in some very tantalizing features of its own. d
44、evelopers of android applications will be able to tie their applications into existing google offerings such as google maps and the omnipresent google search. suppose you want to write an application that pulls up a google map of where an incoming call is emanating from, or you want to be able to st
45、ore common search results with your contacts; the doors of possibility have been flung wide open with android. ask the expert q: what is the difference between google and the open handset alliance?a: google is a member of the open handset alliance. google, after purchasing the original developer of
46、android, released the operating system under the open handset alliance.q: is android capable of running any linux software?a: not necessarily. while i am sure that there will be ways to get around most any open source system, applications need to be compiled using the android sdk to run on android.
47、the main reason for this is that android applications execute files in a specific format; this will be discussed in later chapters.reference:1hello android. introducing googles mobile developmeng platform 3rd.edition,ed burnette,the pragmatic bookshelf2the.android.developers.cookbook building applic
48、ations with the android sdk,james steele nelson,addison-wesley3 pro android media. developing graphics,music,video and rich media apps for smartphones and tablets,shawn van every,apress4 professional.android.2.application.development.(wrox,.2010,.0470565527)程序员指南原著:j.f.dimarzio翻译:张劲锋关于作者:j.f.dimarzi
49、o是一个在网络和程序开发领域拥有超过15年经验的程序开发员并且是7本关于计算机科学书籍的作者。他已经成为it界顾问和发展的领导人物。他住在centralflorida.关于技术编辑:gilbertl.polo是一个在电信,财政,最近最多是教育机构工作上拥有超过20年经验的程序开发员。他已经用多种语言(包括c,c+,java和c#)项目编程。第一章 什么是 android?关键技术&概念l 嵌入式设备编程项目历史l 解释开放手机联盟l 第一次观看android主屏幕-能够说,传统的桌面应用程序开发者已经很受宠了。这不是说传统桌面应用程序开发比其他形式的开发更简单。然而,作为一个传统桌面应用程序开
50、发者,我们已经有创建所有我们能够想象的任何一种应用程序的能力。我也指包括我在内,因为我以前就开始桌面项目开发。一方面,我们已经有能力去和桌面操作系统互动已经使桌面编程开发更易接受,这样的互动是和任何底层的硬件的。相当自由(或者至少有很小的例外)。这种自由、独立地编程,已经不再是那些敢于冒险跳进手机开发黑水中的小数量的开发者能够获得的。注意:-在这个讨论中我提及到了两种不同的开发者:传统桌面应用程序开发者,他们几乎用所有的编程语言来工作,他们的最终产品、应用程序被构建成能运行在任何一种桌面操作系统上;android开发者(java开发者),为android平台开发。这不是有意图说哪一种开发者在某
51、种意义上比另一种更好或者更坏。然而,这个讨论意图在于:桌面操作系统环境和移动操作系统环境android的开发形式和开发工具的比较。简短的嵌入式设备开发历史很长一段时间,手机开发者构成了一个认作是嵌入式设备开发者的小的稍微大点的派别。理解成一个小的具有魅力的桌面家族成员-后来的网络web-开发,嵌入式设备开发代表性地得到闻名的短的结局,远至硬件和操作系统特色,因为嵌入式设备制造业在特色支持方面恶名昭彰地吝啬。嵌入式设备制造厂商典型地需要封闭地保护他们硬件的机密,因此,当嵌入式设备开发者试着去与特殊的设备互动时嵌入式设备制造厂商给他们很少的函数库去调用。嵌入式设备不同于桌面系统是一个嵌入式设备是一
52、个典型的“片上计算机”。例如:考虑你的标准电视机的远程控制。它不是真正看上去像一个无法实现的复杂技术的实现。当任何一个按钮按下,芯片以一种方法解释信号(已经编程嵌入到设备中)。这允许设备从输入设备(键盘)知道用户期望干什么,和如何对这些命令响应(例如,打开电视机)。这是一个来自嵌入式设备的编程例子。然而,信或不信,诸如这些简单的设备被明确涉及到早期手机设备和开发的根源。大多数嵌入式设备运行(在一些情况仍然运行)在专有的操作系统上。选择创建一个专有的操作系统而不是使用任何消费者系统的理由是:这是一个产品正真必需的。简单的设备不需要很耐用、完善的操作系统。作为一种设备产品的发展,大约2年前左右,许
53、多复杂的嵌入式设备,例如早期的pdas,家庭安全系统,和和gpss,被移植到有点标准化的操作系统平台上。小体积的操作系统如linux,或甚至嵌入式版本的microsoftwindows,已经是在许多嵌入式设备上很流行了。围绕这个时间段的设备发展,手机从其他的嵌入式设备分支成他们己的路线。当你查看他们的业绩时,这个分支显得很明显。几乎从他们起初,当运行专有的软件(被制造厂商拥有和控制,几乎也总是被考虑是“封闭”系统)时,手机就已经成为终端设备的范围内。制造厂商使用专有的操作系统的实践开始比其他任何理由更加不必要。这是因为手机制造商代表性的使用完全在内部开发出的硬件。或至少硬件是为运行手机设备特别
54、开发出来的,结果,这些硬件、专有系统不是开发地可获得的,空架的软件包,或者解答(这些都是能够确切与他们硬件互动的)。自制造商想更可靠地保护他们的硬件交易机密(通过允许接近设备软件水平可以显露出来),通常的实践是(在多数情况下仍然是)通过完全专用的和封闭的软件来运行他们的设备。接下来就是,任何想为手机开发能够在上面运行的应用程序的人不得不去揭秘专有系统环境。解决方法是直接向制造商购买昂贵的开发工具。这孤立了很多“业余爱好”的开发者们。注意:-一种成长的业余爱好开发者文化已经拥抱着手机应用程序开发。“业余爱好者”队伍事实涉及到了那些具有代表性的、不是为手机开发公司工作的开发者和普遍地小生产,利用他
55、们自己时间开发产品的人。其他的,更多强制的“必需品”是硬件制造商对于“内存对照需求”困境的解答(这使天天进行手机开发的开发者难以入手)。直到最近,手机不是比实现多一点点,接收电话,跟踪你的联系,并且可能的发送和接收文本短信;当今他们不是真正的“瑞士军刀”技术。甚至迟到2002年,带有照相机的手机在消费者的手上一般的也没有见到。到1997年,小应用程序例如计算器和游戏(俄罗斯方块,举例)缓慢地在手机上爬行他们的发展路线,但是这些无法实现的功能仍然是电话拨号程序本身。手机还没有成为今天它们的多样的,多功能的个人工具。这是可能的,1997年,手机制造商完全没有意识到消费者需求是所有功能集聚一个设备上
56、。不过,即使这个需求是目前的,设备的内存缺乏,存储能力是一个更大的要去克服的障碍。更多的人可能已经想过他们的设备变成聚集所有功能为一身的工具,但是制造商仍然不得不攀爬内存障碍。为了使问题简单,这使得任何设备上让内存去存储和运行应用程序,包括手机。手机,作为一种设备,直到最近都还没有使手机容易包含额外程序的大量内存。在最近两年里,内存价格已经达到很低的水平了。设备制造商现在有能力以更低的价格包含更多的内存。现在很多手机拥有比1990世纪中期普通pc机更标准的内存。因此,现在我们有了需要、内存,我们可以深入,并且在世界范围里为手机开发酷的应用程序,对不?不是确切的。设备制造商仍然封闭地保护运行在他
57、们设备上的操作系统。而一些对这一点已经开放,他们允许一些以java为基础的应用程序在手机上的小环境里运行,许多的都不允许这样做。甚至某些不允许运行一些java应用程序的系统不允许接近标准桌面开发者习惯去拥有的核心系统。开放手机联盟和 android在2007年11月,当google,在开放手机联盟下,发布android,这个对于应用程序开发者的障开始消失。开放手机联盟是一个硬件和软件开发者组织,它包 括 google 、ntt docomo ,sprint nextel, 和 htc,它的目标是创建一个更 开放的手机环境。在开放手机联盟组织下发布的第一个产品是android-移动设备操作系统。(获得更多关于开放手机联盟的信息,登陆)和android发行一起,google开发了可获得的主要开发工具和指南去帮助要成为新系统开发者的人。帮助文档、平台软件开发包(sdk)和甚至在google的android网站上能被找到的一个开发者社区,注意:-google,为促进新的android操作系统,甚至开始了举办了一个1000万的竞赛,寻求新的、令人兴奋地android应用程序。而运行在linux、windows、甚至palmos上的手机能轻易找到,到写这书为止,没有硬件平台被宣布专
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 市政工程专项施工方案
- 河道引流的施工方案
- 被动网施工方案
- 硬岩竖井施工方案
- 格栅幕墙施工方案
- 二零二五年度债权债务资产保全执行合同
- 2025年度离婚财产分割及子女成长环境优化协议书
- 二零二五年度美容仪器加盟保证金及售后服务合同
- 2025年度跨境电商平台员工劳动合同解除书
- 二零二五年度公益歌曲委托创作与宣传推广合同
- 川教版四年级《生命.生态.安全》下册全册 课件
- 专题06 无机物的转化与应用-五年(2020-2024)高考化学真题分类汇编(原卷版)
- 医院品管圈(QCC)活动成果报告书-基于QFD 润心服务改善 ICU 患者及家属就医体验
- TFT-LCD显示原理介绍
- 2024年中国心力衰竭诊断和治疗指南2024版
- 超龄员工用工免责协议书
- 摩托车过户委托别人代办的委托书
- 现代家政导论-课件 4.2.2国外家庭教育
- 金波读书乐课件
- 2《中国老年糖尿病诊疗指南(2024年版)》解读
- 国自科项目申报协议书模板
评论
0/150
提交评论