Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Enterprise Android™
PREMIUM
Số trang
408
Kích thước
14.4 MB
Định dạng
PDF
Lượt xem
1916

Enterprise Android™

Nội dung xem thử

Mô tả chi tiết

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

ffirs.indd i 26-09-2013 19:13:29

ffirs.indd ii 26-09-2013 19:13:29

Enterprise Android™

ffirs.indd iii 26-09-2013 19:13:29

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

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 http://www.wiley.com/go/permissions.

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 specifi cally disclaim all warranties, including

without limitation warranties of fi tness 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

http://booksupport.wiley.com. 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.

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

ffirs.indd vii 26-09-2013 19:13:30

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 product￾defi 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 pro￾vided the platform for “Device of the Show” at JavaOne. Again at Sun Microsystems, Laird contin￾ued 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 ser￾vice backend system using Big Data and NoSQL at Nokia.

ffirs.indd ix 26-09-2013 19:13:30

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.

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 fi ction, interactive user

experience design, creating and solving puzzles for puzzle hunts, and functional programming.

ffirs.indd x 26-09-2013 19:13:30

EXECUTIVE EDITOR

Robert Elliott

SENIOR PROJECT EDITOR

Kevin Kent

TECHNICAL EDITOR

Maija Mednieks

PRODUCTION EDITOR

Christine Mugnolo

COPY EDITOR

Kezia Endsley

EDITORIAL MANAGER

Mary Beth Wakefi eld

FREELANCER EDITORIAL MANAGER

Rosemarie Graham

ASSOCIATE DIRECTOR OF MARKETING

David Mayhew

MARKETING MANAGER

Ashley Zurcher

BUSINESS MANAGER

Amy Knies

PRODUCTION MANAGER

Tim Tate

VICE PRESIDENT AND EXECUTIVE GROUP

PUBLISHER

Richard Swadley

VICE PRESIDENT AND EXECUTIVE PUBLISHER

Neil Edde

ASSOCIATE PUBLISHER

Jim Minatel

PROJECT COORDINATOR, COVER

Katie Crocker

PROOFREADER

Nancy Carrasco

TECHNICAL PROOFREADER

Jim Fitzgerald

INDEXER

John Sleeva

COVER DESIGNER

Ryan Sneed

COVER IMAGE

©iStockphoto.com/Iaroslav Neliubov

CREDITS

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

ffirs.indd xii 26-09-2013 19:13:30

CONTENTS

INTRODUCTION xix

CHAPTER 1: DEVELOPING FOR ANDROID TABLETS

AND SMARTPHONES 1

Android Is a Java Operating System 2

Your Tools and Your First Android App 2

Prerequisites and Getting Ready 2

Toolchain Test Drive 4

One Code-Base for All Types of Devices 4

Getting Started with the Code Framework Example 5

Automatically Adapting to Screen Size 10

Components, Views, and Lifecycle 11

Destroying and Re-Creating Components 11

The MainActivity Class 12

Activity: The Basic Unit of User Interaction 12

Fragment: A Tool for Organizing Code and UI 17

The PickFragment Class 18

The ItemFragment Class 22

The ItemDetailFragment Class 25

Tying Together Activities, Fragments,

and the Action Bar 25

The TabbedActivity Class 25

A Main.xml File for Large Tablets 28

A Main.xml and a Subsidiary Activity for Smaller Screens 29

The TabActivity Class 30

The Android Task and Process Model 33

Starting Dalvik Instances 34

Death, but No Transfi guration 34

Tasks Span Applications and Processes 35

Multiprocessing, Security, and Lifecycle 35

The Process and User ID as Security Boundary 36

Declaring Application Properties 36

Summary 37

ftoc.indd xiii 26-09-2013 19:12:59

Tải ngay đi em, còn do dự, trời tối mất!