1. Trang chủ
  2. » Công Nghệ Thông Tin

Pro android 3

1,2K 80 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 1.201
Dung lượng 25,76 MB

Nội dung

www.it-ebooks.info Pro Android ■■■ Satya Komatineni Dave MacLean Sayed Y Hashimi i www.it-ebooks.info Pro Android Copyright © 2011 by Satya Komatineni, Dave MacLean, and Sayed Y Hashimi All rights reserved No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage or retrieval system, without the prior written permission of the copyright owner and the publisher ISBN-13 (pbk): 978-1-4302-3222-3 ISBN-13 (electronic): 978-1-4302-3223-0 Trademarked names, logos, and images may appear in this book Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark NFC Forum and the NFC Forum logo are trademarks of the Near Field Communication Forum Download from Wow! eBook The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights President and Publisher: Paul Manning Lead Editor: Matthew Moodie Technical Reviewer: Dylan Phillips Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft, Matt Wade, Tom Welsh Coordinating Editor: Corbin Collins Copy Editors: Heather Lang, Tracy Brown, Mary Behr Compositor: MacPS, LLC Indexer: BIM Indexing & Proofreading Services Artist: April Milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC., 233 Spring Street, 6th Floor, New York, NY 10013 Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com For information on translations, please e-mail rights@apress.com, or visit www.apress.com Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use eBook versions and licenses are also available for most titles For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/info/bulksales The information in this book is distributed on an “as is” basis, without warranty Although every precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly by the information contained in this work The source code for this book is available to readers at www.apress.com www.it-ebooks.info To my brother Hari, to whom life yielded few favors —Satya Komatineni To my wife, Rosie, and my son, Mike, for their support; I couldn't have done this without you And to Max, for spending so much time at my feet keeping me company —Dave MacLean To my son, Sayed-Adieb —Sayed Y Hashimi www.it-ebooks.info Contents at a Glance Contents vi Foreword xviii About the Authors .xix About the Technical Reviewer .xx Acknowledgments xxi Preface .xxii ■Chapter 1: Introducing the Android Computing Platform 1 ■Chapter 2: Setting Up Your Development Environment 21 ■Chapter 3: Understanding Android Resources 63 ■Chapter 4: Understanding Content Providers 89 ■Chapter 5: Understanding Intents 125 ■Chapter 6: Building User Interfaces and Using Controls 145 ■Chapter 7: Working with Menus 217 ■Chapter 8: Working with Dialogs 243 ■Chapter 9: Working with Preferences and Saving State 265 ■Chapter 10: Exploring Security and Permissions 287 ■Chapter 11: Building and Consuming Services 307 ■Chapter 12: Exploring Packages 377 ■Chapter 13: Exploring Handlers 399 ■Chapter 14: Broadcast Receivers and Long-Running Services 425 ■Chapter 15: Exploring the Alarm Manager 465 ■Chapter 16: Exploring 2D Animation 491 ■Chapter 17: Exploring Maps and Location-based Services 519 ■Chapter 18: Using the Telephony APIs 559 ■Chapter 19: Understanding the Media Frameworks 575 ■Chapter 20: Programming 3D Graphics with OpenGL 623 ■Chapter 21: Exploring Live Folders 693 ■Chapter 22: Home Screen Widgets 711 ■Chapter 23: Android Search 745 ■Chapter 24: Exploring Text to Speech 825 ■Chapter 25: Touch Screens 845 ■Chapter 26: Using Sensors 891 ■Chapter 27: Exploring the Contacts API 937 ■Chapter 28: Deploying Your Application: Android Market and Beyond 993 ■Chapter 29: Fragments for Tablets and More 1015 ■Chapter 30: Exploring ActionBar 1069 ■Chapter 31: Additional Topics in 3.0 1097 Index 1141 iv www.it-ebooks.info Contents Contents at a Glance iv Foreword xviii About the Authors .xix About the Technical Reviewer xx Acknowledgments xxi Preface xxii ■Chapter 1: Introducing the Android Computing Platform 1 A New Platform for a New Personal Computer .1 Early History of Android 3 Delving Into the Dalvik VM 6 Understanding the Android Software Stack 6 Developing an End-User Application with the Android SDK 8 Android Emulator .8 The Android UI 9 The Android Foundational Components 10 Advanced UI Concepts .11 Android Service Components 13 Android Media and Telephony Components 13 Android Java Packages 14 Taking Advantage of Android Source Code 18 The Sample Projects in this Book 19 Summary 20 ■Chapter 2: Setting Up Your Development Environment 21 Setting Up Your Environment 22 Downloading JDK 22 Downloading Eclipse 3.6 23 Downloading the Android SDK 23 The Tools Window 26 Installing Android Development Tools (ADT) 26 v www.it-ebooks.info ■ CONTENTS Learning the Fundamental Components .29 View 29 Activity .29 Intent 29 Content Provider 30 Service .30 AndroidManifest.xml 30 Android Virtual Devices 30 Hello World! 31 Android Virtual Devices 37 Exploring the Structure of an Android Application 39 Analyzing the Notepad Application .42 Loading and Running the Notepad Application 42 Dissecting the Application .44 Examining the Application Lifecycle .51 Debugging Your App .54 Launching the Emulator 56 StrictMode .57 References .61 Summary 62 ■Chapter 3: Understanding Android Resources 63 Understanding Resources .63 String Resources 64 Layout Resources 66 Resource Reference Syntax .67 Defining Your Own Resource IDs for Later Use 69 Compiled and Uncompiled Android Resources 70 Enumerating Key Android Resources 71 Working with Arbitrary XML Resource Files 80 Working with Raw Resources .82 Working with Assets .82 Reviewing the Resources Directory Structure 83 Resources and Configuration Changes 83 Reference URLs 87 Summary 88 ■Chapter 4: Understanding Content Providers 89 Exploring Android’s Built-in Providers 90 Architecture of Content Providers 96 Implementing Content Providers 108 Exercising the Book Provider 120 Adding A Book 120 Removing a Book 120 Getting a Count of the Books 121 Displaying the List of Books 121 Resources 122 Summary 123 ■Chapter 5: Understanding Intents 125 Basics of Android Intents 125 Available Intents in Android 127 Exploring Intent Composition 129 Intents and Data URIs 129 vi www.it-ebooks.info ■ CONTENTS Generic Actions 130 Using Extra Information 131 Using Components to Directly Invoke an Activity 133 Understanding Intent Categories 134 Rules for Resolving Intents to Their Components 137 Exercising the ACTION_PICK .139 Exercising the GET_CONTENT Action 141 Introducing Pending Intents 142 Resources 144 Summary 144 ■Chapter 6: Building User Interfaces and Using Controls 145 UI Development in Android 145 Building a UI Completely in Code 147 Building a UI Completely in XML 149 Building a UI in XML With Code 150 Understanding Android’s Common Controls .152 Text Controls 152 Button Controls 157 The ImageView Control 165 Date and Time Controls 167 The MapView Control .169 Understanding Adapters .170 Getting to Know SimpleCursorAdapter 171 Getting to Know ArrayAdapter .172 Using Adapters With AdapterViews 174 The Basic List Control: ListView .175 The GridView Control .183 The Spinner Control .185 The Gallery Control .187 Creating Custom Adapters .188 Other Controls in Android .194 Styles and Themes 194 Using Styles 194 Using Themes 197 Understanding Layout Managers 198 The LinearLayout Layout Manager 199 The TableLayout Layout Manager 202 The RelativeLayout Layout Manager 206 The FrameLayout Layout Manager 208 Customizing Layout for Various Device Configurations 210 Debugging and Optimizing Layouts with the Hierarchy Viewer 213 References 216 Summary 216 ■Chapter 7: Working with Menus 217 Understanding Android Menus 217 Creating a Menu 219 Working with Menu Groups 220 Responding to Menu Items 221 Creating a Test Harness for Testing Menus 222 Working with Other Menu Types 229 Expanded Menus 229 Working with Icon Menus 229 vii www.it-ebooks.info ■ CONTENTS Working with Submenus 230 Provisioning for System Menus .231 Working with Context Menus 231 Working with Alternative Menus 234 Working with Menus in Response to Changing Data .238 Loading Menus Through XML Files .238 Structure of an XML Menu Resource File 239 Inflating XML Menu Resource Files .239 Responding to XML-Based Menu Items 240 A Brief Introduction to Additional XML Menu Tags 241 Resource .242 Summary 242 ■Chapter 8: Working with Dialogs 243 Using Dialogs in Android .243 Designing an Alert Dialog 244 Designing a Prompt Dialog 246 Nature of Dialogs in Android 251 Rearchitecting the Prompt Dialog 252 Working with Managed Dialogs 253 Understanding the Managed-Dialog Protocol 253 Recasting the Nonmanaged Dialog as a Managed Dialog .253 Simplifying the Managed-Dialog Protocol .255 Working with Toast .263 Resources 264 Summary 264 ■Chapter 9: Working with Preferences and Saving State 265 Exploring the Preferences Framework .265 Understanding ListPreference .266 Understanding CheckBoxPreference .275 Understanding EditTextPreference 277 Understanding RingtonePreference .278 Organizing Preferences 280 Manipulating Preferences Programmatically 283 Saving State with Preferences 284 Reference 285 Summary 286 ■Chapter 10: Exploring Security and Permissions 287 Understanding the Android Security Model 287 Overview of Security Concepts 287 Signing Applications for Deployment .288 Performing Runtime Security Checks 295 Understanding Security at the Process Boundary 295 Declaring and Using Permissions 295 Understanding and Using Custom Permissions .297 Understanding and Using URI Permissions 303 References 305 Summary 305 ■Chapter 11: Building and Consuming Services 307 Consuming HTTP Services 307 Using the HttpClient for HTTP GET Requests 308 Using the HttpClient for HTTP POST Requests (a Multipart Example) 310 viii www.it-ebooks.info ■ CONTENTS SOAP, JSON, and XML Parsers 312 Dealing with Exceptions .313 Addressing Multithreading Issues 315 Fun With Timeouts 318 Using the HttpURLConnection 319 Using the AndroidHttpClient 319 Using Background Threads (AsyncTask) 320 Handling Configuration Changes with AsyncTasks 327 Getting Files Using DownloadManager 331 Using Android Services .337 Understanding Services in Android 338 Understanding Local Services .339 Understanding AIDL Services 346 Defining a Service Interface in AIDL 347 Implementing an AIDL Interface 349 Calling the Service from a Client Application 351 Passing Complex Types to Services 355 Real-World Example Using Services 366 Google Translate API 366 Using the Google Translate API 367 References 375 Summary 376 ■Chapter 12: Exploring Packages 377 Packages and Processes 377 Details of a Package Specification 377 Translating Package Name to a Process Name .378 Listing Installed Packages .378 Deleting a Package through the Package Browser 379 Revisiting the Package Signing Process .379 Understanding Digital Signatures: Scenario .380 Understanding Digital Signatures: Scenario .380 A Pattern for Understanding Digital Signatures .380 So How Do You Digitally Sign? .381 Implications of the Signing Process .381 Sharing Data Among Packages 382 The Nature of Shared User IDs .382 A Code Pattern for Sharing Data 383 Library Projects 384 What Is a Library Project? 384 Library Project Predicates 385 Creating a Library Project 387 Creating an Android Project That Uses a library 390 References 397 Summary 398 ■Chapter 13: Exploring Handlers 399 Android Components and Threading 399 Activities Run on the Main Thread 400 Broadcast Receivers run on the Main Thread 401 Services Run on the Main Thread 401 Content Provider Runs on the Main Thread 401 Implications of a Singular Main Thread 401 Thread Pools, Content Providers, External Service Components 401 ix www.it-ebooks.info 1164 Index signing of, 379–382 overview, 380 and PKI certificates, 381–382 and public and private keys, 381 specification details of, 377–378 Paint class, 15 PaintDrawable class, 79 Palette.java file, 1126 palette.xml file, 1125, 1138 parameters, for SoundPool, 590 params HashMap, 839–840 Parcel class, 357 Parcelable class, 357–358, 365 Parcelable interface, 356–357 parentActivity variable, 405 parentContainer, 149 Path class, 15 PATH variable, 25 PathShape, 15 path_to_/JDK_directory, 23 pause( ) method, 584, 592–593, 595 Pause Player button, 584 penaltyDeath( ) method, 58 pending intents, 142–144 Pending.getActivity( ) method, 143 PendingIntent class, 467–468, 556 People class, 101–102 People table, 101 period character, 831 permissions custom, 297–303 declaring and using, 295–297 URI, 303–306 in content providers, 304–305 passing in intents, 303–304 permitDiskReads( ) method, 60 persistentDrawingCache tag, 504 Person class, 358, 360–361, 364 Person.aidl file, 357 Person.java file, 357–358 perspective projection, 636 Phone application, 18 PhoneNumberUtils class, 16 PhoneStateListener, 570 photo setting screen, contacts API, 948–949 PICK intent, 141 Pico engine, 827, 837–838, 843 Pico Text To Speech engine, 13 pinch gesture, 875–878 pixels, 205 PKI (public key infrastructure) certificates, and signing of packages, 381–382 pkzip file, 19 planets.xml file, 186 platforms adding to Android SDK, 24 on Android, platforms\android-1.6\samples folder, 43 Play button, 612, 834, 837 play( ) method, 590, 592 playAudio( ) method, 584 playbackPosition integer member, 584 playEarcon( ) method, 840 playing audio content, 581–585 playing video content, 593–595 playRecording( ) method, 612 playSilence( ) method, 840, 842 PluralRules.java resource code, 74 plurals, 73–74 Plurals resource, 71 pname, 1006 pointer Id, 864 points, 205 populate( ) method, 531–532 populating context menus, 233–234 portrait mode, 1042 postInvalidate( ) method, 552 postTranslate method, 513, 516 PowerManager class, 16 PREFERENCE, 274 preference screen view, 267 PreferenceActivity class, 16, 271, 273–275, 283 PreferenceCategory element, 280, 282 preferences framework, 265–286 CheckBoxPreference, 275–277 EditTextPreference, 277–278 ListPreference, 266–275 manipulating programmatically, 283–284 RingtonePreference, 278–280 saving preferences, 284–286 organizing, 280–282 preferences activity, 827 Preferences dialog box, Eclipse, 28 preferences Editor, 285 Preferences window, Eclipse, 576 PreferenceScreen element, 267, 278, 280–282 prepare( ) method, 584–585, 592, 612 pressure sensors, interpreting data from, 907 pressure value, 852 preTranslate method, 513, 516 primitive shapes, 628 printCursorColumnNames( ) method, 970 PRIORITY parameter, 590 PrivActivity class, 298–299, 303 privileged activities, 298 process boundary, 295 process lifetimes, 418–421 of activities, 418–419 of providers, 421 of receivers, 420–421 of services, 420 process name, and packages, 378 profile file, 23, 25 ProgressBar control, 194 ProgressBar view, 718 ProgressBar widget, 17 ProgressDialog, 264 Project option, Android, 42, 422 project properties screen, 385 Projection interface, 872 projection maps, 110, 119 projection parameter, managedQuery( ) method, 47 projections, 102, 116 www.it-ebooks.info Index prompt dialog designing, 246–251 creating and showing, 249 PromptListener class, 249 setting up alert-dialog builder with user view, 248 setting up buttons and listeners, 248 XML layout file for, 247 rearchitecting, 252 PromptDialogFragment dialog fragment, 1054–1058 PromptDialogFragment.java file, 1050 PromptListener class, 248–250, 252 promptReply field, 249 properties context menu, 389 properties dialog, 389 properties window, 385 provider class, 108 provider declaration, 701 Provider projects, 19 tag, 304–305 providers, life cycles of, 421 proximity sensors, interpreting data from, 906 ProximityReceiver class, 557 Proxy class, 349 ptrId, 870 ptrIndex, 870 public and private keys, and signing of packages, 381 public key infrastructure (PKI) certificates, and signing of packages, 381–382 public Map getPrefsToSave( ) method, 735 public static identifier, 47 public String getPrefname( ) method, 735 public void setProjectionMap(Map columnMap), 119 public void setValueForPref method, 735 Publish button, 1010 publisher, becoming, 994–1001 publishProgress( ) method, 323, 331 putExtras, 131 putFragment( ) method, 1036–1037 ■Q QSB (Quick Search Box), 771, 773, 776, 791–793, 814–815 quantity attribute, 74 queries, passing to suggestion provider, 802–804 query( ) method, 108, 110, 116–117, 337, 707, 788–789, 797, 802 query string, 806 queryActionMsg attribute, 820 queryActionMsg value, 820 queryAfterZeroResults attribute, 788, 805 QueryBuilder class, 119 queryString, 782 QUEUE_ADD intent, 829, 831 QUEUE_ADD mode, 840 QUEUE_FLUSH intent, 829–831 queues, sending message objects to, 407–408 queueSound( ) method, 591 queuing mechanism, 840 Quick Search Box (QSB), 771, 773, 776, 791–793, 814–815 Quick Search Box tab, 755 ■R R class, 47 Radio Frequency ID (RFID), 923 RadioButton control, 162–165 RadioButton widget, 17 RadioGroup class, 162–164 RadioGroup widget, 17 Rasterizer class, 15 RatingBar control, 194 RatingButton widget, 17 raw assest, arbitrary, 72 raw contacts, 977–985 raw directory, 70 raw files, 70, 72 raw folder, 41 raw resources, 82 RawContact object, 981 RawContactEntity view, 984 RawContactFunctionTester.java, 977 raw_contact_id, 955 RawContact.java file, 977–978 ray, 636 R.draawable.robot icon, 438 R.drawable.frame_animation resource, 497 readFromParcel( ) method, 357 README.TXT file, 1067 Receiver class, 426 receiver element, 428 receiver node, 725 receivers life cycles of, 420–421 setting up for simple alarm, 467 RecentSearchSuggestionProvider, 795 recognize( ) method, 889 Record button, 834 recording audio with AudioRecord, 600–604 required permission for, 296 using intent, 615–618 video, 605–614 RECORDING message, 606, 612 recordoutput.3gpp file, 600 records, inserting in content providers, 106–107 RectShape, 15 recycle( ) method, 858 recycling MotionEvents, 857 red book, 625, 690 redeliver intents mode, 457 Reduced Instruction Set Computer (RISC), reference syntax for resources, 67 References tab, 1099 refunds, 996 registerDialogs( ) function, 259 registerForContextMenu method, 233 registering view for context menus, 233 registerListener( ) method, 897 www.it-ebooks.info 1165 1166 Index RegularActivity class, 758, 761, 770, 775, 777–778 RegularActivity.java file, 757, 766, 770, 775 RegularPolygon class overview, 656–657 rendering square with, 664–665 shapes animating, 666–668 implementing, 657–664 RelativeLayout, 198, 206–208, 527, 718, 848 release( ) method, 584, 593 releaseCamera( ) method, 609 release.keystore file, 289 releaseRecorder( ) method, 609 remapCoordinateSystem( ) method, 922 remote services, 30, 337–338 remote views, 1098–1113 factory, 1118–1120 layout loading, 1104–1105 preparing, 1101–1104 onClick events handler, 1110–1112 responding to, 1112–1113 RemoteViewsFactory interface, 1106–1109 constructor, 1107 getCount( ) callback method, 1108 getItemId( ) callback method, 1109 getLoadingView( ) callback method, 1108–1109 getViewAt( ) callback method, 1108 getViewTypeCount( ) callback method, 1109 hasStableIds( ) callback method, 1109 onCreate( ) callback method, 1107 onDataSetChanged( ) callback method, 1109 onDestroy( ) callback method, 1107–1108 RemoteViewsService class, 1105–1106 service, 1120 RemoteView interface, 1099 RemoteViews class, 711, 718–719, 721, 740–743, 1098 RemoteViewService class, 1106 RemoteViewsFactory class, 1100 RemoteViewsFactory interface, 1106–1109 constructor, 1107 getCount( ) callback method, 1108 getItemId( ) callback method, 1109 getLoadingView( ) callback method, 1108–1109 getViewAt( ) callback method, 1108 getViewTypeCount( ) callback method, 1109 hasStableIds( ) callback method, 1109 onCreate( ) callback method, 1107 onDataSetChanged( ) callback method, 1109 onDestroy( ) callback method, 1107–1108 RemoteViews.RemoteView interface, 1099 RemoteViewsService class, 1100, 1105–1106 RemoteViews.setOnClickFillIntent( ) method, 1100 RemoteViews.setPendingIntentTemplate( ) method, 1100 remove( ) method, 1035 removeData( ) method, 730 removePrefs( ) method, 729–730 Renderer interface, 638–641 RENDERMODE_CONTINUOUSLY, 651 RENDERMODE_WHEN_DIRTY, 651 replace( ) method, 1034–1035 reportBack( ) method, 1073–1075 ReportStatusHandler class, 411–412, 417 ReportStatusHandler.java class, 413 reportTransient( ) method, 964, 1073 REpresentational State Transfer (REST), 89 requery, 703, 707–708 requestCode, 140, 143 requestLocationUpdates( ) method, 545, 548 ReqularActivity.java, 765 /res/anim/alpha.xml file, 504 /res/anim subdirectory, 498, 503 /res/anim/translate_alpha.xml file, 505 /res/animator directory, 1066 res/drawable/box1.xml file, 723, 1120 /res/drawable folder, 159, 230, 438, 493, 531, 727, 1103 /res file, 1002 res folder, 40–41, 47, 70 res/layout/bday_widget.xml file, 723 /res/layout directory, 126, 1031 /res/layout file, 1002 res/layout folder, 187 /res/layout-large file, 1002 res/layout/local_search_enabled_activity.xml file, 757 /res/layout/main.xml file, 273, 332, 368, 462, 757 /res/layout-normal file, 1002 res/layout/no_search_activity.xml file, 757 res/layout/search_activity.xml file, 757 res/layout/search_invoker_activity.xml file, 757 /res/layout subdirectory, 493, 960 \res\layout\test_list_widget_layout.xml file, 1120 /res/menu/main_menu.xml file, 273, 414, 462, 643, 758 res/menu/search_invoker_menu.xml file, 758 /res/raw folder, 585–586, 838, 840, 888 /res/values/arrays.xml file, 271, 368 /res/values directory, 1004, 1135 /res/values folder, 151 /res/values-fr folder, 1003 /res/values/planets.xmlfile, 174 /res/values/strings.xml file, 155, 186, 272, 301, 368, 758, 780 /res/xml/, 267 res/xml/bday_appwidget_provider.xml file, 723 \res\xml\ test_list_appwidget_provider file, 1121 reset( ) method, 592 ResolveInfo API, 136 ResolveInfo class, 237 resource-reference syntax, 67 ResourceCursorAdapter adapter, 174 Resource.drawable.frame_animation resource ID, 496 resources, 63–88 arbitrary XML resource files, 80–81 assets, 82 color, 76 color-drawable, 79–80 compiled and noncompiled, 70 and configuration changes, 83–87 defining IDs for, 69 www.it-ebooks.info Index dimension, 77 directory structure, 83 image, 78–79 key Android, 71–80 layout, 66–67 plurals, 73–74 raw, 82 reference syntax for, 67 string, 64–66, 74–76 string arrays, 73 Resources class, 14 tag, 65, 159 Resources.java resource code, 74 respondToMenuItem( ) method, 405 ResportStatusHandler class, 410 REST ( REpresentational State Transfer), 89 Restart Player button, 584 RESULT_CANCEL constant, 141 RESULT_FIRST_USER constant, 140–141 RESULT_OK constant, 141, 829 retrieveData( ) method, 730 retrievePrefs( ) method, 729–730 returns false button, 853–856 returns true button, 854–856 RFID (Radio Frequency ID), 923 R.id.menu_library_activity menu item, 392 R.id.mid_si_search, 769 R.id.text constant, 69 Ringtone class, 15 ringtone value, 280 RingtonePreference view, 275, 278–280 ringtoneType attribute, 280 RISC (Reduced Instruction Set Computer), R.java constants file, 220 R.java file, 10, 64–65, 68, 84, 385, 395–397 R.java namespace, 77 R.layout class, 66 R.layout.details resource, 1031 R.layout.list_layout ID, 501 RootElement class, 16 rotate animation, 498 rotation vector sensors, interpreting data from, 923 RotationAnimation class, 17 RoundRectShape, 15 RPC service See remote services Rubin, Andy, rules for becoming publisher, 994 run( ) method, 411–412, 540 RunHelloWorld configuration, 33 Runnable class, 495 runnable state, 413 runOnFirstFix( ) method, 552 runtime security checks custom permissions, 297–303 declaring and using permissions, 295–297 process boundary, 295 URI permissions, 303–306 in content providers, 304–305 passing in intents, 303–304 ■S Save button, 1058 saveRecentQuery, 788 scale animation, 498 scale-independent pixels, 206 ScaleAnimation class, 17 scale.xml file, 503–504 scanFile( ) method, 620 Screen Capture button, 1008 screen sizes, supporting, 1001–1002 screenshots, 1008 Scroller widget, 17 ScrollView control, 194, 1080 ScrollView widget, 17 SD (Secure Digital) cards, 575–580 sdcard folder, 577, 885 /sdcard/gestures file, 888 sdcard.img file, 576 SDK Manager, 28 SDK/platforms//data/res/drawable folder, 342 SDK (Software Development Kit), 2, 22, 145, 742 search disabling, 766–767 invoking through menu, 767–771 SEARCH actions, 774, 804 search activity for custom suggestion provider finishing, 812 layout, 811 responding to ACTION_SEARCH and ACTION_VIEW, 810–811 responding to onCreate( ) and onNewIntent( ), 812 responsibilities of, 807 SearchActivity invocation, 809–810 source code, 808–809 strings.xml, 811 search activity for simple suggestion provider, 784–789 Search Activity screen, 792 search box, 746 search framework, 746–822 action keys in Android search, 818–821 activities and search key interaction disabling search, 766–767 enabling type-to-search, 777–778 invoking search through menu, 767–771 local search and related activities, 771–777 overview, 757 regular activities, 758–765 application-specific search context, 821–822 custom suggestion provider, 796–818 manifest file, 813–814 planning, 796 SuggestURLProvider class, 797–807 SuggestURLProvider project implementation files, 796–797 user experience, 814–818 global search, 746, 753, 757 simple suggestion provider, 778–795 implementation files, 779–780 planning, 779 www.it-ebooks.info 1167 1168 Index search activity, 784–789 search invoker activity, 789–790 SimpleSuggestionProvider class, 780–784 user experience, 791–795 search icon, 752–753, 771, 773, 796, 815 Search Invoker Activity, 770–772 search metadata XML file, 774 Search option, 755, 771 search query method, 810 Search Recent Suggestions API, 823 search results activity, 772 Search settings application, 755, 814 search suggestions, 750–751 search URI, 797, 801 Searchable items option, 755 searchable.xml file, 801, 803 SearchActivity class, 784–789, 796–797, 804, 807 SearchActivity.java file, 757, 779, 796, 807 search_activity.xml file, 780 SearchEanabledActivity, 775 SearchInvokerActivity class, 767, 770 SearchInvokerActivity XML, 769–770 SearchInvokerActivity.java file, 757 SearchInvokingActivity, 773 SearchManager class, 801–802, 805, 820, 823 SearchManager.APP_DATA, 822 SearchManager.QUERY, 786 SearchRecentSuggestionsProvider database modes, 781–783 saving query with, 787–788 searchSuggestAuthority attribute, 788 searchSuggestIntentAction attribute, 804 searchSuggestIntentData attribute, 804 searchSuggestPath attribute, 804 searchSuggestSelection attribute, 788, 803–804 searchSuggestThreshold attribute, 804 Sears, Nick, Secure Digital (SD) cards, 575–580 Secure Sockets Layer (SSl) library, security model, 294 overview, 287–288 runtime checks custom permissions, 297–303 declaring and using permissions, 295–297 process boundary, 295 URI permissions, 303–305 signing applications for deployment, 288–294 aligning applications with zipalign, 293–294 generating self-signed certificate with Keytool, 288–291 updating and signing applications, 294 using Jarsigner tool to sign apk file, 292 security.auth package, 18 security.auth.callback package, 18 security.auth.login package, 18 security.auth.x500 package, 18 security.cert package, 18 SecurityException, 571 security.interfaces package, 18 security.spec package, 18 seekTo( ) method, 584, 593, 595 select argument, 797 Select root directory option, Eclipse, 421, 461 selected_flight_sort_option argument, 273 selected_flight_sort_option string, 272 selected_flight_sort_option value, 274 selectInitialQuery argument, 769, 822 selection argument, 105, 802–804 selection parameter, managedQuery( ) method, 47 selection string, 788 selectionArgs argument, 802–803 selectionArgs parameter, managedQuery( ) method, 47 self-signed certificates, 288–291 sendBroadCast( ) method, 425–426, 432–433 sendDataMessage( ) method, 562 sendMessage( ) method, 407–408, 422 sendMessageDelayed( ) method, 407–408 sendMultipartTextMessage( ) method, 563 sendSmsMessage( ) method, 562 sendTextMessage( ) method, 562–563 SensorEventListener interface, 897 SensorManager class, 906, 922 sensors, 891–935 detecting, 892 interpreting data from accelerometers, 908–914 gravity sensors, 923 gyroscope sensors, 907–908 light sensors, 905–906 linear acceleration sensors, 923 magnetic declination and GeomagneticField class, 922 magnetic field sensors, 914–915 NFC sensors, 923 orientation sensors, 915–922 pressure sensors, 907 proximity sensors, 906 rotation vector sensors, 923 temperature sensors, 907 issues with events for, 895–905 no direct access to sensor values, 898 onAccuracyChanged( ) method, 898 sensor values not sent fast enough, 898 sensors turn off with screen in Android 2.1, 899–905 querying information about, 892–895 Service class, 30 service components, of Android, 13 service flags, specifying in OnStartCommand method, 457 Service object, 341 tag, 345, 351 ServiceConnection interface, 354 services AIDL in, 346, 349–351 consuming HTTP exceptions, 313–315 multithreading issues, 315 overview, 307–308 timeouts for, 318–319 using AndroidHttpClien, 319–320 using AsyncTask, 320–331 www.it-ebooks.info Index using DownloadManager, 331–337 using HttpClient for HTTP GET requests, 308–310 using HttpClient for HTTP POST requests, 310–312 using HttpURLConnection, 319 defining interface in Android Interface Definition Language (AIDL), 347–349 external components, 401 Google Translate example using, 366–375 interprocess communication calling services from client applications, 351–355 passing complex types to services, 355–366 JSON support, 313 life cycles of, 420 local, 339–346 overview, 337–339 setting up development environment, 30 SOAP support, 312–313 Service.START_NOT_STICKY flag, 456 Service.START_REDELIVER flag, 457 Service.START_STICKY flag, 457 ServiceWorker class, 342 Session Initiation Protocol (SIP), 559, 571–574 Set Package Name option, 278 Set Ringtone Preference option, 280 tag, 1067 setAdapter( ) method, 156 setAlpha( ) method, 1065 setArguments( ) method, 1020 setAutoLinkMask( ) method, 153 setBounds( ) method, 532 setBuiltInZoomControls( ) method, 527 setCenter( ) method, 533 setChecked( ) method, 161, 163 setClickable(true) method, 526 setConsiderGoneChildrenWhenMeasuring( ) method, 209 setContentView( ) method, 148, 151, 181, 439, 1042 setContext( ) method, 331 setCustomAnimations( ) method, 1034, 1065 setData( ) method, 344, 407 setDataSource( ) method, 581, 585–586, 595 setDataSource(FileDescriptor desc), 586 setDestination*( ) methods, 336 setDropDownViewResource( ) method, 187 setEdgeFlags( ) method, 853 setEngineByPackageName( ) method, 840 setEntity( ) method, 310, 312 setEntries( ) method, 284 setGroupCheckable method, 220 setGroupEnabled method, 220 setGroupVisible method, 220 setHint( ) method, 155 setIcon method, MenuItem class, 229 setImageInView( ) method, 328, 331 setImageResource( ) method, 159, 166 setIntent( ) method, 222 setLanguage method, 841 setLatestEventInfo( ) method, 364, 439–440 setListAdapter( ) method, 175, 1040 setLooping( ) method, 592 setMarker( ) method, 532 setMaxDuration(int length_in_ms) method, 600 setMaxFileSize(long length_in_bytes) method, 600 setMediaController( ) method, 595 setMovementMethod( ) method, 1081 setOnCheckedChangeListener( ) method, 161, 163 setOnClickFillIntent( ) method, 1112 setOnClickListener( ) method, 158 setOneShot( ) method, 496 setOnTouchListener( ) method, 846, 871 setOnUtteranceCompletedListener( ) method, 830 setOptionText( ) method, 273–274 setPendingIntentTemplate( ) method, 1111 setPitch method, 842 setProfile( ) method, 614 setProgress( ) method, 331 setRemoteAdapter( ) method, 1106 setResult( ) method, 141 setRetainInstance( ) method, 1023, 1036 setRotate method, 516 setRotation( ) method, 1065 setScale method, 512, 516 setSkew method, 516 setSpeechRate method, 842 setTabListener( ) method, 1080 setTargetFragment( ) method, 1064 setText( ) method, 195 setThreadPolicy( ) method, 58 Settings application, 16, 18 settings page, Android, 754 Settings screen, 825 SettingsProvider project, 19 setTokenizer( ) method, 156 setTransition( ) method, 1034 setTranslate method, 516 setupMatrices function, 688 setValue( ) method, 734 setValueForPref( ) method, 731 setVideoPath( ) method, 595 setVideoURI( ) method, 595 setVolume( ) method, 592 setX( ) method, 1066 setZoom( ) method, 533 SGI (Silicon Graphics, Inc.) Open GL See OpenGL Shader class, 15 Shakespeare class, 1032 tag, 72, 79–80 shared user IDs, 382–383 SharedPreferences class, 16, 274, 742 SharedPreferences file, 734 SharedPreferences.Editor class, 734, 743 SharedPrferences facility, 732 sharing data, among packages, 382–384 code pattern for, 383–384 and shared user IDs, 382–383 shell command sets, 93 Short Message Service See SMS shortcut URI, 801 shortcut_id, 806 SHORTCUT_MIME_TYPE, SearchManager class, 802 show contact detail screen, contacts API, 945 show contacts screen, contacts API, 944 www.it-ebooks.info 1169 Download from Wow! eBook 1170 Index Show Me! button, 921 show( ) method, 251, 256–258, 1034, 1047, 1049, 1053, 1058 showAllRawContacts( ) method, 981 showAsAction tag, 1083 showDetails( ) method, 1027, 1032, 1040–1041 showDialog method, 254 showRawContactsCursor( ) function, 981 showRawContactsDataForRawContact( ) function, 988 showSilent attribute, 280 shutdown( ) method, 830 sides variable, 667 signing applications for deployment, 288–294 aligning applications with zipalign, 293–294 generating self-signed certificate with Keytool, 288–291 updating and signing applications, 294 using Jarsigner tool to sign apk file, 292 of packages, 379–382 overview, 380 and PKI certificates, 381–382 and public and private keys, 381 silence, playing with TTS APIs, 840 Silicon Graphics, Inc (SGI) Open GL See OpenGL SIM card, 998 SIM (Subscriber Identity Module) serial number, 16 simple suggestion providers, 778–795 implementation files, 779–780 planning, 779 search activity, 784–789 SimpleSuggestionProvider class, 780–784 declaring in manifest file, 783–784 responsibilities of, 780–781 source code for, 781 user experience, 791–795 SimpleAdapter adapter, 174 SimpleCursorAdapter adapter, 47, 171–172, 174 simple_list_item_1.xml file, 173 SimpleMainActivity.java file, 779 SimpleSpinnerArrayAdapter java file, 1084–1085 SimpleSuggestionProvider class, 780–784 SimpleSuggestionProvider.java file, 779 SimpleTriangleRenderer class, 639, 642 SimpleTriangleRenderer2 class, 650 SingleAbstractTextureRenderer class, 670 singleLine property, 155 singleTop mode, 784, 787, 807, 823 SIP (Session Initiation Protocol), 559, 571–574 SipManager object, 573 Skia library, Google, SkMatrix.cpp file, 19 sleep( ) method, 402, 404, 411 slide_out_down.xml file, 1067 SMS (Short Message Service), 559–568 e-mail, 567–568 folders, 565–567 monitoring incoming messages, 563–565 sending messages, 559–563 SmsManager class, 562–563, 565 SmsManager.sendTextMessage( ) method, 562 SmsMessage object, Android, 565 SmsMessage.createFromPdu( ) method, 565 SOAP, support for, 312–313 soft keyboard, 750 Software Development Kit (SDK), 2, 22, 145, 742 software stack, 6–8 Software Updates, Eclipse See Install New Software option, Eclipse SomeHandlerDerivedFromHandler handler, 405 some_view layout, 126 sort option, 271 sortOrder parameter, managedQuery( ) method, 47 soundFileResourceId, 838 SoundPool class, 587–591 SoundRecorder application, 18 source code example that defers work, 405–406 standard navigation, 1090–1091 taking advantage of, 18–19 source variable, 684 sourceid field, 954 Spare Parts application, 750 Speak button, 831, 834, 837 speak( ) method, 829–830, 837–840 specification details, of packages, 377–378 speech synthesis engine, Pico, 827 Spinner class, 186 Spinner control, 185–187 Spinner widget, 17 SpinnerAdapter interface, 1085–1086 spinner_while_refreshing, 806 sql package, 18 SQLite database library, 7, 952–953 SQLite, primer on, 95 sqlite3 commands, 94 SQLiteCursor class, 15, 707 SQLiteDatabase class, 15, 117 Sqliteman tool, 95 sqlite_master table, 95 SQLiteOpenHelper class, 50 SQLiteQuery class, 15 SQLiteQueryBuilder class, 15, 105, 116, 119 SQLiteStatement class, 15 sqllite database, 721 src folder, 33, 40, 61, 723 SRC_QUALITY value, 590 SSl (Secure Sockets Layer) library, stand-alone BCR files, 462–463 stand-alone BCR project, 461 StandaloneReceiver.java file, 433, 462 standard navigation, 1090–1095 AndroidManifest.xml file, 1092 BaseActionBarActivity class, 1091–1092 examining, 1092–1095 source code, 1090–1091 StandardNavigationActionBarActivity java file, 1090–1092 start event, 457 start( ) method, 496, 540, 584, 593, 595, 612 Start Playing Audio button, 584 startActicity( ) method, 48, 139, 222, 926, 1064 www.it-ebooks.info Index startActivityForResult( ) method, 48, 140, 616, 829, 1064 startDrag( ) method, 1135 startMethodTracing( ) method, Debug class, 55 startMyActivityDesc constant, 301 startOffset value, 503 startRecording( ) method, 604 startSearch( ) method, 765, 769, 822 startService( ) method, 342–343, 346, 352, 401, 420, 442, 444, 455, 457 static final property, 357 stickiness, 457–458 sticky services, 457 Stk application, 18 StockQuoteClient, 351 StockQuoteService project, 350 StockQuoteService.java class, 350 stop( ) method, 496, 584, 591, 593, 612, 830 Stop Recording button, 612 stopPlayback( ) method, 595 stopPlayingRecording( ) method, 612 stopRecording( ) method, 612 stopSelf( ) method, 444, 457 stopService( ) method, 343, 421, 456 StopWatch, 742 storepass argument, 289 storing values, 272 STREAM_ALARM audio stream, 839 STREAM_MUSIC audio stream, 839 STREAM_NOTIFICATION audio stream, 839 STREAM_RING audio stream, 839 STREAM_SYSTEM audio stream, 839 STREAM_VOICE_CALL audio stream, 839 Street button, 874 StreetView activity, 878 StreetView application, 872–874, 877, 921 StreetView mode, 877 stretchable images, 78 StrictModeWrapper class, 60 stride argument, 630 String arrays, 71, 73 string clause, 104 element, 65 string resources, 64–66, 74–76 String type, 105 StringEscapeUtils, 374 Strings resource, 71 strings.xml file, 64–65, 68, 151, 272, 761, 763, 811–812, 1003 structure of Android applications, 39–42 Stub class, 349–350 styles, 194–197 styles.xml file, 197 submenus, 230–231 Subscribed FeedsProvider project, 19 Subscriber Identity Module (SIM) serial number, 16 substitutable values, 803 SUCCESS intent, 830 suggest URI, 797 suggestActionMsg attribute, 820 suggestActionMsg value, 820 suggestActionMsgColumn attribute, 820–821 suggestion columns, 751 suggestion cursor, 752, 820 suggestion list, 751 suggestion providers custom, 796–818 manifest file, 813–814 planning, 796 SuggestURLProvider class, 797–807 SuggestURLProvider project implementation files, 796–797 user experience, 814–818 enabling for global search in Android 2.2, 754–756 in Android 2.3, 756–757 overview, 753 simple, 778–795 implementation files, 779–780 planning, 779 search activity, 784–789 search invoker activity, 789–790 SimpleSuggestionProvider class, 780–784 user experience, 791–795 suggestion rewriting, 752 suggestions cursor, 751 SUGGEST_MIME_TYPE, SearchManager class, 802 SuggestURLProvider class, 797–807 SuggestUrlProvider class getType( ) method and specifying Multipurpose Internet Mail Extensions (MIME) types, 802 passing query to suggestion provider: selection argument, 802–804 populating and returning list of columns, 806–807 project implementation files, 796–797 responsibilities of, 797 search metadata for custom suggestion providers, 804–805 source code, 798 suggestion cursor columns, 805–806 URIs, 801–802 SuggestUrlProvider.java file, 796 summary attribute, 267 summary property, 267 summaryOff attribute, 277 summaryOn attribute, 277 supporting different screen sizes, 1001–1002 element, 1001 Surface Manager library, Surface object, 605 Surface.Callback callbacks, 608 surfaceCreated( ) method, 609 SurfaceHolder.Callback interface, 607 SurfaceView, 680 suspended option, 957 SweepGradient class, 15 Swing, Java SE, switch statement, 227 syh.permission.STARTMYACTIVITY permission, 299, 302 Sync application, 18 sync fields, 954–955 syncing contacts, impacts of, 989–991 synonyms, 110 www.it-ebooks.info 1171 1172 Index synthesizeToFile( ) method, 837 system menus, 231 SystemProperties class, 614 ■T t command, 38 T-Mobile G1, t1_1_en_p string, 87 t1_1_en_port resource ID, 85 t1_enport resource ID, 85 t1_enport string, 87 t2 resource ID, 85 t2 string, 87 tab1, 1084 tab2, 1084 Tabbed Action bar, 1071 tabbed navigation, 1071–1084 action bar and menu interaction, 1081–1083 displaying menu, 1082 menu items as actions, 1083 assigning uniform behavior, 1075–1077 base classes, 1073–1075 examining, 1084 manifest file, 1083–1084 navigation modes, 1079–1080 obtaining action bar instance, 1079 scrollable debug text view layout, 1080–1081 tabbed listener, 1077–1078 TableLayout layout manager, 198, 202–206 TableRow elements, 202–203 tablets, for Android, TabListener.java file, 1072 Tabs area, 1071 TabWidget widget, 17 TED conference, 862 telephony APIs SIP, 571–574 SMS, 559–568 e-mail, 567–568 folders, 565–567 monitoring incoming messages, 563–565 sending messages, 559–563 telephony manager, 568–571 telephony components, of Android, 13–14 TelephonyManager class, 16, 568–571 TelephonyManager.getLine1Number( ) function, 570 TelephonyProvider project, 19 temperature sensors, interpreting data from, 907 TemperatureSensor project, 907 Terms of Service, 999 test harness creating for menus, 222–224 adding regular menu items, 225–226 adding secondary menu items, 226 creating activity, 224–225 creating XML layout, 224 responding to menu-item clicks, 227–228 setting up menu, 225 tweaking AndroidManifest.xml file, 228–229 planning for 2D layout animation, 499 Test List Widget Application widget, 1122–1123 test1 string, 792 Test60SecBCR.java file, 460, 463 Test60SecBCRService.java file, 460, 463 testAccounts( ) method, 962 TestAppActivity.java file, 390 TestBCR files, 461–462 TestBCR project, 461 TestBCRActivity.java file, 428, 461 TestContactsDriverActivity.java class, 965 TestContactsDriverActivity.java file, 960, 978, 982, 986 TestHandlersDriverActivity activity, 418, 422 TestHandlersDriverActivity.java file, 414 testing devices, different, 1001 TestLibActivity.class, 392 TestLibActivity.java file, 387 TestListWidgetProvider.ACTION_LIST_CLICK action, 1110 TestListWidgetProvider.java file, 1114 testport_port resource ID, 85 testport_port string, 87 TestReceiver.java file, 428, 430, 461 TestRemoteViewsFactory.java file, 1114 TestRemoteViewsService.java file, 1114 testSendBroadcast( ) method, 432 TestStandaloneBCR application, 463 teststring_all resource ID, 85 teststring_all string, 86 testThread( ) function, 409 TestTimeDelayReceiver.java file, 461 test.xml file, 81 text argument, 838 text controls, 152–157 AutoCompleteTextView, 155–156 EditText, 154–155 MultiAutoCompleteTextView, 156–157 TextView, 153–154 text messaging, 559 text package, 18 Text to Speech APIs See TTS APIs text1 constant, 67, 805 text_2 constant, 805 textColor attribute, 197 TextToSpeech class, 16, 825, 830, 842 TextToSpeech.LANG_AVAILABLE intent, 841 TextToSpeech.LANG_COUNTRY_AVAILABLE intent, 841 TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE intent, 841 TextToSpeech.LANG_MISSING_DATA intent, 841 TextToSpeech.LANG_NOT_SUPPORTED intent, 841 TexturedSquareRenderer class, 672–673, 676 textures, OpenGL abstracting common handling, 669–672 drawing with, 672–673 normalized coordinates, 669 overview, 668–669 TextView controls, 76, 148–149, 153–154, 195, 233, 273, 494, 880 TextView field, 1021 TextView view, 67, 718 TextView widget, 17 www.it-ebooks.info Index thefreewebdictionary.com, 806 \"Theme.Dialog.AppError\"styles, 198 themes, 197–198 themes.xml file, 198 this variable, 407 Thread object, 321 ThreadGroup class, 342–343 threading and components, 399–403 content providers, 401 external service components, 401 main thread, 400–401 thread pools, 401 thread utilities, 401–403 ThreadPolicy method, 58 threads behavior of, 412–413 pools, 401 utilities, 401–403 worker, 408–413 communicating between main threads and, 410–412 invoking from menu, 409–410 thread behavior, 412–413 ThreadSafeClientConnManager, 317, 319 ThumbnailUtils class, 193 timeouts, consuming HTTP services, 318–319 TimePicker control, 167–168 TimePicker widget, 17 TimePickerDialog, 264 TimeUtils class, 17 Title area, 1071 title attribute, 267 title property, 267 TITLE value, 618 TitlesFragment class, 1037, 1040 TNF (Type Name Format), 931 TNF_UNCHANGED record type, 931 to parameter, 172 Toast class, 263, 563, 1073 Toast message, 885 toggle( ) method, 161, 163 ToggleButton control, 159–160, 590 Tools window, 577 toPixels( ) method, 872 touch events, 846 touches with maps, 871–874 touchscreens gestures, 874–889 custom, 881 GestureDetector class, 878–881 and Gestures Builder app, 882–889 pinch gesture, 875–878 MotionEvents, 845–862 drag and drop, 859–862 MotionEvent object, 845–857 recycling, 857 velocitytracker, 857–859 multi-touch, 862–871 post version 2.2, 871 prior to version 2.2, 863–870 touches with maps, 871–874 toUri( ) method, 1110–1111 transaction fees, 999 transformation matrices, 516 transitions, FragmentTransaction objects, 1034–1035 translate animation, 498 Translate example, Google, 366–375 translate methods, 514 tag, 1034 TranslationAnimation class, 17 Translator.java code, 367 trouble words, 838 trueBtnTop, 851 TrueButton class, 848–849, 853 trueLayoutTop, 855 tryOneOfThese(activity), 128 TTS engine, 829, 831–832 TTS (Text to Speech) APIs, 842 advanced features of TTS engine, 838–842 earcons, 839–840 language methods, 840–842 playing silence, 840 setting audio streams, 839 audio files, 832–838 overview, 825–830 using alternative engines, 840 utterances, 830–832 tv.getText( ) method, 195 tweening animation, 11, 17 Type Name Format (TNF), 931 type-to-search, enabling, 777–778 TYPE_AUTOMATIC, 989 TypeFace class, 15 TYPE_KEEP_SEPARATE, 989 TYPE_KEEP_TOGETHER, 989 ■U udpateAppWidget function, 740 UI/Application Exerciser Monkey, 1001 UI framework, Android SDK, UI (User Interface), 145–152 advanced concepts, 11–13 for Android, with code overview, 147–149 and XML, 150–151 with XML and code, 150–151 overview, 149–150 unbindService( ) method, 354–355 uniform behavior, assigning for tabbed navigation, 1075–1077 Uniform Resource Identifiers See URIs Uniform Resource Identifiers (Android URIs), 14 uninstalling widget packages, 722 unlocked, 998 up vector, 635 update method, 108, 110, 117 updateAppWidget( ) function, 740 updateAppWidgetLocal( ) function, 740 Updater application, 18 updates of ADT, checking for, 27 www.it-ebooks.info 1173 1174 Index of content providers, 108 updating and signing applications, 294 Upload Application screen, 1009 uploading applications, 1007–1010 Uri class, 15, 105, 568 URI parameter, managedQuery( ) method, 47 URIFunctionTester class, 969 UriMatcher class, 105, 111, 802 URIs (Uniform Resource Identifiers) data, relationship to intents, 129 overview, 801–802 passing where clauses through, 104–105 permissions, 303–306 in content providers, 304–305 passing in intents, 303–304 reading data with, 100–102 structure of, 97–98 url field, 735 UrlEncodedFormEntity class, 310 Use as ringtone option, 280 Use with field, 837 user experience of Android market, 1010–1012 User Interface See UI User's Calendar Data, required permission for, 296 User's Contact Data, required permission for, 296 users' data protection, 996 User's Guide, Android, 944 tag, 1002–1003 tag, 895, 906, 914, 933, 1002–1003 tag, 305, 599, 1002–1003, 1009 uT (micro-Teslas), 914 util package, 18 util.concurrent package, 18 util.concurrent.atomic package, 18 util.concurrent.locks package, 18 utilities, date-related, 737–738 util.jar package, 18 util.logging package, 18 util.prefs package, 18 util.regex package, 18 Utils class, 427, 970 Utils.java class, 413 Utils.java file, 427–428, 433–434, 461, 463, 969 Utils.logThreadSignature( ) method, 408, 411 Utils.logThreadSignature(tag) method, 432 util.zip package, 18 utterances, 830–832 ■V v argument, 289 validity argument, 289 values storing, 272 substitutable, 803 values directory, 41, 70, 85 values/strings.xml file, 797 variable length ID field, 931 variable length payload field, 931 variable length type field, 931 vcf files, 950–951 VelocityTracker, 845, 857–859 video playing content, 593–595 recording, 605–614 VideoView class, 594–595 VideoView component, 595 VideoView interface, 607 VideoView widget, 17, 593 VIEW action, 804, 807, 809 view animation, 2D, 507–516 adding animation to ListView, 511–514 AnimationListener class, 515–516 overview, 507–510 providing depth perception with camera, 514–515 transformation matrices, 516 View attributes, 196 View class, 17, 145, 194, 846 view groups, VIEW intent, 130 View menu, 1008 view method, 810 View object, 158, 248, 846–847, 852, 854, 857 view point, 635 ViewAnimation class, 511 ViewAnimationActivity, 512 ViewAnimationListener class, 516 ViewGroup class, 17, 145, 1033 ViewHolder object, 192–193 viewing live folders, 697 volume, 625, 629, 636 viewing box, 625, 629 View.OnTouchListener interface, 846–847 views, 9, 29, 146, 694 virtual keyboard object, 846 Virtual Machine (Dalvik VM), 6–8 VirtualJax application, 916 VirtualJaxWithRemap application, 922 vnd.android.cursor.item, 100 vnd.ms-excel subtype, 99 VoiceDialer application, 18 VOICE_RECOGNITION audio source, 599 v.onTouchEvent(event), 855 ■W wake locks abstracting with LightedGreenRoom abstraction, 449–455 controlling from two places, 458 WebKit library, WebView class, 17, 194 web.xml file, 41 weight, in LinearLayout, 199–201 WHERE clause, 985 where clauses, 104–106, 116–117, 803 whereClause argument, 108 while loop, navigating through cursors using, 103 White, Chris, widget background shape file, 727–728 widget configurator, 715–716 widget definition, 715, 717–719, 725 widget instance creation, 719–720 www.it-ebooks.info Index widget instance ID, 716 widget layout file, 726–727 widget layout-related files, 726–728 widget manager class, 743 widget model abstract implementation of, 732–734 implementation for birthday widget, 735–737 interface for, 731–732 overview, 730 widget provider class, 712, 715, 728 widget providers metadata, 1121 test, 1114–1118 widget view, mouse click event callbacks, 722 widgets code for, 743 defining provider, 724–725 defining size, 725–726 description of, 146 designing, 743 extensions for, 742–743 implementing configuration activity, 738–742 implementing provider, 728–730 lifecycle of, 716–722 creating instance on home screen, 713–715 deleting widget instance, 722 onUpdate phase, 720–721 uninstalling widget packages, 722 widget definition phase, 717–719 widget instance creation phase, 719–720 widget view mouse click event callbacks phase, 722 limitations of, 742–743 main layout file, 1120 WiFi location information, required permission for, 296 WifiConfiguration class, 16 WifiManager class, 16 WorkerThreadRunnable class, 410–411, 413 world coordinates, 629, 634 wrapping cursors, 707 writeToParcel( ) method, 357 ■X X component, 852 X coordinate, 856 x, y, z values, 628 XAL (Extensible Address Language), 15 Xml class, 17 xml directory, 70 XML (Extensible Markup Language) arbitrary resource files, 80–81 layout files, for prompt dialog, 247 menu tags checkable behavior tags, 241 group category tag, 241 menu enabling/disabling tag, 242 menu icon tag, 241 menu item shortcuts, 242 menu visibility, 242 to simulate submenu, 241 UI development with, 149–151 XML files, 70, 72 xml folder, 41 xml/searchable.xml file, 757, 780, 797 xml\ test_list_appwidget_provider.xml file, 1114 xmlparsers package, 18 XmlPullParser, 81 XmlResourceParser, 81 ■Y Y coordinate, 855 YourGLESRenderer class, 679 ■Z zero suggestions mode, 749–750 ZIP files, creating projects from, 421, 461 zipalign tool, 293–294, 1007 ZoomButton widget, 17 zoomIn( ) method, 525 zoomOut( ) method, 525 zoomToSpan( ) method, 5, 533 www.it-ebooks.info 1175 1176 Index www.it-ebooks.info Index www.it-ebooks.info 1177 1178 1178 www.it-ebooks.info ... Content Provider 30  Service .30  AndroidManifest.xml 30  Android Virtual Devices 30  Hello World! 31  Android. .. .38 2 A Code Pattern for Sharing Data 38 3 Library Projects 38 4 What Is a Library Project? 38 4 Library Project Predicates 38 5... written permission of the copyright owner and the publisher ISBN- 13 (pbk): 978-1- 430 2 -32 22 -3 ISBN- 13 (electronic): 978-1- 430 2 -32 23- 0 Trademarked names, logos, and images may appear in this book

Ngày đăng: 27/03/2019, 13:21

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN