Book description
Pro Android 3 shows you how to build real-world and fun mobile applications using the new Android 3.0 SDK. It covers everything from the fundamentals of building apps for embedded devices, phones, and tablets to advanced concepts such as custom 3D components and multi-tasking.
Using the tutorials and expert advice, you'll quickly be able to build cool mobile apps and run them on dozens of Android-based smartphones. You'll explore and use the Android APIs, including those for media and sensors. And you'll check out what's new with Android 3.0, including the improved UI across all Android platforms, integration with WebM, and more, giving you the knowledge to create stunning, cutting-edge apps, while keeping you agile enough to respond to changes in the future.
What you'll learn
How to use Android to build Java-based mobile applications for Google phones with a touch screen or keyboard
How to design and implement irresistible user interfaces for touchscreens with Views and layouts
How to populate your application with data from data sources, using Content Providers
How to create 3D graphics with OpenGL and custom components
How to build multimedia and game apps using Android's Media APIs and OpenGL
How to use Android's location-based services, network-based services, and security
How to use new Android 3.0 features, such as Fragments and the ActionBar
Who this book is for
This book is for professional software engineers/programmers looking to move their ideas and applications into the mobile space with Android. It assumes a passable understanding of Java, including how to write classes and handle basic inheritance structures.
Table of contents
- Copyright
- Foreword
- About the Authors
- About the Technical Reviewer
- Acknowledgments
- Preface
-
1. Introducing the Android Computing Platform
- 1.1. A New Platform for a New Personal Computer
- 1.2. Early History of Android
- 1.3. Delving Into the Dalvik VM
- 1.4. Understanding the Android Software Stack
- 1.5. Developing an End-User Application with the Android SDK
- 1.6. Taking Advantage of Android Source Code
- 1.7. The Sample Projects in this Book
- 1.8. Summary
- 2. Setting Up Your Development Environment
- 3. Understanding Android Resources
-
4. Understanding Content Providers
- 4.1. Exploring Android's Built-in Providers
- 4.2. Architecture of Content Providers
-
4.3. Implementing Content Providers
-
4.3.1.
- 4.3.1.1. Planning a Database
- 4.3.1.2. Extending ContentProvider
- 4.3.1.3. Fulfilling MIME-Type Contracts
- 4.3.1.4. Implementing the Query Method
- 4.3.1.5. Implementing an Insert Method
- 4.3.1.6. Implementing an Update Method
- 4.3.1.7. Implementing a Delete Method
- 4.3.1.8. Using UriMatcher to Figure Out the URIs
- 4.3.1.9. Using Projection Maps
- 4.3.1.10. Registering the Provider
-
4.3.1.
- 4.4. Exercising the Book Provider
- 4.5. Resources
- 4.6. Summary
-
5. Understanding Intents
- 5.1. Basics of Android Intents
- 5.2. Available Intents in Android
- 5.3. Exploring Intent Composition
- 5.4. Exercising the ACTION_PICK
- 5.5. Exercising the GET_CONTENT Action
- 5.6. Introducing Pending Intents
- 5.7. Resources
- 5.8. Summary
-
6. Building User Interfaces and Using Controls
- 6.1. UI Development in Android
- 6.2. Understanding Android's Common Controls
- 6.3. Understanding Adapters
- 6.4. Using Adapters With AdapterViews
- 6.5. Styles and Themes
- 6.6. Understanding Layout Managers
- 6.7. Debugging and Optimizing Layouts with the Hierarchy Viewer
- 6.8. References
- 6.9. Summary
-
7. Working with Menus
- 7.1. Understanding Android Menus
- 7.2. Responding to Menu Items
- 7.3. Creating a Test Harness for Testing Menus
- 7.4. Working with Other Menu Types
- 7.5. Loading Menus Through XML Files
- 7.6. Resource
- 7.7. Summary
-
8. Working with Dialogs
- 8.1. Using Dialogs in Android
- 8.2. Working with Managed Dialogs
- 8.3. Working with Toast
- 8.4. Resources
- 8.5. Summary
- 9. Working with Preferences and Saving State
- 10. Exploring Security and Permissions
-
11. Building and Consuming Services
-
11.1. Consuming HTTP Services
- 11.1.1. Using the HttpClient for HTTP GET Requests
- 11.1.2. Using the HttpClient for HTTP POST Requests (a Multipart Example)
- 11.1.3. SOAP, JSON, and XML Parsers
- 11.1.4. Dealing with Exceptions
- 11.1.5. Addressing Multithreading Issues
- 11.1.6. Fun With Timeouts
- 11.1.7. Using the HttpURLConnection
- 11.1.8. Using the AndroidHttpClient
- 11.1.9. Using Background Threads (AsyncTask)
- 11.1.10. Handling Configuration Changes with AsyncTasks
- 11.1.11. Getting Files Using DownloadManager
- 11.2. Using Android Services
- 11.3. Real-World Example Using Services
- 11.4. References
- 11.5. Summary
-
11.1. Consuming HTTP Services
- 12. Exploring Packages
-
13. Exploring Handlers
-
13.1. Android Components and Threading
- 13.1.1. Activities Run on the Main Thread
- 13.1.2. Broadcast Receivers run on the Main Thread
- 13.1.3. Services Run on the Main Thread
- 13.1.4. Content Provider Runs on the Main Thread
- 13.1.5. Implications of a Singular Main Thread
- 13.1.6. Thread Pools, Content Providers, External Service Components
- 13.1.7. Thread Utilities: Discover Your Threads
- 13.2. Handlers
- 13.3. Using Worker Threads
- 13.4. Handler Example Driver classes
- 13.5. Component and Process Lifetimes
- 13.6. Instructions for Compiling the Code
- 13.7. References
- 13.8. Summary
-
13.1. Android Components and Threading
-
14. Broadcast Receivers and Long-Running Services
- 14.1. Broadcast Receivers
- 14.2. Using Notifications from a Receiver
- 14.3. Long-Running Receivers and Services
- 14.4. Extending IntentService for a Broadcast Receiver
-
14.5. Long-Running Service Implementation
- 14.5.1. Details of a Nonsticky Service
- 14.5.2. Details of a Sticky Service
- 14.5.3. A Variation of Nonsticky: Redeliver Intents
- 14.5.4. Specifying Service Flags in OnStartCommand
- 14.5.5. Picking Suitable Stickiness
- 14.5.6. Controlling the Wake Lock from Two Places
- 14.5.7. Long-Running Service Implementation
- 14.5.8. Testing Long Running Services
- 14.6. Instructions for Compiling the Code
- 14.7. References
- 14.8. Summary
-
15. Exploring the Alarm Manager
- 15.1. Alarm Manager Basics: Setting Up a Simple Alarm
- 15.2. Exploring Alarm Manager Alternate Scenarios
- 15.3. Alarm Manager Predicates
- 15.4. References
- 15.5. Summary
- 16. Exploring 2D Animation
-
17. Exploring Maps and Location-based Services
- 17.1. Understanding the Mapping Package
- 17.2. Understanding the Location Package
- 17.3. References
- 17.4. Summary
- 18. Using the Telephony APIs
-
19. Understanding the Media Frameworks
- 19.1. Using the Media APIs
- 19.2. Playing Media
-
19.3. Recording Media
- 19.3.1. Exploring Audio Recording with MediaRecorder
- 19.3.2. Recording Audio with AudioRecord
- 19.3.3. Exploring Video Recording
- 19.3.4. Exploring the MediaStore Class
- 19.3.5. Recording Audio Using an Intent
- 19.3.6. Adding Media Content to the Media Store
- 19.3.7. Triggering MediaScanner for the Entire SD Card
- 19.3.8. References
- 19.4. Summary
-
20. Programming 3D Graphics with OpenGL
- 20.1. Understanding the History and Background of OpenGL
- 20.2. Fundamentals of OpenGL
- 20.3. Interfacing OpenGL ES with Android
- 20.4. Braving OpenGL: Shapes and Textures
- 20.5. OpenGL ES 2.0
- 20.6. Instructions for Compiling the Code
- 20.7. Summary
- 21. Exploring Live Folders
-
22. Home Screen Widgets
- 22.1. Architecture of Home Screen Widgets
- 22.2. A Sample Widget Application
- 22.3. Widget Limitations and Extensions
- 22.4. Resources
- 22.5. Summary
-
23. Android Search
- 23.1. Android Search Experience
- 23.2. Activities and Search Key Interaction
-
23.3. Implementing a Simple Suggestion Provider
- 23.3.1. Planning the Simple Suggestions Provider
- 23.3.2. Simple Suggestions Provider Implementation Files
- 23.3.3. Implementing the SimpleSuggestionProviderclass
- 23.3.4. Understanding Simple Suggestions Provider Search Activity
- 23.3.5. Search Invoker Activity
- 23.3.6. Simple Suggestion Provider User Experience
-
23.4. Implementing a Custom Suggestion Provider
- 23.4.1. Planning the Custom Suggestion Provider
- 23.4.2. SuggestURLProvider Project Implementation Files
-
23.4.3. Implementing the SuggestUrlProvider Class
- 23.4.3.1. Responsibilities of a Suggestion Provider
- 23.4.3.2. Overall Source Code for SuggestUrlProvider
- 23.4.3.3. Understanding Suggestion Provider URIs
- 23.4.3.4. Implementing getType() and Specifying MIME Types
- 23.4.3.5. Passing Query to the Suggestion Provider: The Selection Argument
- 23.4.3.6. Exploring Search Metadata for Custom Suggestion Providers
- 23.4.3.7. Suggestion Cursor Columns
- 23.4.3.8. Populating and Returning the List of Columns
-
23.4.4. Implementing a Search Activity for a Custom Suggestion Provider
- 23.4.4.1. SearchActivity for a Custom Suggestion Provider
- 23.4.4.2. Details of SearchActivity Invocation
- 23.4.4.3. Responding to ACTION_SEARCH and ACTION_VIEW
- 23.4.4.4. Search Activity Layout
- 23.4.4.5. Corresponding strings.xml
- 23.4.4.6. Responding to onCreate() and onNewIntent()
- 23.4.4.7. Notes on Finishing a Search Activity
- 23.4.5. Custom Suggestions Provider Manifest File
- 23.4.6. Custom Suggestion User Experience
- 23.5. Using Action Keys and Application-Specific Search Data
- 23.6. Resources
- 23.7. Implications for Tablets
- 23.8. Summary
- 24. Exploring Text to Speech
- 25. Touch Screens
-
26. Using Sensors
- 26.1. What Is a Sensor?
- 26.2. Getting Sensor Events
-
26.3. Interpreting Sensor Data
- 26.3.1. Light Sensors
- 26.3.2. Proximity Sensors
- 26.3.3. Temperature Sensors
- 26.3.4. Pressure Sensors
- 26.3.5. Gyroscope Sensors
- 26.3.6. Accelerometers
- 26.3.7. Magnetic Field Sensors
- 26.3.8. Using Accelerometers and Magnetic Field Sensors Together
- 26.3.9. Orientation Sensors
- 26.3.10. Magnetic Declination and GeomagneticField
- 26.3.11. Gravity Sensors
- 26.3.12. Linear Acceleration Sensors
- 26.3.13. Rotation Vector Sensors
- 26.3.14. Near Field Communication Sensors
- 26.4. References
- 26.5. Summary
-
27. Exploring the Contacts API
- 27.1. Understanding Accounts
- 27.2. Understanding Contacts Application
- 27.3. Understanding Contacts
-
27.4. Working with the Contacts API
- 27.4.1. Exploring Accounts
- 27.4.2. Exploring Aggregated Contacts
- 27.4.3. Exploring Raw Contacts
- 27.4.4. Exploring Raw Contact Data
- 27.4.5. Adding a Contact and Its Details
- 27.5. Controlling Aggregation
- 27.6. Impacts of Syncing
- 27.7. References
- 27.8. Summary
-
28. Deploying Your Application: Android Market and Beyond
- 28.1. Becoming a Publisher
-
28.2. Preparing Your Application for Sale
- 28.2.1. Testing for Different Devices
- 28.2.2. Supporting Different Screen Sizes
- 28.2.3. Preparing AndroidManifest.xml for Uploading
- 28.2.4. Localizing Your Application
- 28.2.5. Preparing Your Application Icon
- 28.2.6. Considerations for Making Money From Apps
- 28.2.7. Directing Users Back to the Market
- 28.2.8. The Android Licensing Service
- 28.2.9. Preparing Your .apk File for Uploading
- 28.3. Uploading Your Application
- 28.4. User Experience on Android Market
- 28.5. Beyond Android Market
- 28.6. References
- 28.7. Summary
-
29. Fragments for Tablets and More
-
29.1. What is a Fragment?
- 29.1.1. When to Use Fragments
- 29.1.2. The Structure of a Fragment
-
29.1.3. A Fragment's Lifecycle
- 29.1.3.1. The onInflate() Callback
- 29.1.3.2. The onAttach() Callback
- 29.1.3.3. The onCreate() Callback
- 29.1.3.4. The onCreateView() Callback
- 29.1.3.5. The onActivityCreated() Callback
- 29.1.3.6. The onStart() Callback
- 29.1.3.7. The onResume() Callback
- 29.1.3.8. The onPause() Callback
- 29.1.3.9. The onStop() Callback
- 29.1.3.10. The onDestroyView() Callback
- 29.1.3.11. The onDestroy() Callback
- 29.1.3.12. The onDetach() Callback
- 29.1.3.13. Using setRetainInstance()
- 29.1.4. Sample Fragment App Showing the Lifecycle
- 29.2. FragmentTransactions and the Fragment Back Stack
- 29.3. The FragmentManager
- 29.4. Understanding Dialog Fragments
- 29.5. More Communications with Fragments
- 29.6. Custom Animations with ObjectAnimator
- 29.7. References
- 29.8. Summary
-
29.1. What is a Fragment?
-
30. Exploring ActionBar
- 30.1. Anatomy of an Action Bar
-
30.2. Tabbed Navigation Action Bar Activity
- 30.2.1. Implementing Base Activity Classes
- 30.2.2. Assigning Uniform Behavior for the ActionBar
- 30.2.3. Implementing the Tabbed Listener
- 30.2.4. Implementing the Tabbed Action Bar Activity
- 30.2.5. Scrollable Debug Text View Layout
- 30.2.6. Action Bar and Menu Interaction
- 30.2.7. Android Manifest File
- 30.2.8. Examining the Tabbed Action Bar Activity
- 30.3. List Navigation Action Bar Activity
- 30.4. Standard Navigation Action Bar Activity
- 30.5. References
- 30.6. Summary
-
31. Additional Topics in 3.0
-
31.1. List-Based Home Screen Widgets
- 31.1.1. New Remote Views in 3.0
-
31.1.2. Working with Lists in Remote Views
- 31.1.2.1. Preparing a Remote Layout
- 31.1.2.2. Loading a Remote Layout
- 31.1.2.3. Setting up RemoteViewsService
-
31.1.2.4. Setting up RemoteViewsFactory
- 31.1.2.4.1. RemoteViewsFactory Constructor
- 31.1.2.4.2. onCreate() Callback
- 31.1.2.4.3. onDestroy() Callback
- 31.1.2.4.4. getCount() Callback
- 31.1.2.4.5. getViewAt() Callback
- 31.1.2.4.6. getLoadingView() Callback
- 31.1.2.4.7. getViewTypeCount() Callback
- 31.1.2.4.8. getItemId() Callback
- 31.1.2.4.9. hasStableIds() Callback
- 31.1.2.4.10. onDataSetChanged() Callback
- 31.1.2.5. Setting up onClick Events
- 31.1.2.6. Responding to onClick Events
- 31.1.3. Working Sample: Test Home Screen List Widget
- 31.1.4. Testing the Test List Widget
- 31.2. Drag and Drop
- 31.3. References
- 31.4. Summary
-
31.1. List-Based Home Screen Widgets
Product information
- Title: Pro Android 3
- Author(s):
- Release date: April 2011
- Publisher(s): Apress
- ISBN: 9781430232223
You might also like
book
Pro Android 4
Pro Android 4shows you how to build real-world and fun mobile apps using the new Android …
book
Palm® Pre™ for Dummies®
Everything you need to know to make the most of Palm's newest smartphone Smartphones provide all …
book
Android Wireless Application Development
The start-to-finish guide to Android development–from concept to market! Android Wireless Application Development combines all the …
book
Palm webOS
A Note from the Author and from O'Reilly Media about what this bookdoes--and doesn't--do: Palm webOS …