You are previewing Sams Teach Yourself Android Application Development in 24 Hours, Fourth Edition.
O'Reilly logo
Sams Teach Yourself Android Application Development in 24 Hours, Fourth Edition

Book Description

In just 24 sessions of one hour or less, learn how to build powerful apps for the world’s most popular mobile platform: Android. Using this book’s straightforward, step-by-step approach, you’ll build complete Android 5 apps from the ground up with Android Studio. As you do, you’ll master key skills for designing, developing, and publishing meaningful apps of your own. Extensively updated for Android 5’s newest capabilities, every lesson builds on what you’ve already learned, giving you a rock-solid foundation for real-world success!

Highlights of this new Fourth Edition include

  • Extensive new coverage: Android 5 (Lollipop), Android Studio, and Material Design; plus Android M early preview

  • A laser focus on modern Android essentials, including activities, intents, resources, and background processing

  • New Android 5 features for Android TV and Android Wear

  • Complete Android Studio projects in nearly every chapter

  • Learn how to…

  • Use the powerful new Android Studio development environment

  • Build layouts that automatically display properly on any device

  • Craft more dynamic, intuitive apps with Google’s new material design language

  • Display the right information at the right time with ListViews and adapters

  • Make apps more responsive with background processes

  • Add sophisticated navigation with action toolbars and slide-out menus

  • Integrate images and media into your apps

  • Save data for your app and create public files that can be used by anyone

  • Access the cloud to download and parse JSON data

  • Use SQLite and content providers to create responsive, data-driven apps

  • Create, update, and cancel notifications

  • Start developing Android Wearable and TV apps

  • Use Google Play Services to add location, mapping, and more

  • Package and publish apps to Google Play and other markets

  • Table of Contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Praise for Sams Teach Yourself Android™ Application Development in 24 Hours, Fourth Edition
    5. Contents at a Glance
    6. Table of Contents
    7. Preface
      1. New in the Fourth Edition
      2. Who This Book Is For
      3. How This Book Is Organized
      4. Source Code for the Book
    8. About the Authors
    9. Dedication
    10. Acknowledgments
    11. We Want to Hear from You
    12. Reader Services
    13. Part I: Android Fundamentals
      1. Hour 1. Introducing Android
        1. Defining Android
          1. Operating System
          2. Development Environment
          3. Mobile Platform
        2. Understanding Android Development
          1. Getting the Big Picture
        3. Beginning Android Studio
          1. Installation
          2. Creating a Project
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
      2. Hour 2. Understanding Intents
        1. Using Intents to Start an Activity
          1. Creating the User Interface in Android Studio
          2. Creating a Second Activity
          3. Adding Code to Start an Activity
          4. Running the App
          5. Passing Data Between Activities
          6. Explicit and Implicit Intents
        2. Using Implicit Intents
          1. Opening a Map to a Specific Location
          2. Displaying a Web Page
          3. More Actions
        3. Handling an Implicit Intent
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
      3. Hour 3. Understanding Resources
        1. Resources in Your Project
        2. Understanding Common Resources
          1. Using Resources
          2. Working with Simple Resources
          3. Working with Drawable Resources
          4. Using Style
        3. Providing Alternative Resources
        4. Internationalization: Using Alternative Languages Resources
          1. Handling Locales with Android
          2. Specifying Default Resources
          3. Specifying Language-Specific Resources
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
        8. Exercises
      4. Hour 4. Activities and Fragments
        1. Working with Activities
          1. A Quick Review
          2. Using Layouts
          3. Returning a Result: Using StartActivityForResult
          4. Handling Configuration Changes
        2. Understanding the Activity Lifecycle
          1. Create, Start, Resume, Pause, Stop, and Destroy
          2. Common Tasks in Callback Methods
        3. Introducing Fragments
          1. Creating an Activity and Fragment
          2. Using a Layout for Fragment Display
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercises
      5. Hour 5. Responsive Apps: Running in the Background
        1. Working in the Background
          1. The UI Thread
          2. Using a Thread and View.post()
        2. Using an AsyncTask
        3. Service and IntentService
          1. Using an IntentService
          2. Defining an IntentService
          3. Adding a BroadcastReceiver
          4. Using Android Studio for IntentServices
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
    14. Part II: Creating the User Interface
      1. Hour 6. Using Basic UI Controls
        1. Using the Android Studio Palette
        2. Handling User Input
          1. Adding a TextView
          2. Using EditText
        3. Using Buttons for User Actions
          1. Button Properties
          2. Handling a Button Click
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
      2. Hour 7. Using Layouts
        1. Getting Started with Layouts
          1. Designing Layouts Using the Android Studio
          2. Editing Layouts Using XML
          3. Using Layout Resources Programmatically
        2. Becoming a RelativeLayout Expert
          1. Aligning to Parent
          2. Aligning Views Relative to Each Other
        3. Common Attributes
          1. Layout Margins
          2. Padding
        4. More Layout Types
          1. Using LinearLayout
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
        8. Exercises
      3. Hour 8. ListViews and Adapters
        1. Getting Started with ListViews
          1. Using ArrayAdapters
        2. Extending Base Adapters
          1. Creating a BaseAdapter
          2. Adding a Complex Child View to a ListView
        3. Introducing the View Holder Pattern
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercises
      4. Hour 9. Material Design
        1. The Evolution of App Design
          1. Skeuomorphism
          2. Flat Design
        2. Introducing Material Design
          1. 3D Space and Shadows
          2. Graphics
          3. Typography
          4. Animation
          5. Cards
        3. Implementing Material Design
          1. Setting Theme and Elevation
          2. CardView and RecyclerView
          3. Floating Action Button (FAB)
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
      5. Hour 10. More Views and Controls
        1. Controls for Collecting Information
          1. Using a Spinner Control
          2. Using an AutoCompleteTextView
          3. CheckBoxes and RadioButtons
        2. Indicating Progress
        3. Displaying Data
          1. Using a GridView
          2. Using an AdapterViewFlipper
          3. Page Flipping and Horizontal Scrolling
        4. More Views
          1. WebView
          2. When to Use a ScrollView
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
        8. Exercise
      6. Hour 11. ImageViews and Bitmaps
        1. Examining ImageView
          1. Displaying an Image
          2. Using ScaleTypes in ImageView
          3. Rotating an Image
          4. Setting Alpha
        2. Using Bitmaps and Canvas
          1. Handling Large Images
          2. Using BitmapFactory.Options
          3. Drawing Directly on a Canvas
        3. Introducing Picasso
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
      7. Hour 12. Using VideoViews and Media
        1. Playing Video
          1. Using an Intent
          2. Using a VideoView
          3. Adding a MediaController to a VideoView
          4. Starting, Pausing, and Positioning a Video
        2. Handling VideoView Events
          1. Listening for the States of a VideoView
        3. Playing Audio with MediaPlayer
        4. More Media
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
        8. Exercise
      8. Hour 13. Adding Navigation
        1. Using the ActionBar
          1. Displaying the Options Menu
          2. Responding to the Options Menu
          3. Adding Up Navigation
        2. Introducing the Toolbar
          1. A Basic Toolbar
          2. Adding a Child View to a Toolbar
        3. Sliding Drawer Navigation
          1. The Importance of Layouts
          2. Setting Up the Sliding Drawer
          3. Populating ListView and Handling Selection
          4. Odds and Ends for the Sliding Drawer
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
    15. Part III: Working with Data
      1. Hour 14. Using the File System
        1. File System Overview
          1. Understanding Internal and External Storage
          2. Understanding Public and Private Storage
          3. Understanding Cached Storage
        2. Saving Data Privately in Your App
        3. Saving Data in Public Folders
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
      2. Hour 15. Using SharedPreferences
        1. Using SharedPreferences to Store Data
          1. Setting Preferences
          2. Reading from SharedPreferences
          3. Data Types and Methods in SharedPreferences
        2. Setting User Preferences
          1. Creating a PreferencesFragment
          2. Generating a PreferenceActivity
        3. Summary
        4. Q&A
        5. Workshop
          1. Quiz
          2. Answers
        6. Exercise
      3. Hour 16. Using SQLite and File Storage
        1. Organizing a Database with Tables
        2. Managing Data with SQLiteOpenHelper
        3. Adding, Deleting, and Updating Data
        4. Querying Data and Using Cursors
          1. Defining a Query
          2. Getting an Object from a Cursor
        5. Using a Database in the App
          1. Using PieDbAdapter
          2. Using a SimpleCursorAdapter to Display Data
        6. Summary
        7. Q&A
        8. Workshop
          1. Quiz
          2. Answers
        9. Exercise
      4. Hour 17. Accessing the Cloud: Working with a Remote API
        1. Fetching Remote Data
          1. Making an API Call
          2. Retrieving Data with HttpUrlConnection
          3. The Structure of This App
        2. Using and Parsing JSON-Formatted Data
          1. Creating a JSONObject
          2. Using a JSONArray
          3. Parsing JSON
        3. Putting the Pieces Together
          1. Downloading in the Background with AsyncTask
          2. Displaying the List in a Fragment
        4. Checking Connectivity
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
        8. Exercise
      5. Hour 18. Introducing Content Providers
        1. Introducing Content Providers
        2. All About the Calendar
          1. Calendar Data on Android
        3. Calendar Data via the Calendar Content Provider
          1. Listing Calendar Events
          2. Drilling Further into Calendar Data
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
      6. Hour 19. Creating a Content Provider
        1. Specifying a URI for Data Retrieval
        2. Using PieDbAdapter
        3. Building a Content Provider
          1. Methods Required in a Content Provider
          2. Declaring the Content Provider
          3. Updating the Android Manifest
          4. Content Provider Query Method
          5. Implementing the GetType() Method
          6. Implementing Insert, Update, and Delete Methods
        4. Using MyContentProvider in the App
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
        8. Exercise
      7. Hour 20. Loaders and CursorAdapters
        1. How Loaders Work
        2. Loader Classes
        3. Understanding Loader States
          1. Initializing a Loader
          2. Creating a Loader
          3. Taking Action When Data Is Available
          4. Resetting a Loader
          5. Using a CursorLoader with a CursorAdapter
        4. Creating Cursor Adapters
          1. Implementing newView()
          2. Implementing BindView
        5. The Rest of the App
        6. Summary
        7. Q&A
        8. Workshop
          1. Quiz
          2. Answers
        9. Exercise
    16. Part IV: Next Steps
      1. Hour 21. Using Notifications
        1. Introducing Notifications
          1. Components of a Notification
          2. Classes Used for a Notification
        2. Creating and Managing Notifications
          1. Building a Basic Notification
          2. Adding a Destination
          3. Updating a Notification
          4. More Notification Options
        3. Customizing Notifications
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
      2. Hour 22. Android TV and Wear Apps
        1. Android as a Platform
        2. Developing Android Wear Apps
          1. Designing for Android Wear Differences
          2. Setting Up for Wear Development
          3. Testing a Wear App
          4. Adding a Notification
        3. Developing Android TV Apps
          1. Designing for Android TV Differences
          2. Android TV Development
          3. Testing an Android TV App
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
      3. Hour 23. More Features to Explore
        1. Using Google Play Services
          1. Setting Up Google Play Services
          2. Checking for Google Play Services
        2. Using Google Play Services for Location
          1. Determining Location
          2. Implementing Location Tracking
        3. Using Open Source and External SDKs
          1. Picasso
          2. Realm
          3. Fabric and Crashlytics
        4. Digging Deeper into Android
          1. Using Sensors
          2. Handling User Gestures
          3. Customizing Styles and Themes
          4. Designing Custom View and ViewGroup Controls
          5. Camera
          6. Using the OpenGL ES Graphics API
          7. Bluetooth
          8. NFC and Beam
        5. Summary
        6. Q&A
        7. Workshop
          1. Quiz
          2. Answers
        8. Exercise
      4. Hour 24. Publishing Your Apps
        1. Preparing for Release
          1. Preparing the Android Manifest File for Release
          2. Signing Your Apps
        2. Sharing Your App with the World
          1. Publishing on Google Play
          2. Publishing on Amazon
        3. Monetizing Your App
          1. Free Apps
          2. Ad Supported
          3. Paid
          4. In-App Payments
        4. Summary
        5. Q&A
        6. Workshop
          1. Quiz
          2. Answers
        7. Exercise
    17. Index
    18. Code Snippets