Ted Hagos

Learn Android Studio 4

Efficient Java-Based Android Apps Development

2nd ed.
Ted Hagos
Manila, National Capital Region, Philippines
ISBN 978-1-4842-5936-8e-ISBN 978-1-4842-5937-5
© Ted Hagos 2020
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Distributed to the book trade worldwide by Apress Media, LLC, 1 New York Plaza, New York, NY 10004, U.S.A. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.

For Adrianne and Stephanie.

Introduction

Welcome to Learn Android Studio 4. This book will help you get started in your programming journey with the little green robot. You already bought the book (many thanks to you), so you don’t need to be convinced that programming for the mobile platform offers many opportunities for software developers.

The book is aimed at beginning Android programmers but not wholly new to programming. The book assumes that you have prior programming experience with any of the CFOL (C family of languages, e.g., C, C++, Java, C#, JavaScript). Ideally, you are already a Java programmer trying to get your feet wet in Android; if you’re not, don’t worry. Basic Java programming is covered in the Appendix, and you can refer to that as you try to feel your way into the language.

The book covers two fronts: the fundamentals of Android programming and the use of Android Studio 4. Android programming concepts and the use of the IDE are explained using a combination of graphics and code walk-throughs: there’s plenty of those in the book.

Chapter Overview

Chapter 1 : Android Overview—This chapter introduces Android. It deals with a bit of Android’s history and the technical makeup of its OS.

Chapter 2 : Android Studio—If you haven’t set up your Android environment yet, don’t skip this chapter; it walks you through the setup of Android Studio, whether you’re on macOS, Windows, or Linux. It also introduces the essential parts of the IDE.

Chapter 3 : Project Basics—This chapter introduces the concept and mechanics of an Android project. It walks through creating a project and running a project in an AVD (Android Virtual Device).

Chapter 4 : Android Studio IDE—Android Studio is a full-fledged IDE; it has lots of features and parts. This chapter introduces you to the most common tools and windows of Android Studio.

Chapter 5 : Android Application Overview—What makes up an Android project? What are components? What are Intents? These are some of the questions this chapter addresses. You’ll discover how different an Android app is from a desktop app.

Chapter 6 : Activities and Layouts—We get into the basics of UI building. Activities are the primary means by which the user sees your app. We get to learn how to build these and other UI elements that are in common use.

Chapter 7 : Event Handling—Handling user actions is a very common task in Android programming. This chapter walks you through the basics of listener objects, how to create them, and how to bind them to View elements (like Buttons).

Chapter 8 : Intents—Intents are uniquely Android’s. See how this message-passing mechanism works in Android and how it glues all the other Android components.

Chapter 9 : Fragments—Fragments are a granular way to compose a screen. This chapter walks through the fundamental concepts of Fragments.

Chapter 10 : Navigation—Navigation components are quite new. They are a part of Jetpack. This chapter introduces you to the more modern ways on how to build multiscreen apps.

Chapter 11 : Running in the Background—When you start building nontrivial apps, you will need to read or write from I/O sources, fetch data from the network, and so on. These activities take time, and they need to be run in the background. This chapter is all about that.

Chapter 12 : Debugging—You will often make coding mistakes. This chapter introduces you to the types of errors you may encounter and how to use Android Studio’s debugging features to solve them.

Chapter 13 : Testing—At some point, you have to test your code before you release them. This chapter introduces you to the many kinds of testing you can do to an app. More importantly, it introduces you to unit testing and Espresso testing.

Chapter 14 : Working with Files—You’ll need to save to a text file or read from it; this chapter walks through the basics of file input and output in Android.

Chapter 15 : BroadcastReceivers—One of Android’s foundational components is the BroadcastReceiver; this component lets you build decoupled apps by adopting the publish-subscribe pattern.

Chapter 16 : Jetpack, LiveData, ViewModel, and Room—More goodies from Architecture components. This chapter walks through the basics of how to build components that have lifecycle awareness of other components and how to use Room.

Chapter 17 : Distributing Apps—When you’re ready to distribute your app, you’ll need to sign it and list it in a marketplace like Google Play. This chapter walks you through the steps on how to do it.

Chapter 18 : Short Takes—More Android Studio goodness.

Appendix—The Appendix breezes through the Java language. It deals with some of the basic language concepts you will need to get started in Android programming.

Acknowledgments

To Stephanie and Adrianne, my thanks and my love.

To Mark Powers and Steve Anglin, and to all who made this book possible. Many, many thanks.

Table of Contents
Setup 255
Syntax 257
Methods 263
Casting 271
Unary 278
Arrays 291
Classes 301
Strings 308
Index 319
About the Author
Ted Hagos

is a software developer by trade. At the moment, he’s Chief Technology Officer and Data Protection Officer of RenditionDigital International, a software development company based out of Dublin. He wore many hats in his 20+ years in software development, for example, team lead, project manager, architect, and director for development. He also spent time as a trainer for IBM Advanced Career Education, Ateneo ITI, and Asia Pacific College.

 
About the Technical Reviewer
Jeff Friesen
../images/457413_2_En_BookFrontmatter_Figb_HTML.jpg

is a freelance teacher and software developer with an emphasis on Java. In addition to authoring Java I/O, NIO and NIO.2 (Apress) and Java Threads and the Concurrency Utilities (Apress), Jeff has written numerous articles on Java and other technologies (such as Android) for JavaWorld (www.javaworld.com ), InformIT (www.informit.com ), Java.net , SitePoint (www.sitepoint.com ), and other websites. Jeff can be contacted via his website at JavaJeff.ca or via his LinkedIn profile (www.linkedin.com/in/javajeff ).

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

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