?
第一章 Hello,?Android
?
WHAT’S?IN?THIS?CHAPTER?
??A?background?to?mobile?application?development
??What?Android?is?(and?what?it?isn’t)
??An?introduction?to?the?Android?SDK?features
??What?devices?Android?runs?on
??Why?develop?for?mobile?and?Android?
??An?introduction?to?the?SDK?and?the?Android?development?framework
?
本章内容:
- ?移动应用开发背景
- ?Android是与不是
- ?介绍Android?SDK特性
- ?Android运行在什么设备上
- ?为什么为手机和Android开发?
- ?介绍SDK和Android开发框架
?
?
Whether?you’re?an?experienced?mobile?engineer,?a?desktop?or?web?developer,?or?a?complete
programming?novice ,?Android?represents?an?exciting?new?opportunity?to?write?innovative?applications?for?mobile?devices.
无论你是否是一个老练的手机工程师,一个桌面或Web程序员,或一个彻底的编程菜鸟,Android代表的是一个激动人心的为手机设备开发新应用的崭新机会。
?
Despite?the?name,?Android?will?not?help?you?create?an?unstoppable?army?of?emotionless?robot
warriors?on?a?relentless?quest?to?cleanse?the?earth?of?the?scourge?of?humanity.?
别管这个名字,Android不会帮你创造一直永不停息的没有感情的机器人战士军队来无情地消灭地球上的人类。
?
Instead,?Android?is?an?open-source?software?stack?that?includes?the?operating?system,?middleware,?and?key?mobile?applications?along?with?a?set?of?API?libraries?for?writing?mobile?applications?that?can?shape?the?look,?feel,?and?function?of?mobile?handsets.
相反,Android是一个开源软件包括了操作系统,中间件和关键的手机应用及一组用于开发视觉、感官和功能都符合手机硬件的手机应用移动的API库。
?
Small,?stylish,?and?versatile ,?modern?mobile?devices?have?become?powerful?tools?that?incorporate?cameras,?media?players,?GPS?systems,?and?touchscreens.?As?technology?has?evolved,?mobile?phones?have?become?about?more?than?simply?making?calls,?but?their?software?and?development?platforms?have?struggled?to?keep?pace.
小巧,时髦,功能种多,现代手机设备变为强大的工具,吸纳了照相机,多媒体,GSP?系统和触摸屏。随着技术的发展,手机变得不仅仅能打电话,但是他们的软件和开发平台的努力依旧缓步不前。
?
Until?recently,?mobile?phones?were?largely?closed?environments?built?on?highly?fragmented,?proprietary?operating?systems?that?required?proprietary?development?tools.?
直到最近,手机厂商很大程度上封闭地构造在高度分裂的环境上,操作系统和开发工具都是私有的。
?
The?phones?themselves?often?prioritized?native?applications?over?those?written?by?third?parties.?This?has?introduced?an?artificial?barrier?for?developers?hoping?to?build?on?increasingly?powerful?mobile?hardware.
手机厂商自己经常优先照顾自己的应用而非第三方应用。这种行为对开发者希望在手机硬件上构造强大的应用造成了一种人为的障碍。
?
In?Android,?native?and?third-party?applications?are?written?with?the?same?APIs?and?executed?on?the?same?run?time.?These?APIs?feature?hardware?sensor?access,?video?recording,?location-based?services,?support?for?background?services,?map-based?activities,?relational?databases,?inter-application?communication,?and?2D?and?3D?graphics.
在Android中,本地和第三方应用都是用相同的API开发在相同时间被执行。这些API以访问传感器硬件、视频记录、本地定位服务、支持后台服务、基于地图的Activity、关系数据库、应用互通信、2D和3D图形为特色。
?
Using?this?book,?you?will?learn?how?to?use?these?APIs?to?create?your?own?Android?applications.?In?this?chapter?you’ll?learn?some?mobile?development?guidelines?and?be?introduced?to?the?features?available?from?the?Android?development?platform.
使用本书,你将学习如何用这些API来创建你自己的Android应用。本章你将学习一些手机开发的指导方针并介绍Android开发平台的特征。
?
Android?has?powerful?APIs,?excellent?documentation,?a?thriving?developer?community,?and?no?development? or?distribution?costs.?As?mobile?devices?continue?to?increase?in?popularity,?this?is?an?exciting?opportunity?to?create?innovative?mobile?phone?applications?no?matter?what?your?development?experience.
Android有强大的API,卓越的文档,一个人气兴旺的开发者社区和免费的开发或发布环境。如果移动设备继续普及流行,无论你是否有开发经验都将是一个令人兴奋的开发新型手机应用的机会。
?
?
A?LITTLE?BACKGROUND
一个小背景
?
In?the?days?before?Twitter?and?Facebook,?when?Google?was?still?a?twinkle?in?its?founders’?eyes?and?dinosaurs?roamed?the?earth,?mobile?phones?were?just?that?—?portable?phones?small?enough?to?fit?inside?a?briefcase,?featuring?batteries?that?could?last?up?to?several?hours.?They?did?however?offer?the?freedom?to?make?calls?without?being?physically?connected?to?a?landline.
在Twitter和Fackbook之前,当谷歌仍然还在创始人的酝酿之中好比恐龙还漫步在地球上,手机还只是小得足够放在公文包里,特性电池最多用几个小时。可还是提供了不需要连接到通讯线路就能打电话的自由。
?
Increasingly?small,?stylish,?and?powerful?mobile?phones?are?now?as?ubiquitous?as?they?are?indispensable.?Hardware?advancements?have?made?mobiles?smaller?and?more?efficient?while?including?an?increasing?number?of?peripherals.
?
日益增长的小巧、时髦并功能强大的手机现在因其乃不可缺少之物而已无所不在。硬件的发展使得手机越来越小,加上了更多外围设备后也变得越发有用。
?
After?first?getting?cameras?and?media?players,?mobiles?now?include?GPS?systems,?accelerometers,?and?touch?screens.?While?these?hardware?innovations?should?prove?fertile?ground?for?software?development,?the?applications?available?for?mobile?phones?have?generally?lagged?behind?the?hardware.
在最早配备了照相机和多媒体后,手机现在加入了GPS系统,加速器和触摸屏。当这些新型的硬件能提供多样的软件开发的基础,有效的应用程序通常都可以支持底层的硬件。
?
The?Not-So-Distant?Past
不远的过去
?
Historically,?developers,?generally?coding?in?low-level?C?or?C++,?have?needed?to?understand?the?specific?hardware?they?were?coding?for,?generally?a?single?device?or?possibly?a?range?of?devices?from?a?single?manufacturer.?As?hardware?technology?and?mobile?Internet?access?has?advanced,?this?closed?approach?has?become?outmoded.
历史上,开发者,通常用底层的C或者C++开发,必须对他们理解面对的硬件,通常一个设备或可能是一个厂商的系列硬件。当硬件技术和手机访问因特网提速,这一切都过时了。
?
More?recently,?platforms?like?Symbian?have?been?created?to?provide?developers?with?a?wider?target?audience.These?systems?have?proven?more?successful?in?encouraging mobile??? developers?to?provide?richapplications?that?better?leverage?the?hardware?available.
最近,很多像Symbian这样的平台开始提供开发者一个宽广的目标客户。这些系统证明了通过更好的可用的硬件来提供富应用以激励手机开发者是成功的。
?
These?platforms?offer?some?access?to?the?device?hardware,?but?require?the?developer?to?write?complex?C/C++?code?and?make?heavy?use?of?proprietary?APIs?that?are?notoriously?difficult?to?work?with.?This?difficulty?is?amplified?for?applications?that?must?work?on?different?hardware?implementations?and?those?that?make?use?of?a?particular?hardware?feature,?like?GPS.
这些平台提供了一些访问硬件设备的渠道,丹需要开发者编写复杂的C/C++代码并大量使用众所周知难以驾驭的厂商的API。这些困难增加了应用程序运行在不同硬件上实现的难度,且要用到硬件的特性,比如GPS。
?
In?more?recent?years,?the?biggest?advance?in?mobile?phone?development?was?the?introduction?of?Java?hosted MIDlets.
更近几年,手机开发最大的提升是Java宿主下的MIDlet的引入。
MIDlets?are?executed?on?a?Java?virtual?machine,?a?process?that?abstracts?the?underlying
hardware?and?lets?developers?create?applications?that?run?on?the?wide?variety?of?devices?that?supports?the?Java?run?time.?Unfortunately,?this?convenience?comes?at?the?price?of?restricted?access?to?the?device?hardware.
MIDlet?在一个Java虚拟机(一个抽象了底层硬件的进程)上执行,让开发者创建运行在广泛不同设备上的支持JRE的应用程序。不过,这样便于访问到受限制的硬件设备。