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

Enterprise android

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 (12.56 MB, 408 trang )

www.it-ebooks.info


www.it-ebooks.info
ffirs.indd viii

26-09-2013 19:13:30


ENTERPRISE ANDROID™
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
CHAPTER 1

Developing for Android Tablets and Smartphones . . . . . . . . . . . . . . . . . . . 1

CHAPTER 2

The Relational Model and SQLite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

CHAPTER 3

Android Database Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

CHAPTER 4

Content Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

CHAPTER 5

REST, Content Providers, Concurrency,
Networking, and Sync Adapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115



CHAPTER 6

Service Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

CHAPTER 7

Mobile and the Cloud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

CHAPTER 8

Complex Device-Based Data: Android Contacts. . . . . . . . . . . . . . . . . . 245

CHAPTER 9

Generic Data Synchronization:
Project Migrate and the WebData API . . . . . . . . . . . . . . . . . . . . . . . . . . . 265

CHAPTER 10

WebData Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

CHAPTER 11

Building Human Interfaces for Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305

CHAPTER 12

Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325


INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369

www.it-ebooks.info
ffirs.indd i

26-09-2013 19:13:29


www.it-ebooks.info
ffirs.indd ii

26-09-2013 19:13:29


Enterprise Android™

www.it-ebooks.info
ffirs.indd iii

26-09-2013 19:13:29


www.it-ebooks.info
ffirs.indd iv

26-09-2013 19:13:29


Enterprise Android™
PROGRAMMING ANDROID DATABASE

APPLICATIONS FOR THE ENTERPRISE

Zigurd Mednieks
G. Blake Meike
Laird Dornin
Zane Pan

www.it-ebooks.info
ffirs.indd v

26-09-2013 19:13:29


Enterprise Android™: Programming Android Database Applications for the Enterprise
Published by
John Wiley & Sons, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com

Copyright © 2014 by John Wiley & Sons, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-1-118-18349-6
ISBN: 978-1-118-22747-3 (ebk)
ISBN: 978-1-118-24046-5 (ebk)
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108
of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization

through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers,
MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the
Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011,
fax (201) 748-6008, or online at />Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is
sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. If professional assistance is required, the services of a competent professional person should be sought. Neither
the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is
referred to in this work as a citation and/or a potential source of further information does not mean that the author or the
publisher endorses the information the organization or Web site may provide or recommendations it may make. Further,
readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this
work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley publishes in a variety of print and electronic formats and by print-on-demand. Some material included with
standard print versions of this book may not be included in e-books or in print-on-demand. If this book refers to media
such as a CD or DVD that is not included in the version you purchased, you may download this material at
. For more information about Wiley products, visit www.wiley.com.
Library of Congress Control Number: 2013936843
Trademarks: Wiley, , Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or
registered trademarks of John Wiley & Sons, Inc. and/or its affi liates, in the United States and other countries, and may
not be used without written permission. Android is a trademark of Google, Inc. All other trademarks are the property of
their respective owners. John Wiley & Sons, Inc., is not associated with any product or vendor mentioned in this book.

www.it-ebooks.info
ffirs.indd vi

26-09-2013 19:13:30



To Maija and Charles
—Zigurd Mednieks
To Jerry Meike, my inspiration for writing a book...
and a lot more
—G. Blake Meike
To Norah and Claire, my girls
—Laird Dornin
To Zhengfang
—Zane Pan

www.it-ebooks.info
ffirs.indd vii

26-09-2013 19:13:30


www.it-ebooks.info
ffirs.indd viii

26-09-2013 19:13:30


ABOUT THE AUTHORS

ZIGURD MEDNIEKS is a consultant to leading OEMs, enterprises, investors, and entrepreneurial
ventures creating Android-based systems and software. Previously, he was Chief Architect at D2
Technologies, a voice-over-IP (VoIP) technology provider. There he led engineering and productdefi nition work for products that blend communication and social media in purpose-built embedded
systems and on the Android platform.


Zigurd is a 25-year veteran of user interface, telephony, and social media product creation in
the computing and telecommunications industries. He has authored and co-authored books
about Android software development, and written book chapters on telephony and inter-process
communication. His fi rst book, C Programming Techniques for the Macintosh, co-authored with
Terry Mednieks, was published in 1986. Information about Zigurd can be found at zigurd.com.
G. BLAKE MEIKE is a passionate engineer and code poet with more than 20 years of experience. He
has spent much of his time working with Java, building systems as large as Amazon’s massively
scalable Auto Scaling service and as small as a pre-Android OSS/Linux- and Java-based platform
for cell phones. He is co-author of the bestselling Programming Android and has taught nearly a
thousand people the art of writing Android apps that aren’t toys.
LAIRD DORNIN graduated from Williams College in 1997 with a Bachelor of Arts degree in

Computer Science. Laird began his career at Sun Microsystems working on the Java JDK (RMI) and
the forward-looking Jini Technology out of Sun Labs. From there he moved to SavaJe Technologies
and helped to build a full-featured Java SE mobile operating system that shipped in 2006 and provided the platform for “Device of the Show” at JavaOne. Again at Sun Microsystems, Laird continued working on SavaJe OS to integrate the WebKit browser library to provide a full-featured mobile
browser. Laird is an author of two books on Android programming and now works as an architect
for a major wireless carrier.
ZANE PAN began building large, scalable distributed systems at Sun Microsystems Labs working

on Jini Technology in the late ‘90s. He has been actively designing and architecting solutions for
distributed computing performance and scalability problems since then. Zane has held architect
level roles at many large companies including Lotus Development Corporation, Digital Equipment
Corporation, Intuit, and EMC. Most recently, Zane architected and built a large-scale mobile service backend system using Big Data and NoSQL at Nokia.

www.it-ebooks.info
ffirs.indd ix

26-09-2013 19:13:30



ABOUT THE TECHNICAL EDITOR

MAIJA MEDNIEKS is a senior at the Carnegie Mellon University School of Computer Science and a
former buggy driver. Among her interests are knitting, Norse epics, science fiction, interactive user
experience design, creating and solving puzzles for puzzle hunts, and functional programming.

ABOUT THE TECHNICAL PROOFREADER

JIM FITZGERALD has worked in many facets of the technology industry. His humble beginnings
in Silicon Valley as a software engineer for Hewlett-Packard eventually led him to positions in
marketing and sales before graduate school brought him back to software development and
project management. He has programmed in many different languages and operating systems,
from old mainframes to Windows desktops, and currently spends his time in Android and
Windows mobile environments. While he considers himself more of a frontend guy, he will
admit to dabbling with PHP and writing a lot of PL/SQL in the past when pressed.

When not investigating how technical things work, Jim spends his time as a bibliophile, avid artist
and photographer, collecting far more books, paint brushes, and lenses than he can hope to use.
Jim has a undergraduate BS degree from California Polytechnic, and a MS degree from Yale
University.

www.it-ebooks.info
ffirs.indd x

26-09-2013 19:13:30


CREDITS


EXECUTIVE EDITOR

PRODUCTION MANAGER

Robert Elliott

Tim Tate

SENIOR PROJECT EDITOR

VICE PRESIDENT AND EXECUTIVE GROUP
PUBLISHER

Kevin Kent

Richard Swadley
TECHNICAL EDITOR

Maija Mednieks

VICE PRESIDENT AND EXECUTIVE PUBLISHER

Neil Edde
PRODUCTION EDITOR

Christine Mugnolo

ASSOCIATE PUBLISHER

Jim Minatel

COPY EDITOR

Kezia Endsley

PROJECT COORDINATOR, COVER

Katie Crocker
EDITORIAL MANAGER

Mary Beth Wakefield

PROOFREADER

Nancy Carrasco
FREELANCER EDITORIAL MANAGER

Rosemarie Graham

TECHNICAL PROOFREADER

Jim Fitzgerald
ASSOCIATE DIRECTOR OF MARKETING

David Mayhew

INDEXER

John Sleeva
MARKETING MANAGER


Ashley Zurcher

COVER DESIGNER

Ryan Sneed
BUSINESS MANAGER

Amy Knies

COVER IMAGE

©iStockphoto.com/Iaroslav Neliubov

www.it-ebooks.info
ffirs.indd xi

26-09-2013 19:13:30


ACKNOWLEDGMENTS

I WANT TO THANK the editors at Wiley who have the vision to publish books about Android in the

enterprise; our agent, Carole Jelen, for bringing this project to us; and my co-authors who brought the
concept of a book about data-oriented apps to life. I also thank Maija Mednieks and Jim Fitzgerald,
the technical editor and technical proofreader, for their exacting attention to making sure our
examples work.

—Zigurd Mednieks


I WOULD LIKE TO THANK my co-authors, Zigurd, Laird, and Zane, for making this book way bigger
than the sum of its parts. Bob Elliott and Kevin Kent were incredibly patient with us; and the rest of
the editors, Maija Mednieks, Christine Mugnolo, Kezia Endsley, and Jim Fitzgerald, kept us honest
and intelligible. Marakana Inc., my employer, gave me time to work on it. A special shout out to
L. Carl Pedersen for taking the time to explain SQL. As always, a project like this would be
impossible without the support of my wife, Catherine. You and me, babe, ‘til the wheels fall off.

—G. Blake Meike

I NEED TO THANK my sweetie, Norah, for being so patient with all the long weekends and late nights

working on this ambitious project. You’ve been amazing for this, and for carrying another far more
important project—our new son.
Thanks to my parents—we’ve missed trips to NH!
I’d like to thank Kevin and Robert for all their excellent support on this project. I’m excited that we
managed to cover so many popular topics to create a comprehensive picture of end-to-end enterprise
Android development. Thanks to Jim and Maija, our reviewers; this book contained a lot of material
to cover. Thanks to my brother, Chris, and to Nathan Babb for reviewing parts of the manuscript.
Finally, thanks to my co-authors for collaborating to bring this project to completion.

—Laird Dornin

I’D LIKE TO THANK Kevin and Robert for their support on this project.

—Zane Pan

www.it-ebooks.info
ffirs.indd xii

26-09-2013 19:13:30



CONTENTS

INTRODUCTION

xix

CHAPTER 1: DEVELOPING FOR ANDROID TABLETS
AND SMARTPHONES

Android Is a Java Operating System
Your Tools and Your First Android App
Prerequisites and Getting Ready
Toolchain Test Drive

One Code-Base for All Types of Devices
Getting Started with the Code Framework Example
Automatically Adapting to Screen Size

Components, Views, and Lifecycle
Destroying and Re-Creating Components
The MainActivity Class
Activity: The Basic Unit of User Interaction
Fragment: A Tool for Organizing Code and UI
The PickFragment Class
The ItemFragment Class
The ItemDetailFragment Class

Tying Together Activities, Fragments,

and the Action Bar
The TabbedActivity Class
A Main.xml File for Large Tablets
A Main.xml and a Subsidiary Activity for Smaller Screens
The TabActivity Class

The Android Task and Process Model

1

2
2
2
4

4
5
10

11
11
12
12
17
18
22
25

25
25

28
29
30

33

Starting Dalvik Instances
Death, but No Transfiguration
Tasks Span Applications and Processes

34
34
35

Multiprocessing, Security, and Lifecycle

35

The Process and User ID as Security Boundary

Declaring Application Properties
Summary

36

36
37

www.it-ebooks.info
ftoc.indd xiii


26-09-2013 19:12:59


CONTENTS

CHAPTER 2: THE RELATIONAL MODEL AND SQLITE

Databases and the Relational Model
The History of the RDBMS
The Relational Model
Other DBMS Features
The SQL Language

Introduction to SQLite

39

40
41
41
43
45

48

SQLite from the Command Line
An Example SQLite Database

Summary


49
53

58

CHAPTER 3: ANDROID DATABASE SUPPORT

59

SQL in Java: The SQLiteDatabase Class

60

Basic SQL Embedding
Syntactic SQL
Creating a Database: The SQLiteOpenHelper Class
Managing a Database

Cursors, Loaders, and Adapters
Cursors
Adapters and View Binders
Loaders

Summary

60
61
67
71


73
74
76
79

81

CHAPTER 4: CONTENT PROVIDERS

Using a Content Provider

83

84

URIs as Names for Virtual Datasets
Content Resolvers: The Link between Clients and Providers
Content Observers: Completing the Loop
IPC: System-Wide Accessibility

The Contract: URIs and Types
Authority
Virtual Table URIs
Return Value MIME Types
Permissions
Publishing the Contract

84
85

87
89

90
91
93
94
94
95

Implementing the Content Provider

95

Creating the Content Provider
Return Types and the URI Matcher
Writing the Database
Database Queries
Content Observers (Again)

96
97
98
101
105

xiv

www.it-ebooks.info
ftoc.indd xiv


26-09-2013 19:12:59


CONTENTS

Permissions and Registration
Content Providers and Files
Summary
CHAPTER 5: REST, CONTENT PROVIDERS, CONCURRENCY,
NETWORKING, AND SYNC ADAPTERS

Basic REST

106
109
114
115

116

Why REST?
REST over HTTP
An Example REST API
Contact Representation
Contact Methods and URIs
Contact Transactions

117
118

120
120
122
122

Android Networking

125

The Apache Libraries
The java.net Libraries
Permissions

125
126
128

Considering Concurrency and Lifecycles

128

The Android Concurrency Architecture
A Naive Request

128
129

An Architecture for Robust Networking

131


Approach 1: Service-Centric
Approach 2: ContentProvider-Centric
Approach 3: SyncAdapter-Centric
REST within Android
The restfulCachingProviderContacts Project: An Example Client
Adding a Contact

Using Sync Adapters

131
133
135
135
136
138

143

Android Account Management
Creating a Sync Adapter

Summary

144
155

165

CHAPTER 6: SERVICE DEVELOPMENT


167

A Choice for Service Development

168

The Lifecycle of a Request
Three-Tier Service Architecture
Service Development Background

Building a RESTful Service for Contacts
A Conservative Software Stack
Writing the Examples: Spring Contacts Service
and Its Synchronization Variant
Code Example: Spring Sync Contacts Service

Summary

168
169
169

172
172
175
195

202
xv


www.it-ebooks.info
ftoc.indd xv

26-09-2013 19:12:59


CONTENTS

CHAPTER 7: MOBILE AND THE CLOUD

205

Cloud Performance and Scalability

206

The Scale of Mobile
Persistence in the Cloud: From SQL to NoSQL
Database File Format
NoSQL Persistence

Design Considerations for Scalable Persistence
To SQL or Not to SQL?

207
208
211
213


215
215

Looking at Popular Cloud Providers

218

Amazon AWS
Google App Engine
Joyent: Hosted MongoDB+node.js
Red Hat OpenShift

218
219
219
220

Exploring the Code Examples
The Contacts DAO Interface (Again)
Writing the Code: Amazon Contacts Service
Writing the Code: Google App Engine Contacts

Summary

220
221
221
235

243


CHAPTER 8: COMPLEX DEVICE-BASED DATA:
ANDROID CONTACTS

PIM Databases: Fossils from Smartphone Pre-History
Android’s Contacts Provider
The ContactsContract API
A Contacts Provider Explorer
Code for Exploring a Database
Source Code for a Contacts Provider Explorer

Summary

245

246
246
246
247
249
249

262

CHAPTER 9: GENERIC DATA SYNCHRONIZATION:
PROJECT MIGRATE AND THE WEBDATA API

Introducing WebData and Project Migrate
How Project Migrate Works
How Project Migrate Streamlines the Mobile Connection

to the Enterprise
The WebData API in Detail
The WebData API RESTful Protocol

Project Migrate in Detail

265

266
266
267
268
269

279

The Migrate Project Android WebData Client
Project Migrate Android Features

279
279

xvi

www.it-ebooks.info
ftoc.indd xvi

26-09-2013 19:12:59



CONTENTS

The WebData Content Provider Android API
Android Built-In Provider APIs
The Migrate Provider API

Summary

281
281
281

281

Service-Side Advantages
Client Advantages

282
282

CHAPTER 10: WEBDATA APPLICATIONS

The Migrate Client
Creating a Migrate Project

283

284
285


Step 1: Importing the Project
Step 2: Enabling the Project as a Migrate Client
Step 3: Defining the Information to Be Managed by Migrate
Step 4: Generating the Contacts Contract

Interfacing with the Migrate REST Proxy
Step 5: Starting a Local Migrate Service
Step 6: Publishing Your Application’s Schema

Setting Up a Device

285
285
286
287

291
296
296

298

Step 1: Installing the Migrate Client
Step 2: Adding a WebData Account
Step 3: Turning on Synchronization
Step 4: Running the Application
Step 5: Configuring an Account in Migrate Contacts (Optional)

Future Directions: MigrateClinic
Summary

CHAPTER 11: BUILDING HUMAN INTERFACES FOR DATA

Modularity and Flexibility Compared
with a “Cookbook” Approach
Overview of Modules
Layout Changes

298
299
299
300
300

300
303
305

306
306
307

Direct Manipulation

308

The TabbedActivity Class
The TabbedPagedFragment Class

Navigation


308
319

320

Multitasking in a Small-Screen Environment
The Android Task Model
Tasks and the Conventional Process Model
Modifying Task Behavior
Navigation in Tablets

Choosing to Use the Support Package
Summary

320
320
321
321
323

323
324
xvii

www.it-ebooks.info
ftoc.indd xvii

26-09-2013 19:12:59



CONTENTS

CHAPTER 12: SECURITY

325

Platform Security
Keeping Handsets Safe

326
327

Avoiding Malicious Applications
Understand Malware Mechanics: The Malware Genome

Writing Secure Applications
Hacking Targets
Ingredients of a Secure Application
Example Code: Protecting RESTful Invocations
Preventing Piracy

Summary

327
330

331
331
332
353

365

366

INDEX

369

xviii

www.it-ebooks.info
ftoc.indd xviii

26-09-2013 19:12:59


INTRODUCTION

MANY ENTERPRISE-ORIENTED APPLICATIONS fit a broad template: They access data using one or
more RESTful APIs. They present the data to the user. They may enable the user to modify the data,
and update the data on servers. Enterprise Android is a book about those applications.

WHO THIS BOOK IS FOR
If you are an experienced Java or JavaScript coder, you may have some ideas about how RESTful
apps should work. You can correctly think of Android as a Java OS: You write apps in Java and
deploy them to an environment that, in some ways, very closely resembles a Java VM. These apps
communicate with RESTful APIs to fetch data to present to the user.
But, as with many aspects of Android software development, it pays to look at how Android is
designed before wading in. This book was created to give you a substantial head start at applying
your experience with RESTful applications and APIs to creating Android apps that are efficient,

versatile, and responsive. You will avoid the pitfalls of assuming Android programming is like web
programming or client Java programming using Oracle’s class libraries, and be able to do it using
Android APIs effectively on the fi rst try.
If you are a beginning Android programmer, and do not have significant experience with iOS or Java,
or if you are unsure that RESTful applications are what you need to learn about, you should start with
a general introduction to Android. Beginners will appreciate a book like Reto Meier’s excellent
Professional Android 4 Application Development (John Wiley & Sons, 2012) or the online tutorials
at developer.android.com, which are much improved compared to the early days of Android.
If you are interested in expanding your development horizon beyond device programming by pushing into service-side development, this book builds competence handling application data on both
sides of the network.

WHAT THIS BOOK COVERS
This book starts with the basics of creating an Enterprise-oriented Android app that can run on
handsets and tablets. But it’s not a beginner’s book. You should, at least, read the online tutorials at
Google’s Android Developer’s site before reading this book.
Android uses SQLite, and this book covers SQL and SQLite in enough depth that you will
understand how data is stored in SQLite databases in Android systems.
Android wraps SQLite in database classes, and this book covers those classes in depth, as well.
When apps make use of data in the Android environment, they often use a specialized service
component called a ContentProvider. This class, and the related ContentResolver class, provide
a REST-like interface to data within an Android device. Using these classes has other advantages in
building apps that use the observer pattern.

www.it-ebooks.info
flast.indd xix

26-09-2013 22:37:20


INTRODUCTION


Enabling you to implement an end-to-end observer pattern is a key element of this book. Your data
resides in a database behind a RESTful API on your servers. Locally, it is likely to be stored in a
SQLite database inside a ContentProvider component. This book shows you how to make sure the
data you present to the user is consistent and up to date.
Simplicity is important, too. JSON is a simple way to represent data with simplicity and flexibility
where, otherwise, a complex database design might be required. This book shows you how to use JSON
with SQLite to maintain simplicity in your implementation. It also shows you a complex Android database and ContentProvider interface, implemented with a conventional approach to database design.
You will create and deploy a server for your front end as you use the examples in this book. In
particular, Chapters 5 and 6 come together at the end of Chapter 6 to form an end-to-end example
of the techniques covered in this book. You’ll deploy this service on Amazon and Google cloud
resources in Chapter 7.
One thing you won’t spend much time on is loading indicators. A networked app should be as responsive as a “local” app. Create, update, and delete (CRUD) should not be interposed between the user and
the data the user wants. A very important part of this book explains how to keep CRUD off the network and out of the user’s way, using a lightweight but powerful synchronization protocol. The book
completes this approach by introducing an open source framework that encapsulates this approach.
The book concludes with an in-depth tour of Android security.

HOW THIS BOOK IS STRUCTURED
This book is called Enterprise Android because it is about acquiring, presenting, and updating data
on devices and using cloud resources, which is the core of most enterprise applications.
This book starts with a brisk-paced introduction to Android programming that puts you on track to make
an application for displaying data. This is about as fast an introduction as can be, so don’t be surprised if
you need to go to the online tutorials in the Android documentation to go deeper on some basics.
Following this introduction, you will be immersed in the core subject matter of this book: data. The
book progresses from the bottom up: how to store data locally, how to make queries, how to get it
and serve it from REST APIs, how the observer pattern is implemented in Android idioms, how to
update it, and how to make this all happen with or without connectivity and with the best apparent
performance. Later in the book, more UI programming oriented toward presenting data is covered.
The book closes with a chapter on security.


WHAT YOU NEED TO USE THIS BOOK
This book is about Android software development, and the examples in it require the use of the
Android software development kit (SDK), which is available from developer.android.com. The
SDK is compatible with the three most widely used desktop operating systems: Windows, Mac OS
X, and Linux. You may prefer to use an Android device to run the example code, but you can use an
emulator, included in the SDK, running on your desktop computer.
xx

www.it-ebooks.info
flast.indd xx

26-09-2013 22:37:20


INTRODUCTION

NOTE Database code in Android has been very stable for several versions of
the Android OS. Mostly due to the way we cover user interface for database
apps, this book assumes you will run your programs on Android 4 or later
versions. You can expect most of this book to remain current for future version
of Android.

To run the service examples in the book, you’ll need to download the packages in each chapter,
including the following: Apache Tomcat, ant, MySQL, and the cygwin toolkit. You’ll also need
an Amazon AWS account with manager privileges and a Google account.

CONVENTIONS
To help you get the most from the text and keep track of what’s happening, you’ll see a number of
conventions throughout the book.


WARNING Warnings like this one hold important, not-to-be forgotten information that is directly relevant to the surrounding text.

NOTE Notes offer tips, hints, tricks, and asides to the current discussion.

As for styles in the text:


New terms and important words are highlighted when they are introduced.



Keyboard strokes appear like this: Ctrl+A.



Filenames, URLs, and code within the text appear like so: persistence.properties.



Code appears in two different ways:
We use a monofont type with no highlighting for most code examples.
We use bold to emphasize code that’s particularly important in the present context.

SOURCE CODE
As you read the chapters in this book, you will want to run, inspect, and perhaps modify the source
code fi les that accompany the book. Please note that all the code examples in this chapter are available at and as a part of the
book’s code download at www.wrox.com on the Download Code tab.
xxi

www.it-ebooks.info

flast.indd xxi

26-09-2013 22:37:21


INTRODUCTION

To fi nd the source code via the Wrox site, locate the book’s title (either by using the Search box or
by using one of the title lists) and click the Download Code link on the book’s detail page to obtain
all the source code for the book.

NOTE Because many books have similar titles, you may fi nd it easiest to search

by ISBN; this book’s ISBN is 978-1-118-18349-6

Alternately, you can go to the main Wrox code download page at />books/download.aspx to see the code available for this book and all other Wrox books.

ERRATA
We make every effort to ensure that there are no errors in the text or in the code. However, no one
is perfect, and mistakes do occur. If you fi nd an error in one of our books, like a spelling mistake or
faulty piece of code, we would be very grateful for your feedback. By sending in errata you may save
another reader hours of frustration and at the same time you will be helping us provide even higher
quality information.
To find the errata page for this book, go to and locate the title using the Search
box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page
you can view all errata that has been submitted for this book and posted by Wrox editors.

NOTE A complete book list including links to each book’s errata is also available
at www.wrox.com/misc-pages/booklist.shtml.


If you don’t spot “your” error on the Book Errata page, go to www.wrox.com/contact/techsupport
.shtml and complete the form there to send us the error you have found. We’ll check the information
and, if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions of the book.

P2P.WROX.COM
For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a web-based
system for you to post messages relating to Wrox books and related technologies and interact with
other readers and technology users. The forums offer a subscription feature to e-mail you topics
of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other
industry experts, and your fellow readers are present on these forums.

xxii

www.it-ebooks.info
flast.indd xxii

26-09-2013 22:37:21


INTRODUCTION

At you will fi nd a number of forums that will help you not only as you read
this book, but also as you develop your own applications. To join the forums, just follow these steps:

1.

Go to p2p.wrox.com and click the Register link.

2.


Read the terms of use and click Agree.

3.

Complete the required information to join as well as any optional information you wish to
provide and click Submit.

4.

You will receive an e-mail with information describing how to verify your account and complete the joining process.

NOTE You can read messages in the forums without joining P2P, but in order to
post your own messages, you must join.

Once you join, you can post new messages and respond to messages other users post. You can read
messages at any time on the web. If you would like to have new messages from a particular forum
e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to
questions about how the forum software works as well as many common questions specific to P2P
and Wrox books. To read the FAQs, click the FAQ link on any P2P page.

xxiii

www.it-ebooks.info
flast.indd xxiii

26-09-2013 22:37:21



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

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