Android Studio 4.0 Development Essentials - Java Edition

Book description

Explore Android Studio 4.0 and update your skills to build modern applications in Java

Key Features

  • Set up your Android development and testing environments
  • Create user interfaces with Android Studio Editor, XML, and Java
  • Explore the essential elements of Android Jetpack

Book Description

Android rolls out frequent updates to meet the demands of the dynamic mobile market and to enable its developer community to lead advancements in application development. This book focuses on the updated features of Android Studio (the fully integrated development environment launched by Google) to build reliable Android applications using Java.

The book starts by outlining the steps necessary to set up an Android development and testing environment. You'll then learn how to create user interfaces with the help of Android Studio Layout Editor, XML files, and by writing the code in Java. The book introduces you to Android architecture components and advanced topics such as intents, touchscreen handling, gesture recognition, multi-window support integration, and biometric authentication, and lets you explore key features of Android Studio 4.0, including the layout editor, direct reply notifications, and dynamic delivery. You'll also cover Android Jetpack in detail and create a sample app project using the ViewModel component. Finally, you'll upload your app to the Google Play Console and handle the build process with Gradle.

By the end of this book, you'll have gained the skills necessary to develop applications using Android Studio 4.0 and Java.

What you will learn

  • Design impressive UI for Android application using Android Studio Editor and Java
  • Understand how Android Jetpack can help you reduce the amount of code
  • Explore unique ways to handle single-touch and multi-touch events
  • Trigger local and remote notifications on the device
  • Integrate biometric authentication into an Android app
  • Create, test, and upload an Android app bundle on Google Play Store

Who this book is for

This book is for application developers and Java programmers who want to explore Android Studio 4.0 to create powerful Android applications. A basic understanding of Java and the Android SDK will be helpful.

Table of contents

  1. 1. Introduction
    1. 1.1 Downloading the Code Samples
    2. 1.2 Feedback
    3. 1.3 Errata
  2. 2. Setting up an Android Studio Development Environment
    1. 2.1 System Requirements
    2. 2.2 Downloading the Android Studio Package
    3. 2.3 Installing Android Studio
      1. 2.3.1 Installation on Windows
      2. 2.3.2 Installation on macOS
      3. 2.3.3 Installation on Linux
    4. 2.4 The Android Studio Setup Wizard
    5. 2.5 Installing Additional Android SDK Packages
    6. 2.6 Making the Android SDK Tools Command-line Accessible
      1. 2.6.1 Windows 7
      2. 2.6.2 Windows 8.1
      3. 2.6.3 Windows 10
      4. 2.6.4 Linux
      5. 2.6.5 macOS
    7. 2.7 Android Studio Memory Management
    8. 2.8 Updating Android Studio and the SDK
    9. 2.9 Summary
  3. 3. Creating an Example Android App in Android Studio
    1. 3.1 About the Project
    2. 3.2 Creating a New Android Project
    3. 3.3 Creating an Activity
    4. 3.4 Defining the Project and SDK Settings
    5. 3.5 Modifying the Example Application
    6. 3.6 Modifying the User Interface
    7. 3.7 Reviewing the Layout and Resource Files
    8. 3.8 Adding Interaction
    9. 3.9 Summary
  4. 4. Creating an Android Virtual Device (AVD) in Android Studio
    1. 4.1 About Android Virtual Devices
    2. 4.2 Creating a New AVD
    3. 4.3 Starting the Emulator
    4. 4.4 Running the Application in the AVD
    5. 4.5 Stopping a Running Application
    6. 4.6 Supporting Dark Theme
    7. 4.7 AVD Command-line Creation
    8. 4.8 Android Virtual Device Configuration Files
    9. 4.9 Moving and Renaming an Android Virtual Device
    10. 4.10 Summary
  5. 5. Using and Configuring the Android Studio AVD Emulator
    1. 5.1 The Emulator Environment
    2. 5.2 The Emulator Toolbar Options
    3. 5.3 Working in Zoom Mode
    4. 5.4 Resizing the Emulator Window
    5. 5.5 Extended Control Options
      1. 5.5.1 Location
      2. 5.5.2 Displays
      3. 5.5.3 Cellular
      4. 5.5.4 Camera
      5. 5.5.5 Battery
      6. 5.5.6 Phone
      7. 5.5.7 Directional Pad
      8. 5.5.8 Microphone
      9. 5.5.9 Fingerprint
      10. 5.5.10 Virtual Sensors
      11. 5.5.11 Snapshots
      12. 5.5.12 Record and Playback
      13. 5.5.13 Google Play
      14. 5.5.14 Settings
      15. 5.5.15 Help
    6. 5.6 Working with Snapshots
    7. 5.7 Configuring Fingerprint Emulation
    8. 5.8 Summary
  6. 6. A Tour of the Android Studio User Interface
    1. 6.1 The Welcome Screen
    2. 6.2 The Main Window
    3. 6.3 The Tool Windows
    4. 6.4 Android Studio Keyboard Shortcuts
    5. 6.5 Switcher and Recent Files Navigation
    6. 6.6 Changing the Android Studio Theme
    7. 6.7 Summary
  7. 7. Testing Android Studio Apps on a Physical Android Device
    1. 7.1 An Overview of the Android Debug Bridge (ADB)
    2. 7.2 Enabling ADB on Android based Devices
      1. 7.2.1 macOS ADB Configuration
      2. 7.2.2 Windows ADB Configuration
      3. 7.2.3 Linux adb Configuration
    3. 7.3 Testing the adb Connection
    4. 7.4 Summary
  8. 8. The Basics of the Android Studio Code Editor
    1. 8.1 The Android Studio Editor
    2. 8.2 Splitting the Editor Window
    3. 8.3 Code Completion
    4. 8.4 Statement Completion
    5. 8.5 Parameter Information
    6. 8.6 Parameter Name Hints
    7. 8.7 Code Generation
    8. 8.8 Code Folding
    9. 8.9 Quick Documentation Lookup
    10. 8.10 Code Reformatting
    11. 8.11 Finding Sample Code
    12. 8.12 Live Templates
    13. 8.13 Summary
  9. 9. An Overview of the Android Architecture
    1. 9.1 The Android Software Stack
    2. 9.2 The Linux Kernel
    3. 9.3 Android Runtime – ART
    4. 9.4 Android Libraries
      1. 9.4.1 C/C++ Libraries
    5. 9.5 Application Framework
    6. 9.6 Applications
    7. 9.7 Summary
  10. 10. The Anatomy of an Android Application
    1. 10.1 Android Activities
    2. 10.2 Android Fragments
    3. 10.3 Android Intents
    4. 10.4 Broadcast Intents
    5. 10.5 Broadcast Receivers
    6. 10.6 Android Services
    7. 10.7 Content Providers
    8. 10.8 The Application Manifest
    9. 10.9 Application Resources
    10. 10.10 Application Context
    11. 10.11 Summary
  11. 11. An Overview of Android View Binding
    1. 11.1 Find View by ID
    2. 11.2 View Bindings
    3. 11.3 Converting the AndroidSample Project
    4. 11.4 Enabling View Binding
    5. 11.5 Using View Bindings
    6. 11.6 Choosing an Option
    7. 11.7 Summary
  12. 12. Understanding Android Application and Activity Lifecycles
    1. 12.1 Android Applications and Resource Management
    2. 12.2 Android Process States
      1. 12.2.1 Foreground Process
      2. 12.2.2 Visible Process
      3. 12.2.3 Service Process
      4. 12.2.4 Background Process
      5. 12.2.5 Empty Process
    3. 12.3 Inter-Process Dependencies
    4. 12.4 The Activity Lifecycle
    5. 12.5 The Activity Stack
    6. 12.6 Activity States
    7. 12.7 Configuration Changes
    8. 12.8 Handling State Change
    9. 12.9 Summary
  13. 13. Handling Android Activity State Changes
    1. 13.1 New vs. Old Lifecycle Techniques
    2. 13.2 The Activity and Fragment Classes
    3. 13.3 Dynamic State vs. Persistent State
    4. 13.4 The Android Lifecycle Methods
    5. 13.5 Lifetimes
    6. 13.6 Foldable Devices and Multi-Resume
    7. 13.7 Disabling Configuration Change Restarts
    8. 13.8 Lifecycle Method Limitations
    9. 13.9 Summary
  14. 14. Android Activity State Changes by Example
    1. 14.1 Creating the State Change Example Project
    2. 14.2 Designing the User Interface
    3. 14.3 Overriding the Activity Lifecycle Methods
    4. 14.4 Filtering the Logcat Panel
    5. 14.5 Running the Application
    6. 14.6 Experimenting with the Activity
    7. 14.7 Summary
  15. 15. Saving and Restoring the State of an Android Activity
    1. 15.1 Saving Dynamic State
    2. 15.2 Default Saving of User Interface State
    3. 15.3 The Bundle Class
    4. 15.4 Saving the State
    5. 15.5 Restoring the State
    6. 15.6 Testing the Application
    7. 15.7 Summary
  16. 16. Understanding Android Views, View Groups and Layouts
    1. 16.1 Designing for Different Android Devices
    2. 16.2 Views and View Groups
    3. 16.3 Android Layout Managers
    4. 16.4 The View Hierarchy
    5. 16.5 Creating User Interfaces
    6. 16.6 Summary
  17. 17. A Guide to the Android Studio Layout Editor Tool
    1. 17.1 Basic vs. Empty Activity Templates
    2. 17.2 The Android Studio Layout Editor
    3. 17.3 Design Mode
    4. 17.4 The Palette
    5. 17.5 Design Mode and Layout Views
    6. 17.6 Code Mode
    7. 17.7 Split Mode
    8. 17.8 Setting Attributes
    9. 17.9 Converting Views
    10. 17.10 Displaying Sample Data
    11. 17.11 Creating a Custom Device Definition
    12. 17.12 Changing the Current Device
    13. 17.13 Layout Validation (Multi Preview)
    14. 17.14 Summary
  18. 18. A Guide to the Android ConstraintLayout
    1. 18.1 How ConstraintLayout Works
      1. 18.1.1 Constraints
      2. 18.1.2 Margins
      3. 18.1.3 Opposing Constraints
      4. 18.1.4 Constraint Bias
      5. 18.1.5 Chains
      6. 18.1.6 Chain Styles
    2. 18.2 Baseline Alignment
    3. 18.3 Working with Guidelines
    4. 18.4 Configuring Widget Dimensions
    5. 18.5 Working with Barriers
    6. 18.6 Ratios
    7. 18.7 ConstraintLayout Advantages
    8. 18.8 ConstraintLayout Availability
    9. 18.9 Summary
  19. 19. A Guide to using ConstraintLayout in Android Studio
    1. 19.1 Design and Layout Views
    2. 19.2 Autoconnect Mode
    3. 19.3 Inference Mode
    4. 19.4 Manipulating Constraints Manually
    5. 19.5 Adding Constraints in the Inspector
    6. 19.6 Viewing Constraints in the Attributes Window
    7. 19.7 Deleting Constraints
    8. 19.8 Adjusting Constraint Bias
    9. 19.9 Understanding ConstraintLayout Margins
    10. 19.10 The Importance of Opposing Constraints and Bias
    11. 19.11 Configuring Widget Dimensions
    12. 19.12 Adding Guidelines
    13. 19.13 Adding Barriers
    14. 19.14 Widget Group Alignment and Distribution
    15. 19.15 Converting other Layouts to ConstraintLayout
    16. 19.16 Summary
  20. 20. Working with ConstraintLayout Chains and Ratios in Android Studio
    1. 20.1 Creating a Chain
    2. 20.2 Changing the Chain Style
    3. 20.3 Spread Inside Chain Style
    4. 20.4 Packed Chain Style
    5. 20.5 Packed Chain Style with Bias
    6. 20.6 Weighted Chain
    7. 20.7 Working with Ratios
    8. 20.8 Summary
  21. 21. An Android Studio Layout Editor ConstraintLayout Tutorial
    1. 21.1 An Android Studio Layout Editor Tool Example
    2. 21.2 Creating a New Activity
    3. 21.3 Preparing the Layout Editor Environment
    4. 21.4 Adding the Widgets to the User Interface
    5. 21.5 Adding the Constraints
    6. 21.6 Testing the Layout
    7. 21.7 Using the Layout Inspector
    8. 21.8 Summary
  22. 22. Manual XML Layout Design in Android Studio
    1. 22.1 Manually Creating an XML Layout
    2. 22.2 Manual XML vs. Visual Layout Design
    3. 22.3 Summary
  23. 23. Managing Constraints using Constraint Sets
    1. 23.1 Java Code vs. XML Layout Files
    2. 23.2 Creating Views
    3. 23.3 View Attributes
    4. 23.4 Constraint Sets
      1. 23.4.1 Establishing Connections
      2. 23.4.2 Applying Constraints to a Layout
      3. 23.4.3 Parent Constraint Connections
      4. 23.4.4 Sizing Constraints
      5. 23.4.5 Constraint Bias
      6. 23.4.6 Alignment Constraints
      7. 23.4.7 Copying and Applying Constraint Sets
      8. 23.4.8 ConstraintLayout Chains
      9. 23.4.9 Guidelines
      10. 23.4.10 Removing Constraints
      11. 23.4.11 Scaling
      12. 23.4.12 Rotation
    5. 23.5 Summary
  24. 24. An Android ConstraintSet Tutorial
    1. 24.1 Creating the Example Project in Android Studio
    2. 24.2 Adding Views to an Activity
    3. 24.3 Setting View Attributes
    4. 24.4 Creating View IDs
    5. 24.5 Configuring the Constraint Set
    6. 24.6 Adding the EditText View
    7. 24.7 Converting Density Independent Pixels (dp) to Pixels (px)
    8. 24.8 Summary
  25. 25. A Guide to using Apply Changes in Android Studio
    1. 25.1 Introducing Apply Changes
    2. 25.2 Understanding Apply Changes Options
    3. 25.3 Using Apply Changes
    4. 25.4 Configuring Apply Changes Fallback Settings
    5. 25.5 An Apply Changes Tutorial
    6. 25.6 Using Apply Code Changes
    7. 25.7 Using Apply Changes and Restart Activity
    8. 25.8 Using Run App
    9. 25.9 Summary
  26. 26. An Overview and Example of Android Event Handling
    1. 26.1 Understanding Android Events
    2. 26.2 Using the android:onClick Resource
    3. 26.3 Event Listeners and Callback Methods
    4. 26.4 An Event Handling Example
    5. 26.5 Designing the User Interface
    6. 26.6 The Event Listener and Callback Method
    7. 26.7 Consuming Events
    8. 26.8 Summary
  27. 27. Android Touch and Multi-touch Event Handling
    1. 27.1 Intercepting Touch Events
    2. 27.2 The MotionEvent Object
    3. 27.3 Understanding Touch Actions
    4. 27.4 Handling Multiple Touches
    5. 27.5 An Example Multi-Touch Application
    6. 27.6 Designing the Activity User Interface
    7. 27.7 Implementing the Touch Event Listener
    8. 27.8 Running the Example Application
    9. 27.9 Summary
  28. 28. Detecting Common Gestures using the Android Gesture Detector Class
    1. 28.1 Implementing Common Gesture Detection
    2. 28.2 Creating an Example Gesture Detection Project
    3. 28.3 Implementing the Listener Class
    4. 28.4 Creating the GestureDetectorCompat Instance
    5. 28.5 Implementing the onTouchEvent() Method
    6. 28.6 Testing the Application
    7. 28.7 Summary
  29. 29. Implementing Custom Gesture and Pinch Recognition on Android
    1. 29.1 The Android Gesture Builder Application
    2. 29.2 The GestureOverlayView Class
    3. 29.3 Detecting Gestures
    4. 29.4 Identifying Specific Gestures
    5. 29.5 Installing and Running the Gesture Builder Application
    6. 29.6 Creating a Gestures File
    7. 29.7 Creating the Example Project
    8. 29.8 Extracting the Gestures File from the SD Card
    9. 29.9 Adding the Gestures File to the Project
    10. 29.10 Designing the User Interface
    11. 29.11 Loading the Gestures File
    12. 29.12 Registering the Event Listener
    13. 29.13 Implementing the onGesturePerformed Method
    14. 29.14 Testing the Application
    15. 29.15 Configuring the GestureOverlayView
    16. 29.16 Intercepting Gestures
    17. 29.17 Detecting Pinch Gestures
    18. 29.18 A Pinch Gesture Example Project
    19. 29.19 Summary
  30. 30. An Introduction to Android Fragments
    1. 30.1 What is a Fragment?
    2. 30.2 Creating a Fragment
    3. 30.3 Adding a Fragment to an Activity using the Layout XML File
    4. 30.4 Adding and Managing Fragments in Code
    5. 30.5 Handling Fragment Events
    6. 30.6 Implementing Fragment Communication
    7. 30.7 Summary
  31. 31. Using Fragments in Android Studio - An Example
    1. 31.1 About the Example Fragment Application
    2. 31.2 Creating the Example Project
    3. 31.3 Creating the First Fragment Layout
    4. 31.4 Adding the Second Fragment
    5. 31.5 Adding the Fragments to the Activity
    6. 31.6 Making the Toolbar Fragment Talk to the Activity
    7. 31.7 Making the Activity Talk to the Text Fragment
    8. 31.8 Testing the Application
    9. 31.9 Summary
  32. 32. Modern Android App Architecture with Jetpack
    1. 32.1 What is Android Jetpack?
    2. 32.2 The “Old” Architecture
    3. 32.3 Modern Android Architecture
    4. 32.4 The ViewModel Component
    5. 32.5 The LiveData Component
    6. 32.6 ViewModel Saved State
    7. 32.7 LiveData and Data Binding
    8. 32.8 Android Lifecycles
    9. 32.9 Repository Modules
    10. 32.10 Summary
  33. 33. An Android Jetpack ViewModel Tutorial
    1. 33.1 About the Project
    2. 33.2 Creating the ViewModel Example Project
    3. 33.3 Reviewing the Project
      1. 33.3.1 The Main Activity
      2. 33.3.2 The Content Fragment
      3. 33.3.3 The ViewModel
    4. 33.4 Designing the Fragment Layout
    5. 33.5 Implementing the View Model
    6. 33.6 Associating the Fragment with the View Model
    7. 33.7 Modifying the Fragment
    8. 33.8 Accessing the ViewModel Data
    9. 33.9 Testing the Project
    10. 33.10 Summary
  34. 34. An Android Jetpack LiveData Tutorial
    1. 34.1 LiveData - A Recap
    2. 34.2 Adding LiveData to the ViewModel
    3. 34.3 Implementing the Observer
    4. 34.4 Summary
  35. 35. An Overview of Android Jetpack Data Binding
    1. 35.1 An Overview of Data Binding
    2. 35.2 The Key Components of Data Binding
      1. 35.2.1 The Project Build Configuration
      2. 35.2.2 The Data Binding Layout File
      3. 35.2.3 The Layout File Data Element
      4. 35.2.4 The Binding Classes
      5. 35.2.5 Data Binding Variable Configuration
      6. 35.2.6 Binding Expressions (One-Way)
      7. 35.2.7 Binding Expressions (Two-Way)
      8. 35.2.8 Event and Listener Bindings
    3. 35.3 Summary
  36. 36. An Android Jetpack Data Binding Tutorial
    1. 36.1 Removing the Redundant Code
    2. 36.2 Enabling Data Binding
    3. 36.3 Adding the Layout Element
    4. 36.4 Adding the Data Element to Layout File
    5. 36.5 Working with the Binding Class
    6. 36.6 Assigning the ViewModel Instance to the Data Binding Variable
    7. 36.7 Adding Binding Expressions
    8. 36.8 Adding the Conversion Method
    9. 36.9 Adding a Listener Binding
    10. 36.10 Testing the App
    11. 36.11 Summary
  37. 37. An Android ViewModel Saved State Tutorial
    1. 37.1 Understanding ViewModel State Saving
    2. 37.2 Implementing ViewModel State Saving
    3. 37.3 Saving and Restoring State
    4. 37.4 Adding Saved State Support to the ViewModelDemo Project
    5. 37.5 Summary
  38. 38. Working with Android Lifecycle-Aware Components
    1. 38.1 Lifecycle Awareness
    2. 38.2 Lifecycle Owners
    3. 38.3 Lifecycle Observers
    4. 38.4 Lifecycle States and Events
    5. 38.5 Summary
  39. 39. An Android Jetpack Lifecycle Awareness Tutorial
    1. 39.1 Creating the Example Lifecycle Project
    2. 39.2 Creating a Lifecycle Observer
    3. 39.3 Adding the Observer
    4. 39.4 Testing the Observer
    5. 39.5 Creating a Lifecycle Owner
    6. 39.6 Testing the Custom Lifecycle Owner
    7. 39.7 Summary
  40. 40. An Overview of the Navigation Architecture Component
    1. 40.1 Understanding Navigation
    2. 40.2 Declaring a Navigation Host
    3. 40.3 The Navigation Graph
    4. 40.4 Accessing the Navigation Controller
    5. 40.5 Triggering a Navigation Action
    6. 40.6 Passing Arguments
    7. 40.7 Summary
  41. 41. An Android Jetpack Navigation Component Tutorial
    1. 41.1 Creating the NavigationDemo Project
    2. 41.2 Adding Navigation to the Build Configuration
    3. 41.3 Creating the Navigation Graph Resource File
    4. 41.4 Declaring a Navigation Host
    5. 41.5 Adding Navigation Destinations
    6. 41.6 Designing the Destination Fragment Layouts
    7. 41.7 Adding an Action to the Navigation Graph
    8. 41.8 Implement the OnFragmentInteractionListener
    9. 41.9 Triggering the Action
    10. 41.10 Passing Data Using Safeargs
    11. 41.11 Summary
  42. 42. Creating and Managing Overflow Menus on Android
    1. 42.1 The Overflow Menu
    2. 42.2 Creating an Overflow Menu
    3. 42.3 Displaying an Overflow Menu
    4. 42.4 Responding to Menu Item Selections
    5. 42.5 Creating Checkable Item Groups
    6. 42.6 Menus and the Android Studio Menu Editor
    7. 42.7 Creating the Example Project
    8. 42.8 Designing the Menu
    9. 42.9 Modifying the onOptionsItemSelected() Method
    10. 42.10 Testing the Application
    11. 42.11 Summary
  43. 43. An Introduction to MotionLayout
    1. 43.1 An Overview of MotionLayout
    2. 43.2 MotionLayout
    3. 43.3 MotionScene
    4. 43.4 Configuring ConstraintSets
    5. 43.5 Custom Attributes
    6. 43.6 Triggering an Animation
    7. 43.7 Arc Motion
    8. 43.8 Keyframes
      1. 43.8.1 Attribute Keyframes
      2. 43.8.2 Position Keyframes
    9. 43.9 Time Linearity
    10. 43.10 KeyTrigger
    11. 43.11 Cycle and Time Cycle Keyframes
    12. 43.12 Starting an Animation from Code
    13. 43.13 Summary
  44. 44. An Android MotionLayout Editor Tutorial
    1. 44.1 Creating the MotionLayoutDemo Project
    2. 44.2 ConstraintLayout to MotionLayout Conversion
    3. 44.3 Configuring Start and End Constraints
    4. 44.4 Previewing the MotionLayout Animation
    5. 44.5 Adding an OnClick Gesture
    6. 44.6 Adding an Attribute Keyframe to the Transition
    7. 44.7 Adding a CustomAttribute to a Transition
    8. 44.8 Adding Position Keyframes
    9. 44.9 Summary
  45. 45. A MotionLayout KeyCycle Tutorial
    1. 45.1 An Overview of Cycle Keyframes
    2. 45.2 Using the Cycle Editor
    3. 45.3 Creating the KeyCycleDemo Project
    4. 45.4 Configuring the Start and End Constraints
    5. 45.5 Creating the Cycles
    6. 45.6 Previewing the Animation
    7. 45.7 Adding the KeyFrameSet to the MotionScene
    8. 45.8 Summary
  46. 46. Working with the Floating Action Button and Snackbar
    1. 46.1 The Material Design
    2. 46.2 The Design Library
    3. 46.3 The Floating Action Button (FAB)
    4. 46.4 The Snackbar
    5. 46.5 Creating the Example Project
    6. 46.6 Reviewing the Project
    7. 46.7 Removing Navigation Features
    8. 46.8 Changing the Floating Action Button
    9. 46.9 Adding the ListView to the Content Layout
    10. 46.10 Adding Items to the ListView
    11. 46.11 Adding an Action to the Snackbar
    12. 46.12 Summary
  47. 47. Creating a Tabbed Interface using the TabLayout Component
    1. 47.1 An Introduction to the ViewPager
    2. 47.2 An Overview of the TabLayout Component
    3. 47.3 Creating the TabLayoutDemo Project
    4. 47.4 Creating the First Fragment
    5. 47.5 Duplicating the Fragments
    6. 47.6 Adding the TabLayout and ViewPager
    7. 47.7 Creating the Pager Adapter
    8. 47.8 Performing the Initialization Tasks
    9. 47.9 Testing the Application
    10. 47.10 Customizing the TabLayout
    11. 47.11 Displaying Icon Tab Items
    12. 47.12 Summary
  48. 48. Working with the RecyclerView and CardView Widgets
    1. 48.1 An Overview of the RecyclerView
    2. 48.2 An Overview of the CardView
    3. 48.3 Summary
  49. 49. An Android RecyclerView and CardView Tutorial
    1. 49.1 Creating the CardDemo Project
    2. 49.2 Modifying the Basic Activity Project
    3. 49.3 Designing the CardView Layout
    4. 49.4 Adding the RecyclerView
    5. 49.5 Creating the RecyclerView Adapter
    6. 49.6 Adding the Image Files
    7. 49.7 Initializing the RecyclerView Component
    8. 49.8 Testing the Application
    9. 49.9 Responding to Card Selections
    10. 49.10 Summary
  50. 50. A Layout Editor Sample Data Tutorial
    1. 50.1 Adding Sample Data to a Project
    2. 50.2 Using Custom Sample Data
    3. 50.3 Summary
  51. 51. Working with the AppBar and Collapsing Toolbar Layouts
    1. 51.1 The Anatomy of an AppBar
    2. 51.2 The Example Project
    3. 51.3 Coordinating the RecyclerView and Toolbar
    4. 51.4 Introducing the Collapsing Toolbar Layout
    5. 51.5 Changing the Title and Scrim Color
    6. 51.6 Summary
  52. 52. An Android Studio Master/Detail Flow Tutorial
    1. 52.1 The Master/Detail Flow
    2. 52.2 Creating a Master/Detail Flow Activity
    3. 52.3 The Anatomy of the Master/Detail Flow Template
    4. 52.4 Modifying the Master/Detail Flow Template
    5. 52.5 Changing the Content Model
    6. 52.6 Changing the Detail Pane
    7. 52.7 Modifying the WebsiteDetailFragment Class
    8. 52.8 Modifying the WebsiteListActivity Class
    9. 52.9 Adding Manifest Permissions
    10. 52.10 Running the Application
    11. 52.11 Summary
  53. 53. An Overview of Android Intents
    1. 53.1 An Overview of Intents
    2. 53.2 Explicit Intents
    3. 53.3 Returning Data from an Activity
    4. 53.4 Implicit Intents
    5. 53.5 Using Intent Filters
    6. 53.6 Checking Intent Availability
    7. 53.7 Summary
  54. 54. Android Explicit Intents – A Worked Example
    1. 54.1 Creating the Explicit Intent Example Application
    2. 54.2 Designing the User Interface Layout for MainActivity
    3. 54.3 Creating the Second Activity Class
    4. 54.4 Designing the User Interface Layout for ActivityB
    5. 54.5 Reviewing the Application Manifest File
    6. 54.6 Creating the Intent
    7. 54.7 Extracting Intent Data
    8. 54.8 Launching ActivityB as a Sub-Activity
    9. 54.9 Returning Data from a Sub-Activity
    10. 54.10 Testing the Application
    11. 54.11 Summary
  55. 55. Android Implicit Intents – A Worked Example
    1. 55.1 Creating the Android Studio Implicit Intent Example Project
    2. 55.2 Designing the User Interface
    3. 55.3 Creating the Implicit Intent
    4. 55.4 Adding a Second Matching Activity
    5. 55.5 Adding the Web View to the UI
    6. 55.6 Obtaining the Intent URL
    7. 55.7 Modifying the MyWebView Project Manifest File
    8. 55.8 Installing the MyWebView Package on a Device
    9. 55.9 Testing the Application
    10. 55.10 Summary
  56. 56. Android Broadcast Intents and Broadcast Receivers
    1. 56.1 An Overview of Broadcast Intents
    2. 56.2 An Overview of Broadcast Receivers
    3. 56.3 Obtaining Results from a Broadcast
    4. 56.4 Sticky Broadcast Intents
    5. 56.5 The Broadcast Intent Example
    6. 56.6 Creating the Example Application
    7. 56.7 Creating and Sending the Broadcast Intent
    8. 56.8 Creating the Broadcast Receiver
    9. 56.9 Registering the Broadcast Receiver
    10. 56.10 Testing the Broadcast Example
    11. 56.11 Listening for System Broadcasts
    12. 56.12 Summary
  57. 57. A Basic Overview of Threads and AsyncTasks
    1. 57.1 An Overview of Threads
    2. 57.2 The Application Main Thread
    3. 57.3 Thread Handlers
    4. 57.4 A Basic AsyncTask Example
    5. 57.5 Subclassing AsyncTask
    6. 57.6 Testing the App
    7. 57.7 Canceling a Task
    8. 57.8 Summary
  58. 58. An Overview of Android Started and Bound Services
    1. 58.1 Started Services
    2. 58.2 Intent Service
    3. 58.3 Bound Service
    4. 58.4 The Anatomy of a Service
    5. 58.5 Controlling Destroyed Service Restart Options
    6. 58.6 Declaring a Service in the Manifest File
    7. 58.7 Starting a Service Running on System Startup
    8. 58.8 Summary
  59. 59. Implementing an Android Started Service – A Worked Example
    1. 59.1 Creating the Example Project
    2. 59.2 Creating the Service Class
    3. 59.3 Adding the Service to the Manifest File
    4. 59.4 Starting the Service
    5. 59.5 Testing the IntentService Example
    6. 59.6 Using the Service Class
    7. 59.7 Creating the New Service
    8. 59.8 Modifying the User Interface
    9. 59.9 Running the Application
    10. 59.10 Creating an AsyncTask for Service Tasks
    11. 59.11 Summary
  60. 60. Android Local Bound Services – A Worked Example
    1. 60.1 Understanding Bound Services
    2. 60.2 Bound Service Interaction Options
    3. 60.3 An Android Studio Local Bound Service Example
    4. 60.4 Adding a Bound Service to the Project
    5. 60.5 Implementing the Binder
    6. 60.6 Binding the Client to the Service
    7. 60.7 Completing the Example
    8. 60.8 Testing the Application
    9. 60.9 Summary
  61. 61. Android Remote Bound Services – A Worked Example
    1. 61.1 Client to Remote Service Communication
    2. 61.2 Creating the Example Application
    3. 61.3 Designing the User Interface
    4. 61.4 Implementing the Remote Bound Service
    5. 61.5 Configuring a Remote Service in the Manifest File
    6. 61.6 Launching and Binding to the Remote Service
    7. 61.7 Sending a Message to the Remote Service
    8. 61.8 Summary
  62. 62. An Android Notifications Tutorial
    1. 62.1 An Overview of Notifications
    2. 62.2 Creating the NotifyDemo Project
    3. 62.3 Designing the User Interface
    4. 62.4 Creating the Second Activity
    5. 62.5 Creating a Notification Channel
    6. 62.6 Creating and Issuing a Basic Notification
    7. 62.7 Launching an Activity from a Notification
    8. 62.8 Adding Actions to a Notification
    9. 62.9 Bundled Notifications
    10. 62.10 Summary
  63. 63. An Android Direct Reply Notification Tutorial
    1. 63.1 Creating the DirectReply Project
    2. 63.2 Designing the User Interface
    3. 63.3 Creating the Notification Channel
    4. 63.4 Building the RemoteInput Object
    5. 63.5 Creating the PendingIntent
    6. 63.6 Creating the Reply Action
    7. 63.7 Receiving Direct Reply Input
    8. 63.8 Updating the Notification
    9. 63.9 Summary
  64. 64. Foldable Devices and Multi-Window Support
    1. 64.1 Foldables and Multi-Window Support
    2. 64.2 Using a Foldable Emulator
    3. 64.3 Entering Multi-Window Mode
    4. 64.4 Enabling and using Freeform Support
    5. 64.5 Checking for Freeform Support
    6. 64.6 Enabling Multi-Window Support in an App
    7. 64.7 Specifying Multi-Window Attributes
    8. 64.8 Detecting Multi-Window Mode in an Activity
    9. 64.9 Receiving Multi-Window Notifications
    10. 64.10 Launching an Activity in Multi-Window Mode
    11. 64.11 Configuring Freeform Activity Size and Position
    12. 64.12 Summary
  65. 65. An Overview of Android SQLite Databases
    1. 65.1 Understanding Database Tables
    2. 65.2 Introducing Database Schema
    3. 65.3 Columns and Data Types
    4. 65.4 Database Rows
    5. 65.5 Introducing Primary Keys
    6. 65.6 What is SQLite?
    7. 65.7 Structured Query Language (SQL)
    8. 65.8 Trying SQLite on an Android Virtual Device (AVD)
    9. 65.9 The Android Room Persistence Library
    10. 65.10 Summary
  66. 66. The Android Room Persistence Library
    1. 66.1 Revisiting Modern App Architecture
    2. 66.2 Key Elements of Room Database Persistence
      1. 66.2.1 Repository
      2. 66.2.2 Room Database
      3. 66.2.3 Data Access Object (DAO)
      4. 66.2.4 Entities
      5. 66.2.5 SQLite Database
    3. 66.3 Understanding Entities
    4. 66.4 Data Access Objects
    5. 66.5 The Room Database
    6. 66.6 The Repository
    7. 66.7 In-Memory Databases
    8. 66.8 Summary
  67. 67. An Android TableLayout and TableRow Tutorial
    1. 67.1 The TableLayout and TableRow Layout Views
    2. 67.2 Creating the Room Database Project
    3. 67.3 Converting to a LinearLayout
    4. 67.4 Adding the TableLayout to the User Interface
    5. 67.5 Configuring the TableRows
    6. 67.6 Adding the Button Bar to the Layout
    7. 67.7 Adding the RecyclerView
    8. 67.8 Adjusting the Layout Margins
    9. 67.9 Summary
  68. 68. An Android Room Database and Repository Tutorial
    1. 68.1 About the RoomDemo Project
    2. 68.2 Modifying the Build Configuration
    3. 68.3 Building the Entity
    4. 68.4 Creating the Data Access Object
    5. 68.5 Adding the Room Database
    6. 68.6 Adding the Repository
    7. 68.7 Modifying the ViewModel
    8. 68.8 Creating the Product Item Layout
    9. 68.9 Adding the RecyclerView Adapter
    10. 68.10 Preparing the Main Fragment
    11. 68.11 Adding the Button Listeners
    12. 68.12 Adding LiveData Observers
    13. 68.13 Initializing the RecyclerView
    14. 68.14 Testing the RoomDemo App
    15. 68.15 Summary
  69. 69. Accessing Cloud Storage using the Android Storage Access Framework
    1. 69.1 The Storage Access Framework
    2. 69.2 Working with the Storage Access Framework
    3. 69.3 Filtering Picker File Listings
    4. 69.4 Handling Intent Results
    5. 69.5 Reading the Content of a File
    6. 69.6 Writing Content to a File
    7. 69.7 Deleting a File
    8. 69.8 Gaining Persistent Access to a File
    9. 69.9 Summary
  70. 70. An Android Storage Access Framework Example
    1. 70.1 About the Storage Access Framework Example
    2. 70.2 Creating the Storage Access Framework Example
    3. 70.3 Designing the User Interface
    4. 70.4 Declaring Request Codes
    5. 70.5 Creating a New Storage File
    6. 70.6 The onActivityResult() Method
    7. 70.7 Saving to a Storage File
    8. 70.8 Opening and Reading a Storage File
    9. 70.9 Testing the Storage Access Application
    10. 70.10 Summary
  71. 71. Video Playback on Android using the VideoView and MediaController Classes
    1. 71.1 Introducing the Android VideoView Class
    2. 71.2 Introducing the Android MediaController Class
    3. 71.3 Creating the Video Playback Example
    4. 71.4 Designing the VideoPlayer Layout
    5. 71.5 Downloading the Video File
    6. 71.6 Configuring the VideoView
    7. 71.7 Adding the MediaController to the Video View
    8. 71.8 Setting up the onPreparedListener
    9. 71.9 Summary
  72. 72. Android Picture-in-Picture Mode
    1. 72.1 Picture-in-Picture Features
    2. 72.2 Enabling Picture-in-Picture Mode
    3. 72.3 Configuring Picture-in-Picture Parameters
    4. 72.4 Entering Picture-in-Picture Mode
    5. 72.5 Detecting Picture-in-Picture Mode Changes
    6. 72.6 Adding Picture-in-Picture Actions
    7. 72.7 Summary
  73. 73. An Android Picture-in-Picture Tutorial
    1. 73.1 Adding Picture-in-Picture Support to the Manifest
    2. 73.2 Adding a Picture-in-Picture Button
    3. 73.3 Entering Picture-in-Picture Mode
    4. 73.4 Detecting Picture-in-Picture Mode Changes
    5. 73.5 Adding a Broadcast Receiver
    6. 73.6 Adding the PiP Action
    7. 73.7 Testing the Picture-in-Picture Action
    8. 73.8 Summary
  74. 74. Making Runtime Permission Requests in Android
    1. 74.1 Understanding Normal and Dangerous Permissions
    2. 74.2 Creating the Permissions Example Project
    3. 74.3 Checking for a Permission
    4. 74.4 Requesting Permission at Runtime
    5. 74.5 Providing a Rationale for the Permission Request
    6. 74.6 Testing the Permissions App
    7. 74.7 Summary
  75. 75. Android Audio Recording and Playback using MediaPlayer and MediaRecorder
    1. 75.1 Playing Audio
    2. 75.2 Recording Audio and Video using the MediaRecorder Class
    3. 75.3 About the Example Project
    4. 75.4 Creating the AudioApp Project
    5. 75.5 Designing the User Interface
    6. 75.6 Checking for Microphone Availability
    7. 75.7 Performing the Activity Initialization
    8. 75.8 Implementing the recordAudio() Method
    9. 75.9 Implementing the stopAudio() Method
    10. 75.10 Implementing the playAudio() method
    11. 75.11 Configuring and Requesting Permissions
    12. 75.12 Testing the Application
    13. 75.13 Summary
  76. 76. Working with the Google Maps Android API in Android Studio
    1. 76.1 The Elements of the Google Maps Android API
    2. 76.2 Creating the Google Maps Project
    3. 76.3 Obtaining Your Developer Signature
    4. 76.4 Adding the Apache HTTP Legacy Library Requirement
    5. 76.5 Testing the Application
    6. 76.6 Understanding Geocoding and Reverse Geocoding
    7. 76.7 Adding a Map to an Application
    8. 76.8 Requesting Current Location Permission
    9. 76.9 Displaying the User’s Current Location
    10. 76.10 Changing the Map Type
    11. 76.11 Displaying Map Controls to the User
    12. 76.12 Handling Map Gesture Interaction
      1. 76.12.1 Map Zooming Gestures
      2. 76.12.2 Map Scrolling/Panning Gestures
      3. 76.12.3 Map Tilt Gestures
      4. 76.12.4 Map Rotation Gestures
    13. 76.13 Creating Map Markers
    14. 76.14 Controlling the Map Camera
    15. 76.15 Summary
  77. 77. Printing with the Android Printing Framework
    1. 77.1 The Android Printing Architecture
    2. 77.2 The Print Service Plugins
    3. 77.3 Google Cloud Print
    4. 77.4 Printing to Google Drive
    5. 77.5 Save as PDF
    6. 77.6 Printing from Android Devices
    7. 77.7 Options for Building Print Support into Android Apps
      1. 77.7.1 Image Printing
      2. 77.7.2 Creating and Printing HTML Content
      3. 77.7.3 Printing a Web Page
      4. 77.7.4 Printing a Custom Document
    8. 77.8 Summary
  78. 78. An Android HTML and Web Content Printing Example
    1. 78.1 Creating the HTML Printing Example Application
    2. 78.2 Printing Dynamic HTML Content
    3. 78.3 Creating the Web Page Printing Example
    4. 78.4 Removing the Floating Action Button
    5. 78.5 Removing Navigation Features
    6. 78.6 Designing the User Interface Layout
    7. 78.7 Loading the Web Page into the WebView
    8. 78.8 Adding the Print Menu Option
    9. 78.9 Summary
  79. 79. A Guide to Android Custom Document Printing
    1. 79.1 An Overview of Android Custom Document Printing
      1. 79.1.1 Custom Print Adapters
    2. 79.2 Preparing the Custom Document Printing Project
    3. 79.3 Creating the Custom Print Adapter
    4. 79.4 Implementing the onLayout() Callback Method
    5. 79.5 Implementing the onWrite() Callback Method
    6. 79.6 Checking a Page is in Range
    7. 79.7 Drawing the Content on the Page Canvas
    8. 79.8 Starting the Print Job
    9. 79.9 Testing the Application
    10. 79.10 Summary
  80. 80. An Introduction to Android App Links
    1. 80.1 An Overview of Android App Links
    2. 80.2 App Link Intent Filters
    3. 80.3 Handling App Link Intents
    4. 80.4 Associating the App with a Website
    5. 80.5 Summary
  81. 81. An Android Studio App Links Tutorial
    1. 81.1 About the Example App
    2. 81.2 The Database Schema
    3. 81.3 Loading and Running the Project
    4. 81.4 Adding the URL Mapping
    5. 81.5 Adding the Intent Filter
    6. 81.6 Adding Intent Handling Code
    7. 81.7 Testing the App Link
    8. 81.8 Associating an App Link with a Web Site
    9. 81.9 Summary
  82. 82. A Guide to the Android Studio Profiler
    1. 82.1 Accessing the Android Profiler
    2. 82.2 Enabling Advanced Profiling
    3. 82.3 The Android Profiler Tool Window
    4. 82.4 The Sessions Panel
    5. 82.5 The CPU Profiler
    6. 82.6 Memory Profiler
    7. 82.7 Network Profiler
    8. 82.8 Energy Profiler
    9. 82.9 Summary
  83. 83. An Android Biometric Authentication Tutorial
    1. 83.1 An Overview of Biometric Authentication
    2. 83.2 Creating the Biometric Authentication Project
    3. 83.3 Configuring Device Fingerprint Authentication
    4. 83.4 Adding the Biometric Permission to the Manifest File
    5. 83.5 Designing the User Interface
    6. 83.6 Adding a Toast Convenience Method
    7. 83.7 Checking the Security Settings
    8. 83.8 Configuring the Authentication Callbacks
    9. 83.9 Adding the CancellationSignal
    10. 83.10 Starting the Biometric Prompt
    11. 83.11 Testing the Project
    12. 83.12 Summary
  84. 84. Creating, Testing and Uploading an Android App Bundle
    1. 84.1 The Release Preparation Process
    2. 84.2 Android App Bundles
    3. 84.3 Register for a Google Play Developer Console Account
    4. 84.4 Configuring the App in the Console
    5. 84.5 Enabling Google Play App Signing
    6. 84.6 Creating a Keystore File
    7. 84.7 Creating the Android App Bundle
    8. 84.8 Generating Test APK Files
    9. 84.9 Uploading the App Bundle to the Google Play Developer Console
    10. 84.10 Exploring the App Bundle
    11. 84.11 Managing Testers
    12. 84.12 Uploading New App Bundle Revisions
    13. 84.13 Analyzing the App Bundle File
    14. 84.14 Enabling Google Play Signing for an Existing App
    15. 84.15 Summary
  85. 85. An Overview of Android Dynamic Feature Modules
    1. 85.1 An Overview of Dynamic Feature Modules
    2. 85.2 Dynamic Feature Module Architecture
    3. 85.3 Creating a Dynamic Feature Module
    4. 85.4 Converting an Existing Module for Dynamic Delivery
    5. 85.5 Working with Dynamic Feature Modules
    6. 85.6 Handling Large Dynamic Feature Modules
    7. 85.7 Summary
  86. 86. An Android Studio Dynamic Feature Tutorial
    1. 86.1 Creating the DynamicFeature Project
    2. 86.2 Adding Dynamic Feature Support to the Project
    3. 86.3 Designing the Base Activity User Interface
    4. 86.4 Adding the Dynamic Feature Module
    5. 86.5 Reviewing the Dynamic Feature Module
    6. 86.6 Adding the Dynamic Feature Activity
    7. 86.7 Implementing the launchIntent() Method
    8. 86.8 Uploading the App Bundle for Testing
    9. 86.9 Implementing the installFeature() Method
    10. 86.10 Adding the Update Listener
    11. 86.11 Handling Large Downloads
    12. 86.12 Using Deferred Installation
    13. 86.13 Removing a Dynamic Module
    14. 86.14 Summary
  87. 87. An Overview of Gradle in Android Studio
    1. 87.1 An Overview of Gradle
    2. 87.2 Gradle and Android Studio
      1. 87.2.1 Sensible Defaults
      2. 87.2.2 Dependencies
      3. 87.2.3 Build Variants
      4. 87.2.4 Manifest Entries
      5. 87.2.5 APK Signing
      6. 87.2.6 ProGuard Support
    3. 87.3 The Top-level Gradle Build File
    4. 87.4 Module Level Gradle Build Files
    5. 87.5 Configuring Signing Settings in the Build File
    6. 87.6 Running Gradle Tasks from the Command-line
    7. 87.7 Summary
  88. Index

Product information

  • Title: Android Studio 4.0 Development Essentials - Java Edition
  • Author(s): Neil Smyth
  • Release date: September 2020
  • Publisher(s): Packt Publishing
  • ISBN: 9781800562660