Pro Android 2 -  Sayed Hashimi,  Satya Komatineni,  Dave MacLean

Pro Android 2 (eBook)

eBook Download: PDF
2010 | 1st ed.
XVI, 736 Seiten
Apress (Verlag)
978-1-4302-2660-4 (ISBN)
Systemvoraussetzungen
52,99 inkl. MwSt
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

Pro Android 2 shows how to build real-world and fun mobile applications using Google's latest Android software development kit. This new edition is updated for Android 2, covering everything from the fundamentals of building applications for embedded devices to advanced concepts such as custom 3D components, OpenGL, and touchscreens including gestures. While other Android development guides simply discuss topics, Pro Android 2 offers the combination of expert insight and real sample applications that work.

  • Discover the design and architecture of the Android SDK through practical examples, and how to build mobile applications using the Android SDK.
  • Explore and use the Android APIs, including those for media and Wi-Fi.
  • Learn about Android 2's integrated local and web search, handwriting gesture UI, Google Translate, and text-to-speech features.

Pro Android 2 dives deep, providing you with all the knowledge and techniques you need to build mobile applications ranging from games to Google apps, including add-ons to Google Docs. You'll be able to extend and run the new Google Chrome APIs on the G1, the G2, and other next-generation Google phones and Android-enabled devices.



Sayed Y. Hashimi is the author of Pro Android, as well as a consultant and trainer in Jacksonville, Florida. Sayed has worked for startups and Fortune 100 companies. He has developed large-scale distributed applications with a variety of programming languages and platforms, including C++, Java, and .NET. Sayed has published in major software journals on topics ranging from low-level programming techniques to high-level architecture concepts.
Pro Android 2 shows how to build real-world and fun mobile applications using Google's latest Android software development kit. This new edition is updated for Android 2, covering everything from the fundamentals of building applications for embedded devices to advanced concepts such as custom 3D components, OpenGL, and touchscreens including gestures. While other Android development guides simply discuss topics, Pro Android 2 offers the combination of expert insight and real sample applications that work. Discover the design and architecture of the Android SDK through practical examples, and how to build mobile applications using the Android SDK. Explore and use the Android APIs, including those for media and Wi-Fi. Learn about Android 2's integrated local and web search, handwriting gesture UI, Google Translate, and text-to-speech features. Pro Android 2 dives deep, providing you with all the knowledge and techniques you need to build mobile applications ranging from games to Google apps, including add-ons to Google Docs. You'll be able to extend and run the new Google Chrome APIs on the G1, the G2, and other next-generation Google phones and Android-enabled devices.

Sayed Y. Hashimi is the author of Pro Android, as well as a consultant and trainer in Jacksonville, Florida. Sayed has worked for startups and Fortune 100 companies. He has developed large-scale distributed applications with a variety of programming languages and platforms, including C++, Java, and .NET. Sayed has published in major software journals on topics ranging from low-level programming techniques to high-level architecture concepts.

Table of Contents 6
About the Authors 14
About the Technical Reviewer 15
Acknowledgments 16
Foreword 17
Chapter 1 Introducing the Android Computing Platform 18
A New Platform for a New Personal Computer 18
History of Android 20
Delving into the Dalvik VM 22
Comparing Android and Java ME 24
Understanding the Android Software Stack 27
Developing an End-User Application with the Android SDK 28
Android Emulator 28
The Android UI 29
The Android Foundational Components 30
Advanced UI Concepts 31
Android Service Components 33
Android Media and Telephony Components 33
Android Java Packages 35
Taking Advantage of Android Source Code 40
Summary 41
Chapter 2 Getting Your Feet Wet 42
Setting Up Your Environment 42
Downloading JDK 6 43
Downloading Eclipse 3.5 43
Downloading the Android SDK 44
Installing Android Development Tools (ADT) 45
Learning the Fundamental Components 48
View 48
Activity 48
Intent 48
Content Provider 49
Service 49
AndroidManifest.xml 49
Android Virtual Devices 49
Hello World! 50
Android Virtual Devices 55
Exploring the Structure of an Android Application 57
Analyzing the Notepad Application 59
Loading and Running the Notepad Application 60
Dissecting the Application 61
Examining the Application Lifecycle 68
Debugging Your App 71
Summary 72
Chapter 3 Using Resources, Content Providers, and Intents 73
Understanding Resources 74
String Resources 75
Layout Resources 76
Resource-Reference Syntax 78
Defining Your Own Resource IDs for Later Use 79
Compiled and Noncompiled Android Resources 80
Enumerating Key Android Resources 81
Color Resources 83
More on String Resources 84
Dimension Resources 85
Image Resources 86
Color-Drawable Resources 87
Working with Arbitrary XML Resource Files 89
Working with Raw Resources 90
Working with Assets 91
Reviewing the Resources Directory Structure 91
Understanding Content Providers 92
Exploring Android’s Built-in Providers 93
Exploring Databases on the Emulator and Available Devices 93
Quick SQLite Primer 98
Architecture of Content Providers 99
Structure of Android Content URIs 100
Structure of Android MIME Types 101
Reading Data Using URIs 103
Using the Cursor 105
Working with the where Clause 107
Passing a where Clause Through a URI 107
Using Explicit WHERE Clauses 108
Inserting Records 109
Adding a File to a Content Provider 110
Updates and Deletes 110
Implementing Content Providers 111
Planning a Database 111
Extending ContentProvider 113
Fulfilling MIME-Type Contracts 115
Implementing the Query Method 116
Implementing an Insert Method 117
Implementing an Update Method 118
Implementing a Delete Method 119
Using UriMatcher to Figure Out the URIs 120
Using Projection Maps 121
Registering the Provider 122
Understanding Intents 122
Available Intents in Android 123
Intents and Data URIs 125
Generic Actions 126
Using Extra Information 127
Using Components to Directly Invoke an Activity 129
Best Practice for Component Designers 130
Understanding Intent Categories 130
The Rules for Resolving Intents to Their Components 133
Exercising the ACTION_PICK 133
Exercising the GET_CONTENT Action 135
Further Resources for This Chapter 137
Summary 137
Chapter 4 Building User Interfaces and Using Controls 139
UI Development in Android 139
Understanding Android’s Common Controls 145
Text Controls 145
TextView 145
EditText 146
AutoCompleteTextView 147
MultiAutoCompleteTextView 148
Button Controls 149
The Button Control 149
The ImageButton Control 150
The ToggleButton Control 151
The CheckBox Control 151
The RadioButton Control 152
List Controls 155
Grid Controls 159
Date and Time Controls 161
The DatePicker and TimePicker Controls 161
The AnalogClock and DigitalClock Controls 163
Other Interesting Controls in Android 163
The MapView Control 164
The Gallery Control 164
The Spinner Control 164
Understanding Layout Managers 165
The LinearLayout Layout Manager 165
Understanding Weight and Gravity 166
android:gravity vs. android:layout_gravity 168
The TableLayout Layout Manager 169
The RelativeLayout Layout Manager 173
The FrameLayout Layout Manager 175
Customizing Layout for Various Device Configurations 178
Understanding Adapters 180
Getting to Know SimpleCursorAdapter 181
Getting to Know ArrayAdapter 181
Creating Custom Adapters 182
Debugging and Optimizing Layouts with the Hierarchy Viewer 183
Summary 186
Chapter 5 Working with Menus and Dialogs 187
Understanding Android Menus 187
Creating a Menu 189
Working with Menu Groups 190
Responding to Menu Items 191
Responding to Menu Items Through onOptionsItemSelected 191
Responding to Menu Items Through Listeners 191
Using an Intent to Respond to Menu Items 192
Creating a Test Harness for Testing Menus 192
Creating an XML Layout 194
Creating an Activity 194
Setting Up the Menu 195
Adding Regular Menu Items 195
Adding Secondary Menu Items 196
Responding to Menu-Item Clicks 196
Tweaking the AndroidManifest.xml File 198
Working with Other Menu Types 199
Expanded Menus 199
Working with Icon Menus 199
Working with Submenus 200
Provisioning for System Menus 201
Working with Context Menus 201
Registering a View for a Context Menu 203
Populating a Context Menu 203
Responding to Context Menu Items 204
Working with Alternative Menus 204
Working with Menus in Response to Changing Data 208
Loading Menus Through XML Files 208
Structure of an XML Menu Resource File 209
Inflating XML Menu Resource Files 209
Responding to XML-Based Menu Items 210
A Brief Introduction to Additional XML Menu Tags 211
Group Category Tag 211
Checkable Behavior Tags 211
Tags to Simulate a Submenu 211
Menu Icon Tag 211
Menu Enabling/Disabling Tag 212
Menu Item Shortcuts 212
Menu Visibility 212
Using Dialogs in Android 212
Designing an Alert Dialog 213
Designing a Prompt Dialog 215
XML Layout File for the Prompt Dialog 216
Setting Up an Alert-Dialog Builder with a User View 216
Setting Up Buttons and Listeners 217
Creating and Showing the Prompt Dialog 217
Prompt Dialog Listener 218
Putting It All Together 218
The Nature of Dialogs in Android 220
Rearchitecting the Prompt Dialog 221
Working with Managed Dialogs 222
Understanding the Managed-Dialog Protocol 222
Recasting the Non-Managed Dialog As a Managed Dialog 222
Simplifying the Managed-Dialog Protocol 224
IDialogProtocol 226
ManagedActivityDialog 227
DialogRegistry 227
ManagedDialogsActivity 228
IDialogFinishedCallBack 229
GenericManagedAlertDialog 229
GenericPromptDialog 230
Summary 231
Chapter 6 Unveiling 2D Animation 233
Frame-by-Frame Animation 234
Planning for Frame-by-Frame Animation 234
Creating the Activity 235
Adding Animation to the Activity 236
Layout Animation 239
Basic Tweening Animation Types 240
Planning the Layout-Animation Test Harness 241
Creating the Activity and the ListView 242
Animating the ListView 244
Using Interpolators 247
View Animation 249
Understanding View Animation 249
Adding Animation 252
Using Camera to Provide Depth Perception in 2D 255
Exploring the AnimationListener Class 256
Some Notes on Transformation Matrices 257
Summary 258
Chapter 7 Exploring Security and Location-Based Services 259
Understanding the Android Security Model 259
Overview of Security Concepts 260
Signing Applications for Deployment 260
Generating a Self-Signed Certificate Using the Keytool 261
Using the Jarsigner Tool to Sign the .apk File 262
Aligning Your Application with zipalign 263
Installing Updates to an Application and Signing 265
Performing Runtime Security Checks 265
Understanding Security at the Process Boundary 265
Declaring and Using Permissions 266
Understanding and Using Custom Permissions 268
Understanding and Using URI Permissions 274
Working with Location-Based Services 274
Understanding the Mapping Package 275
Obtaining a map-api Key from Google 275
Understanding MapView and MapActivity 277
Using Overlays 282
Understanding the Location Package 286
Geocoding with Android 286
Geocoding with Background Threads 290
Understanding the LocationManager Service 293
Using MyLocationOverlay 298
Summary 303
Chapter 8 Building and Consuming Services 304
Consuming HTTP Services 304
Using the HttpClient for HTTP GET Requests 305
Using the HttpClient for HTTP POST Requests 306
Dealing with Exceptions 310
Addressing Multithreading Issues 312
Doing Interprocess Communication 316
Creating a Simple Service 316
Understanding Services in Android 317
Understanding Local Services 318
Understanding AIDL Services 322
Defining a Service Interface in AIDL 323
Implementing an AIDL Interface 325
Calling the Service from a Client Application 327
Passing Complex Types to Services 331
Summary 341
Chapter 9 Using the MediaFramework and Telephony APIs 342
Using the Media APIs 342
Understanding and Using SD Cards 343
Playing Audio Content 346
Understanding the setDataSource Method 350
Playing Video Content 351
Understanding the MediaPlayer Oddities 353
Exploring Audio Recording 354
Exploring Video Recording 358
Exploring the MediaStore Class 363
Adding Media Content to the Media Store 367
Using the Telephony APIs 369
Working with SMS 369
Sending SMS Messages 369
Monitoring Incoming SMS Messages 372
Working with SMS Folders 374
Sending E-mail 375
Working with the Telephony Manager 376
Summary 377
Chapter 10 Programming 3D Graphics with OpenGL 378
Understanding the History and Background of OpenGL 379
OpenGL ES 380
OpenGL ES and Java ME 381
M3G: Another Java ME 3D Graphics Standard 382
Fundamentals of OpenGL 382
Essential Drawing with OpenGL ES 383
glVertexPointer and Specifying Drawing Vertices 384
glDrawElements 386
glClear 388
glColor 388
Understanding OpenGL Camera and Coordinates 389
gluLookAt and the Camera Symbolism 389
glFrustum and the Viewing Volume 391
glViewport and Screen Size 392
Interfacing OpenGL ES with Android 393
Using GLSurfaceView and Related Classes 394
Simple Test Harness That Draws a Triangle 395
Changing Camera Settings 399
Using Indices to Add Another Triangle 401
Animating the Simple OpenGL Triangle 402
AnimatedTriangleActivity.java 403
AnimatedSimpleTriangleRenderer 404
Braving OpenGL: Shapes and Textures 405
A Simple Menu Trick for Your Demos 406
Drawing a Rectangle 410
Working with Shapes 412
A Regular Polygon As a Shape 412
Implementing the RegularPolygon Shape 413
Rendering a Square Using RegularPolygon 420
Animating RegularPolygons 422
Working with Textures 425
Understanding Textures 425
Normalized Texture Coordinates 425
Abstracting Common Texture Handling 426
Drawing Using Textures 429
Drawing Multiple Figures 430
OpenGL Resources 434
Summary 434
Chapter 11 Managing and Organizing Preferences 435
Exploring the Preferences Framework 435
Understanding ListPreference 436
Manipulating Preferences Programmatically 443
Understanding CheckBoxPreference 444
Understanding EditTextPreference 446
Understanding RingtonePreference 447
Organizing Preferences 449
Summary 452
Chapter 12 Exploring Live Folders 453
Exploring Live Folders 453
How a User Experiences Live Folders 454
Building a Live Folder 459
AndroidManifest.xml 460
AllContactsLiveFolderCreatorActivity.java 461
MyContactsProvider.java 463
MyCursor.java 468
BetterCursorWrapper.java 468
SimpleActivity.java 469
Exercising Live Folders 470
Summary 470
Chapter 13 Home Screen Widgets 471
Architecture of Home Screen Widgets 472
What Are Home Screen Widgets? 472
User Experience with Home Screen Widgets 473
Creating a Widget Instance on the Home Screen 473
Understanding Widget Configurator 475
Lifecycle of a Widget 476
Widget Definition Phase 476
Widget Instance Creation Phase 478
onUpdate Phase 480
Widget View Mouse Click Event Callbacks Phase 481
Deleting a Widget Instance 482
Uninstalling Widget Packages 482
A Sample Widget Application 482
Defining the Widget Provider 484
Defining Widget Size 485
Widget Layout-Related Files 486
Widget Layout File 486
Widget Background Shape File 487
Implementing a Widget Provider 488
Implementing Widget Models 490
Interface for a Widget Model 490
Abstract Implementation of a Widget Model 491
Implementation of a Widget Model for Birthday Widget 494
A Few Date-Related Utilities 496
Implementing Widget Configuration Activity 497
Widget Limitations and Extensions 501
Resources 502
Summary 503
Chapter 14 Android Search 504
Android Search Experience 505
Exploring Android Global Search 505
Enabling Suggestion Providers for Global Search 510
QSB and Suggestions Provider Interaction 513
Activities and Search Key Interaction 515
Behavior of Search Key on a Regular Activity 516
Behavior of an Activity That Disables Search 523
Invoking Search Through a Menu 524
Understanding Local Search and Related Activities 527
Enabling Type-to-Search 532
Implementing a Simple Suggestion Provider 533
Planning the Simple Suggestions Provider 533
Simple Suggestions Provider Implementation Files 534
Implementing the SimpleSuggestionProvider class 534
Responsibilities of a Simple Suggestion Provider 535
Complete Source Code of SimpleSuggestionProvider 535
Understanding SearchRecentSuggestionsProvider Database Modes 535
Declaring the Suggestion Provider in the Manifest File 537
Understanding Simple Suggestions Provider Search Activity 538
Responsibilities of a Simple Search Activity 538
Complete Source Code of a Search Activity 538
Checking the Action and Retrieving the Query 540
Understanding onCreate() and onNewIntent() 540
How to Test for onNewIntent() 540
Saving the Query Using SearchRecentSuggestionsProvider 541
Search Metadata 541
Search Invoker Activity 542
Simple Suggestion Provider User Experience 544
Implementing a Custom Suggestion Provider 548
Planning the Custom Suggestion Provider 548
SuggestURLProvider Project Implementation Files 549
Implementing the SuggestUrlProvider Class 549
Responsibilities of a Suggestion Provider 550
Overall Source Code for SuggestUrlProvider 550
Understanding Suggestion Provider URIs 553
Implementing getType() and Specifying MIME Types 554
Passing Query to the Suggestion Provider: The Selection Argument 554
Exploring Search Metadata for Custom Suggestion Providers 555
Suggestion Cursor Columns 556
Populating and Returning the List of Columns 557
Implementing a Search Activity for a Custom Suggestion Provider 558
Responsibilities of a Search Activity 558
Source Code of SearchActivity for a Custom Suggestion Provider 559
Details of SearchActivity Invocation 561
Responding to ACTION_SEARCH and ACTION_VIEW 561
Search Activity Layout 562
Corresponding strings.xml 563
Responding to onCreate() and onNewIntent() 563
Notes on Finishing a Search Activity 563
Custom Suggestions Provider Manifest File 564
Custom Suggestion User Experience 565
Using Action Keys and Application-Specific Search Data 569
Using Action Keys in Android Search 570
Working with Application-Specific Search Context 572
Resources 574
Summary 575
Chapter 15 Exploring Text to Speech and Translate APIs 576
The Basics of Text to Speech in Android 576
Using Utterances to Keep Track of Our Speech 581
Using Audio Files for Your Voice 582
Advanced Features of the TTS Engine 589
Setting Audio Streams 589
Using Earcons 590
Playing Silence 590
Using Language Methods 591
Translating Text to a Different Language 592
Summary 601
Chapter 16 Touchscreens 603
Understanding MotionEvents 603
Using VelocityTracker 615
Exploring Drag and Drop 617
Multi-Touch 620
Touches with Maps 627
Gestures 630
Summary 637
Chapter 17 Titanium Mobile: A WebKit-Based Approach to Android Development 638
Titanium Mobile Overview 639
Architecture 640
Nature of a Titanium Project 642
Components of the Titanium Developer IDE 642
Building and Deploying Projects through Titanium IDE 642
The Titanium Ecosystem 643
Downloading and Installing Titanium Developer 644
Getting to Know the Ropes: The First Project 651
Creating a Titanium Mobile Project 651
Crafting “Hello World” 653
Provisioning the Application for Debugging 655
Packaging the Application 658
Installing the .apk File on Your Own Emulator 660
Planning for Real-World Applications 661
Essential Primer on JQuery 662
Essential Primer on Advanced JavaScript 664
Understanding the Microtemplating Engine 667
Additional Titanium Mobile APIs 670
Summary 671
Chapter 18 Working with Android Market 672
Becoming a Publisher 672
Following the Rules 673
Developer Console 676
Preparing Your Application for Sale 677
Testing for Different Devices 677
Supporting Different Screen Sizes 677
Preparing AndroidManifest.xml for Uploading 678
Localizing Your Application 678
Preparing Your Application Icon 679
Considerations for Paid Apps 679
Directing Users Back to the Market 680
Preparing Your .apk File for Uploading 680
Uploading Your Application 681
User Experience on Android Market 683
Summary 685
Chapter 19 Outlook and Resources 686
Current State of Android 686
Android Based Mobile Device Manufacturers 687
Motorola Droid 687
T-Mobile G1 688
Nexus One 688
Android Application Stores 688
Outlook For Android 690
Quick Summary of Mobile Operating Systems 690
Contrasting Android with other Mobile OSs 692
Support for HTML 5 and What it Reveals 693
Android Resources 694
Core Android Resources 694
Android News Related Resources 695
Summary 696
Index 697

Erscheint lt. Verlag 4.8.2010
Zusatzinfo XVI, 736 p.
Verlagsort Berkeley
Sprache englisch
Themenwelt Informatik Betriebssysteme / Server Android
Mathematik / Informatik Informatik Netzwerke
Informatik Software Entwicklung Mobile- / App-Entwicklung
Mathematik / Informatik Informatik Theorie / Studium
Mathematik / Informatik Informatik Web / Internet
Informatik Weitere Themen Smartphones / Tablets
Schlagworte Android • Animation • Appcelerator Titanium • Control • graphics • Netbook • programming
ISBN-10 1-4302-2660-9 / 1430226609
ISBN-13 978-1-4302-2660-4 / 9781430226604
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 54,0 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich