Beginning Android, Fifth Edition

Book description

Get started in creating marketable apps for the burgeoning Android market. Begin your journey by learning the essentials of programming for phones and tables that are built around Google's wildly-successful Android platform. Beginning Android, Fifth Edition is fresh with details on the latest iteration of the Android 5 and earlier versions.

Google’s Android operating-system has taken the industry by storm, going from its humble beginnings as a smartphone operating system to its current status as a platform for apps that run across a gamut of devices from phones to tablets to netbooks to televisions, and the list is sure to grow. Smart developers are not sitting idly by in the stands, but are jumping into the game of creating innovative and salable applications for this fast-growing, mobile- and consumer-device platform. If you’re not in the game yet, now is your chance!

Begin at the beginning by installing the tools and compiling a skeleton app. Move through creating layouts, employing widgets, taking user input, and giving back results. Soon you’ll be creating innovative applications involving multi-touch, multi-tasking, and more! You’ll be drawing data live from the Internet using web services and delighting your customers with life-enhancing apps. Not since the PC era first began has there been this much opportunity for the common developer. What are you waiting for? Grab your copy of Beginning Android and get started!

Table of contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Author
  8. About the Technical Reviewer
  9. Acknowledgments
  10. Introduction
  11. Part I: Get Android and Get Coding!
    1. Chapter 1 : Welcome to Android
      1. The Fast Path to Learning Android Development
      2. Thinking in a Smartphone Mindset
        1. Computing on the Go!
        2. Size Matters
        3. The Interface Is More Than the Screen
        4. You Are Not Alone
      3. Translating Developer Dreams into Android Action
      4. A Look Inside Android
      5. A Look Inside This Book
    2. Chapter 2 : Ready, Set, Code!
      1. Getting the Prerequisites for Android
        1. Determining the Right Java for You
        2. Knowing (Enough) Java for Android
      2. Choosing a Development Environment
        1. Option 1: Choosing Android Studio
        2. Option 2: Choosing Eclipse the Quick Way
        3. Options 3: Choosing Eclipse the Do-It-Yourself Way
        4. Completing Your Development Environment Setup
      3. Creating Your First Android Virtual Device
      4. Creating Your First Android Application
      5. Writing Your First Android Code
    3. Chapter 3 : Inside Your First Android Project
      1. Looking at Android Project Structure
      2. Starting at the Source
      3. Benefitting from Generated Components
      4. Using Libraries and JARs
      5. Counting Your Assets
      6. Putting Things in the Bin
      7. Using Resources
        1. Picturing What Drawables Can Do For You
        2. User Interface Layouts
        3. What’s on the Menu?
        4. Valuable Values
      8. Working with Other Key Files in Your Project
        1. Controlling Applications with Android Manifests
        2. Permutating Projects with Properties
        3. “R” You Forgetting Something?
        4. Solving the Appcompat Mystery
    4. Chapter 4 : Changing and Enhancing Your Project
      1. Extending Your Application with the Android Manifest
        1. Editing the Android Manifest
        2. Specifying Target Screen Sizes
        3. Controlling Support for Different Android Versions
      2. Writing Actual Android Code
      3. Introducing the Activity
      4. Looking Inside Your First Activity
      5. Building and Running Your Enhanced Application
  12. Part II: Activities and the User Interface
    1. Chapter 5 : Working with Android Widgets
      1. Understanding Activity Fundamentals
      2. Naming with Labels
      3. Pressing Buttons (redux)
      4. Handling Images with ImageView and ImageButton
      5. Fielding Text with EditText
      6. CheckBox? Got It.
      7. Switching to the Switch
      8. Working with Radio Buttons
      9. Timing All Manner of Things with Clocks
      10. Easing Input with SeekBar
      11. Views: The Base of All UI Widgets
        1. Useful Common Inherited Properties
        2. Useful Common Inherited Methods
      12. Even More UI Widgets
    2. Chapter 6 : Layouts and UI Design
      1. Working with Relative Layouts
        1. Positioning Relative to the Activity Container
        2. Identifiying Properties for Relative Layout
        3. Relative Positioning Properties
        4. Determining the Order of Layout Relationships
        5. A RelativeLayout Example
        6. Overlapping Widgets in Relative Layouts
      2. Working with Linear Layouts
        1. Controlling the Five Key Qualifiers for LinearLayout
        2. An Example LinearLayout
      3. Working with Table Layouts
        1. Understanding Widget Behavior within TableLayout
        2. An Example TableLayout
      4. Working with Grid Layouts
      5. Layout Manipulation with the Layout Editor
        1. Recap of the Layout Editor UI
        2. Even More Reasons for XML Layouts
        3. Converting to XML-based Layouts with Java Logic
        4. Attaching Layout Definitions to Java
      6. Completing Your Revised App
    3. Chapter 7 : Building Layouts with Lists and Adapters
      1. Using Adapters to Populate Options
        1. Why Adapters?
        2. Starting with ArrayAdapter
      2. Making Lists
      3. Making More Sophisticated Lists
      4. Adapting to the GridView
      5. Taking Options for a Spin
      6. Automatic Field Population
      7. Summary
    4. Chapter 8 : Working with Input Methods, Menus and Dialogs
      1. Using The Input Method Framework
        1. Real and Virtual Keyboards
        2. Customizing IMEs
        3. Accessorizing with Soft Keyboards
        4. Scrolling in to View
        5. Forcing the IME out of Existence
      2. Working with Menus
        1. Creating Menus for your Application
        2. Working With Context Menus
        3. Menus In Action
        4. Inflating Menus from XML
      3. Interacting with Dialogs
        1. Creating Toast Notifications
        2. Generating Traditional Dialog Alerts
        3. Pardon The Interruption
      4. Summary
    5. Chapter 9 : Adopting the Action Bar
      1. Recognizing the Action Bar
        1. Managing Android Versions for Action Bar
      2. Creating Action Bar Applications
        1. Enabling the Action Bar for your Application
        2. Moving Menu Functionality to the Action Bar
      3. Using Java to Manage Action Bars
        1. Working with a Standard Action Bar in Java
        2. Choosing a Tab Layout for the Action Bar
        3. Using Other Layouts for the Action Bar
      4. Summary
    6. Chapter 10 : The Life of an Activity
      1. Understanding the Activity Lifecycle
        1. Working with Activity Callback Methods
      2. Understanding the Goals of Android Activity Behavior
      3. Working with Activity Configuration Changes
        1. Understanding the Default Configuration Change Approach
        2. Saving Custom State
  13. Part III: A World of Wonderful Devices and Screens
    1. Chapter 11 : Android Fragments
      1. Introducing the Fragment Class
        1. Backwards Compatibility with Fragments
        2. Designing with Fragments in Mind
      2. Introducing the Fragment Lifecycle
        1. Understanding Fragment Lifecycle Callback Methods
        2. Keeping Sane with Fragment Lifecycles
      3. Implementing Your Own Fragment-Based Application
        1. Creating Layouts for the Fragments Examples
        2. Controlling Which Layout Is Chosen
        3. Coding Differences for Fragments
        4. Seeing Differing Fragment Behavior in Action
      4. Summary
    2. Chapter 12 : Intents and Receivers
      1. Introducing Intents
        1. The Anatomy of an Intent
        2. Intent Actions for all Kinds of Purposes
        3. Understanding Intent Routing
        4. Adding Intents to Your Manifest
      2. Seeing Intent-launched Activities in Action
        1. Deciding on Activity Dependency.
        2. Creating an Intent
        3. Starting the Intent-Invoked Activity
      3. Introducing Receivers
        1. Using Receivers When No UI is Needed
        2. Navigating Receiver Limitations
    3. Chapter 13 : Making Phone Calls
      1. Checking for Phones and “Phonies”
        1. Mandating Telephony Support
        2. Optional Telephony Support
      2. Making Outbound Calls
        1. Using ACTION_DIAL
        2. Using ACTION_CALL
      3. Working with Incoming Calls
    4. Chapter 14 : Making Noise with Audio for Android
      1. Introducing the Media package
      2. Building Your First Audio Application
    5. Chapter 15 : Locations and Mapping with Android
      1. Choosing Map Providers for Your Application
        1. Google Maps
        2. The OpenStreetMap Project
        3. HERE/Ovi Maps
        4. Which Technology to Choose?
      2. Preparing for Google Maps Development
        1. Creating Your API Project
        2. Enabling a Maps API on Your Google API Project
        3. Getting the API Key
        4. Retrieving Your API Key
      3. Building Your First Maps Application
        1. Using MapActivity or FragmentActivity with MapView
        2. Permissions and Manifest Settings for Maps
        3. Building the Layout for Your Map Application
        4. Adding Code for a Basic Map
      4. Adding Flair and Features to Your Maps
        1. Zoomin’
        2. True North
        3. Toolbars and theMy Location Button
        4. Shakin’ It!
        5. Changing Map Type
        6. Listeners for Every Conceivable Type of Map Interaction
        7. Even More Map Options
      5. Summary
  14. Part IV: Working with Resources and Services
    1. Chapter 16 : Weaving the Web with Android
      1. Working with the WebView Widget
        1. Creating a Simple Application with a WebView
        2. Simple and Not-So-Simple WebView Security
      2. Building HTML Layouts with WebView
      3. UI-less Internet Interaction with Android
        1. Why Multiple Approaches to Web Interaction?
        2. Building a JSON-based Application with HttpURLConnection
        3. Troubleshooting Issues with Internet Connections
      4. Mastering Downloads with DownloadManager
        1. Introducing the DownloadManager System Service
        2. Selecting Permissions for DownloadManager Use
        3. A Simple Downloader Example
        4. Coding DownloadManager Behavior
        5. Dealing with Download Problems
    2. Chapter 17 : Working with Files
      1. Using Raw and Asset-based Files
        1. Populating Lists from Resource Files
      2. Working with Files from the File System
        1. Android’s File System Model
        2. Permissions for Reading and Writing Files
        3. Examining External Files in Action
        4. Seeing File Save and Read Behavior in Action
        5. Ensuring External Storage Is Available When Needed
      3. Other Considerations with Android File Systems
        1. Android Filesystems Throughout History
        2. Controlling UI Delays with File I/O
    3. Chapter 18 : Managing Databases with Android
      1. SQLite: A Seriously Popular Database
      2. A Crash Course in SQLite
        1. Creating SQLite Databases for Your Application
        2. Introducing the SQLiteExample Application
      3. Building a Database-Driven Activity
        1. Choosing Query Approaches for SQLite and Android
        2. Managing Data Results with Cursors
      4. Modifying Data with Your Android Application
        1. Inserting Data
        2. Updating Data
        3. Deleting Data
      5. Tracking SQLite Versions and Android Versions
      6. Packaging and Managing SQLite Databases for Android
        1. Managing Performance and Android Storage
        2. Packaging Your Own SQLite Database with Your Application
        3. Preparing SQLite Databases for Packaging
    4. Chapter 19 : Using Preferences
      1. Everything Old Is New Again
      2. Starting with Preferences
        1. Recording Preferences
        2. Working with Preference-Specific Activities and Fragments
        3. Seeing the Big Picture with Preferences
        4. Using Preference and Preference Header Resources
        5. Filling in the Blanks with PreferenceFragment
      3. Bringing the Preference Puzzle Pieces Together
      4. Other Preference Considerations
        1. Customizing Preferences
        2. Nesting Preferences and Display Quirks
      5. Using the Old-School Approach to Preferences
        1. Losing Headers and Fragments
        2. Adapting PreferenceActivty for Older Behavior
    5. Chapter 20 : Android Security and Permissions
      1. Requesting Permissions for Your Application
        1. Dealing with Debugging Permissions
      2. Installing Applications and Accepting Permissions
        1. Pre-Marshmallow Behavior
        2. Marshmallow and Beyond
        3. Trading In Permissions
      3. Creating Custom Permissions
        1. Declaring Custom Permissions
        2. Enforcing Custom Permissions
      4. Securing Applications for Publication and Execution
        1. Securing Your Application with Certificate Signing
        2. Signing Is (Almost) Forever, So Take Care
        3. Protecting Android and Applications at Runtime
    6. Chapter 21 : Incorporating External Libraries with Android
      1. The ART of Android
      2. Choosing Library Sources or JARs
        1. Direct Source Inclusion
        2. Incorporating JARs
      3. When Is Java not Java?
        1. Absent JVM Features
        2. Considering Java Performance for Android
      4. Adapting an Application to Use an External Library
        1. Sourcing Apache Commons IOUtils
        2. Adding the JAR to Your Project’s Libraries
        3. Referencing (or Refactoring for) Your External Libraries
      5. Using Languages Beyond Java
        1. Scripting Layer for Android Overview
        2. Choosing Your Approach to SL4A
        3. Testing SL4A on Your Emulator
    7. Chapter 22 : Leveraging Android Services
      1. Services Background
      2. Defining Your Own Service
        1. Implementing Your Own Service Class
        2. Controlling Service Lifecycle via Callbacks
        3. Adding Manifest Entries for Your Service
      3. Service Communication
        1. Client-to-Service Communication
        2. Service-to-Client Communication
      4. Services in Action
        1. Choosing the Service Design
        2. Implementing the Java Logic for Our Service
        3. Creating an Example Client for the Service
        4. Testing the Service in Action
    8. Chapter 23 : Communicating with Notifications
      1. Configuring Notifications
        1. Customizing the Notification Object
        2. Adding Icons for Notifications
      2. Notifications in Action
        1. Coding Notification Behavior
        2. Notifications as the User Experiences Them
      3. Using the Builder Approach to Notifications
        1. Other Uses and Extensions to Notifications
        2. Notifications and Services
      4. More Advanced Notification Features
        1. Timeline Notifications
        2. Bundled Notifications
        3. Expanding Notifications
        4. More Embedded Actions in Notifications
        5. Notifications Tailored for Wear
  15. Index

Product information

  • Title: Beginning Android, Fifth Edition
  • Author(s):
  • Release date: April 2015
  • Publisher(s): Apress
  • ISBN: 9781430246879