You are previewing Java for Android.
O'Reilly logo
Java for Android

Book Description

This book is for you if you want to learn Java and specialize in Android application development. To save you time and effort, this book covers the most important Java programming concepts that are directly related to Android programming. All in an easy to follow tutorial. It is a guide to building real-world mobile applications in Java. 

Table of Contents

  1. Introduction
    1. Java, the Language and the Technology
    2. An Overview of Object-Oriented Programming
    3. About This Book
    4. Downloading and Installing Java
    5. Downloading Program Examples
  2. Chapter 1: Your First Taste of Java
    1. Your First Java Program
    2. Java Code Conventions
    3. Integrated Development Environments (IDEs)
    4. Summary
    5. Questions
  3. Chapter 2: Language Fundamentals
    1. ASCII and Unicode
    2. Separators
    3. Primitives
    4. Variables
    5. Constants
    6. Literals
    7. Primitive Conversions
    8. Operators
    9. Comments
    10. Summary
    11. Questions
  4. Chapter 3: Statements
    1. An Overview of Java Statements
    2. The if Statement
    3. The while Statement
    4. The do-while Statement
    5. The for Statement
    6. The break Statement
    7. The continue Statement
    8. The switch Statement
    9. Summary
    10. Questions
  5. Chapter 4: Objects and Classes
    1. What Is a Java Object?
    2. Java Classes
    3. Creating Objects
    4. The null Keyword
    5. Objects in Memory
    6. Java Packages
    7. Encapsulation and Access Control
    8. The this Keyword
    9. Using Other Classes
    10. Final Variables
    11. Static Members
    12. Static Final Variables
    13. Static import
    14. Variable Scope
    15. Method Overloading
    16. By Value or By Reference?
    17. Loading, Linking, and Initialization
    18. Object Creation Initialization
    19. Comparing Objects
    20. The Garbage Collector
    21. Summary
    22. Questions
  6. Chapter 5: Core Classes
    1. java.lang.Object
    2. java.lang.String
    3. java.lang.StringBuffer and java.lang.StringBuilder
    4. Primitive Wrappers
    5. Arrays
    6. java.lang.Class
    7. java.lang.System
    8. java.util.Scanner
    9. Boxing and Unboxing
    10. Varargs
    11. The format and printf Methods
    12. Summary
    13. Questions
  7. Chapter 6: Inheritance
    1. An Overview of Inheritance
    2. Accessibility
    3. Method Overriding
    4. Calling the Superclass’s Constructors
    5. Calling the Superclass’s Hidden Members
    6. Type Casting
    7. Final Classes
    8. The instanceof Keyword
    9. Summary
    10. Questions
  8. Chapter 7: Error Handling
    1. Catching Exceptions
    2. try without catch
    3. Catching Multiple Exceptions
    4. The try-with-resources Statement
    5. The java.lang.Exception Class
    6. Throwing an Exception from a Method
    7. User-Defined Exceptions
    8. Final Words on Exception Handling
    9. Summary
    10. Question
  9. Chapter 8: Numbers and Dates
    1. Number Parsing
    2. Number Formatting
    3. Number Parsing with java.text.NumberFormat
    4. The java.lang.Math Class
    5. The java.util.Date Class
    6. The java.util.Calendar Class
    7. Date Parsing and Formatting with DateFormat
    8. Summary
    9. Questions
  10. Chapter 9: Interfaces and Abstract Classes
    1. The Concept of Interface
    2. The Interface, Technically Speaking
    3. Base Classes
    4. Abstract Classes
    5. Summary
    6. Questions
  11. Chapter 10: Enums
    1. An Overview of Enum
    2. Enums in a Class
    3. The java.lang.Enum Class
    4. Iterating Enumerated Values
    5. Switching on Enum
    6. Summary
    7. Questions
  12. Chapter 11: The Collections Framework
    1. An Overview of the Collections Framework
    2. The Collection Interface
    3. List and ArrayList
    4. Iterating Over a Collection with Iterator and for
    5. Set and HashSet
    6. Queue and LinkedList
    7. Collection Conversion
    8. Map and HashMap
    9. Making Objects Comparable and Sortable
    10. Summary
    11. Questions
  13. Chapter 12: Generics
    1. Life without Generics
    2. Introducing Generic Types
    3. Using the ? Wildcard
    4. Using Bounded Wildcards in Methods
    5. Writing Generic Types
    6. Summary
    7. Questions
  14. Chapter 13: Input Output
    1. The File Class
    2. The Concept of Input/Output Streams
    3. Reading Binary Data
    4. Writing Binary Data
    5. Writing Text (Characters)
    6. Reading Text (Characters)
    7. Logging with PrintStream
    8. RandomAccessFile
    9. Object Serialization
    10. Summary
    11. Questions
  15. Chapter 14: Nested and Inner Classes
    1. An Overview of Nested Classes
    2. Static Nested Classes
    3. Member Inner Classes
    4. Local Inner Classes
    5. Anonymous Inner Classes
    6. Behind Nested and Inner Classes
    7. Summary
    8. Questions
  16. Chapter 15: Polymorphism
    1. Defining Polymorphism
    2. Polymorphism and Reflection
    3. Summary
    4. Questions
  17. Chapter 16: Annotations
    1. An Overview of Annotations
    2. Standard Annotations
    3. Common Annotations
    4. Standard Meta-Annotations
    5. Custom Annotation Types
    6. Summary
    7. Questions
  18. Chapter 17: Internationalization
    1. Locales
    2. Internationalizing Applications
    3. Summary
    4. Questions
  19. Chapter 18: Java Networking
    1. An Overview of Networking
    2. The Hypertext Transfer Protocol (HTTP)
    3. java.net.URL
    4. java.net.URLConnection
    5. java.net.Socket
    6. java.net.ServerSocket
    7. A Web Server Application
    8. Summary
    9. Questions
  20. Chapter 19: Java Threads
    1. Introduction to Java Threads
    2. Creating a Thread
    3. Working with Multiple Threads
    4. Thread Priority
    5. Stopping a Thread
    6. Synchronization
    7. Visibility
    8. Thread Coordination
    9. Summary
    10. Questions
  21. Chapter 20: Concurrency Utilities
    1. Atomic Variables
    2. Executor and ExecutorService
    3. Callable and Future
    4. Locks
    5. Summary
    6. Questions
  22. Chapter 21: Introduction to Android
    1. Overview
    2. Versions of Android
    3. Which Java Versions Can I Use?
    4. Online Reference
    5. Downloading and Installing Android Development Tools
  23. Chapter 22: Your First Android Application
    1. Creating An Application
    2. The Android Manifest
    3. Running An Application on An Emulator
    4. Application Structure
    5. Logging
    6. Debugging An Application
    7. Running on A Real Device
    8. Upgrading the SDK
    9. Summary
  24. Chapter 23: Activities
    1. The Activity Lifecycle
    2. ActivityDemo Example
    3. Changing the Application Icon
    4. Using Android Resources
    5. Starting Another Activity
    6. Summary
  25. Chapter 24: UI Components
    1. Overview
    2. Using the ADT Eclipse UI Tool
    3. Using Basic Components
    4. Toast
    5. AlertDialog
    6. Summary
  26. Chapter 25: Layouts
    1. Overview
    2. LinearLayout
    3. RelativeLayout
    4. FrameLayout
    5. TableLayout
    6. Grid Layout
    7. Creating A Layout Programmatically
    8. Summary
  27. Chapter 26: Listeners
    1. Overview
    2. Using the onClick Attribute
    3. Implementing A Listener
    4. Summary
  28. Chapter 27: The Action Bar
    1. Overview
    2. Adding Action Items
    3. Adding Dropdown Navigation
    4. Going Back Up
    5. Summary
  29. Chapter 28: Menus
    1. Overview
    2. The Menu File
    3. The Options Menu
    4. The Context Menu
    5. The Popup Menu
    6. Summary
  30. Chapter 29: ListView
    1. Overview
    2. Creating A ListAdapter
    3. Using A ListView
    4. Extending ListActivity and Writing A Custom Adapter
    5. Styling the Selected Item
    6. Summary
  31. Chapter 30: GridView
    1. Overview
    2. Example
    3. Summary
  32. Chapter 31: Styles and Themes
    1. Overview
    2. Using Styles
    3. Using Themes
    4. Summary
  33. Chapter 32: Bitmap Processing
    1. Overview
    2. Example
    3. Summary
  34. Chapter 33: Graphics and Custom Views
    1. Overview
    2. Hardware Acceleration
    3. Creating A Custom View
    4. Drawing Basic Shapes
    5. Drawing Text
    6. Transparency
    7. Shaders
    8. Clipping
    9. Using Paths
    10. The CanvasDemo Application
    11. Summary
  35. Chapter 34: Fragments
    1. The Fragment Lifecycle
    2. Fragment Management
    3. Using A Fragment
    4. Extending ListFragment and Using FragmentManager
    5. Summary
  36. Chapter 35: Multi-Pane Layouts
    1. Overview
    2. A Multi-Pane Example
    3. Summary
  37. Chapter 36: Animation
    1. Overview
    2. Property Animation
    3. Example
    4. Summary
  38. Chapter 37: Preferences
    1. SharedPreferences
    2. The Preference API
    3. Using Preferences
    4. Summary
  39. Chapter 38: Working with Files
    1. Overview
    2. Creating a Notes Application
    3. Accessing the Public Storage
    4. Summary
  40. Chapter 39: Working with the Database
    1. Overview
    2. The Database API
    3. Example
    4. Summary
  41. Chapter 40: Taking Pictures
    1. Overview
    2. Using Camera
    3. The Camera API
    4. Using the Camera API
    5. Summary
  42. Chapter 41: Making Videos
    1. Using the Built-in Intent
    2. MediaRecorder
    3. Using MediaRecorder
    4. Summary
  43. Chapter 41: The Sound Recorder
    1. The MediaRecorder Class
    2. Example
    3. Summary
  44. Chapter 42: Handling the Handler
    1. Overview
    2. Example
    3. Summary
  45. Chapter 43: Asynchronous Tasks
    1. Overview
    2. Example
    3. Summary
  46. Appendix A: javac
    1. Options
    2. Command Line Argument Files
  47. Appendix B: java
    1. Options
  48. Appendix C: jar
    1. Syntax
    2. Options
    3. Examples
    4. Setting an Application’s Entry Point
  49. Appendix D: NetBeans
    1. Download and Installation
    2. Creating a Project
    3. Creating a Class
    4. Running a Java Class
    5. Adding Libraries
    6. Debugging Code
    7. Eclipse
    8. Download and Installation
    9. Creating a Project
    10. Creating a Class
    11. Running a Java Class
    12. Adding Libraries
    13. Debugging Code