The Android Developer's Cookbook: Building Applications with the Android SDK (2nd Edition) (Developer's Library)
Ronan Schwarz, James Steele, Nelson To
Language: English
Pages: 464
ISBN: 0321897536
Format: PDF / Kindle (mobi) / ePub
Do you want to get started building apps for Android, today’s number one mobile platform? Are you already building Android apps but want to get better at it? The Android ™ Developer’s Cookbook, Second Edition, brings together all the expert guidance and code you’ll need.
This edition has been extensively updated to reflect the other Android 4.2.2 releases. You’ll find all-new chapters on advanced threading and UI development, in-app billing, push messages, and native development, plus new techniques for everything from accessing NFC hardware to using Google Cloud Messaging.
Proven modular recipes take you from the basics all the way to advanced services, helping you to make the most of the newest Android APIs and tools. The authors’ fully updated code samples are designed to serve as templates for your own projects and components. You’ll learn best-practice techniques for efficiently solving common problems and for avoiding pitfalls throughout the entire development lifecycle. Coverage includes
- Organizing Android apps and integrating their activities
- Working efficiently with services, receivers, and alerts
- Managing threads, including advanced techniques using AsyncTasks and loaders
- Building robust, intuitive user interfaces
- Implementing advanced UI features, including Custom Views, animation, accessibility, and large screen support
- Capturing, playing, and manipulating media
- Interacting with SMS, websites, and social networks
- Storing data via SQLite and other methods
- Integrating in-app billing using Google Play services
- Managing push messaging with C2DM
- Leveraging new components and structures for native Android development
- Efficiently testing and debugging with Android’s latest tools and techniques, including LINT code analysis
The Android ™ Developer’s Cookbook, Second Edition, is all you need to jumpstart any Android project, and create high-value, feature-rich apps that sell.
Between Activities 46 3 Threads, Services, Receivers, and Alerts Threads 51 51 Recipe: Launching a Secondary Thread Recipe: Creating a Runnable Activity Recipe: Setting a Thread’s Priority Recipe: Canceling a Thread 51 55 57 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 Services 62 64 Recipe:
package names, whereas the Android package name must be unique across all applications installed on the Android device. For the OS to access them, each application must declare its available components in a single AndroidManifest XML file. In addition, this file contains the required permissions and behavior for the application to run. Listing 2.5 shows what it looks like for the “Creating a Project and an Activity” recipe. Listing 2.5 AndroidManifest.xml
of interest.The main technique introduced in each recipe is specified in the section heading. However, additional techniques are included in each recipe as needed to support the main recipe. After reading this book, a developer should Be able to write an Android Application from scratch. Be able to write code that works across multiple versions of Android. Be able to utilize the various Application Programming Interfaces (APIs) provided in Android. Have a large reference of code snippets to
android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class SimpleBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context rcvContext, Intent rcvIntent) { String action = rcvIntent.getAction(); if (action.equals(Intent.ACTION_CAMERA_BUTTON)) { rcvContext.startService(new Intent(rcvContext, SimpleService2.class)); } } } The service that is started in the SimpleBroadcastReceiver of Listing 3.15 is shown in Listing
195 9 Data Storage Methods 10 Location-Based Services 221 251 11 Advanced Android Development 12 Debugging Index 277 303 317 Download at www.wowebook.com Table of Contents 1 Overview of Android 1 The Evolution of Android 1 The Dichotomy of Android 2 Devices Running Android HTC Models Motorola Models 6 Samsung Models 6 Tablets 2 6 7 Other Devices 7 Hardware Differences on Android Devices Screens User Input Methods Sensors 8 8 9 9 Features of Android 10