Androidin Action 2nd edition

594 1.3K 0
Androidin Action 2nd edition

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Hành động trong android

MANNING W. Frank Ableson Robi Sen Chris King Covers Android 2 SECOND EDITION IN ACTION Android in Action Second Edition Download from Wow! eBook <www.wowebook.com> Download from Wow! eBook <www.wowebook.com> Android in Action SECOND EDITION W. FRANK ABLESON ROBI SEN CHRIS KING Revised Edition of Unlocking Android MANNING Greenwich (74° w. long.) Download from Wow! eBook <www.wowebook.com> 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. 180 Broad St. Suite 1323 Stamford, CT 06901 Email: orders@manning.com ©2011 by Manning Publications Co. All rights reserved. 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. Development editor: Troy Mott 180 Broad St. Copyeditors: Joan Celmer, Liz Welch Suite 1323 Typesetter: Dottie Marsico Stamford, CT 06901 Cover designer: Marija Tudor ISBN 978-1-935182-72-6 Printed in the United States of America 12 34567 8910– MAL–16 151413 1211 Download from Wow! eBook <www.wowebook.com> v brief contents PART 1 WHAT IS ANDROID?—THE BIG PICTURE 1 1 ■ Introducing Android 3 2 ■ Android’s development environment 31 PART 2 EXERCISING THE ANDROID SDK 61 3 ■ User interfaces 63 4 ■ Intents and Services 101 5 ■ Storing and retrieving data 129 6 ■ Networking and web services 159 7 ■ Telephony 187 8 ■ Notifications and alarms 205 9 ■ Graphics and animation 222 10 ■ Multimedia 246 11 ■ Location, location, location 267 PART 3 ANDROID APPLICATIONS 291 12 ■ Putting Android to work in a field service application 293 13 ■ Building Android applications in C 338 Download from Wow! eBook <www.wowebook.com> BRIEF CONTENTSvi PART 4 THE MATURING PLATFORM 365 14 ■ Bluetooth and sensors 367 15 ■ Integration 387 16 ■ Android web development 421 17 ■ AppWidgets 454 18 ■ Localization 491 19 ■ Android Native Development Kit 506 Download from Wow! eBook <www.wowebook.com> vii contents preface xvii preface to the first edition xix acknowledgments xxi about this book xxiv about the cover illustration xxix PART 1 WHAT IS ANDROID?—THE BIG PICTURE 1 1 Introducing Android 3 1.1 The Android platform 4 1.2 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 11 ■ Running in the Dalvik VM 12 1.4 The Intent of Android development 12 Empowering intuitive UIs 13 ■ Intents and how they work 13 Download from Wow! eBook <www.wowebook.com> CONTENTSviii 1.5 Four kinds of Android components 17 Activity 17 ■ Service 18 ■ BroadcastReceiver 19 ContentProvider 22 1.6 Understanding the AndroidManifest.xml file 24 1.7 Mapping applications to processes 25 1.8 Creating an Android application 26 1.9 Summary 30 2 Android’s development environment 31 2.1 Introducing the Android SDK 32 Core Android packages 33 ■ Optional packages 34 2.2 Exploring the development environment 34 The Java perspective 35 ■ The DDMS perspective 37 Command-line tools 40 2.3 Building an Android application in Eclipse 43 The Android Project Wizard 43 ■ Android sample application code 44 ■ Packaging the application 50 2.4 Using the Android emulator 51 Setting up the emulated environment 52 Testing your application in the emulator 56 2.5 Debugging your application 57 2.6 Summary 58 PART 2 EXERCISING THE ANDROID SDK 61 3 User interfaces 63 3.1 Creating the Activity 65 Creating an Activity class 66 ■ Exploring the Activity lifecycle 71 3.2 Working with views 74 Exploring common views 75 ■ Using a ListView 77 Multitasking with Handler and Message 81 Creating custom views 82 ■ Understanding layout 84 Handling focus 86 ■ Grasping events 87 3.3 Using resources 89 Supported resource types 89 ■ Referencing resources in Java 89 Defining views and layouts through XML resources 92 Externalizing values 94 ■ Providing animations 97 Download from Wow! eBook <www.wowebook.com> CONTENTS ix 3.4 Exploring the AndroidManifest file 98 3.5 Summary 99 4 Intents and Services 101 4.1 Serving up RestaurantFinder with Intent 102 Defining Intents 102 ■ Implicit and explicit invocation 103 Adding external links to RestaurantFinder 104 ■ Finding your way with Intent 106 ■ Taking advantage of Android-provided activities 108 4.2 Checking the weather with a custom URI 109 Offering a custom URI 109 ■ Inspecting a custom Uri 111 4.3 Checking the weather with broadcast receivers 113 Broadcasting Intent 113 ■ Creating a receiver 115 4.4 Building a background weather service 115 4.5 Communicating with the WeatherAlertService from other apps 119 Android Interface Definition Language 119 ■ Binder and Parcelable 121 ■ Exposing a remote interface 122 Binding to a Service 123 ■ Starting versus binding 126 Service lifecycle 127 4.6 Summary 128 5 Storing and retrieving data 129 5.1 Using preferences 130 Working with SharedPreferences 130 ■ Preference access permissions 133 5.2 Using the filesystem 136 Creating files 136 ■ Accessing files 137 ■ Files as raw resources 138 ■ XML file resources 139 ■ External storage via an SD card 141 5.3 Persisting data to a database 144 Building and accessing a database 144 ■ Using the sqlite3 tool 149 5.4 Working with ContentProvider classes 149 Using an existing ContentProvider 150 ■ Creating a ContentProvider 151 5.5 Summary 158 Download from Wow! eBook <www.wowebook.com> [...]... graphics Many of the original graphics from the first edition, Unlocking Android, have been reused in this version of the book While the title of the revised edition was changed to Android in Action, Second Edition during development, we kept the original book title in our graphics and sample applications Author Online Purchase of Android in Action, Second Edition includes free access to a private web forum... just what this Android thing was all about Now, two years after the publication of the first edition, Android is nearly a household term The first edition of the book, Unlocking Android, enjoyed enough success that we were privileged to have the opportunity to write this second edition, renamed as Android in Action The first thirteen chapters of the book have been refreshed and/or rewritten to bring... challenging than writing a technical book is writing the second edition There is a lot of excitement when writing the proposed table of contents for the updated edition but at some point the work must commence The size and scope of this project meant working together as a team from the start I had the privilege of working again with Robi Sen from the first edition and also with experienced developer and writer... breaks and using indentation carefully Sometimes, however, very long lines will include line-continuation markers Source code for all the working examples is available from www.manning.com/ AndroidinActionSecondEdition or http://www.manning.com/ableson2 A readme.txt file is provided in the root folder and also in each chapter folder; the files provide details on how to install and run the code Code... challenging Android continues to mature and promises to be a major player for years to come Many thanks are owed to readers of the first edition, for without you, there wouldn’t be a second edition! FRANK ABLESON Download from Wow! eBook preface to the first edition The first mobile applications I had the opportunity to work with were inventory control programs used in retail and manufacturing... make comments about the book, ask technical questions, and receive help from the authors and from other users To access the forum and subscribe to it, point your web browser to www.manning.com/ AndroidinActionSecondEdition or www.manning.com/ableson2 This page provides information on how to get on the forum once you’re registered, what kind of help is available, and the rules of conduct on the forum Manning’s... fruition We could have written many more chapters, but we had to draw the line somewhere! The second edition of this book was written by Frank Ableson, Robi Sen, and Chris King Chris updated chapters 4, 5, 7, and 11 Some excellent content originally written by Charlie Collins remains in this second edition Early on in the project Chris and I were discussing the need to bring social networking into... talented team at Manning, we are pleased to present Android in Action, the update to Unlocking Android In particular, we’d like to acknowledge and thank those at Manning who helped bring this book about First, thanks to Troy Mott, our acquisition and development editor, who has been involved in every aspect of both the first and second editions Troy was there from the beginning, from the “what if”... more often than I liked, had to do without me while I worked on my chapters, worked multiple jobs, and finished grad school Download from Wow! eBook about this book Android in Action, Second Edition is a revision and update of Unlocking Android, published in April 2009 This book doesn’t fit nicely into the camp of “introductory text,” nor is it a highly detailed reference manual The... will be accessible from the publisher’s website as long as the book is in print Download from Wow! eBook about the cover illustration The illustration on the cover of Android in Action, Second Edition is taken from a French book of dress customs, Encyclopédie des Voyages by J G St Saveur, published in 1796 Travel for pleasure was a relatively new phenomenon at the time and illustrated . 2 SECOND EDITION IN ACTION Android in Action Second Edition Download from Wow! eBook <www.wowebook.com> Download from Wow! eBook <www.wowebook.com> Android in Action SECOND EDITION W first edition, Android is nearly a household term. The first edition of the book, Unlocking Android, enjoyed enough success that we were privileged to have the opportunity to write this second edition, . readers of the first edition, for without you, there wouldn’t be a second edition! FRANK ABLESON Download from Wow! eBook <www.wowebook.com> xix preface to the first edition The first mobile

Ngày đăng: 27/05/2014, 21:20

Từ khóa liên quan

Mục lục

  • Android in Action

  • brief contents

  • contents

  • preface xvii

  • preface to the first edition xix

  • acknowledgments xxi

  • about this book xxiv

  • about the cover illustration xxix

    • preface

    • preface to the first edition

    • acknowledgments

      • Frank Ableson

      • Chris King

      • Robi Sen

      • about this book

        • The audience

        • Roadmap

        • Code conventions and downloads

        • Software requirements

        • A note about the graphics

        • Author Online

        • about the cover illustration

        • Part 1 What is Android?— The Big Picture

          • Introducing Android

            • 1.1 The Android platform

Tài liệu cùng người dùng

Tài liệu liên quan