Contents

About the Author

About the Technical Reviewer

Acknowledgments

Introduction

image Part I: Get Android and Get Coding!

image Chapter 1: Welcome to Android

The Fast Path to Learning Android Development

Thinking in a Smartphone Mindset

Computing on the Go!

Size Matters

The Interface Is More Than the Screen

You Are Not Alone

Translating Developer Dreams into Android Action

A Look Inside Android

A Look Inside This Book

image Chapter 2: Ready, Set, Code!

Getting the Prerequisites for Android

Determining the Right Java for You

Knowing (Enough) Java for Android

Choosing a Development Environment

Option 1: Choosing Android Studio

Option 2: Choosing Eclipse the Quick Way

Options 3: Choosing Eclipse the Do-It-Yourself Way

Completing Your Development Environment Setup

Creating Your First Android Virtual Device

Creating Your First Android Application

Writing Your First Android Code

image Chapter 3: Inside Your First Android Project

Looking at Android Project Structure

Starting at the Source

Benefitting from Generated Components

Using Libraries and JARs

Counting Your Assets

Putting Things in the Bin

Using Resources

Picturing What Drawables Can Do For You

User Interface Layouts

What’s on the Menu?

Valuable Values

Working with Other Key Files in Your Project

Controlling Applications with Android Manifests

Permutating Projects with Properties

“R” You Forgetting Something?

Solving the Appcompat Mystery

image Chapter 4: Changing and Enhancing Your Project

Extending Your Application with the Android Manifest

Editing the Android Manifest

Specifying Target Screen Sizes

Controlling Support for Different Android Versions

Writing Actual Android Code

Introducing the Activity

Looking Inside Your First Activity

Building and Running Your Enhanced Application

image Part II: Activities and the User Interface

image Chapter 5: Working with Android Widgets

Understanding Activity Fundamentals

Naming with Labels

Pressing Buttons (redux)

Handling Images with ImageView and ImageButton

Fielding Text with EditText

CheckBox? Got It

Switching to the Switch

Working with Radio Buttons

Timing All Manner of Things with Clocks

Easing Input with SeekBar

Views: The Base of All UI Widgets

Useful Common Inherited Properties

Useful Common Inherited Methods

Even More UI Widgets

image Chapter 6: Layouts and UI Design

Working with Relative Layouts

Positioning Relative to the Activity Container

Identifiying Properties for Relative Layout

Relative Positioning Properties

Determining the Order of Layout Relationships

A RelativeLayout Example

Overlapping Widgets in Relative Layouts

Working with Linear Layouts

Controlling the Five Key Qualifiers for LinearLayout

An Example LinearLayout

Working with Table Layouts

Understanding Widget Behavior within TableLayout

An Example TableLayout

Working with Grid Layouts

Layout Manipulation with the Layout Editor

Recap of the Layout Editor UI

Even More Reasons for XML Layouts

Converting to XML-based Layouts with Java Logic

Attaching Layout Definitions to Java

Completing Your Revised App

image Chapter 7: Building Layouts with Lists and Adapters

Using Adapters to Populate Options

Why Adapters?

Starting with ArrayAdapter

Making Lists

Making More Sophisticated Lists

Adapting to the GridView

Taking Options for a Spin

Automatic Field Population

Summary

image Chapter 8: Working with Input Methods, Menus and Dialogs

Using The Input Method Framework

Real and Virtual Keyboards

Customizing IMEs

Accessorizing with Soft Keyboards

Scrolling in to View

Forcing the IME out of Existence

Working with Menus

Creating Menus for your Application

Working With Context Menus

Menus In Action

Inflating Menus from XML

Interacting with Dialogs

Creating Toast Notifications

Generating Traditional Dialog Alerts

Pardon The Interruption

Summary

image Chapter 9: Adopting the Action Bar

Recognizing the Action Bar

Managing Android Versions for Action Bar

Creating Action Bar Applications

Enabling the Action Bar for your Application

Moving Menu Functionality to the Action Bar

Using Java to Manage Action Bars

Working with a Standard Action Bar in Java

Choosing a Tab Layout for the Action Bar

Using Other Layouts for the Action Bar

Summary

image Chapter 10: The Life of an Activity

Understanding the Activity Lifecycle

Working with Activity Callback Methods

Understanding the Goals of Android Activity Behavior

Working with Activity Configuration Changes

Understanding the Default Configuration Change Approach

Saving Custom State

image Part III: A World of Wonderful Devices and Screens

image Chapter 11: Android Fragments

Introducing the Fragment Class

Backwards Compatibility with Fragments

Designing with Fragments in Mind

Introducing the Fragment Lifecycle

Understanding Fragment Lifecycle Callback Methods

Keeping Sane with Fragment Lifecycles

Implementing Your Own Fragment-Based Application

Creating Layouts for the Fragments Examples

Controlling Which Layout Is Chosen

Coding Differences for Fragments

Seeing Differing Fragment Behavior in Action

Summary

image Chapter 12: Intents and Receivers

Introducing Intents

The Anatomy of an Intent

Intent Actions for all Kinds of Purposes

Understanding Intent Routing

Adding Intents to Your Manifest

Seeing Intent-launched Activities in Action

Deciding on Activity Dependency

Creating an Intent

Starting the Intent-Invoked Activity

Introducing Receivers

Using Receivers When No UI is Needed

Navigating Receiver Limitations

image Chapter 13: Making Phone Calls

Checking for Phones and “Phonies”

Mandating Telephony Support

Optional Telephony Support

Making Outbound Calls

Using ACTION_DIAL

Using ACTION_CALL

Working with Incoming Calls

image Chapter 14: Making Noise with Audio for Android

Introducing the Media package

Building Your First Audio Application

Using Resources or Assets

Coding for Audio Playback Using the Media Framework

Starting With A Simple Audio Player Layout

Coding the AudioExample Behavior

Building Your Own Android Music Streaming Application

Synchronous versus Asynchronous Playback

Playing at Last

Alternative Audio Playback Approaches

Using SoundPool for Simultaneous Playback

Going Fully-Asynchronous with AsyncPlayer

Recording Audio with Android

Making Recordings with MediaRecorder

image Chapter 15: Locations and Mapping with Android

Choosing Map Providers for Your Application

Google Maps

The OpenStreetMap Project

HERE/Ovi Maps

Which Technology to Choose?

Preparing for Google Maps Development

Creating Your API Project

Enabling a Maps API on Your Google API Project

Getting the API Key

Retrieving Your API Key

Building Your First Maps Application

Using MapActivity or FragmentActivity with MapView

Permissions and Manifest Settings for Maps

Building the Layout for Your Map Application

Adding Code for a Basic Map

Adding Flair and Features to Your Maps

Zoomin’

True North

Toolbars and theMy Location Button

Shakin’ It!

Changing Map Type

Listeners for Every Conceivable Type of Map Interaction

Even More Map Options

Summary

image Part IV: Working with Resources and Services

image Chapter 16: Weaving the Web with Android

Working with the WebView Widget

Creating a Simple Application with a WebView

Simple and Not-So-Simple WebView Security

Building HTML Layouts with WebView

UI-less Internet Interaction with Android

Why Multiple Approaches to Web Interaction?

Building a JSON-based Application with HttpURLConnection

Troubleshooting Issues with Internet Connections

Mastering Downloads with DownloadManager

Introducing the DownloadManager System Service

Selecting Permissions for DownloadManager Use

A Simple Downloader Example

Coding DownloadManager Behavior

Dealing with Download Problems

image Chapter 17: Working with Files

Using Raw and Asset-based Files

Populating Lists from Resource Files

Working with Files from the File System

Android’s File System Model

Permissions for Reading and Writing Files

Examining External Files in Action

Seeing File Save and Read Behavior in Action

Ensuring External Storage Is Available When Needed

Other Considerations with Android File Systems

Android Filesystems Throughout History

Controlling UI Delays with File I/O

image Chapter 18: Managing Databases with Android

SQLite: A Seriously Popular Database

A Crash Course in SQLite

Creating SQLite Databases for Your Application

Introducing the SQLiteExample Application

Building a Database-Driven Activity

Choosing Query Approaches for SQLite and Android

Managing Data Results with Cursors

Modifying Data with Your Android Application

Inserting Data

Updating Data

Deleting Data

Tracking SQLite Versions and Android Versions

Packaging and Managing SQLite Databases for Android

Managing Performance and Android Storage

Packaging Your Own SQLite Database with Your Application

Preparing SQLite Databases for Packaging

image Chapter 19: Using Preferences

Everything Old Is New Again

Starting with Preferences

Recording Preferences

Working with Preference-Specific Activities and Fragments

Seeing the Big Picture with Preferences

Using Preference and Preference Header Resources

Filling in the Blanks with PreferenceFragment

Bringing the Preference Puzzle Pieces Together

Other Preference Considerations

Customizing Preferences

Nesting Preferences and Display Quirks

Using the Old-School Approach to Preferences

Losing Headers and Fragments

Adapting PreferenceActivty for Older Behavior

image Chapter 20: Android Security and Permissions

Requesting Permissions for Your Application

Dealing with Debugging Permissions

Installing Applications and Accepting Permissions

Pre-Marshmallow Behavior

Marshmallow and Beyond

Trading In Permissions

Creating Custom Permissions

Declaring Custom Permissions

Enforcing Custom Permissions

Securing Applications for Publication and Execution

Securing Your Application with Certificate Signing

Signing Is (Almost) Forever, So Take Care

Protecting Android and Applications at Runtime

image Chapter 21: Incorporating External Libraries with Android

The ART of Android

Choosing Library Sources or JARs

Direct Source Inclusion

Incorporating JARs

When Is Java not Java?

Absent JVM Features

Considering Java Performance for Android

Adapting an Application to Use an External Library

Sourcing Apache Commons IOUtils

Adding the JAR to Your Project’s Libraries

Referencing (or Refactoring for) Your External Libraries

Using Languages Beyond Java

Scripting Layer for Android Overview

Choosing Your Approach to SL4A

Testing SL4A on Your Emulator

image Chapter 22: Leveraging Android Services

Services Background

Defining Your Own Service

Implementing Your Own Service Class

Controlling Service Lifecycle via Callbacks

Adding Manifest Entries for Your Service

Service Communication

Client-to-Service Communication

Service-to-Client Communication

Services in Action

Choosing the Service Design

Implementing the Java Logic for Our Service

Creating an Example Client for the Service

Testing the Service in Action

image Chapter 23: Communicating with Notifications

Configuring Notifications

Customizing the Notification Object

Adding Icons for Notifications

Notifications in Action

Coding Notification Behavior

Notifications as the User Experiences Them

Using the Builder Approach to Notifications

Other Uses and Extensions to Notifications

Notifications and Services

More Advanced Notification Features

Timeline Notifications

Bundled Notifications

Expanding Notifications

More Embedded Actions in Notifications

Notifications Tailored for Wear

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset