Tải bản đầy đủ (.pdf) (662 trang)

Manning android in action 3rd

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (14.95 MB, 662 trang )

IN ACTION
THIRD EDITION

W. Frank Ableson
Robi Sen
Chris King
C. Enrique Ortiz

MANNING


Android in Action
Third Edition



Android in Action
Third Edition
W. FRANK ABLESON
ROBI SEN
CHRIS KING
C. ENRIQUE ORTIZ

MANNING
SHELTER ISLAND


For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department


Manning Publications Co.
20 Baldwin Road
PO Box 261
Shelter Island, NY 11964
Email:

©2012 by Manning Publications Co. All rights reserved.

Download from www.UpeBook.Com

No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.

Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.

Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books
are printed on paper that is at least 15 percent recycled and processed without the use of
elemental chlorine.

Manning Publications Co.
20 Baldwin Road
PO Box 261
Shelter Island, NY 11964


Development editor:
Copyeditors:
Typesetter:
Cover designer:

ISBN 9781617290503
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – MAL – 16 15 14 13 12 11

Troy Mott
Benjamin Berg, Tiffany Taylor
Dottie Marsico
Marija Tudor


brief contents
PART 1 WHAT IS ANDROID? THE BIG PICTURE............................1
1



Introducing Android

3

2



Android’s development environment


33

PART 2 EXERCISING THE ANDROID SDK ..................................63
3



User interfaces

65

4



Intents and Services

5



Storing and retrieving data

6



Networking and web services


7



Telephony

8



Notifications and alarms 206

9



Graphics and animation 226

10



Multimedia

11



Location, location, location 284


102
130
160

188

260

PART 3 ANDROID APPLICATIONS ............................................309
12



Putting Android to work in a field service application

13



Building Android applications in C

v

356

311


vi


BRIEF CONTENTS

PART 4 THE MATURING PLATFORM ........................................383
14



Bluetooth and sensors

15



385

Integration

16



Android web development 439

17



AppWidgets

472


18



Localization

509

19



Android Native Development Kit

20



Activity fragments 545

21



Android 3.0 action bar

22




Drag-and-drop 579

405

560

524


contents
preface xix
acknowledgments xxi
about this book xxiii
about the cover illustration xxviii

PART 1 WHAT IS ANDROID? THE BIG PICTURE ...................1

1

Introducing Android
1.1
1.2

3

The Android platform 4
Understanding the Android market

5


Mobile operators 5 Android vs. the feature phones 6
Android vs. the smartphones 7 Android vs. itself 8
Licensing Android 9




1.3

The layers of Android

10

Building on the Linux kernel
Dalvik VM 12

1.4



Running in the

The Intent of Android development
Empowering intuitive UIs

1.5

11


13



13

Intents and how they work

Four kinds of Android components 17
Activity 17 Service
ContentProvider 22


vii

18



BroadcastReceiver

19

14


viii

CONTENTS


1.6
1.7
1.8
1.9

Understanding the AndroidManifest.xml file 24
Mapping applications to processes 26
Creating an Android application 26
Android 3.0 for tablets and smartphones 30
Why develop for Android tablets? 30 What’s new in the
Android 3.0 Honeycomb platform? 31


1.10

2

Summary

32

Android’s development environment
2.1

Introducing the Android SDK 34
Core Android packages

2.2

35




Optional packages

Exploring the development environment
The Java perspective 37
Command-line tools 42

2.3

33



36

36

The DDMS perspective 39

Building an Android application in Eclipse

45

The Android Project Wizard 45 Android sample
application code 46 Packaging the application 52





2.4

Using the Android emulator

53

Setting up the emulated environment
application in the emulator 58

2.5
2.6

54



Testing your

Debugging your application 59
Summary 61

PART 2 EXERCISING THE ANDROID SDK .........................63

3

User interfaces
3.1

65


Creating the Activity 66
Creating an Activity class 68 XML vs. programmatic
layouts 69 Exploring the Activity lifecycle 72 The server
connection 73




3.2



Working with views 75
Exploring common views 76 Using a ListView 78
Multitasking with Handler and Message 82 Creating custom
views 83 Understanding layout 86 Handling focus 88
Grasping events 89









ix

CONTENTS


3.3

Using resources

90

Supported resource types 90 Referencing resources in
Java 91 Defining views and layouts through XML
resources 93 Externalizing values 95 Providing
animations 98






3.4
3.5

4

Exploring the AndroidManifest file 99
Summary 101

Intents and Services
4.1




102

Serving up RestaurantFinder with Intent

103

Defining Intents 103 Implicit and explicit invocation 104
Adding external links to RestaurantFinder 105 Finding your
way with Intent 107 Taking advantage of Android-provided
activities 109






4.2

Checking the weather with a custom URI 110
Offering a custom URI

4.3

110

Inspecting a custom URI 112

Checking the weather with broadcast receivers 114
Broadcasting Intent 114


4.4
4.5





Creating a receiver

115

Building a background weather service 116
Communicating with the WeatherAlertService
from other apps 120
Android Interface Definition Language 120 Binder and
Parcelable 122 Exposing a remote interface 123
Binding to a Service 124 Starting vs. binding 127
Service lifecycle 128






4.6

5

Summary


129

Storing and retrieving data
5.1

Using preferences

130

131

Working with SharedPreferences
permissions 134

5.2

Using the filesystem

131



Preference access

137

Creating files 137 Accessing files 138
resources 139 XML file resources 140
via an SD card 142





5.3

Persisting data to a database




Files as raw
External storage

145

Building and accessing a database
tool 150

146



Using the sqlite3


x

CONTENTS

5.4


Working with ContentProvider classes 151
Using an existing ContentProvider
ContentProvider 152

5.5

6

Summary

Creating a

160

An overview of networking
Networking basics

6.2
6.3
6.4



159

Networking and web services
6.1

151


162



162

Clients and servers

Checking the network status 165
Communicating with a server socket
Working with HTTP 169

164

166

Simple HTTP and java.net 170 Robust HTTP with
HttpClient 171 Creating an HTTP and HTTPS
helper 173




6.5

Web services 179
POX: putting it together with HTTP and XML 180
REST 182 To SOAP or not to SOAP, that is the question



6.6

7

Summary

Telephony
7.1

186

188

Exploring telephony background and terms
Understanding GSM

7.2
7.3

190



189

Understanding CDMA

Phone or not? 191
Accessing telephony information

Retrieving telephony properties 192
information 195

7.4

185

190

192


Obtaining phone state

Interacting with the phone 196
Using Intents to make calls 196 Using phone number–related
utilities 198 Intercepting outbound calls 200




7.5

Working with messaging: SMS 200
Sending SMS messages

7.6

8


Summary

205

Notifications and alarms
8.1

201

Introducing Toast

206
207



Receiving SMS messages

204


xi

CONTENTS

8.2
8.3
8.4

Placing your Toast message 209

Making a custom Toast view 210
Introducing notifications 212
The Notification class
button press 214

8.5
8.6

212



Notifying a user with a simple

Making a custom notification view
Introducing alarms 219
Creating a simple alarm example
with alarms 222

8.7

9

Summary

Drawing graphics in Android 227


Exploring XML drawable


Creating animations with Android’s Graphics API 231
Android’s frame-by-frame animation
creating an animation 234

9.3

Using notifications

226

Drawing with XML 228
shapes 230

9.2



225

Graphics and animation
9.1

220

216

232




Programmatically

Introducing OpenGL for Embedded Systems 238
Creating an OpenGL context 239 Drawing a rectangle with
OpenGL ES 243 Three-dimensional shapes and surfaces with
OpenGL ES 245




9.4

9.5

10

Introducing RenderScript for Android

250

RenderScript advantages and disadvantages
RenderScript application 252

251

Summary

Multimedia
10.1




Building a

258

260

Introduction to multimedia and Stagefright 261
Stagefright overview 261

10.2
10.3
10.4

Playing audio 263
Playing video 264
Capturing media 266
Understanding the camera 267
Recording video 276

10.5

Summary

282



Capturing audio


272


xii

CONTENTS

11

Location, location, location
11.1

284

Simulating your location within the emulator 286
Sending in your coordinates with the DDMS tool 286 The GPS
Exchange Format 288 The Google Earth Keyhole Markup
Language 289




11.2

Using LocationManager and LocationProvider

292

Accessing location data with LocationManager 292

Using a LocationProvider 294 Receiving location
updates with LocationListener 296


11.3

Working with maps 298
Extending MapActivity 299 Using a MapView
Placing data on a map with an Overlay 302

299



11.4
11.5

Converting places and addresses with Geocoder 305
Summary 307

PART 3 ANDROID APPLICATIONS ...................................309

12

Putting Android to work in a field service application 311
12.1

Designing a real-world Android application 312
Core requirements of the application 313 Managing the
data 314 Application architecture and integration 315





12.2

Mapping out the application flow 316
Mapping out the field service application 316 List of source
files 318 Field service application’s AndroidManifest.xml 320




12.3

Application source code
Splash Activity
Activity 322
Settings 325

12.4

320

320 Preferences used by the FieldService
Implementing the FieldService Activity 324
Managing job data 327






Source code for managing jobs

334

RefreshJobs 335 Managing jobs: the ManageJobs Activity 338
Working with a job with the ShowJob Activity 341 Capturing a
signature with the CloseJob Activity 345




12.5

Server code

351

Dispatcher user interface 352 Database 352 PHP
dispatcher code 353 PHP mobile integration code 354




12.6

Summary

355





xiii

CONTENTS

13

Building Android applications in C
13.1

356

Building Android apps without the SDK

357

The C compiler and linker tools 357 Building a Hello World
application 358 Installing and running the application 360
C application build script 362




13.2

Solving the problem with dynamic linking 362
Android system libraries 363 Building a dynamically linked

application 364 exit() vs. return() 367 Startup code 368




13.3



What time is it? The DayTime Server 370
DayTime Server application 370 daytime.c 371 The SQLite
database 373 Building and running the DayTime Server 376






13.4

Daytime Client
Activity 378
Client 380

13.5

PART

Summary


378
Socket client



379



Testing the Daytime

380

4 THE MATURING PLATFORM .............................. 383

14

Bluetooth and sensors
14.1

385

Exploring Android’s Bluetooth capabilities

386

Replacing cables 387 Primary and secondary roles and
sockets 387 Trusting a device 388 Connecting to a
remote device 390 Capturing Bluetooth events 392
Bluetooth permissions 393









14.2

Interacting with the SensorManager 393
Types of sensors 394 Reading sensor values
Enabling and disabling sensors 396


14.3

Building the SenseBot application

395

397

User interface 398 Interpreting sensor values 400
Driving the robot 401 Communication with the robot 402




14.4


15

Summary

Integration
15.1

403

405

Understanding the Android contact model

406

Choosing open-ended records 406 Dealing with multiple
accounts 408 Unifying a local view from diverse remote
stores 410 Sharing the playground 411







xiv

CONTENTS


15.2
15.3

Getting started with LinkedIn 411
Managing contacts 413
Leveraging the built-in Contacts app 413 Requesting operations
from your app 416 Directly reading and modifying the contacts
database 417 Adding contacts 418






15.4

Keeping it together

421

The dream of sync 421 Defining accounts
secrets: The AccountManager service 423

422



15.5

Creating a LinkedIn account 424

Not friendly to mobile 424

15.6



Authenticating to LinkedIn

Synchronizing to the backend with SyncAdapter
The synchronizing lifecycle
data 432

15.7

432

16



425

432

Synchronizing LinkedIn

Wrapping up: LinkedIn in action 435
Finalizing the LinkedIn project
Moving on 437


15.8

Telling



Summary

435



Troubleshooting tips

436

437

Android web development 439
16.1

What’s Android web development? 440
Introducing WebKit
options 441

16.2

440




Examining the architectural

Optimizing web applications for Android

442

Designing with mobile in mind 442 Adding the viewport
tag 444 Selectively loading content 446 Interrogating the
user agent 446 The media query 447 Considering a madefor-mobile application 448








16.3



Storing data directly in the browser

449

Setting things up 450 Examining the code 451 The user
interface 451 Opening the database 453 Unpacking the
transaction function 454 Inserting and deleting rows 456
Testing the application with WebKit tools 457











16.4

Building a hybrid application 458
Examining the browser control 458 Wiring up the control 459
Implementing the JavaScript handler 461 Accessing the code
from JavaScript 463 Digging into the JavaScript 463
Security matters 465 Implementing a WebViewClient 466
Augmenting the browser 466 Detecting navigation events 467
Implementing the WebChromeClient 470










16.5


Summary

471


xv

CONTENTS

17

AppWidgets 472
17.1

Introducing the AppWidget 473
What’s an AppWidget?
strategies 475

17.2

473

Introducing SiteMonitor
Benefits of SiteMonitor

17.3




AppWidget deployment

476

476

The user experience



SiteMonitor application architecture
Bird’s-eye view of the application

480



477

480
File by file

17.4

AppWidget data handling

17.5

Implementing the AppWidgetProvider


482

483
487

AppWidgetProvider method inventory 487 Implementing
SiteMonitorWidgetImpl 488 Handling zombie widgets 490




17.6

Displaying an AppWidget with RemoteViews 491
Working with RemoteViews
explained 492

17.7

491



UpdateOneWidget

Configuring an instance of the AppWidget 494
AppWidget metadata 495 Working with Intent data
Confirming widget creation 497



17.8

Updating the AppWidget

498

Comparing services to alarms 499
Updating the widgets, finally! 502

17.9
17.10

18



Triggering the update 500

Tying it all together with AndroidManifest.xml
Summary

Localization

496

506

507

509


18.1

The need for localization

510

18.2

Exploring locales

18.3

Strategies for localizing an application

511
512

Identifying target locales and data 512 Identifying and
managing strings 513 Drawables and layouts 515
Dates, times, numbers, and currencies 516 Working with
the translation team 517






18.4


Leveraging Android resource capabilities
More than locale

518



518

Assigning strings in resources

18.5

Localizing in Java code

520

18.6

Formatting localized strings

521

518


xvi

CONTENTS


18.7
18.8

19

Obstacles to localization
Summary 523

522

Android Native Development Kit
19.1

Introducing the NDK
Uses for the NDK

19.2

19.3

525

524

525


Looking at the NDK

526


Building an application with the NDK

527

Demonstrating the completed application
project structure 529



Building the JNI library

528

Examining the

530

Understanding JNI 530 Implementing the library
Compiling the JNI library 536


19.4

Building the user interface
User interface layout
edges 541

19.5
19.6


20



537
Taking a photo 539



Finding the

Integrating the NDK into Eclipse 542
Summary 544

Activity fragments
20.1
20.2

537

531

545

Fragment lifecyle 546
Creating fragments and fragment layouts 548
Create the fragment subclass 548 Defining a fragment
layout 551 Include the fragment within the activity 552





20.3
20.4
20.5
20.6
20.7
20.8

21

Background fragments 553
The fragment manager 555
Fragment transactions 555
Fragment back stack 556
The Android Compatibility Package
Summary 558

Android 3.0 action bar
21.1
21.2
21.3

557

560

Introducing the action bar 561
Overview of the ActionBar classes

Action bar display options 563
Application name and icon

564



562

Navigation modes

565


xvii

CONTENTS

21.4

Action items

570

The application icon as an action item

21.5
21.6
21.7


22

appendix A
appendix B



Action views

Removing, showing, and hiding the action bar
Action bar styling 575
Summary 578

Drag-and-drop
22.1
22.2
22.3
22.4
22.5
22.6
22.7
22.8
22.9

573

579

The drag-and-drop classes 580
Drag-and-drop operations 581

The shadow builder 583
Drag events 585
Starting drag operations 586
Listening for drag-and-drop events 587
Responding to drag-start operations 588
Handling drop operations 589
Summary 590
Installing the Android SDK 591
Publishing applications 601
index 613

575

574



preface
The idea of a writing a book about Android development can be somewhat futile at
times, considering the pace at which Android continues to expand, morph, and
change. What started out as a book project a few years ago has now become a series of
updates to the original work with the page count nearly double the original project—
and that after making hard decisions about what to leave out of the book to make sure
it gets published.
This update to Android in Action represents our latest effort to provide coverage
on important Android development topics, namely the expansion into the tablet
space with Android 3.x as well as advances in mobile graphics and media such as
RenderScript.
Although there have been many off-brand and name-brand tablet offerings popping up over time, the Android development team has taken the step of adding tabletspecific capabilities to the SDK under the banner of 3.0. True to form, 3.0 was quickly
updated, so we generally refer to the tablet-specific features as 3.x; and before long I

am sure Android 4.x will be out with a super-set of features.
Like many things in life, the only constant is change, but by now we’re somewhat
accustomed to the rapid-fire environment of Android development. To that end, we
have ensured that all of the applications in the book work with Android 3.x. The newest chapters covering tablet-specific content (20–22) require the 3.x SDK, whereas the
remaining chapters are compatible with the 2.x SDK versions. If you plan to write application software for Android, you simply need to steel yourself for navigating the multiple version game. It is at once a strength and a challenge of the Android ecosystem.

xix


xx

PREFACE

The third edition was written by Frank Ableson, Robi Sen, Chris King, and newcomer C. Enrique Ortiz, aka CEO. To borrow a line from the air-travel industry, “We
know you have a choice when it comes to Android development books, so thank you
for learning and collaborating with us.”
FRANK ABLESON


acknowledgments
Writing a third edition of Android in Action feels somewhat like the old saying about
weddings: “Something old, something new…” The deadlines for the third edition did
not become any easier as at last count there are still only 24 hours in the day. And as
for something new—it seems as though Android’s pace of innovation is continuing to
match its adoption rate by mobile users around the globe. Like the two earlier editions, Android in Action, Third Edition represents a collaboration between a number of
contributors. I had the privilege of working again with Robi Sen and Chris King, who
worked with me on the second edition. C. Enrique Ortiz joined us to contribute the
tablet content. Once again the talented team at Manning have labored to bring about
this edition.
In particular, we’d like to acknowledge and thank everyone at Manning. First,

thanks to Troy Mott, our acquisition and development editor, who has been involved
in every aspect of now three editions of this project—congratulations, Troy, on your
hat-trick! Bob Herbstman did all the big and little things to bring the project together;
Mary Piergies skillfully piloted the team through the harrowing production process;
and Marjan Bace, our publisher, showed an attention to detail at once challenging,
beneficial, and appreciated.
Once the writing was finished, the next round of work began. Special thanks need
to go to Benjamin Berg, who performed the preproduction editing pass; Tiffany Taylor, who did the second copyediting pass and helped us bring the final pieces of the
project together; and finally Dottie Marsico, who handled the actual layout of the
pages. It’s sometimes hard to envision the final product when looking at edits upon
edits in MS Word, but Dottie’s magic made the product you hold in your hands. Next,

xxi


xxii

ACKNOWLEDGMENTS

we would like to thank Candace Gillhoolley for her efforts in getting the word out
about the book. Thanks to each of you for your special contribution to this project.
And special thanks to the reviewers who read our revised manuscript at different
times during its development: Steve Prior, Matthew Johnson, Julian Harty, David
Strong, Loïc Simon, Al Scherer, Gabor Paller, and Pieter Kuijpers; and to Jérôme
Bâton for his careful technical review of the final manuscript during production.
Last, we want to thank the thoughtful and encouraging MEAP subscribers who provided feedback along the way; the book is better thanks to your contributions.
FRANK ABLESON
I would like to thank my coauthors: Robi Sen, a real pro who has been involved in this
project from the beginning; Chris King, who has proven to be rock-solid in terms of
both technical capability and reliability; and newcomer C. Enrique Ortiz (CEO), who

has injected energy and enthusiasm into the Third Edition. Of course, through each
iteration of this project, Troy Mott has led the way: managing the process, coaxing us
at times, and delivering every time. Bob Herbstman has contributed invaluably to the
finished product and is likely tired of cleaning up after my writing and amateurish
graphics after all of these years. Special thanks to Bob for re-creating many illustrations. Thanks also to the production team at Manning Publications who have once
again delivered an excellent work. Thanks also to Candace Gillhoolley for continued
support with books and promotions to support speaking events and conferences—
always aiding my last-minute requests. Last and most important, I would like to thank
Nikki and company at the Ableson household for unconditional support. Praise be to
God, another version is complete!
CHRIS KING
I am deeply grateful to Troy Mott, Frank, Robi, and Enrique for being such a pleasure
to collaborate with as we drove toward the latest incarnation of this book. I also appreciate all the work done by the reviewers and editors from Manning, and also the dedicated readers of previous editions who contributed suggestions at the Author Online
forums. Special thanks go to Eric Tamo and Zac White for their support and relentless
good cheer. Finally, my love to my family: Charles, Karen, Patrick, Kathryn, and
Andrew.
ROBI SEN
I would like to thank Troy Mott and the team—and everyone at Manning Publications—for their hard work making this book something worth reading. I would like to
thank my coauthors, Frank and Chris, who were great to work with and very understanding when I was the one holding things up. I would also like to thank C. Enrique
Ortiz for his contributions. Finally, I would like to dedicate my efforts on this book to
my brother Neel, who passed away while we were wrapping up the book.
C. ENRIQUE ORTIZ
To my parents, family, friends, and colleagues, who influence my work and make it
exciting.


about this book
Android in Action, Third Edition is a revision and update of, you guessed it, the Second
Edition, published in January 2011. This third edition adds new content related to
Android’s push into the tablet space as well as enhancements to various sub-systems

within the Android platform. Like its predecessors, this book covers important beginner topics such as “What is Android?” and installing and using the development environment. We then advance to practical working examples of core programming topics
any developer will be happy to have at the ready on the reference shelf. The remaining chapters present detailed example applications covering advanced topics, including a complete field-service application, localization, and material on Android web
applications, Bluetooth, sensors, AppWidgets, and integration adapters. We even
include two chapters on writing applications in C—one for the native side of Android
and one using the more generally accepted method of employing the Android Native
Development Kit. Brand-new content covering tablet programming is found in chapters 20 through 22. Chapters 20–22 specifically require Android SDK 3.0 and beyond,
whereas the balance of the book is compatible with 2.x versions of Android.
Although you can read the book from start to finish, you can also consider it a few
books in one. If you’re new to Android, focus first on chapter 1, appendix A, and then
chapter 2. With that foundation, you can work your way through chapters 3–12. Chapters 13 and on are more in-depth in nature and can be read independently of the others. Chapters 20–22 focuses on important topics related to Android 3.0 and tablets.

Who should read this book?
We wrote this book for professional programmers and hobbyists alike. Many of the
concepts can be absorbed without specific Java language knowledge, although you’ll
xxiii


xxiv

ABOUT THIS BOOK

obtain the most value if you have Java programming skills—Android application programming requires them. If you have C, C++, or C# programming knowledge, you’ll
be able to follow the examples.
Prior Eclipse experience is helpful, but not required. A number of good resources
are available on Java and Eclipse to augment the content of this book.

Roadmap
This book is divided into four parts. Part 1 contains introductory material about the
platform and development environment. Part 2 takes a close look at the fundamental
skills required for building Android applications. Part 3 presents a larger-scope application and a Native C Android application. Part 4 explores features added to the

Android platform, providing examples of using the capable Android platform to create innovative mobile applications.

Part 1: The essentials
Part 1 introduces the Android platform, including its architecture and setting up the
development environment.
Chapter 1 delves into the background and positioning of the Android platform,
including comparisons to other popular platforms such as BlackBerry, iPhone, and
Windows Mobile. After an introduction to the platform, the balance of the first chapter introduces the high-level architecture of Android applications and the operating
system environment.
Chapter 2 takes you on a step-by-step development exercise, teaching you the ropes
of using the Android development environment, including the key tools and concepts
for building an application. If you’ve never used Eclipse or have never written an
Android application, this chapter will prepare you for the next part of the book.

Part 2: The programming environment
Part 2 includes an extensive survey of fundamental programming topics in the
Android environment.
Chapter 3 covers the fundamental Android UI components, including View and
Layout. We also review the Activity in more detail. These are the basic building
blocks of screens and applications on the Android platform. Along the way, we also
touch on other basic concepts such as accessing external resources, responding to
events, and the lifecycle of an Android application.
Chapter 4 expands on the concepts you learned in chapter 3. We delve into the
Android Intent to demonstrate interaction between screens, activities, and entire
applications. We also introduce and use the Service framework, which allows for
ongoing background processes.
Chapter 5 incorporates methods and strategies for storing and retrieving data
locally. The chapter examines use of the filesystem, databases, the SD card, and
Android-specific storage entities such as the SharedPreferences and ContentProvider



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×