Showing posts with label Android. Show all posts
Showing posts with label Android. Show all posts

Wednesday, October 5, 2011

The Android Developer’s Cookbook






Table of Contents
1 Overview of Android 1
The Evolution of Android 1
The Dichotomy of Android 2
Devices Running Android 2
HTC Models 6
Motorola Models 6
Samsung Models 6
Tablets 7
Other Devices 7
Hardware Differences on Android Devices 8
Screens 8
User Input Methods 9
Sensors 9
Features of Android 10
Multiprocess and App Widgets 11
Touch, Gestures, and Multitouch 11
Hard and Soft Keyboards 11
Android Development 11
How to Use the Recipes in This Book 12
Designing Applications Well 12
Maintaining Forward Compatibility 13
Robustness 13
Software Development Kit 14
Installing and Upgrading 14
Software Features and API Level 15
Emulator and Android Device Debug 16
Using the Android Debug Bridge 18
Signing and Publishing 18
Android Market 19
End-User License Agreement 19
Improving App Visibility 19
Differentiating an App 20
Charging for an App 20
Managing Reviews and Updates 21
Alternatives to the Android Market 22
�viii Contents
2 Application Basics: Activities and Intents 23
Android Application Overview 23
Recipe: Creating a Project and an Activity 24
Directory Structure of Project and Autogenerated
Content 26
Android Package and Manifest File 28
Renaming Parts of an Application 30
Activity Lifecycle 30
Recipe: Utilizing Other Lifecycle Functions 31
Recipe: Forcing Single Task Mode 33
Recipe: Forcing Screen Orientation 34
Recipe: Saving and Restoring Activity Information 34
Multiple Activities 35
Recipe: Using Buttons and TextView 36
Recipe: Launching Another Activity from an Event 37
Recipe: Launching an Activity for a Result Using
Speech to Text 41
Recipe: Implementing a List of Choices 43
Recipe: Using Implicit Intents for Creating an
Activity 44
Recipe: Passing Primitive Data Types Between
Activities 46
3 Threads, Services, Receivers, and Alerts 51
Threads 51
Recipe: Launching a Secondary Thread 51
Recipe: Creating a Runnable Activity 55
Recipe: Setting a Thread’s Priority 57
Recipe: Canceling a Thread 57
Recipe: Sharing a Thread Between Two
Applications 58
Messages Between Threads: Handlers 58
Recipe: Scheduling a Runnable Task from the Main
Thread 59
Recipe: Using a Countdown Timer 61
Recipe: Handling a Time-Consuming Initialization 62
Services 64
Recipe: Creating a Self-Contained Service 65
���������������Contents
Adding a Broadcast Receiver 69
Recipe: Starting a Service When the Camera Button Is
Pressed 70
App Widgets 72
Recipe: Creating an App Widget 72
Alerts 74
Recipe: Using Toast to Show a Brief Message on the
Screen 74
Recipe: Using an Alert Dialog Box 75
Recipe: Showing Notification in Status Bar 76
4 User Interface Layout 79
Resource Directories and General Attributes 79
Recipe: Specifying Alternate Resources 81
Views and ViewGroups 82
Recipe: Building Layouts in the Eclipse Editor 83
Recipe: Controlling the Width and Height of UI
Elements 86
Recipe: Setting Relative Layout and Layout ID 89
Recipe: Declaring a Layout Programmatically 90
Recipe: Updating a Layout from a Separate
Thread 92
Text Manipulation 94
Recipe: Setting and Changing Text Attributes 95
Recipe: Providing Text Entry 98
Recipe: Creating a Form 100
Other Widgets: From Buttons to Seek Bars 101
Recipe: Using Image Buttons in a Table Layout 102
Recipe: Using Check Boxes and Toggle Buttons 105
Recipe: Using Radio Buttons 108
Recipe: Creating a Drop-Down Menu 110
Recipe: Using a Progress Bar 112
Recipe: Using a SeekBar 114
5 User Interface Events 117
Event Handlers and Event Listeners 117
Recipe: Intercepting a Physical Key Press 117
Recipe: Building Menus 121
Recipe: Defining Menus in XML 126
Recipe: Utilizing the SEARCH Key 127
Recipe: Reacting to Touch Events 128
Recipe: Listening for Fling Gestures 130
Recipe: Using Multitouch 133
Advanced User Interface Libraries 136
Recipe: Using Gestures 136
Recipe: Drawing 3D Images 140
6 Multimedia Techniques 147
Images 148
Recipe: Loading an Image for Manipulation 148
Audio 154
Recipe: Choosing and Playing Back Audio Files 154
Recipe: Recording Audio Files 157
Recipe: Manipulating Raw Audio 158
Recipe: Using Sound Resources Efficiently 163
Recipe: Adding Media and Updating Paths 165
Video 165
7 Hardware Interface 169
Camera 169
Recipe: Customizing the Camera 170
Other Sensors 175
Recipe: Getting a Device’s Rotational Attitude 176
Recipe: Using the Temperature and Light Sensor 179
Telephony 180
Recipe: Utilizing the Telephony Manager 181
Recipe: Listening for Phone States 183
Recipe: Dialing a Phone Number 185
Bluetooth 185
Recipe: Turning on Bluetooth 186
Recipe: Discovering Bluetooth Devices 187
Recipe: Pairing with Bonded Bluetooth Devices 188
Recipe: Opening a Bluetooth Socket 188
Recipe: Using Device Vibration 191
Recipe: Accessing the Wireless Network 191
���������������xi Contents
8 Networking 195
Using SMS 195
Recipe: Autosend an SMS Based on a Received
SMS 197
Using Web Content 204
Recipe: Customizing a Web Browser 204
Recipe: Using an HTTP GET 204
Recipe: Using HTTP POST 209
Social Networking 210
Recipe: Integrating with Twitter 210
9 Data Storage Methods 221
Shared Preferences 221
Recipe: Creating and Retrieving Shared
Preferences 222
Recipe: Using the Preferences Framework 222
Recipe: Changing the UI Based on Stored Data 225
Recipe: Adding a EULA 228
SQLite Database 232
Recipe: Creating a Separate Database Package 232
Recipe: Using a Separate Database Package 236
Recipe: Creating a Personal Diary 239
Content Provider 243
Recipe: Creating a Custom Content Provider 244
File Saving and Loading 249
10 Location-Based Services 251
Location Basics 251
Recipe: Retrieving Last Location 253
Recipe: Updating Location Upon Change 254
Recipe: Listing All Enabled Providers 256
Recipe: Translating a Location to Address (Reverse
Geocoding) 258
Recipe: Translating an Address to Location
(Geocoding) 261
Using Google Maps 263
Recipe: Adding Google Maps to an Application 265
Recipe: Adding Markers on a Map 267
���������������xii Contents
Recipe: Adding Views to a Map 271
Recipe: Marking the Device’s Current Location on a
Map 274
Recipe: Setting up a Proximity Alert 274
11 Advanced Android Development 277
Android Custom View 277
Recipe: Customizing a Button 277
Android Native Components 283
Recipe: Developing a Native Component 284
Android Security 287
Recipe: Declaring and Enforcing Permissions 288
Android Inter-Process Communication 288
Recipe: Implementing a Remote Procedure Call 289
Android Backup Manager 294
Recipe: Creating a Backup of Runtime Data 294
Recipe: Backing Up Files to the Cloud 296
Recipe: Triggering Backup and Restore 296
Android Animation 298
Recipe: Creating an Animation 299
12 Debugging 303
Eclipse Built-in Debug Tools 303
Recipe: Specifying a Run Configuration 303
Recipe: Using the DDMS 304
Recipe: Debugging Through Breakpoints 306
Android SDK Debug Tools 307
Recipe: Using the Android Debug Bridge 307
Recipe: Using LogCat 307
Recipe: Using the Hierarchy Viewer 309
Recipe: Using TraceView 311
Android System Debug Tools 313
Recipe: Setting up GDB Debugging 315
Index 317

Another Android Books
Download

Saturday, October 1, 2011

Professional Android 2 Application Development






PROFESSIONAL
ANDROID™ 2 APPLICATION DEVELOPMENT
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxvii
CHAPTER 1 Hello, Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
CHAPTER 2 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
CHAPTER 3 Creating Applications and Activities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
CHAPTER 4 Creating User Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
CHAPTER 5 Intents, Broadcast Receivers, Adapters,
and the Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
CHAPTER 6 Files, Saving State, and Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
CHAPTER 7 Databases and Content Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
CHAPTER 8 Maps, Geocoding, and Location-Based Services . . . . . . . . . . . . . . . . . 245
CHAPTER 9 Working in the Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
CHAPTER 10 Invading the Phone-Top . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
CHAPTER 11 Audio, Video, and Using the Camera . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
CHAPTER 12 Telephony and SMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
CHAPTER 13 Bluetooth, Networks, and Wi-Fi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
CHAPTER 14 Sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
CHAPTER 15 Advanced Android Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 529


Another Android Books
Downoad

Friday, September 23, 2011

Android Application Development, 1st Edition







By Rick Rogers, John Lombardo
Publisher: O'Reilly Media, Inc.
Pub Date: May 26, 2009
Print ISBN-13: 978-0-596-52147-9
Pages: 336
Slots: 1.0

This practical book provides the concepts and code you need to develop software with Android, the open-source platform for cell phones and mobile devices that's generating enthusiasm across the industry. Based on the Linux operating system and developed by Google and the Open Handset Alliance, Android has the potential to unite a fragmented mobile market. Android Application Development introduces this programming environment, and offers you a complete working example that demonstrates Android architectural features and APIs. With this book, you will:

Get a complete introduction to the Android programming environment, architecture, and tools

Build a modular application, beginning with a core module that serves to launch modules added in subsequent chapters

Learn the concepts and architecture of a specific feature set, including views, maps, location-based services, persistent data storage, 2D and 3D graphics, media services, telephony services, and messaging

Use ready-to-run example code that implements each feature

Delve into advanced topics, such as security, custom views, performance analysis, and internationalization

The book is a natural complement to the existing Android documentation provided by Google. Whether you want to develop a commercial application for mobile devices, or just want to create a mobile mashup for personal use, Android Application Development demonstrates how you can design, build, and test applications for the new mobile market.

Copyright
Preface
Part 1: Development Kit Walk-Through
Chapter 1. Getting to Know Android
Section 1.1. Why Android?
Section 1.2. The Open Handset Alliance
Section 1.3. The Android Execution Environment
Section 1.4. Components of an Android Application
Section 1.5. Android Activity Lifecycle
Section 1.6. Android Service Lifecycle
Section 1.7. How This Book Fits Together
Chapter 2. Setting Up Your Android Development Environment
Section 2.1. Setting Up Your Development Environment
Section 2.2. Hello, Android
Chapter 3. Using the Android Development Environment for Real Applications
Section 3.1. MicroJobs: This Book's Main Sample Application
Section 3.2. Android and Social Networking
Section 3.3. Downloading the MJAndroid Code
Section 3.4. A Brief Tour of the MJAndroid Code
Section 3.5. First Steps: Building and Running the MicroJobs Application
Section 3.6. Summary
Chapter 4. Under the Covers: Startup Code and Resources in the MJAndroid Application
Section 4.1. Initialization Parameters in AndroidManifest.xml
Section 4.2. Initialization in MicroJobs.java
Section 4.3. Summary
Chapter 5. Debugging Android Applications
Section 5.1. The Tools
Section 5.2. Eclipse Java Editor
Section 5.3. Summary
Chapter 6. The ApiDemos Application
Section 6.1. Application Setup in the Manifest File
Section 6.2. Finding the Source to an Interesting Example
Section 6.3. Adding Your Own Examples to ApiDemos
Chapter 7. Signing and Publishing Your Application
Section 7.1. Test Your Application
Section 7.2. Attach an End User License Agreement If Desired
Section 7.3. Create and Attach an Icon and Label
Section 7.4. Clean Up for Release
Section 7.5. Version Your Application
Section 7.6. Obtaining a Signing Certificate and API Key
Section 7.7. Signing Your Application
Section 7.8. Retesting Your Application
Section 7.9. Publishing on Android Market
Part 2: Programming Topics
Chapter 8. Persistent Data Storage: SQLite Databases and Content Providers
Section 8.1. Databases
Section 8.2. Content Providers
Chapter 9. Location and Mapping
Section 9.1. Location-Based Services
Section 9.2. Mapping
Section 9.3. The Google Maps Activity
Section 9.4. The MapView and MapActivity
Section 9.5. Working with MapViews
Section 9.6. Location Without Maps
Chapter 10. Building a View
Section 10.1. Android GUI Architecture
Section 10.2. Assembling a Graphical Interface
Section 10.3. Wiring Up the Controller
Section 10.4. The Menu
Chapter 11. A Widget Bestiary
Section 11.1. Android Views
Section 11.2. ViewGroups
Section 11.3. Layouts
Chapter 12. Drawing 2D and 3D Graphics
Section 12.1. Rolling Your Own Widgets
Section 12.2. Bling
Chapter 13. Inter-Process Communication
Section 13.1. Intents: Simple, Low-Overhead IPC
Section 13.2. Remote Methods and AIDL
Chapter 14. Simple Phone Calls
Section 14.1. Quick and Easy Phone Calls
Section 14.2. Exploring the Phone Code Through the Debugger
Section 14.3. Exception Handling
Section 14.4. Android Application-Level Modularity and Telephony
Chapter 15. Telephony State Information and Android Telephony Classes
Section 15.1. Operations Offered by the android.telephony Package
Section 15.2. Android Telephony Internals
Section 15.3. Android and VoIP
Appendix A. Wireless Protocols
Section A.1. Prehistory
Section A.2. The Dawn of Second Generation (2G) Digital Cellular
Section A.3. Improved Digital Cellular (2.5G)
Section A.4. The Rise of 3G
Section A.5. The Future: 4G
Colophon
Index


Another Android Books
Download

Wednesday, September 7, 2011

Beginning Android Games






Contents at a Glance
Contents .............................................................................................................. v
About the Author ............................................................................................... xii
About the Technical Reviewer ......................................................................... xiii
Acknowledgments ............................................................................................ xiv
Introduction ....................................................................................................... xv
■ Chapter 1: Android, the New Kid on the Block ................................................ 1
■ Chapter 2: First Steps with the Android SDK ................................................. 25
■ Chapter 3: Game Development 101 ............................................................... 51
■ Chapter 4: Android for Game Developers .................................................... 103
■ Chapter 5: An Android Game Development Framework .............................. 185
■ Chapter 6: Mr. Nom Invades Android .......................................................... 229
■ Chapter 7: OpenGL ES: A Gentle Introduction .............................................. 269
■ Chapter 8: 2D Game Programming Tricks ................................................... 351
■ Chapter 9: Super Jumper: A 2D OpenGL ES Game ....................................... 429
■ Chapter 10: OpenGL ES: Going 3D ................................................................ 489
■ Chapter 11: 3D Programming Tricks ........................................................... 525
■ Chapter 12: Droid Invaders: the Grand Finale ............................................. 577
■ Chapter 13: Publishing Your Game .............................................................. 625
■ Chapter 14: What’s Next? ............................................................................ 637
Index.............................................................................................................. 641


Another Android Books
Another Smart Phone Books
Download

Tuesday, September 6, 2011

Developing Android Applications with Flex 4.5







Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1. Hello World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Create a Flex Mobile Project 1
Debug a Flex Mobile Project 10
2. Application Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Blank Application 15
View-Based Application 17
View Life Cycle 24
Tabbed Application 25
3. Permissions and Configuration Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Permissions 29
Other Configuration Settings 32
Automatically Reorient 33
Full Screen 33
Automatically Scale Application for Different Screen Densities 33
Aspect Ratio 33
4. Exploring the APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Accelerometer 35
GPS 37
Camera UI 39
Camera Roll 43
Microphone 45
Multitouch 48
GestureEvent 48
TransformGesture 51
Busy Indicator 56
5. Working with the File System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
File System Access 59
Folder Aliases 59
Read and Write to the File System 61
File Browse for a Single File 64
File Browse for Multiple Files 66
SQLite Databases 69
6. OS Interactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Open in Browser 75
Create Text Message 77
Create Email 79
Place Call 81
Splash Screen 83
StageWebView 85
Screen Options 87
Layout 87
Full Screen 89
ActionBar 90
7. Publish to Android Installer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

Another Smart Phone Books
Another Android Books
Download

Pro Android 3







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


Another Android Books
Another Smart Phone Books
Download

Saturday, August 20, 2011

Learning Android






Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
1. Android Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Android Overview 1
Comprehensive 1
Open Source Platform 2
Designed for Mobile Devices 2
History 3
Google’s Motivation 3
Open Handset Alliance 4
Android Versions 4
Summary 5
2. The Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Stack Overview 7
Linux 7
Portability 7
Security 8
Features 8
Native Libraries 9
Dalvik 9
Android and Java 10
Application Framework 11
Applications 12
The APK 12
Application Signing 12
Application Distribution 12
Summary 13
3. Quick Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Installing the Android SDK 15
Setting Up a PATH to Tools 16
Installing Eclipse 16
Eclipse Workspace 17
Setting Up Android Development Tools 17
Hello, World 18
Creating a New Project 18
Manifest File 20
Layout XML Code 21
Strings 21
The R File 22
Java Source Code 22
The Emulator 23
An Emulator Versus a Physical Phone 25
Summary 25
4. Main Building Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
What Are Main Building Blocks? 27
A Real-World Example 27
Activities 28
Activity Life Cycle 28
Intents 31
Services 31
Content Providers 32
Broadcast Receivers 34
Application Context 34
Summary 35
5. Yamba Project Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
The Yamba Application 37
Design Philosophy 39
Project Design 39
Part 1: Android User Interface 39
Building an Activity 40
Networking and Multithreading 41
Debugging Android Apps 41
Part 2: Preferences, Filesystem, Options Menu, and Intents 41
The Activity 41
Menu System and Intents 42
Filesystem 42
Part 3: Android Services 42
Services 42
Application Object 42
Part 4: Working with Databases 42
SQLite and Android’s Support for It 42
Refactoring the Code Again 43
Part 5: Lists and Adapters 43
Timeline Activity 43
More Refactoring? 43
Part 6: Broadcast Receivers 43
Boot and Network Receivers 44
Timeline Receiver 44
Permissions 44
Part 7: Content Providers 44
Status Data 44
Android Widgets 44
Part 8: System Services 45
Compass and Location 45
Intent Service, Alarms, and Notifications 45
Summary 45
6. Android User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Two Ways to Create a User Interface 47
Declarative User Interface 47
Programmatic User Interface 48
The Best of Both Worlds 48
Views and Layouts 48
LinearLayout 49
TableLayout 50
FrameLayout 50
RelativeLayout 50
AbsoluteLayout 50
Starting the Yamba Project 51
The StatusActivity Layout 52
Imprtant Widget Properties 54
Strings Resource 55
The StatusActivity Java Class 56
Creating Your Application-Specific Object and Initialization Code 56
Compiling Code and Building Your Projects: Saving Files 59
Adding the jtwitter.jar Library 59
Updating the Manifest File for Internet Permission 61
Logging in Android 62
LogCat 62
Threading in Android 65
Single Thread 65
Multithreaded Execution 66
AsyncTask 67
Other UI Events 70
Adding Color and Graphics 74
Adding Images 74
Adding Color 76
Alternative Resources 79
Optimizing the User Interface 80
Hierarchy Viewer 81
Summary 82
7. Preferences, the Filesystem, the Options Menu, and Intents . . . . . . . . . . . . . . . . . . 83
Preferences 83
Prefs Resource 84
PrefsActivity 87
Update the Manifest File 88
The Options Menu 89
The Menu Resource 89
Android System Resources 90
Update StatusActivity to Load the Menu 91
Update StatusActivity to Handle Menu Events 92
Strings Resource 92
Shared Preferences 93
The Filesystem Explained 95
Exploring the Filesystem 95
Filesystem Partitions 96
System Partition 96
SDCard Partition 96
The User Data Partition 97
Filesystem Security 98
Summary 99
8. Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
The Yamba Application Object 102
The YambaApplication Class 102
Update the Manifest File 104
Simplifying StatusActivity 105
UpdaterService 105
Creating the UpdaterService Java Class 106
Update the Manifest File 107
Add Menu Items 108
Update the Options Menu Handling 109
Testing the Service 109
Looping in the Service 110
Testing the Service 113
Pulling Data from Twitter 113
Testing the Service 117
Summary 117
9. The Database . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
About SQLite 119
DbHelper 120
The Database Schema and Its Creation 120
Four Major Operations 121
Cursors 122
First Example 122
Update UpdaterService 124
Testing the Service 127
Database Constraints 129
Refactoring Status Data 130
Summary 135
10. Lists and Adapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
TimelineActivity 137
Basic TimelineActivity Layout 138
Introducing ScrollView 138
Creating the TimelineActivity Class 139
About Adapters 142
Adding a ListView to TimelineActivity 142
Creating a Row Layout 143
Creating an Adapter in TimelineActivity.java 144
TimelineAdapter 146
ViewBinder: A Better Alternative to TimelineAdapter 149
Updating the Manifest File 150
Initial App Setup 152
Base Activity 153
Toggle Service 154
Summary 159
11. Broadcast Receivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
About Broadcast Receivers 161
BootReceiver 162
Registering the BootReceiver with the AndroidManifest File 162
Testing the Boot Receiver 163
The TimelineReceiver 163
Broadcasting Intents 165
The Network Receiver 167
Adding Custom Permissions to Send and Receive Broadcasts 169
Declaring Permissions in the Manifest File 170
Updating the Services to Enforce Permissions 171
Updating TimelineReceiver to Enforce Permissions 172
Summary 173
12. Content Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Creating a Content Provider 175
Defining the URI 176
Inserting Data 177
Updating Data 178
Deleting Data 179
Querying Data 179
Getting the Data Type 180
Updating the Android Manifest File 181
Using Content Providers Through Widgets 181
Implementing the YambaWidget class 182
Creating the XML Layout 185
Creating the AppWidgetProviderInfo File 185
Updating the Manifest File 186
Testing the Widget 186
Summary 186
13. System Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Compass Demo 189
Common Steps in Using System Services 190
Getting Updates from the Compass 190
Compass Main Activity 191
Custom Rose Widget 194
Location Service 195
Where Am I? Demo 196
Updating Yamba to Use the Location Service 200
Updating Our Preferences 200
Updating the Yamba Application 201
Updating the Status Activity 202
Intent Service 206
Alarms 208
Adding an Interval to Preferences 209
Updating BootReceiver 210
Sending Notifications 212
Summary 214
14. The Android Interface Definition Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Implementing the Remote Service 215
Writing the AIDL 216
Implementing the Service 217
Implementing a Parcel 218
Registering with the Manifest File 220
Implementing the Remote Client 221
Binding to the Remote Service 221
Testing That It All Works 224
Summary 225
15. The Native Development Kit (NDK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
What Is and Isn’t the NDK For? 227
Problems Solved by the NDK 227
The Toolchain 228
Packaging Your Libs 228
Documentation and Standardized Headers 228
An NDK Example: Fibonacci 229
FibLib 229
The JNI Header File 231
C Implementation 232
The Makefile 234
Building the Shared Library 234
The Fibonacci Activity 235
Testing That It All Works 236
Summary 237
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

Another Android Books
Download

Monday, August 8, 2011

Android User Interface Development Beginner's Guide






Table of Contents
Preface 1
Chapter 1: Developing a Simple Activity 11
Developing our first example 11
Creating the project structure 12
Time for action – setting up the Android SDK 12
Time for action – starting a new project 13
Examining the Android project layout 14
Time for action – running the example project 14
The screen layout 15
The layout XML file 16
Resource selection qualifiers 16
Time for action – setting up the question activity 18
Populating a View and a ViewGroup 19
Time for action – asking a question 19
Time for action – adding a space for answers 21
Time for action – adding more buttons 23
Defining common dimensions 25
Limitations of the layout XML format 27
Populating the QuestionActivity 29
Time for action – writing more Java code 30
Dynamically creating widgets 32
Time for action – putting the questions on the screen 32
Handling events in Android 34
Summary 36
Chapter 2: Presenting Data for Views 37
Listing and selecting data 38
ListView choice modes 38
No selection mode – CHOICE_MODE_NONE 38
Single selection mode – CHOICE_MODE_SINGLE 39
Multiple selection mode – CHOICE_MODE_MULTIPLE 40
Adding header and footer widgets 40
Creating a simple ListView 41
Time for action – creating a fast food menu 41
Styling the standard ListAdapters 43
Defining standard dimensions 43
Time for action – improving the restaurant list 44
Creating custom adapters 47
Creating a menu for The Burger Place 47
Time for action – creating a Burger item layout 48
Time for action – presenting Burger objects 50
Creating TheBurgerPlaceActivity class 52
Time for action – implementing TheBurgerPlaceActivity 53
Registering and starting TheBurgerPlaceActivity 54
Using the ExpandableListView class 56
Creating ExpandableListAdapter implementations 57
Using the GridView class 58
Time for action – creating the fruit icon 59
Displaying icons in a GridView 60
Time for action – building the fruit menu 61
Time for action – creating the FourBucketsActivity 62
Summary 64
Chapter 3: Developing with Specialized Android Widgets 67
Creating a restaurant review application 68
Time for action – creating the robotic review project structure 68
Building a TabActivity 70
Creating tab icons 70
Android tabs and icons 71
Implementing the ReviewActivity 72
Time for action – writing the ReviewActivity class 72
Time for action – creating the Review layout 74
Working with switcher classes 75
Time for action – turning on the TextSwitcher 76
Creating a simple photo gallery 78
Time for action – building the Photos tab 79
Creating a thumbnail widget 80
Implementing a GalleryAdapter 80
Time for action – the GalleryAdapter 81
Time for action – making the gallery work 83
Building the reservation tab 86
Time for action – implementing the reservation layout 86
Time for action – initializing the reservation tab 89
Time for action – listening to the SeekBar 92
Time for action – selecting date and time 93
Creating complex layouts with Include, Merge, and ViewStubs 96
Using Include tags 97
Merging layouts 97
Using the ViewStub class 99
Summary 100
Chapter 4: Leveraging Activities and Intents 103
Exploring the Activity class 104
Using Bundle objects 105
Time for action – building an example game: "guess my number" 106
Creating and consuming intents 110
Defining Intent actions 111
Passing data in an Intent 112
Adding extra data to an Intent 112
Using advanced Intent features 113
Getting data back from an Intent 113
Time for action – viewing phone book contacts 114
Summary 118
Chapter 5: Developing Non-linear Layouts 119
Time for action – creating a layouts example project 120
FrameLayout 121
Common uses 121
Time for action – developing a FrameLayout example 122
Table Layout 126
Common uses 127
Using TableLayout for a memory game 127
Time for action – developing a simple memory game 128
AbsoluteLayout/Custom Layouts 133
Developing your own Layouts 134
Time for action – creating a custom layout 134
Using the CircleLayout 137
Time for action – finishing the CircleLayout example 137
RelativeLayout 140
Common uses 140
Integrating the RelativeLayout 141
Time for action – creating a contact editor 141
Time for action – integration with the layout example 144
SlidingDrawer 146
Common uses 146
Creating a SlidingDrawer example 147
Time for action – creating a SlidingDrawer 147
Time for action – sliding drawer integration 148
Summary 150
Chapter 6: Validating and Handling Input Data 153
Dealing with undesirable input 153
Correctly labeling input 154
Signaling undesirable input 154
Recovering from undesirable input 155
Giving users direct feedback 155
Avoiding invalid input entirely 156
Capturing date and time 156
Using spinners and ListView for selection 159
Changing the data set 159
Disabling selections 159
Capturing text input 160
Autocompleting text input 160
Building activities for results 162
Generic filtering search Activity 162
Time for action – creating the ListItemSelectionActivity 163
Time for action – creating an ArrayAdapter 164
Time for action – creating the CursorAdapter 165
Time for action – setting up the ListView 169
Time for action – filtering the list 170
Time for action – returning the selection 171
Using the ListItemSelectionActivity 172
Summary 174
Chapter 7: Animating Widgets and Layouts 175
Using standard Android animations 176
Time for action – animating a news feed 176
Using flipper and switcher widgets 181
Using the ImageSwitcher and TextSwitcher implementations 182
Animating layout widgets 182
Time for action – animating a GridView 183
Creating Custom Animations 187
Time for action – writing a custom animation 188
Time for action – making a Button vanish 189
Summary 192
Chapter 8: Designing Content-centric Activities 193
Considering design options when displaying content on an Android device 194
Considering user behavior 195
Drawing user attention 196
Displaying content with the WebView class 197
Using a WebView object 198
Time for action – creating a recipe viewer application 198
Taking WebView further 203
Creating relative layouts for content display 204
Taking full advantage of RelativeLayout 205
Considering Android layout constraints 206
Styling TextView objects 207
Time for action – developing specialized content views 210
Developing an online music store 213
Designing the music store 213
Developing the music store 215
Time for action – building a track item 218
Time for action – developing the main user interface layout 219
Time for action – developing the main user interface Java code 222
Summary 225
Chapter 9: Styling Android Applications 227
Working with style resources 228
Using shape resources 230
How shapes behave 231
Rendering lines 231
Time for action – drawing a broken line 231
Rendering rectangles 232
Time for action – creating a rounded border 232
Rendering ovals 234
Time for action – applying a gradient to an oval shape 235
Rendering rings 236
Time for action – rendering a spinner ring 237
Defining layers 238
Stretching using nine-patch images 239
Creating nine-patch images 240
Using bitmap images in Android 241
Handling different screen sizes 242
Handling different screen densities 243
Handling configuration changes 244
Providing landscape layouts 245
Providing text input on a landscape layout 246
Altering screen content 247
Summary
Chapter 10: Building an Application Theme 249
Creating a basic calculator layout 250
Designing a standard calculator 251
Time for action – building the standard calculator 252
Building the calculator styling 254
Time for action – creating the button images 255
Time for action – styling the calculator buttons 257
Time for action – styling the display 260
Scientific landscape layout 263
Defining string resources for the scientific layout 263
Styling the scientific layout 265
Building the scientific layout 265
Time for action – coding the scientific layout 266
Handling the Activity restart 269
Supporting hardware keyboards 270
Adding in display animations 271
Time for action – animating the display 271
Summary 274
Appendix: Pop quiz answers 275
Chapter 1 275
Layouts as XML fles 275
Populating an activity 275
Chapter 2 276
List views and adapters 276
Chapter 3 276
Gallery objects and ImageViews 276
Chapter 4 276
Intents & Activities 276
Chapter 5. 277
Custom layouts 277
Chapter 6 277
Text input 277
Chapter 8 277
The WebView widget 277
WebView versus native layouts 277
Chapter 10 278
Layout resources 278
Nine-Patch Images 278
Android resources 278
Index 279


Another Android Books
Download

Friday, June 10, 2011

Web Geek’s Guide to the Android Enabled Phone






Table of Contents
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Part I: Devices
1 The Theory of the Android Phone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
The Melding of Google Mobile and Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Today’s Internet Society . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Bringing It All Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Making Devices Usable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Adding Software Applications to the Mix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Closing the Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2 Getting to Know Android Phones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
The T-Mobile G1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
The Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Screen Icons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
The T-Mobile myTouch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Overview of Software and Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Android in Brief . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Core Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Third-Party Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Device Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Closing the Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3 Basic Use of Your Android Phone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Phone Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Calling Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Call Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Text Messages, Multimedia Messages, and IMs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Text Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Multimedia Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Instant Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
To Sync or Not to Sync . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Syncing with the Web, Not the Desktop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
You Can Still Sync With the Desktop—Sorta . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Closing the Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
Part II: The Applications
4 Core Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Connecting with Contacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Adding Contacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Managing Existing Contacts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Saving the Date in the Calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Navigating the Calendar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Adding Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Editing and Deleting Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Adding Multiple Calendars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Figuring with the Calculator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Using the Camera to Capture Pictures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Camera Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
Working with Pictures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Capturing and Sharing Videos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Capturing Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Sharing Videos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Closing the Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
5 Going Online . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Getting Connected . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Connection Is More Than Just the Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
A Bit More on Bluetooth and GPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
The Impotant Stuff: Wi-Fi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Understanding the Android Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Accessing the Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Browser Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Link Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Multiple Page Instances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Go to URL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
Bookmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Refresh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Additional Browser Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Closing the Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
6 Email Anywhere . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Introduction to Gmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Accessing Gmail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Using Gmail to Send and Receive Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Reading Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Receiving Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Composing and Sending Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
Advanced Gmail Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Managing Your Email . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Email Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
Other Email Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Account Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Message Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
Closing the Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
7 Getting Around with GPS and Google Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
An Introduction to the G1’s GPS Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Using Google Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Getting Directions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Additional Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Changing the Map View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Other GPS Capabilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Closing the Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
8 Breaking Boredom with Entertainment Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Listening to Music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Finding Your Music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Using Music Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Putting Music on Your Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Finding Music with Amazon MP3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Watching Videos with YouTube . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Accessing YouTube and Videos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Navigating a Video . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Playing Games and Other Diversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Closing the Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
9 Adding Applications to Your Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Finding Apps in the Android Market . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Downloading and Installing Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Managing Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
Removing Apps the Easy Way . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Managing Apps, Including Removal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Closing the Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
Part III: The Android Platfom
10 Getting to Know Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Understanding Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
Key Components of Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
Features of the Android Platform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
The Principles of the Open Handset Alliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
The Open Handset Alliance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Alliance versus Single Provider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Closing The Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
11 Developing Native Android Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Requirements for Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Android Software Development Kit (SDK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Java Standard Edition Development Kit (JDK) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
Eclipse Integrated Development Environment (IDE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192
ANT Build Tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Developing Android Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Setting Up the Development Environment on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Setting Up the Development Environment on Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195
Making your IDE Android Aware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Bringing It All Together: Creating Your First Android Application . . . . . . . . . . . . . . . . 198
Creating an Application Using Eclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Introduction to Android SDK Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Android Debug Bridge (adb) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Android Device Emulator (emulator) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Make SD Card (mksdcard) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Dalvik Debug Monitor Service (ddms) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
Android Asset Packaging Tool (aapt) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Hierarchy Viewer (hierarchyviewer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
UI/Application Exerciser Monkey . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Trace View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
SQLite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Closing the Door . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
12 Developing Mobile Web Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
Client Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
The User-Agent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Server Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Security and Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
Designing Web Content for Android . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
WebKit Support for Advanced CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
WebKit Support for JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Performance Tips for Mobile Content . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Optimal Loading Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Simple Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Clean Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Handling Broken Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Spell-Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
External Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
13 Advanced Android Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Ultimate Portability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242
Make Contact . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
A Few Programmer/Analyst Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
How to Get Advanced Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Apps by Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
Business Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
Communication Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Location-Based Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Entertainment Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
Utility Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 252
Creating Advanced Apps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Appendixes
A Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Troubleshooting Device Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Troubleshooting Application Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Troubleshooting Design Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
B G1 Keyboard Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
Shortcuts for Navigating Text and Typing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Shortcuts for Navigating Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Browser Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . http://www.blogger.com/img/blank.gif. . . . . . . . 267
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

Another Android Books
Download
Related Posts with Thumbnails

Put Your Ads Here!