Android 4.4 App Development Essentials
Android 4.4 App Development Essentials
About the Book
The goal of this book is to teach the skills necessary to develop Android based applications using the Eclipse Integrated Development Environment (IDE) and the Android 4.4 Software Development Kit (SDK).
Beginning with the basics, this book provides an outline of the steps necessary to set up an Android development and testing environment. An introduction to the architecture of Android is followed by an in-depth look at the design of Android applications and user interfaces. More advanced topics such as database management, content providers and intents are also covered, as are touch screen handling, gesture recognition, camera access and the playback and recording of both video and audio. This edition of the book also covers features introduced with Android 4.4 including printing, transitions and cloud-based file storage.
In addition to covering general Android development techniques, the book also includes Google Play specific topics such as implementing maps using the Google Maps Android API and submitting apps to the Google Play Developer Console.
Assuming you already have some Java programming experience, are ready to download Eclipse and the Android SDK, have access to a Windows, Mac or Linux system and ideas for some apps to develop, you are ready to get started.
Table of Contents
-
1. Introduction
- 1.1 Downloading the Code Samples
- 1.2 Feedback
- 1.3 Errata
-
2. Setting up an Android Development Environment
- 2.1 System Requirements
- 2.2 Installing the Java Development Kit (JDK)
- 2.3 Linux JDK Installation
- 2.4 Downloading the Android Developer Tools (ADT) Bundle
- 2.5 Installing the ADT Bundle
- 2.6 Installing the Latest Android SDK Packages
- 2.7 Making the Android SDK Tools Command-line Accessible
- 2.8 Updating the ADT
- 2.9 Adding the ADT Plugin to an Existing Eclipse Integration
- 2.10 Summary
-
3. Creating an Android Virtual Device (AVD)
- 3.1 About Android Virtual Devices
- 3.2 Creating a New AVD
- 3.3 Starting the Emulator
- 3.4 AVD Command-line Creation
- 3.5 Android Virtual Device Configuration Files
- 3.6 Moving and Renaming an Android Virtual Device
- 3.7 Summary
-
4. Creating an Example Android Application
- 4.1 Creating a New Android Project
- 4.2 Defining the Project Name and SDK Settings
- 4.3 Project Configuration Settings
- 4.4 Configuring the Launcher Icon
- 4.5 Creating an Activity
- 4.6 Running the Application in the AVD
- 4.7 Stopping a Running Application
- 4.8 Modifying the Example Application
- 4.9 Reviewing the Layout and Resource Files
- 4.10 Summary
-
5. Testing Android Applications on a Physical Android Device with ADB
- 5.1 An Overview of the Android Debug Bridge (ADB)
- 5.2 Enabling ADB on Android 4.4 based Devices
- 5.3 Testing the adb Connection
- 5.4 Manual Selection of the Application Run Target
- 5.5 Summary
-
6. An Overview of the Android Architecture
- 6.1 The Android Software Stack
- 6.2 The Linux Kernel
- 6.3 Android Runtime - Dalvik Virtual Machine
- 6.4 Android Runtime – Core Libraries
- 6.5 Application Framework
- 6.6 Applications
- 6.7 Summary
-
7. The Anatomy of an Android Application
- 7.1 Android Activities
- 7.2 Android Intents
- 7.3 Broadcast Intents
- 7.4 Broadcast Receivers
- 7.5 Android Services
- 7.6 Content Providers
- 7.7 The Application Manifest
- 7.8 Application Resources
- 7.9 Application Context
- 7.10 Summary
-
8. Understanding Android Application and Activity Lifecycles
- 8.1 Android Applications and Resource Management
- 8.2 Android Process States
- 8.3 Inter-Process Dependencies
- 8.4 The Activity Lifecycle
- 8.5 The Activity Stack
- 8.6 Activity States
- 8.7 Configuration Changes
- 8.8 Handling State Change
- 8.9 Summary
-
9. Handling Android Activity State Changes
- 9.1 The Activity Class
- 9.2 Dynamic State vs. Persistent State
- 9.3 The Android Activity Lifecycle Methods
- 9.4 Activity Lifetimes
- 9.5 Summary
-
10. Android Activity State Changes by Example
- 10.1 Creating the State Change Example Project
- 10.2 Designing the User Interface
- 10.3 Overriding the Activity Lifecycle Methods
- 10.4 Enabling and Filtering the LogCat Panel
- 10.5 Running the Application
- 10.6 Experimenting with the Activity
- 10.7 Saving Dynamic State
- 10.8 Summary
-
11. Saving and Restoring the User Interface State of an Android Activity
- 11.1 Saving Dynamic State
- 11.2 The Bundle Class
- 11.3 Saving the State
- 11.4 Restoring the State
- 11.5 Testing the Application
- 11.6 Summary
-
12. Understanding Android Views, View Groups and Layouts
- 12.1 Designing for Different Android Devices
- 12.2 Views and View Groups
- 12.3 Android Layout Managers
- 12.4 The View Hierarchy
- 12.5 Creating User Interfaces
- 12.6 Summary
-
13. Designing an Android User Interface using the Graphical Layout Tool
- 13.1 The Android Graphical Layout Tool
- 13.2 A Graphical Layout Tool Example
- 13.3 Adding an XML Resource File to the Project
- 13.4 Editing View Properties
- 13.5 Using the View Properties Sheet
- 13.6 Creating a New Activity
- 13.7 Adding the New Activity to the Manifest File
- 13.8 Running the Application
- 13.9 Manually Creating an XML Layout
- 13.10 Using the Hierarchy Viewer
- 13.11 Summary
-
14. Creating an Android User Interface in Java Code
- 14.1 Java Code vs. XML Layout Files
- 14.2 Creating Views
- 14.3 Properties and Layout Parameters
- 14.4 Creating the Example Project
- 14.5 Adding Views to an Activity
- 14.6 Setting View Properties
- 14.7 Adding Layout Parameters and Rules
- 14.8 Using View IDs
- 14.9 Converting Density Independent Pixels (dp) to Pixels (px)
- 14.10 Summary
-
15. Using the Android GridLayout Manager in the Graphical Layout Tool
- 15.1 Introducing the Android GridLayout and Space Classes
- 15.2 The GridLayout Example
- 15.3 Creating the GridLayout Project
- 15.4 Creating the GridLayout Instance
- 15.5 An Overview of the GridLayout in the Graphical Layout Tool
- 15.6 Adding Views to GridLayout Cells
- 15.7 Implementing Cell Row and Column Spanning
- 15.8 Changing the Gravity of a GridLayout Child
- 15.9 Summary
-
16. Working with the Android GridLayout in XML Layout Resources
- 16.1 GridLayouts in XML Resource Files
- 16.2 Adding Child Views to the GridLayout
- 16.3 Declaring Cell Spanning, Gravity and Margins
- 16.4 Summary
-
17. An Overview and Example of Android Event Handling
- 17.1 Understanding Android Events
- 17.2 Using the android:onClick Resource
- 17.3 Event Listeners and Callback Methods
- 17.4 An Event Handling Example
- 17.5 Designing the User Interface
- 17.6 The Event Listener and Callback Method
- 17.7 Consuming Events
- 17.8 Summary
-
18. Android Touch and Multi-touch Event Handling
- 18.1 Intercepting Touch Events
- 18.2 The MotionEvent Object
- 18.3 Understanding Touch Actions
- 18.4 Handling Multiple Touches
- 18.5 An Example Multi-Touch Application
- 18.6 Designing the Activity User Interface
- 18.7 Implementing the Touch Event Listener
- 18.8 Running the Example Application
- 18.9 Summary
-
19. Detecting Common Gestures using the Android Gesture Detector Class
- 19.1 Implementing Common Gesture Detection
- 19.2 Creating an Example Gesture Detection Project
- 19.3 Implementing the Listener Class
- 19.4 Creating the GestureDetectorCompat Instance
- 19.5 Implementing the onTouchEvent() Method
- 19.6 Testing the Application
- 19.7 Summary
-
20. Implementing Custom Gesture and Pinch Recognition on Android
- 20.1 The Android Gesture Builder Application
- 20.2 The GestureOverlayView Class
- 20.3 Detecting Gestures
- 20.4 Identifying Specific Gestures
- 20.5 Adding SD Card Support to an AVD
- 20.6 Building and Running the Gesture Builder Application
- 20.7 Creating a Gestures File
- 20.8 Extracting the Gestures File from the SD Card
- 20.9 Creating the Example Project
- 20.10 Designing the User Interface
- 20.11 Loading the Gestures File
- 20.12 Registering the Event Listener
- 20.13 Implementing the onGesturePerformed Method
- 20.14 Testing the Application
- 20.15 Configuring the GestureOverlayView
- 20.16 Intercepting Gestures
- 20.17 Detecting Pinch Gestures
- 20.18 A Pinch Gesture Example Project
- 20.19 Summary
-
21. An Introduction to Android Fragments
- 21.1 What is a Fragment?
- 21.2 Creating a Fragment
- 21.3 Adding a Fragment to an Activity using the Layout XML File
- 21.4 Adding and Managing Fragments in Code
- 21.5 Handling Fragment Events
- 21.6 Implementing Fragment Communication
- 21.7 Summary
-
22. Using Fragments in Android - A Worked Example
- 22.1 About the Example Fragment Application
- 22.2 Creating the Example Project
- 22.3 Adding the Android Support Library
- 22.4 Creating the First Fragment Layout
- 22.5 Creating the First Fragment Class
- 22.6 Creating the Second Fragment Layout
- 22.7 Adding the Fragments to the Activity
- 22.8 Making the Toolbar Fragment Talk to the Activity
- 22.9 Making the Activity Talk to the Text Fragment
- 22.10 Testing the Application
- 22.11 Summary
-
23. An Android Master/Detail Flow Tutorial
- 23.1 The Master/Detail Flow
- 23.2 Creating a Master/Detail Flow Activity
- 23.3 The Anatomy of the Master/Detail Flow Template
- 23.4 Modifying the Master/Detail Flow Template
- 23.5 Changing the Content Model
- 23.6 Changing the Detail Pane
- 23.7 Modifying the WebsiteDetailFragment Class
- 23.8 Adding Manifest Permissions
- 23.9 Running the Application
- 23.10 Summary
-
24. Creating and Managing Overflow Menus on Android
- 24.1 The Overflow Menu
- 24.2 Creating an Overflow Menu
- 24.3 Displaying an Overflow Menu
- 24.4 Responding to Menu Item Selections
- 24.5 Creating Checkable Item Groups
- 24.6 Creating the Example Project
- 24.7 Modifying the Menu Description
- 24.8 Implementing the onOptionsItemSelected() Method
- 24.9 Testing the Application
- 24.10 Summary
-
25. Animating User Interfaces with the Android Transitions Framework
- 25.1 Introducing Android Transitions and Scenes
- 25.2 Using Interpolators with Transitions
- 25.3 Working with Scene Transitions
- 25.4 Custom Transitions and TransitionSets in Code
- 25.5 Custom Transitions and TransitionSets in XML
- 25.6 Working with Interpolators
- 25.7 Creating a Custom Interpolator
- 25.8 Using the beginDelayedTransition Method
- 25.9 Summary
-
26. An Android Transition Tutorial using beginDelayedTransition
- 26.1 Creating the TransitionDemo Project
- 26.2 Preparing the Project Files
- 26.3 Implementing beginDelayedTransition Animation
- 26.4 Customizing the Transition
- 26.5 Summary
-
27. Implementing Android Scene Transitions – A Tutorial
- 27.1 An Overview of the Scene Transition Project
- 27.2 Creating the SceneTransitions Project
- 27.3 Identifying and Preparing the Root Container
- 27.4 Designing the First Scene
- 27.5 Designing the Second Scene
- 27.6 Entering the First Scene
- 27.7 Loading Scene 2
- 27.8 Implementing the Transitions
- 27.9 Adding the Transition File
- 27.10 Loading and Using the Transition Set
- 27.11 Configuring Additional Transitions
- 27.12 Summary
-
28. An Overview of Android Intents
- 28.1 An Overview of Intents
- 28.2 Explicit Intents
- 28.3 Returning Data from an Activity
- 28.4 Implicit Intents
- 28.5 Using Intent Filters
- 28.6 Checking Intent Availability
- 28.7 Summary
-
29. Android Explicit Intents – A Worked Example
- 29.1 Creating the Explicit Intent Example Application
- 29.2 Designing the User Interface Layout for ActivityA
- 29.3 Creating the Second Activity Class
- 29.4 Creating the User Interface for ActivityB
- 29.5 Adding ActivityB to the Application Manifest File
- 29.6 Creating the Intent
- 29.7 Extracting Intent Data
- 29.8 Launching ActivityB as a Sub-Activity
- 29.9 Returning Data from a Sub-Activity
- 29.10 Testing the Application
- 29.11 Summary
-
30. Android Implicit Intents – A Worked Example
- 30.1 Creating the Implicit Intent Example Project
- 30.2 Designing the User Interface
- 30.3 Creating the Implicit Intent
- 30.4 Adding a Second Matching Activity
- 30.5 Adding the Web View to the UI
- 30.6 Obtaining the Intent URL
- 30.7 Modifying the MyWebView Project Manifest File
- 30.8 Installing the MyWebView Package on a Device
- 30.9 Testing the Application
- 30.10 Summary
-
31. Android Broadcast Intents and Broadcast Receivers
- 31.1 An Overview of Broadcast Intents
- 31.2 An Overview of Broadcast Receivers
- 31.3 Obtaining Results from a Broadcast
- 31.4 Sticky Broadcast Intents
- 31.5 The Broadcast Intent Example
- 31.6 Creating the Example Application
- 31.7 Creating and Sending the Broadcast Intent
- 31.8 Creating the Broadcast Receiver
- 31.9 Configuring a Broadcast Receiver in the Manifest File
- 31.10 Testing the Broadcast Example
- 31.11 Listening for System Broadcasts
- 31.12 Summary
-
32. A Basic Overview of Android Threads and Thread Handlers
- 32.1 An Overview of Threads
- 32.2 The Application Main Thread
- 32.3 Thread Handlers
- 32.4 A Basic Threading Example
- 32.5 Creating a New Thread
- 32.6 Implementing a Thread Handler
- 32.7 Passing a Message to the Handler
- 32.8 Summary
-
33. An Overview of Android Started and Bound Services
- 33.1 Started Services
- 33.2 Intent Service
- 33.3 Bound Service
- 33.4 The Anatomy of a Service
- 33.5 Controlling Destroyed Service Restart Options
- 33.6 Declaring a Service in the Manifest File
- 33.7 Starting a Service Running on System Startup
- 33.8 Summary
-
34. Implementing an Android Started Service – A Worked Example
- 34.1 Creating the Example Project
- 34.2 Creating the Service Class
- 34.3 Adding the Service to the Manifest File
- 34.4 Starting the Service
- 34.5 Testing the IntentService Example
- 34.6 Using the Service Class
- 34.7 Creating the New Service
- 34.8 Modifying the User Interface
- 34.9 Running the Application
- 34.10 Creating a New Thread for Service Tasks
- 34.11 Summary
-
35. Android Local Bound Services – A Worked Example
- 35.1 Understanding Bound Services
- 35.2 Bound Service Interaction Options
- 35.3 A Local Bound Service Example
- 35.4 Adding a Bound Service to the Project
- 35.5 Implementing the Binder
- 35.6 Binding the Client to the Service
- 35.7 Completing the Example
- 35.8 Testing the Application
- 35.9 Summary
-
36. Android Remote Bound Services – A Worked Example
- 36.1 Client to Remote Service Communication
- 36.2 Creating the Example Application
- 36.3 Designing the User Interface
- 36.4 Implementing the Remote Bound Service
- 36.5 Configuring a Remote Service in the Manifest File
- 36.6 Launching and Binding to the Remote Service
- 36.7 Sending a Message to the Remote Service
- 36.8 Summary
-
37. An Overview of Android SQLite Databases
- 37.1 Understanding Database Tables
- 37.2 Introducing Database Schema
- 37.3 Columns and Data Types
- 37.4 Database Rows
- 37.5 Introducing Primary Keys
- 37.6 What is SQLite?
- 37.7 Structured Query Language (SQL)
- 37.8 Trying SQLite on an Android Virtual Device (AVD)
- 37.9 Android SQLite Java Classes
- 37.10 Summary
-
38. An Android TableLayout and TableRow Tutorial
- 38.1 The TableLayout and TableRow Layout Views
- 38.2 Creating the Database Project
- 38.3 Designing the User Interface Layout
- 38.4 Summary
-
39. An Android SQLite Database Tutorial
- 39.1 About the Database Example
- 39.2 Creating the Data Model
- 39.3 Implementing the Data Handler
- 39.4 Implementing the Activity Event Methods
- 39.5 Testing the Application
- 39.6 Summary
-
40. Understanding Android Content Providers
- 40.1 What is a Content Provider?
- 40.2 The Content Provider
- 40.3 The Content URI
- 40.4 The Content Resolver
- 40.5 The <provider> Manifest Element</provider>
- 40.6 Summary
-
41. Implementing an Android Content Provider
- 41.1 Copying the Database Project
- 41.2 Adding the Content Provider Package
- 41.3 Creating the Content Provider Class
- 41.4 Constructing the Authority and Content URI
- 41.5 Implementing URI Matching in the Content Provider
- 41.6 Implementing the Content Provider onCreate() Method
- 41.7 Implementing the Content Provider insert() Method
- 41.8 Implementing the Content Provider query() Method
- 41.9 Implementing the Content Provider update() Method
- 41.10 Implementing the Content Provider delete() Method
- 41.11 Declaring the Content Provider in the Manifest File
- 41.12 Modifying the Database Handler
- 41.13 Summary
-
42. Accessing Cloud Storage using the Android Storage Access Framework
- 42.1 The Storage Access Framework
- 42.2 Working with the Storage Access Framework
- 42.3 Filtering Picker File Listings
- 42.4 Handling Intent Results
- 42.5 Reading the Content of a File
- 42.6 Writing Content to a File
- 42.7 Deleting a File
- 42.8 Gaining Persistent Access to a File
- 42.9 Summary
-
43. An Android Storage Access Framework Example
- 43.1 About the Storage Access Framework Example
- 43.2 Creating the Storage Access Framework Example
- 43.3 Designing the User Interface
- 43.4 Declaring Request Codes
- 43.5 Creating a New Storage File
- 43.6 The onActivityResult() Method
- 43.7 Saving to a Storage File
- 43.8 Opening and Reading a Storage File
- 43.9 Testing the Storage Access Application
- 43.10 Summary
-
44. Implementing Video Playback on Android using the VideoView and MediaController Classes
- 44.1 Introducing the Android VideoView Class
- 44.2 Introducing the Android MediaController Class
- 44.3 Testing Video Playback
- 44.4 Creating the Video Playback Example
- 44.5 Designing the VideoPlayer Layout
- 44.6 Configuring the VideoView
- 44.7 Adding Internet Permission
- 44.8 Adding the MediaController to the Video View
- 44.9 Setting up the onPreparedListener
- 44.10 Summary
-
45. Video Recording and Image Capture on Android using Camera Intents
- 45.1 Checking for Camera Support
- 45.2 Calling the Video Capture Intent
- 45.3 Calling the Image Capture Intent
- 45.4 Creating an Example Video Recording Project
- 45.5 Designing the User Interface Layout
- 45.6 Checking for the Camera
- 45.7 Launching the Video Capture Intent
- 45.8 Handling the Intent Return
- 45.9 Testing the Application
- 45.10 Summary
-
46. Android Audio Recording and Playback using MediaPlayer and MediaRecorder
- 46.1 Playing Audio
- 46.2 Recording Audio and Video using the MediaRecorder Class
- 46.3 About the Example Project
- 46.4 Creating the AudioApp Project
- 46.5 Designing the User Interface
- 46.6 Checking for Microphone Availability
- 46.7 Performing the Activity Initialization
- 46.8 Implementing the recordAudio() Method
- 46.9 Implementing the stopClicked() Method
- 46.10 Implementing the playAudio() method
- 46.11 Configuring Permissions in the Manifest File
- 46.12 Testing the Application
- 46.13 Summary
-
47. Working with the Google Maps Android API
- 47.1 The Elements of the Google Maps Android API
- 47.2 Getting Ready to use the Google Maps Android API
- 47.3 Adding Map Support to the AndroidManifest.xml File
- 47.4 Checking for Google Play Services Support
- 47.5 Understanding Geocoding and Reverse Geocoding
- 47.6 Adding a Map to an Application
- 47.7 Displaying the User’s Current Location
- 47.8 Changing the Map Type
- 47.9 Displaying Map Controls to the User
- 47.10 Handling Map Gesture Interaction
- 47.11 Creating Map Markers
- 47.12 Controlling the Map Camera
- 47.13 Summary
-
48. Printing with the Android Printing Framework
- 48.1 The Android Printing Architecture
- 48.2 The HP Print Services Plugin
- 48.3 Google Cloud Print
- 48.4 Printing to Google Drive
- 48.5 Save as PDF
- 48.6 Printing from Android Devices
- 48.7 Options for Building Print Support into Android Apps
- 48.8 Summary
-
49. An Android HTML and Web Content Printing Example
- 49.1 Creating the HTML Printing Example Application
- 49.2 Printing Dynamic HTML Content
- 49.3 Creating the Web Page Printing Example
- 49.4 Designing the User Interface Layout
- 49.5 Loading the Web Page into the WebView
- 49.6 Adding the Print Menu Option
- 49.7 Summary
-
50. A Guide to Android Custom Document Printing
- 50.1 An Overview of Android Custom Document Printing
- 50.2 Preparing the Custom Document Printing Project
- 50.3 Creating the Custom Print Adapter
- 50.4 Implementing the onLayout() Callback Method
- 50.5 Implementing the onWrite() Callback Method
- 50.6 Checking a Page is in Range
- 50.7 Drawing the Content on the Page Canvas
- 50.8 Starting the Print Job
- 50.9 Testing the Application
- 50.10 Summary
-
51. Handling Different Android Devices and Displays
- 51.1 Handling Different Device Displays
- 51.2 Creating a Layout for each Display Size
- 51.3 Providing Different Images
- 51.4 Checking for Hardware Support
- 51.5 Providing Device Specific Application Binaries
- 51.6 Summary
-
52. Signing and Preparing an Android Application for Release
- 52.1 The Release Preparation Process
- 52.2 Accessing the Export Wizard
- 52.3 Creating a Keystore File
- 52.4 Generating a Private Key
- 52.5 Creating the Application APK File
- 52.6 Register for a Google Play Developer Console Account
- 52.7 Summary
The Leanpub 60 Day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.
You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!
So, there's no reason not to click the Add to Cart button, is there?
See full terms...
Earn $8 on a $10 Purchase, and $16 on a $20 Purchase
We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $14 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them