Android actions

594 966 0
Android actions

Đ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

tài liệu bao gồm những hành vi mà người dùng hay sử dụ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> [...]... applications for Android with a hands-on tour of the Android development environment (chapter 2) Download from Wow! eBook Download from Wow! eBook Introducing Android This chapter covers  Exploring Android, the open source mobile platform  Android Intents, the way things work  Sample application You’ve heard about Android You’ve read about Android Now it’s time... 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 leveraging the capable Android platform to create innovative mobile applicatoins PART 1: THE ESSENTIALS Part 1 introduces the Android platform, including its architecture and... essential for working with the Android platform In addition to Intent, this chapter introduces the four main application components: Activity, Service, ContentProvider, and BroadcastReceiver The chapter concludes with a simple Android application to get you started quickly 1.1 The Android platform Android is a software environment built for mobile devices It’s not a hardware platform Android includes a Linux... Sensors are exercised See chapter 2 for information on how to set up and use the Android emulator The term platform refers to Android itself—the software—including all the binaries, code libraries, and tool chains This book focuses on the Android platform; the Android emulators available in the SDK are simply components of the Android platform PLATFORM VS DEVICE With all of that as a backdrop, creating... Installing the Android SDK appendix B Publishing applications index 527 538 551 Download from Wow! eBook preface When we set out to write the first version of this book, many friends and family wondered 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, ... industry This chapter introduces Android what it is, and, equally important, what it’s not After reading this chapter, you’ll understand how Android is constructed, how 3 Download from Wow! eBook 4 CHAPTER 1 Introducing Android it compares with other offerings in the market, and what its foundational technologies are, plus you’ll get a preview of Android application architecture... 3 ANDROID APPLICATIONS 291 12 Putting Android to work in a field service application 12.1 Designing a real-world Android application 293 294 Core requirements of the application 295 Managing the data 296 Application architecture and integration 297 ■ ■ 12.2 Mapping out the application flow 298 Mapping out the field service application 298 List of source files 300 Field service application’s AndroidManifest.xml... user applications are built for Android in Java Even the built-in applications are written in Java With the exception of some Linux exploratory exercises in chapter 13 and the Native Developer Kit (NDK) in chapter 19, all the code examples in this book are written in Java, using the Android Android Software software development kit (SDK) Environment One feature of the Android platform is that there’s... shows the relationship between Android and machine the hardware it runs on The most notable feature of Linux Kernel Android might be that it’s open source; missing elements can and will be provided by the global developer community Android s Linux kernel-based OS doesn’t come with a sophisticated shell environment, but because the platform is open, you can write and Figure 1.1 Android is software install... their Android phone Download from Wow! eBook ABOUT THIS BOOK xxvii Chapter 15 explores the Android contact database and demonstrates integrating with an external data source In particular, this application brings Android into the social networking scene by integrating with the popular LinkedIn professional networking service Chapter 16 explores the world of web development Android s . 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 <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. 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

Ngày đăng: 31/05/2014, 13:36

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

  • Đang cập nhật ...

Tài liệu liên quan