android programme's guide pdf,Android A Programmer’s Guide-外文翻译英文.pdf

Android:AProgrammer’sGuide

IntroductiontoAndroid

Android, as a system, is a Java-based operating system that runs on the Linux 2.6

kernel. Thesystemisvery lightweight andfull featured.

Android applications are developed using Java and can be ported rather easily to the

new platform. Ifyou havenot yet downloaded Java or areunsure about which version

you need, I detail the installation ofthe development environment in Chapter 2. Other

features of Android include an accelerated 3-D graphics engine (based on hardware

support), databasesupportpoweredby SQLite, andan integratedwebbrowser.

If you are familiar with Java programming or are an OOP developer of any sort, you

are likely used to programmatic user interface (UI) development—that is, UI

placement which is handled directly within the program code. Android, while

recognizing and allowing for programmatic UI development, also supportsthe newer,

XML-based UI layout. XML UI layout is a fairly new concept tothe average desktop

developer. Iwill coverboththeXMLUIlayout andtheprogrammaticUIdevelopment

inthesupporting chaptersofthisbook.

One of the more exciting and compelling features of Android is that, because of its

architecture, third-party applications—including those that are “home grown”—are

executedwith the same systempriority asthosethat arebundled with the core system.

This is a major departure from most systems, which give embedded system apps a

greater execution priority than the thread priority available to apps created by

third-party developers. Also, each application isexecutedwithin itsownthreadusing a

verylightweightvirtualmachine.

Asidefromthevery generousSDKandthewell-formedlibrariesthatareavailableto

ustodevelopwith, themost excitingfeatureforAndroiddevelopersisthatwenow

haveaccesstoanythingtheoperating systemhasaccessto Inotherwords ifyouwant. ,

tocreateanapplicationthat dialsthephone, youhaveaccesstothephone’sdialer; if

you

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1 What Is Android? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Brief History of Embedded Device Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Open Handset Alliance and Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Introduction to Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2 Downloading and Installing Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Why Eclipse? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Downloading and Installing the JRE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Downloading and Installing Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3 Downloading and Installing the Android SDK . . . . . . . . . . . . . . . . . . . . . . . 21 Downloading the Android SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Downloading and Installing the Android Plugin for Eclipse . . . . . . . . . . . . . . . . . . . . . . 24 Configuring the Android Plugin for Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 4 Exploring the Android SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 What Is in the Android SDK? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Android Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Android Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Try This: Run the API Demos Sample Application . . . . . . . . . . . . . . . . . . . . . . . . . 41 Android Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 Application Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Standard ASP Application Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Android Application Life Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 5 Application: Hello World! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Creating Your First Android Project in Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 Examining the Android-Created Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 AndroidManifest.xml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Referenced Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Hello World! Again . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Hello World! Using an Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Hello World! Code-Based UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Hello World! XML-Based UI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Try This: Use TextView and ImageView . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 6 Using the Command-Line Tools and the Android Emulator . . . . . . . . . . . . 83 Creating a Shell Activity Using the Windows CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 Running the ActivityCreator.bat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 The Project Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 Creating the Hello World! Activity in the Windows CLI . . . . . . . . . . . . . . . . . . . . . . . . 95 Editing the Project Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Adding the JAVA_HOME Variable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Compiling and Installing the Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Hello World! on Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 Configuring the PATH Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 Try This: Create an Image-Based Hello World! in the CLI . . . . . . . . . . . . . . . . . . . 115 7 Using Intents and the Phone Dialer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 What Are Intents? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 Using the Dialer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Placing a Call from Your Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 Adding the Intent to Your Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Editing Activity Permissions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 Modifying the AndroidPhoneDialer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 Adding a Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 Implementing an EditText View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 Try This: Modify the AndroidPhoneDialer Project . . . . . . . . . . . . . . . . . . . . . . . . . . 145 8 Lists, Menus, and Other Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 Building the Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 Intent Code for the .xml File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 Intent Code for the .java File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 Modifying the AndroidManifest.xml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 Using the Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Creating the Activity for AutoComplete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 CheckBox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 EditText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 RadioGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 Spinner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Try This: Modify More View Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 9 Using the Cell Phone’s GPS Functionality . . . . . . . . . . . . . . . . . . . . . . . . . . . 203 Using the Android Location-Based API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204 Creating a kml File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 What Is a track File? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Getting the nmea File in Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Getting the nmea File in Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 Reading the GPS with the Android Location-Based API . . . . . . . . . . . . . . . . . . . . . . . . 212 Creating the AndroidLBS Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 Passing Coordinates to Google Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 Adding Zoom Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 Try This: Toggling Between MapView’s Standard and Satellite Views . . . . . . . . . . 232 10 Using the Google API with GTalk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 Configuring the Android Emulator for GTalk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 Implementing GTalk in Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244 Creating the Activity’s Layout in the GoogleAPI.xml . . . . . . . . . . . . . . . . . . . . . 245 Adding Packages to GoogleAPI.java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247 Implementing the View.OnClickListener . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248 Compiling and Running GoogleAPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252 Try This: Add a Settings Feature to Your GoogleAPI Activity . . . . . . . . . . . . . . . . 255 11 Application: Find a Friend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Creating a SQLite Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 Creating a Custom Content Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 Editing the strings.xml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 Creating Your Content Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265 Creating the FindAFriend Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 Editing AndroidManifest.xml . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276 Creating the NameEditor Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278 Creating the LocationEditor Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 Creating the FriendsMap Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 Creating the FindAFriend Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 299 Running the FindAFriend Activity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302 Try This: Real-Time Location Updating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 12 Android SDK Tool Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307 Android Emulator Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 Android Debug Bridge Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值