Contents

Introduction

Welcome to Android

CHAPTER 1 GETTING STARTED WITH ANDROID

Exploring Android Development Environments

Eclipse (ADT Bundle)

Android Studio

Getting Everything Installed

Installing Eclipse (ADT Bundle) for OS X, Linux, Windows

Installing Android Studio

Updating the Android SDK

Configuring Devices

Virtual Device Emulator

Working with a Physical Device

Creating a New Android Project

Running Your New Project

Eclipse

Android Studio

Troubleshooting the Emulator

Wrapping Up

CHAPTER 2 EXPLORING THE APPLICATION BASICS

The Files

The Manifest

The Activity Class

Watching the Activity in Action

Implementing Your Own Activity

The Life and Times of an Activity

Bonus Round—Data Retention Methods

The Intent Class

Manifest Registration

Adding an Intent

Listening for Intents at Runtime

Moving Your Own Data

The Application Class

The Default Application Declaration

Customizing Your Own Application

Accessing the Application

Wrapping Up

CHAPTER 3 CREATING USER INTERFACES

The View Class

Creating a View

Altering the UI at Runtime

Handling a Few Common Tasks

Creating Custom Views

Resource Management

Resource Folder Overview

Values Folder

Layout Folders

Drawable Folders

Layout Management

The ViewGroup

The AbsoluteLayout

The LinearLayout

The RelativeLayout

Wrapping Up

CHAPTER 4 ACQUIRING DATA

The Main Thread

You There, Fetch Me That Data!

Watchdogs

What Not to Do

When Am I on the Main Thread?

Getting Off the Main Thread

Getting Back to Main Land

There Must Be a Better Way!

The AsyncTask

How to Make It Work for You

A Few Important Caveats

The IntentService

Declaring a Service

Fetching Images

Checking Your Work

Wrapping Up

CHAPTER 5 ADAPTERS, LIST VIEWS, AND LISTS

Two Pieces to Each List

ListView

Adapter

A Main Menu

Creating the Menu Data

Creating a ListActivity

Defining a Layout for Your ListActivity

Making a Menu List Item

Creating and Populating the ArrayAdapter

Reacting to Click Events

Complex List Views

The 1000-foot View

Creating the Main Layout View

Creating the ListActivity

Getting Reddit Data

Making a Custom Adapter

Building the ListViews

How Do These Objects Interact?

More Than One List Item Type

Wrapping Up

CHAPTER 6 BACKGROUND SERVICES

What Is a Service?

The Service Lifecycle

Keeping Your Service Running

Shut It Down!

Communication

Intent-Based Communication

Binder Service Communication

Wrapping Up

CHAPTER 7 MANY DEVICES, ONE APPLICATION

Uncovering the Secrets of the res/ Folder

Layout Folders

What Can You Do Beyond Landscape?

The Full Screen Define

Limiting Access to Your App to Devices That Work

The <uses> Tag

SDK Version Number

Handling Code in Older Android Versions

SharedPreferences and Apply

Version Check Your Troubles Away

Always Keep an Eye on API Levels

Wrapping Up

CHAPTER 8 MOVIES AND MUSIC

Movies

Adding a VideoView

Setting Up for the VideoView

Getting Media to Play

Loading and Playing Media

Cleanup

The Rest, as They Say, Is Up to You

Music

MediaPlayer and State

Playing a Sound

Playing a Sound Effect

Cleanup

It Really Is That Simple

Longer-Running Music Playback

Binding to the Music Service

Finding the Most Recent Track

Listening for Intents

Playing the Audio in the Service

Cleanup

Interruptions

Wrapping Up

CHAPTER 9 DETERMINING LOCATIONS AND USING MAPS

Location Basics

Mother May I?

Be Careful What You Ask For

Finding a Good Supplier

Getting the Goods

The Sneaky Shortcut

That’s It!

Show Me the Map!

Before We Get Started

Getting the Library

Adding to the Manifest

Adjusting the Activity

Creating a MapFragment

Google Maps API Key

Run, Baby, Run

Wrapping Up

CHAPTER 10 TABLETS, FRAGMENTS, AND ACTION BARS, OH MY

Fragments

The Lifecycle of the Fragment

Creating a Fragment

Showing a Fragment

Providing Backward Compatibility

The Action Bar

Setting Up the AppCompat library

Showing the Action Bar

Adding Elements to the Action Bar

Wrapping Up

CHAPTER 11 ADVANCED NAVIGATION

The View Pager

Creating the Project

onCreate

The XML

FragmentPagerAdapter

DummyFragment

The Navigation Drawer

onCreate

The XML

Swapping Fragments

Wrapping Up

CHAPTER 12 PUBLISHING YOUR APPLICATION

Packaging and Versioning

Preventing Debugging

Naming the Package

Versioning

Setting a Minimum SDK Value

Packaging and Signing

Exporting a Signed Build

Submitting Your Build

Watch Your Crash Reports and Fix Them

Update Frequently

Wrapping Up

CHAPTER 13 GRADLE, THE NEW BUILD SYSTEM

Anatomy of a Gradle File

Buildscript and Plug-Ins

The Android Stuff

Build Types

Adding Values to BuildConfig

Product Flavors

Build Variants

Signing and Building

Wrapping Up

Index

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

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