Android Programming for Beginners - Third Edition
Read it now on the O’Reilly learning platform with a 10-day free trial.
O’Reilly members get unlimited access to books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.
Book description
Learn the Java and Android skills you need to start developing powerful mobile applications with the help of actionable steps
Key Features
- Kick-start your Android programming career or just have fun publishing apps to the Google Play marketplace
- Get a first principles introduction to using Java and Android and prepare to start building your own apps from scratch
- Learn by example by building four real-world apps and dozens of mini apps
Book Description
Do you want to make a career in programming but don't know where to start? Do you have a great idea for an app but don't know how to make it a reality? Or are you worried that you'll have to learn Java programming to become an Android developer? Look no further! This new and expanded third edition of Android Programming for Beginners will be your guide to creating Android applications from scratch.
The book starts by introducing you to all the fundamental concepts of programming in an Android context, from the basics of Java to working with the Android API. You'll learn with the help of examples that use up-to-date API classes and are created within Android Studio, the official Android development environment that helps supercharge your mobile application development process. After a crash course on the key programming concepts, you'll explore Android programming and get to grips with creating applications with a professional-standard UI using fragments and storing user data with SQLite. This Android Java book also shows you how you can make your apps multilingual, draw on the screen with a finger, and work with graphics, sound, and animations.
By the end of this Android programming book, you'll be ready to start building your own custom applications in Android and Java.
What you will learn
- Understand the fundamentals of coding in Java for Android
- Install and set up your Android development environment
- Build functional user interfaces with the Android Studio visual designer
- Add user interaction, data captures, sound, and animation to your apps
- Manage your apps' data using the built-in Android SQLite database
- Explore the design patterns used by professionals to build top-grade applications
- Build real-world Android applications that you can deploy to the Google Play marketplace
Who this book is for
This Android book is for you if you are completely new to Java, Android, or programming and want to get started with Android app development. If you have experience of using Java on Android, this book will serve as a refresher to help you advance your knowledge and make progress through the early projects covered in the book.
Show and hide more
Table of contents Product information
Table of contents
- Android Programming for Beginners â Third Edition
- Contributors
- About the author
- About the reviewers
- Preface
- Who this book is for
- What this book covers
- To get the most out of this book
- Download the example code files
- Download the color images
- Conventions used
- Get in touch
- Reviews
- Technical requirements
- What's new in the third edition?
- Why Java and Android?
- The beginner's first stumbling block
- How Java and Android work together
- Understanding the Android API
- Java is object-oriented
- Run that by me again â what exactly is Android?
- Android Studio
- Android resources
- Packages
- Classes
- Methods
- Running and debugging the app on an Android emulator
- Running the app on a real device
- Technical requirements
- Examining the logcat output
- Filtering the logcat output
- Examining the MainActivity.java file
- Examining the app layout file
- Adding a button via the visual designer
- Adding a button by editing the XML code
- Giving the buttons unique id attributes
- Positioning the two buttons in the layout
- Making the buttons call different methods
- Adding message code to the onCreate method
- Writing our own Java methods
- Technical requirements
- Project Explorer and project anatomy
- Exploring the file and folder structure of the Empty Activity project template
- Exploring an Empty Activity project
- Emulator control panel
- Using the emulator as a real device
- Technical requirements
- Finding out about Material Design
- Exploring Android UI design
- Introducing layouts
- Creating and exploring a layout project
- Building a layout with LinearLayout
- Adding a LinearLayout layout type to a project
- Preparing your workspace
- Examining the generated XML
- Adding a TextView to the UI
- Wiring up the UI with the Java code (Part 1)
- Adding layouts within layouts
- Making the layout look pretty
- Wiring up the UI with Java code (Part 2)
- Adding a CalendarView
- Adding and constraining more UI elements
- Making the text clickable
- Adding a TableRow element to TableLayout
- Organizing the table columns
- Technical requirements
- Attributes quick summary
- Sizing using dp
- Sizing fonts using sp
- Determining size with wrap or match
- Using padding and margin
- Using the layout_weight property
- Using gravity
- Setting the view with Java code
- Adding image resources
- Creating the contents for the cards
- Defining dimensions for CardView
- Adding CardView to our layout
- Technical requirements
- The life and times of an Android app
- How Android interacts with our apps
- A simplified explanation of the Android lifecycle
- The lifecycle phases demystified
- Coding the lifecycle demo app
- Running the lifecycle demo app
- Examining the lifecycle demo app output
- Some other overridden methods
- Technical requirements
- Java is everywhere
- Understanding Java syntax and jargon
- More code comments
- Types of variables
- Variable declaration
- Variable initialization
- The assignment operator
- The addition operator
- The subtraction operator
- The division operator
- The multiplication operator
- The increment operator
- The decrement operator
- Expressing Yourself demo app
- Technical requirements
- Making decisions in Java
- Indenting code for clarity
- More operators
- How to use all these operators to test variables
- The switch demo app
- while loops
- do while loops
- Technical requirements
- Methods revisited
- What exactly are Java methods?
- Modifier
- Return type
- Name of the method
- Parameters
- The body
- Real-world methods
- Technical requirements
- Important memory management warning
- Object-oriented programming
- What is OOP exactly?
- Why do it like this?
- Class recap
- Class implementation
- Declaring, initializing, and using an object of the class
- More things we can do with our first class
- Technical requirements
- Remember that encapsulation thing?
- Controlling class use with access modifiers
- Controlling variable use with access modifiers
- Methods can have access modifiers too
- Accessing private variables with getters and setters
- Setting up our objects with constructors
- Abstract classes
- Interfaces
- Technical requirements
- All the Android UI elements are classes too
- Re-introducing references
- So how does this heap thing help me?
- Using buttons and TextView widgets from our layout
- Running the app
- Technical requirements
- Declaring and initializing the objects
- Creating UI widgets from pure Java without XML
- Exploring the palette â part 1
- The EditText widget
- The ImageView widget
- Radio buttons and groups
- Switch
- CheckBox
- TextClock
- Using WebView
- Setting up the Widget Exploration project and UI
- Coding the Widget Exploration app
- Technical requirements
- Dialog windows
- Creating the Dialog Demo project
- Coding a DialogFragment class
- Using the DialogFragment class
- Using naming conventions and string resources
- How to get the code files for the Note to Self app
- The completed app
- Building the project
- Preparing the string resources
- Coding the Note class
- Implementing the dialog designs
- Coding the dialog boxes
- Showing our new dialogs
- Technical requirements
- A random diversion
- Handling large amounts of data with arrays
- Arrays are objects
- Dynamic array example
- Multidimensional array mini-app
- Array-out-of-bounds exceptions
- The enhanced for loop
- Technical requirements
- RecyclerView and RecyclerAdapter
- The problem with displaying lots of widgets
- The solution to the problem of displaying lots of widgets
- How to use RecyclerView and RecyclerAdapter
- What we will do to set up RecyclerView with RecyclerAdapter and an ArrayList of notes
- Removing the temporary "Show Note" button and adding RecyclerView
- Creating a list item for RecyclerView
- Coding the RecyclerAdapter class
- Coding MainActivity to use the RecyclerView and RecyclerAdapter classes
- Technical requirements
- Android intents
- Switching Activity
- Passing data between activities
- Creating SettingsActivity
- Designing the settings screen layout
- Enabling the user to switch to the settings screen
- Coding the SettingsActivity class
- Coding the MainActivity class
- What is JSON?
- Java exceptions â try, catch, and finally
- Technical requirements
- Making the Note to Self app accessible for Spanish and German speakers
- Adding Spanish language support
- Adding German language support
- Adding the string resources
- Making the translations work in Java code
- Technical requirements
- Animations in Android
- Designing cool animations in XML
- Instantiating animations and controlling them with Java code
- More animation features
- Laying out the animation demo
- Coding the XML animations
- Wiring up the animation demo app with Java
- Technical requirements
- Understanding the Canvas class
- Getting started drawing with Bitmap, Canvas, and ImageView
- Preparing the instances of the required classes
- Initializing the objects
- Setting the Activity content
- Creating a new project
- Plotting and drawing
- What is a bitmap exactly?
- The Matrix class
- Adding the graphic to the project
- Technical requirements
- Creating the Live Drawing project
- Refactoring MainActivity to LiveDrawingActivity
- Locking the game to fullscreen and landscape orientation
- Looking ahead at the Live Drawing app
- Coding the LiveDrawingActivity class
- Coding the LiveDrawingView class
- Coding the LiveDrawingView class
- Problems with threads
- Implementing Runnable and providing the run method
- Coding the thread
- Starting and stopping the thread
- Using the Activity lifecycle to start and stop the thread
- Coding the run method
- Technical requirements
- Adding custom buttons to the screen
- Implementing a particle system effect
- Coding the Particle class
- Coding the ParticleSystem class
- Spawning particle systems in the LiveDrawingView class
- Coding the onTouchEvent method
- Finishing the HUD
- Handling different versions of Android
- Detecting the current Android version
- Initializing SoundPool the new way
- Initializing SoundPool the old way
- Making sound effects
- Laying out the sound demo
- Coding the sound demo
- Technical requirements
- Introducing the model-view-controller pattern
- Android design guidelines
- Real-world apps
- Device detection mini-app
- Coding the MainActivity class
- Running the app
- The limitation of configuration qualifiers
- Fragments have a lifecycle too
- Managing Fragments with FragmentManager
- Technical requirements
- Angry Birds classic swipe menu
- Building an image gallery/slider app
- Implementing the layout
- Coding the PagerAdapter class
- Coding the MainActivity class
- Running the gallery app
- Technical requirements
- Introducing NavigationView
- Examining the Simple Database app
- Insert
- Delete
- Search
- Results
- Creating the empty files for the classes and layouts
- Coding the classes
- Designing the layouts
- Designing content_insert.xml
- Designing content_delete.xml
- Designing content_search.xml
- Designing content_results.xml
- Editing the Navigation Drawer menu
- Adding a holder to the main layout
- Coding the MainActivity.java class
- Technical requirements
- Databases 101
- What is a database?
- What is SQL?
- What is SQLite?
- SQLite example code
- SQLiteOpenHelper and SQLiteDatabase
- Building and executing queries
- Database cursors
- Publishing
- Make an app!
- Keep learning
- Keep reading
- GitHub
- Stack Overflow
- Android user forums
- Higher-level study
- Packt is searching for authors like you
- Leave a review - let other readers know what you think
Show and hide more
Product information
- Title: Android Programming for Beginners - Third Edition
- Author(s): John Horton
- Release date: April 2021
- Publisher(s): Packt Publishing
- ISBN: 9781800563438