Vous êtes sur la page 1sur 6

CONTENTS

INTRODUCTION
CHAPTER 1: GETTING STARTED WITH ANDROID PROGRAMMING

What Is Android?
Android Versions
Features of Android
Architecture of Android
Android Devices in the Market
The Android Market
The Android Developer Community

Obtaining the Required Tools


Android SDK
Installing the Android SDK Tools
Conguring the Android SDK Manager
Eclipse
Android Development Tools (ADT)
Creating Android Virtual Devices (AVDs)

Creating Your First Android Application


Anatomy of an Android Application
Summary
CHAPTER 2: ACTIVITIES, FRAGMENTS, AND INTENTS

Understanding Activities
Applying Styles and Themes to an Activity
Hiding the Activity Title
Displaying a Dialog Window
Displaying a Progress Dialog
Displaying a More Sophisticated Progress Dialog

Linking Activities Using Intents


Resolving Intent Filter Collision
Returning Results from an Intent
Passing Data Using an Intent Object

Fragments
Adding Fragments Dynamically
Life Cycle of a Fragment
Interactions between Fragments

xxi
1

2
2
3
4
6
8
9

9
10
11
12
14
15
17

20
29
33
35

36
41
41
42
47
50

53
58
59
63

69
73
76
80

CONTENTS

Calling Built-In Applications Using Intents


Understanding the Intent Object
Using Intent Filters
Adding Categories

Displaying Notications
Summary
CHAPTER 3: GETTING TO KNOW THE ANDROID USER INTERFACE

Understanding the Components of a Screen


Views and ViewGroups
LinearLayout
AbsoluteLayout
TableLayout
RelativeLayout
FrameLayout
ScrollView

Adapting to Display Orientation


Anchoring Views
Resizing and Repositioning

89
91
96

98
103
105

105
106
107
115
116
117
118
121

123
125
127

Managing Changes to Screen Orientation

130

Persisting State Information during Changes


in Conguration
Detecting Orientation Changes
Controlling the Orientation of the Activity

133
135
135

Utilizing the Action Bar


Adding Action Items to the Action Bar
Customizing the Action Items and Application Icon

Creating the User Interface Programmatically


Listening for UI Notications
Overriding Methods Dened in an Activity
Registering Events for Views

Summary
CHAPTER 4: DESIGNING YOUR USER INTERFACE WITH VIEWS

Using Basic Views


TextView View
Button, ImageButton, EditText, CheckBox,
ToggleButton, RadioButton, and RadioGroup Views
ProgressBar View
AutoCompleteTextView View

Using Picker Views


xvi

85

136
139
144

146
148
149
152

156
159

160
160
161
171
177

179

CONTENTS

TimePicker View
DatePicker View

Using List Views to Display Long Lists


ListView View
Using the Spinner View

Understanding Specialized Fragments


Using a ListFragment
Using a DialogFragment
Using a PreferenceFragment

Summary
CHAPTER 5: DISPLAYING PICTURES AND MENUS WITH VIEWS

Using Image Views to Display Pictures


Gallery and ImageView Views
ImageSwitcher
GridView

Using Menus with Views


Creating the Helper Methods
Options Menu
Context Menu

Some Additional Views


AnalogClock and DigitalClock Views
WebView

Summary
CHAPTER 6: DATA PERSISTENCE

Saving and Loading User Preferences


Accessing Preferences Using an Activity
Programmatically Retrieving and Modifying
the Preferences Values
Changing the Default Name of the Preferences File

Persisting Data to Files


Saving to Internal Storage
Saving to External Storage (SD Card)
Choosing the Best Storage Option
Using Static Resources

Creating and Using Databases


Creating the DBAdapter Helper Class
Using the Database Programmatically
Pre-Creating the Database

Summary

179
184

191
191
199

202
202
207
210

214
219

219
220
226
231

234
235
238
240

242
242
243

249
251

251
252
259
261

263
263
268
271
272

273
273
279
285

289
xvii

CONTENTS

CHAPTER 7: CONTENT PROVIDERS

Sharing Data in Android


Using a Content Provider
Predened Query String Constants
Projections
Filtering
Sorting

Creating Your Own Content Providers


Using the Content Provider
Summary
CHAPTER 8: MESSAGING

SMS Messaging
Sending SMS Messages Programmatically
Getting Feedback after Sending a Message
Sending SMS Messages Using Intent
Receiving SMS Messages
Caveats and Warnings

Sending E-mail
Summary
CHAPTER 9: LOCATION-BASED SERVICES

Displaying Maps
Creating the Project
Obtaining the Maps API Key
Displaying the Map
Displaying the Zoom Control
Changing Views
Navigating to a Specic Location
Adding Markers
Getting the Location That Was Touched
Geocoding and Reverse Geocoding

Getting Location Data


Monitoring a Location
Project Building a Location Tracker
Summary
CHAPTER 10: NETWORKING

Consuming Web Services Using HTTP


Downloading Binary Data
xviii

293

293
294
300
303
304
305

305
314
319
321

321
322
325
328
329
344

345
347
351

352
352
353
355
358
361
363
366
369
371

375
384
385
390
393

393
396

CONTENTS

Downloading Text Content


Accessing Web Services Using the GET Method

Consuming JSON Services


Sockets Programming
Summary
CHAPTER 11: DEVELOPING ANDROID SERVICES

Creating Your Own Services

402
404

409
417
426
429

429

Performing Long-Running Tasks in a Service


433
Performing Repeated Tasks in a Service
439
Executing Asynchronous Tasks on Separate Threads Using IntentService 442

Establishing Communication between a Service


and an Activity
Binding Activities to Services
Understanding Threading
Summary

445
449
454
460

CHAPTER 12: PUBLISHING ANDROID APPLICATIONS

463

Preparing for Publishing


Versioning Your Application
Digitally Signing Your Android Applications

Deploying APK Files


Using the adb.exe Tool
Using a Web Server
Publishing on the Android Market

Summary
APPENDIX A: USING ECLIPSE FOR ANDROID DEVELOPMENT

Getting Around in Eclipse


Workspaces
Package Explorer
Using Projects from Other Workspaces
Using Editors within Eclipse
Understanding Eclipse Perspectives
Automatically Importing Packages
Using the Code Completion Feature
Refactoring

Debugging your Application


Setting Breakpoints
Dealing with Exceptions

463
464
466

471
471
474
476

481
483

483
483
485
486
487
490
490
491
492

494
495
497

xix

CONTENTS

xx

APPENDIX B: USING THE ANDROID EMULATOR

499

Uses of the Android Emulator


Creating Snapshots
SD Card Emulation
Emulating Devices with Different Screen Sizes
Emulating Physical Capabilities
Sending SMS Messages to the Emulator
Making Phone Calls
Transferring Files into and out of the Emulator
Resetting the Emulator

499
501
502
504
506
508
509
511
513

APPENDIX C: ANSWERS TO EXERCISES

515

INDEX

521

Vous aimerez peut-être aussi