beginning android 4 application development

564 4.6K 0
beginning android 4 application development

Đ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

www.it-ebooks.info ffirs.indd iiffirs.indd ii 25/01/12 8:34 AM25/01/12 8:34 AM www.it-ebooks.info BEGINNING ANDROID ™ 4 APPLICATION DEVELOPMENT INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi CHAPTER 1 Getting Started with Android Programming . . . . . . . . . . . . . . . . . . . . . . . . .1 CHAPTER 2 Activities, Fragments, and Intents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 CHAPTER 3 Getting to Know the Android User Interface . . . . . . . . . . . . . . . . . . . . . . 105 CHAPTER 4 Designing Your User Interface with Views . . . . . . . . . . . . . . . . . . . . . . . 159 CHAPTER 5 Displaying Pictures and Menus with Views . . . . . . . . . . . . . . . . . . . . . . . 219 CHAPTER 6 Data Persistence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 CHAPTER 7 Content Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293 CHAPTER 8 Messaging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 CHAPTER 9 Location-Based Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 351 CHAPTER 10 Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393 CHAPTER 11 Developing Android Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 CHAPTER 12 Publishing Android Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463 APPENDIX A Using Eclipse for Android Development . . . . . . . . . . . . . . . . . . . . . . . . . 483 APPENDIX B Using the Android Emulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499 APPENDIX C Answers to Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515 INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 521 ffirs.indd iffirs.indd i 25/01/12 8:34 AM25/01/12 8:34 AM www.it-ebooks.info ffirs.indd iiffirs.indd ii 25/01/12 8:34 AM25/01/12 8:34 AM www.it-ebooks.info BEGINNING Android ™ 4 Application Development ffirs.indd iiiffirs.indd iii 25/01/12 8:34 AM25/01/12 8:34 AM www.it-ebooks.info ffirs.indd ivffirs.indd iv 25/01/12 8:34 AM25/01/12 8:34 AM www.it-ebooks.info BEGINNING Android ™ 4 Application Development Wei-Meng Lee John Wiley & Sons, Inc. ffirs.indd vffirs.indd v 25/01/12 8:34 AM25/01/12 8:34 AM www.it-ebooks.info Beginning Android™ 4 Application Development Published by John Wiley & Sons, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2012 by John Wiley & Sons, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-1-118-19954-1 ISBN: 978-1-118-22824-1 (ebk) ISBN: 978-1-118-24067-0 (ebk) ISBN: 978-1-118-26538-3 (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: 2011945560 Trademarks: Wiley, the Wiley logo, 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 viffirs.indd vi 25/01/12 8:34 AM25/01/12 8:34 AM www.it-ebooks.info To my family: Thanks for the understanding and support while I worked on getting this book ready. I love you all! ffirs.indd viiffirs.indd vii 25/01/12 8:34 AM25/01/12 8:34 AM www.it-ebooks.info ffirs.indd viiiffirs.indd viii 25/01/12 8:34 AM25/01/12 8:34 AM www.it-ebooks.info [...]... IntentService 44 2 Establishing Communication between a Service and an Activity Binding Activities to Services Understanding Threading Summary 44 5 44 9 45 4 46 0 CHAPTER 12: PUBLISHING ANDROID APPLICATIONS 46 3 Preparing for Publishing 46 3 Versioning Your Application Digitally Signing Your Android Applications Deploying APK Files 46 4 46 6 47 1 Using the adb.exe Tool Using a Web Server Publishing on the Android. .. Android Market Summary 47 1 47 4 47 6 48 1 APPENDIX A: USING ECLIPSE FOR ANDROID DEVELOPMENT Getting Around in Eclipse 48 3 48 3 Workspaces Package Explorer Using Projects from Other Workspaces Using Editors within Eclipse Understanding Eclipse Perspectives Automatically Importing Packages Using the Code Completion Feature Refactoring Debugging your Application 48 3 48 5 48 6 48 7 49 0 49 0 49 1 49 2 49 4 Setting Breakpoints... 25/01/12 8: 34 AM www.it-ebooks.info ffirs.indd xiv 25/01/12 8: 34 AM CONTENTS INTRODUCTION xxi CHAPTER 1: GETTING STARTED WITH ANDROID PROGRAMMING What Is Android? 1 2 Android Versions Features of Android Architecture of Android Android Devices in the Market The Android Market The Android Developer Community Obtaining the Required Tools Android SDK Installing the Android SDK Tools Configuring the Android. .. 375 3 84 385 390 393 393 396 xviii www.it-ebooks.info ftoc.indd xviii 25/01/12 8:35 AM CONTENTS Downloading Text Content Accessing Web Services Using the GET Method Consuming JSON Services Sockets Programming Summary 40 2 40 4 40 9 41 7 42 6 CHAPTER 11: DEVELOPING ANDROID SERVICES Creating Your Own Services 42 9 42 9 Performing Long-Running Tasks in a Service 43 3 Performing Repeated Tasks in a Service 43 9 Executing... Getting Started with Android Programming WHAT YOU WILL LEARN IN THIS CHAPTER ➤ What is Android? ➤ Android versions and its feature set ➤ The Android architecture ➤ The various Android devices on the market ➤ The Android Market application store ➤ How to obtain the tools and SDK for developing Android applications ➤ How to develop your first Android application Welcome to the world of Android! When I was... Installing the Android SDK Tools Configuring the Android SDK Manager Eclipse Android Development Tools (ADT) Creating Android Virtual Devices (AVDs) Creating Your First Android Application Anatomy of an Android Application Summary CHAPTER 2: ACTIVITIES, FRAGMENTS, AND INTENTS Understanding Activities 2 3 4 6 8 9 9 10 11 12 14 15 17 20 29 33 35 36 Applying Styles and Themes to an Activity Hiding the... with developing your fi rst Android application, and learn how to obtain all the necessary tools and set them up so that you can test your application on an Android 4. 0 emulator By the end of this chapter, you will be equipped with the basic knowledge you need to explore more sophisticated techniques and tricks for developing your next killer Android application WHAT IS ANDROID? Android is a mobile operating... for Android and optimized for battery-powered mobile devices with limited memory and CPU ➤ Application framework — Exposes the various capabilities of the Android OS to application developers so that they can make use of them in their applications ➤ Applications — At this top layer, you will find applications that ship with the Android device (such as Phone, Contacts, Browser, etc.), as well as applications... the same name, Android, Inc In 2005, as part of its strategy to enter the mobile space, Google purchased Android and took over its development work (as well as its development team) Google wanted Android to be open and free; hence, most of the Android code was released under the open source Apache License, which means that anyone who wants to use Android can do so by downloading the full Android source... manufacturers see Android as a solution — they will continue to design their own hardware and use Android as the operating system that powers it The main advantage of adopting Android is that it offers a unified approach to application development Developers need only develop for Android, and their applications should be able to run on numerous different devices, as long as the devices are powered using Android . iffirs.indd i 25/01/12 8: 34 AM25/01/12 8: 34 AM www.it-ebooks.info ffirs.indd iiffirs.indd ii 25/01/12 8: 34 AM25/01/12 8: 34 AM www.it-ebooks.info BEGINNING Android ™ 4 Application Development ffirs.indd. iiiffirs.indd iii 25/01/12 8: 34 AM25/01/12 8: 34 AM www.it-ebooks.info ffirs.indd ivffirs.indd iv 25/01/12 8: 34 AM25/01/12 8: 34 AM www.it-ebooks.info BEGINNING Android ™ 4 Application Development Wei-Meng. 25/01/12 8: 34 AM25/01/12 8: 34 AM www.it-ebooks.info Beginning Android 4 Application Development Published by John Wiley & Sons, Inc. 1 047 5 Crosspoint Boulevard Indianapolis, IN 46 256 www.wiley.com Copyright

Ngày đăng: 01/08/2014, 16:17

Từ khóa liên quan

Mục lục

  • Beginning Android™ 4 Application Development

  • Contents

  • Introduction

  • Chapter 1: Getting Started with Android Programming

    • What Is Android?

      • Android Versions

      • Features of Android

      • Architecture of Android

      • Android Devices in the Market

      • The Android Market

      • The Android Developer Community

      • Obtaining the Required Tools

        • Android SDK

        • Installing the Android SDK Tools

        • Configuring the Android SDK Manager

        • Eclipse

        • Android Development Tools (ADT)

        • Creating Android Virtual Devices (AVDs)

        • Creating Your First Android Application

        • Anatomy of an Android Application

        • Summary

        • Chapter 2: Activities, Fragments, and Intents

          • Understanding Activities

            • Applying Styles and Themes to an Activity

            • Hiding the Activity Title

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

Tài liệu liên quan