My Cart (0)

Customer Service 1-800-221-5528

Murach’s Android Programming

by Joel Murach
18 chapters, 702 pages, 307 illustrations
Published September 2013
ISBN 978-1-890774-71-4
Print: $40.25
List Price: $57.50 Save 30%
eBook: $33.25
List Price: $47.50 Save 30%
Print + eBook: $47.25
List Price: $67.50 Save 30%

If you know how to program in Java, this is the first book you should buy for learning how to develop Android apps the way the pros do. First, it shows how to set up a professional development environment. Then, it presents a series of complete Android apps that illustrate key skills…fragments, services, broadcast receivers, SQLite databases, content providers, Google Maps, and much more! Once you finish this book, the competing books will make more sense.

Our Ironclad Guarantee

You must be satisfied. Try our books for 60 days. They must be the best you've ever used, or send them back for a full refund. No questions asked!

College Instructors

Go to our instructor’s site to learn more about this book and its instructor’s materials.

 

I like the fact that the book approaches the subject by using example apps as the theme of study, and working through the skills incrementally from easy to difficult. These case-study apps are complete apps by themselves and are worthy of being in the Android app stores.”

Jason Ong, ASP.NET World

  • About this Book
  • Table of Contents
  • FREE Downloads
  • Book FAQs
  • Corrections
  • Reviews

What this book does

Briefly stated, we think this is the best book on the market for getting started with Android programming. Once you read this book, the competing Android books will make more sense. Here’s a brief rundown on what each of the sections in our book does.

Section 1: Get started fast

In the four chapters in this section, you’ll quickly master the basics of Android programming. That includes:

  • the essential concepts and terms for Android programming
  • how to use Eclipse for Android development
  • how to develop your first Android app, a simple but complete Tip Calculator app
  • how to use Eclipse to thoroughly test and debug your apps

Section 2: The essential Android skills

In the five chapters in this section, you’ll learn the Android essentials by enhancing the Tip Calculator app that you developed in chapter 3. That includes:

  • how to use different layouts and widgets to develop a sophisticated user interface
  • how to handle high- and low-level events
  • how to use themes and styles to improve the appearance of your app
  • how to use menus and preferences
  • how to use fragments to allow your app to take advantage of the larger screens that are available with mobile devices like tablets

Section 3: The News Reader app

In the three chapters of section 3, you’ll learn how to develop a News Reader app. Along the way, you’ll learn:

  • how to read an RSS feed from the Internet, save that data in a file, and display it on the user interface
  • how to use a service to download data for an app even when the app isn’t running, and to notify a user when new data is available
  • how to respond to actions that are broadcast by Android and its apps

Section 4: The Task List app

In the four chapters of section 4, you’ll learn:

  • how develop a Task List app that stores one or more to-do lists
  • how to create and use a database that stores lists
  • how to use tabs and a custom adapter to display items in the user interface
  • how to use a content provider to allow other apps to work with the same data as this app
  • how to create an app widget that can display some of this app’s data on a device’s Home screen

Section 5: Advanced Android skills

In this section, you’ll learn:

  • how to create a Run Tracker app that uses the Google Maps API
  • how to deploy apps to the Google Play store

Who this book is for

This book is for anyone who wants to learn professional skills for developing Android apps. The only prerequisite is a basic understanding of the Java programming language, roughly equivalent to chapters 1 through 14 of our core Java book, Murach’s Java Programming. Once you have those Java skills, our Android book will work for you, even if you have absolutely no experience developing mobile apps.

What software you need

You can download all of the software that you need for this book for free from the Internet:

  • the Java SDK (Software Development Kit)
  • the ADT (Android Developer Tools) bundle, which includes the Android SDK, Eclipse, and the ADT plugin for Eclipse

Appendixes A and B in this book show an easy way to install and configure this software on Windows and Mac systems.

What software this book supports

What version of Android this book supports

The apps presented in this book have been designed to take advantage of the latest features of Android 4.2, and they have been tested on that version. However, most of these apps have also been designed to work with earlier versions of Android going back to version 2.2, and they have also been tested on Android 2.2.

Since Android is backwards-compatible, the apps presented in this book should continue to work for future versions of Android. In fact, they’ve also been tested on Android 4.3, which was released just as this book went to press, and they work well with that version.

What IDE this book supports

This book shows you how to use the Eclipse IDE (Integrated Development Environment) to code, test, and debug applications. Although there are other IDEs for working with Android, we chose Eclipse because it’s the most widely used IDE for Android development. It’s also available for free, and it runs on all operating systems.

In fact, even if you want to use another IDE, we recommend that you use Eclipse to work with the applications presented in this book. Then, once you’re done with this book, it should be easy for you to switch from Eclipse to another IDE.

However, we know that the IntelliJ IDE has been gaining in popularity for Android development. So appendix C gives you the set-up information you need if you want to use it with this book. That means it shows you how to install and configure IntelliJ, as well as how to import the Eclipse projects into it.

The perfect companion book

As you read our Android book, you may discover that your Java skills aren’t as strong as they ought to be. In that case, we recommend our core Java book, Murach’s Java Programming. This book will get you up-to-speed with Java and the core skills that you need for developing Android apps. And after you’ve learned from it, it becomes the perfect on-the-job Java reference for Android programmers.

What people say about this book

“I dove into Android after a year of iOS development thinking, ‘How hard can it be?’ After a week of uncomfortably slow progress, I'm so happy I invested in this book. Although it's true that there are online tutorials by the gazillions, I find Murach FAR easier to follow - the book introduces concepts in a nice fine-grained level so that whatever your speed, you won't get lost.”
-- Posted at an online bookseller

“If you have any prior experience with Java and want to take the next step and learn Android app creation, then Murach's is the book to buy. If you've been looking for a good resource, this is it! Stop looking and just get it.”
-- Posted at an online bookseller

“Murach's Android Programming is a great way to learn how to write your first Android app. You'll get started quickly and then have a reference when you need idioms or how-to's for that app and later ones. I particularly liked the parts on how to debug and use the emulator.”
-- Jeanne Boyarsky, JavaRanch.com

“I like the fact that the book approaches the subject by using example apps as the theme of study, and working through the skills incrementally from easy to difficult. These case-study apps are complete apps by themselves and are worthy of being in the Android app stores.”
-- Jason Ong, ASP.NET World

“Simple, clear, direct! Easy to understand and with an easy structure. I'm very happy with this book! 100% recommended! For sure!”
-- Posted at an online bookseller

To view the table of contents for this book in a PDF: Table of Contents

Click on any chapter title to display or hide its content.

Section 1 Get started fast with Android

Chapter 1 An introduction to Android

Android overview

Types of devices

Types of apps

A brief history

Versions

System architecture

How apps are compiled and run

A simple Android app

The user interface

The XML for the user interface

The XML for the display text

The Java source code

The Android manifest

Chapter 2 How to use Eclipse for Android development

How to work with existing projects

An introduction to Eclipse projects

How to set the workspace

How to import a project into the workspace

How to remove a project from the workspace

How to work with the user interface

How to work with other XML resources

How to work with the Java code

How to set the run configuration

How to run an app on a physical device

How to run an app on an emulator

How to work with a new project

How to create a new project

How to work with the starting code

How to use the code completion feature

How to detect and correct errors and warnings

The Tester app

The user interface

The XML for the user interface

The Java source code

Chapter 3 How to develop your first Android app

How to develop the user interface

The Tip Calculator app

How to work with a layout

How to add widgets to a layout

How to set the display text

How to work with the strings.xml file

How to set properties

Common properties

The XML for the user interface

How to write the Java code

How to work with an activity

How to get references to widgets

How to handle the EditorAction event

How to get and set the text for widgets

How to handle the Click event

The lifecycle of an activity

How to save and restore values

How to use the documentation for the Android API

The Java code for the app

Chapter 4 How to test and debug an Android app

Basic skills for testing and debugging

Typical test phases

How to check the layout

The three types of errors

How to handle runtime errors

How to trace code execution

How to use LogCat logging

How to use toasts

How to use the debugger

How to set and remove breakpoints

How to step through code

How to inspect variables

How to inspect the stack trace

How to configure step filters

How to configure your emulators

How to add an emulator for an old phone

How to work with an emulator for an old phone

How to add an emulator for a tablet

Section 2 Essential Android skills

Chapter 5 How to work with layouts and widgets

An introduction to layouts and widgets

A summary of layouts

A summary of widgets

The View hierarchy

How to work with layouts

How to use a linear layout

How to use a table layout

How to use a frame layout

How to nest layouts

How to provide a landscape layout

How to work with widgets

How to use editable text views

How to use check boxes

How to use radio buttons

How to use spinners

How to use seek bars

How to display images

How to show and hide widgets

How to add scroll bars

Chapter 6 How to handle events

A summary of listeners

High-level events

Low-level events

Four techniques for handling events

How to use the current class as the listener

How to use a named class as the listener

How to use an anonymous class as the listener

How to use an inner anonymous class as the listener

When to use each technique

How to handle high-level events

How to handle events for check boxes and radio buttons

How to handle events for radio groups

How to handle events for spinners

How to handle events for seek bars

How to handle low-level events

How to handle Key events

How to handle Touch events

The Tip Calculator app

The user interface

The Java code for the activity

Chapter 7 How to work with themes and styles

An introduction to themes and styles

Three themes

The theme framework that’s generated by Eclipse

How to work with styles

How to define a style

How to apply a style

How to create a style sheet

How to work with themes

How to modify a theme

How to modify the text appearance for a theme

A summary of built-in themes

How to apply themes

How to work with colors

How to define colors

How to apply colors

Chapter 8 How to work with menus and preferences

How to work with menus

An introduction to menus

How to define a menu

How to display an options menu

How to handle option menu events

How to start a new activity

How to work with preferences

An introduction to preferences

How to define preferences

How to display preferences in an activity

How to display preferences in a fragment

How to get preferences

How to use preferences

More skills for working with preferences

How to group preferences

How to enable and disable preferences

How to use Java to work with preferences

Chapter 9 How to work with fragments

An introduction to fragments

Single-pane and multi-pane layouts

How to use support libraries

The lifecycle methods of a fragment

How to use single-pane layouts for small screens

How to create the layout for a fragment

How to create the class for a fragment

How to display a fragment in an activity

How to create a preference fragment

How to display a preference fragment in an activity

How to use multi-pane layouts for large screens

How to add multiple fragments to a layout

How to detect large screens

How to detect screen width

How to control the soft keyboard

Other skills for working with fragments

How to get a reference to a fragment

How to replace one fragment with another

Section 3 The News Reader app

Chapter 10 How to work with threads, files, adapters, and intents

An introduction to the News Reader app

The user interface

The XML for an RSS feed

How to work with threads

How threads work

How to execute asynchronous tasks

How to execute timed tasks

How to update the UI thread

How to work with files

How to download a file from the Internet

How to parse an XML file

The RSSFeedHandler class

The RSSFeed class

The RSSItem class

How to work with adapters

How to create the layout for a list view

How to use an adapter to display data in a list view

How to handle events for an adapter

How to work with intents

How to pass data between activities

How to view a URL in a web browser

How to dial or call a phone number

The News Reader app

The activity_items layout

The ItemsActivity class

The FileIO class

The activity_item layout

The ItemActivity class

Chapter 11 How to work with services and notifications

How to work with the Application object

How to define the Application object

How to register the Application object

How to use the Application object

How to work with services

The lifecycle of a service

How to create a service

How to register a service

How to start and stop a service

How to use threads with services

How to test a service

How to view all services

How to work with notifications

How notifications work

How to create a pending intent

How to create a notification

How to work with system services

How to display or remove a notification

How to check if a network connection is available

The News Reader app

The NewsReaderService class

The ItemsActivity class

The FileIO class

Chapter 12 How to work with broadcast receivers

How to work with system broadcasts

A summary of the system broadcasts

How to code a receiver for the boot completed broadcast

How to code a receiver for the connectivity changed broadcast

How to work with custom broadcasts

How to create and send a custom broadcast

How to code a receiver for a custom broadcast

Section 4 The Task List app

Chapter 13 How to work with SQLite databases

An introduction to databases

The user interface for the Task List app

An introduction to SQLite

An introduction to the Task List database

The business objects for the Task List app

How to create a database class

How to define the constants for a database

How to define the SQL statements that create a database

How to create or upgrade a database

How to open and close a database connection

How to add public methods to a database class

How to retrieve multiple rows from a table

How to retrieve a single row from a table

How to get data from a cursor

How to insert, update, and delete rows

How to test the database class and clear its data

How to test the database class

How to clear test data from a device

How to use the DDMS perspective to work with database files

How to use the SQLite Database Browser

Chapter 14 How to work with tabs and custom adapters

How to use tabs

How to add the TabManager class to your project

The layout for an activity that displays tabs

The class for an activity that displays tabs

The class for a fragment that displays tab content

How to use a custom adapter

A layout for a list view item

A class that extends the layout for a list view item

A class for a custom adapter

A class for a fragment that uses a custom adapter

The Task List app

The user interface

The activity_task_list menu

The TaskListActivity class

The activity_add_edit and spinner_list layout

The activity_add_edit menu

The AddEditActivity class

Chapter 15 How to work with content providers

An introduction to content providers

URIs for content providers

MIME types for content providers

How to add supporting methods to the database class

How to create a content provider

How to start a content provider class

How to provide for querying

How to provide for inserting rows

How to provide for updating rows

How to provide for deleting rows

How to register a content provider

How to use a content provider

How to use a custom content provider

How to use a built-in content provider

How to work with a dialog box

How to import the dialog class and interface

How to build and show the dialog box

The Task History app

The user interface

The XML for the layouts

The Java code for the activity

Chapter 16 How to work with app widgets

An introduction to app widgets

A Home screen that has app widgets

How to add app widgets to the Home screen

How to create app widgets

How to create the layout

How to modify the database class

How to create the provider class

How to configure an app widget

How to register an app widget

How to test an app widget

Section 5 Advanced Android skills

Chapter 17 How to deploy an app

An introduction to distribution and monetization

How distribution works

How monetization works

How to create a release build

How to prepare an app for release

How to create the signed APK file

How to distribute directly to the user

How to distribute via a web site

How distribute via email

How to publish on Google Play

How to set up a publisher account

How to use the Developer Console to publish an app

How to view the listing for an app

Chapter 18 How to work with locations and maps

An introduction to locations and maps

The user interface for the Run Tracker app

An introduction to determining location

An introduction to maps

An introduction to the Google Maps Android API

How to configure the Google Maps Android API v2

How to add the Google Play services library to a project

How to get the SHA-1 fingerprint

How to get a Maps API key

How to register the Maps API key

How to set permissions and features

How to work with locations

How to connect to Google Play services

How to get the current location

How to handle a failed connection

How to get location updates

How to make sure GPS is enabled

How to work with Google Maps

How to add a map fragment to a layout

How to display a map

How to zoom in on a location

How to add markers

How to add lines

The Run Tracker app

The activity_run_map layout

The RunMapActivity class

The RunTrackerService class

Appendixes

Appendix A How to set up your PC for this book 

How to install the source code for this book

How to install the Java SE JDK

How to use the ADT bundle to install Android and Eclipse

How to start Eclipse

How to configure Eclipse for this book

How to use the Android SDK Manager

How to create an emulator

How to configure a device for development

How to verify that your PC is set up correctly

Appendix B How to set up your Mac for this book

How to install the source code for this book

How to install the Java SE JDK

How to use the ADT bundle to install Android and Eclipse

How to start Eclipse

How to configure Eclipse for this book

How to use the Android SDK Manager

How to create an emulator

How to configure a device for development

How to verify that your Mac is set up correctly

Appendix J How to use IntelliJ with this book

A comparison of Eclipse, IntelliJ, and Android Studio

How to prepare for using IntelliJ with this book

How install IntelliJ IDEA Community Edition

How to configure IntelliJ for this book

How to import an Eclipse project

How to verify that IntelliJ is set up correctly

Sample chapters

Chapter 1: An introduction to Android programming

To show you how well this book works, this free chapter introduces you to the concepts and terms that you need for developing Android apps. Along the way, this chapter presents some of the code for a simple but complete Tip Calculator app. That will show you how the code for an Android app works. At that point, you’ll be ready to get started with Android development.

Chapter 1 PDF (2.0Mb) Download Now

Book applications and exercises

This download includes:

  • The source code for the applications that are presented in the book
  • The starting source code for the exercises in the book
  • The solutions to the book exercises so you can check your work

Appendixes A and B in the book show how to install and use these files on Windows and Mac systems.

Exe file for Windows (60.6Mb) Download Now

Zip file for any system (60.5Mb) Download Now

Below are the answers to the questions that have come up most often about this book. If you have any questions that aren’t answered here, please email us. Thanks!

I want to configure my system as described in appendix A (PC) or B (Mac), but the bundled files are no longer available from the developer.android.com website. Where can I find these files?

To make it easy for you to get these files, we have posted them to our website. You can download them from the following URLs:

Windows 64-bit (406MB):
http://murach.com/images/downloads/android_programming/adt-bundle-windows-x86_64-20130219.zip

Windows 32-bit (406MB):
http://murach.com/images/downloads/android_programming/adt-bundle-windows-x86-20130219.zip

Mac (373 MB):
http://murach.com/images/downloads/android_programming/adt-bundle-mac-x86_64-20130219.zip

Can I use Android Studio with your book instead of Eclipse?

You can, but we don’t yet provide any support for Android Studio. As a result, you’ll be on your own for figuring out how to convert the source code for this book from Eclipse to Android Studio, figuring out how to work with Android Studio, and so on.

The Run Tracker app in chapter 18 sometimes crashes. How can I fix this?

You can fix this problem by adding the following code to the AndroidManifest.xml file at the application level:
andp 1

While doing exercise 18-2, I got an error saying that I should add FLAG_ACTIVITY_NEW_TASK to the intent. How can I fix this?

You can usually fix this issue by adding the following line to your code:
andp 2

On pages 592-595, the Google APIs Console looks and works differently. Why?

Websites are constantly changing, and this website is no exception. Fortunately, it looks and works similarly enough that you should be able to use it to get the Maps API key.

When I test on an Android device that has a language setting that is not English, the News Reader app crashes. How can I fix this?

You can fix this by changing
andp 3

To view the corrections for this book in a PDF, just click on this link: View the corrections

Then, if you find any other errors, please email us so we can correct them in the next printing of the book. Thank you!

There are no reviews for this product yet.

To leave a review, please log in to your account.     Log In Here

Our Ironclad Guarantee

You must be satisfied. Try our books for 60 days. They must be the best you've ever used or send them back for a prompt refund. No questions asked!

Contact Murach Books

For orders and customer service:

1-800-221-5528

Weekdays, 8 to 4 Pacific Time

College Instructors

If you're a college instructor who would like to consider a book for a course, please visit our website for instructors to learn how to get a complimentary review copy and the full set of instructional materials.