World Headquarters
Jones & Bartlett Learning
5 Wall Street
Burlington, MA 01803
978-443-5000
www.jblearning.com
Jones & Bartlett Learning books and products are available through most bookstores and online booksellers. To contact Jones & Bartlett Learning directly, call 800-832-0034, fax 978-443-8000, or visit our website, www.jblearning.com.
Substantial discounts on bulk quantities of Jones & Bartlett Learning publications are available to corporations, professional associations, and other qualified organizations. For details and specific discount information, contact the special sales department at Jones & Bartlett Learning via the above contact information or send an email to .
Copyright 2018 by Jones & Bartlett Learning, LLC, an Ascend Learning Company
All rights reserved. No part of the material protected by this copyright may be reproduced or utilized in any form, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, without written permission from the copyright owner.
The content, statements, views, and opinions herein are the sole expression of the respective authors and not that of Jones & Bartlett Learning, LLC. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not constitute or imply its endorsement or recommendation by Jones & Bartlett Learning, LLC, and such reference shall not be used for advertising or product endorsement purposes. All trademarks displayed are the trademarks of the parties noted herein. Android App Development is an independent publication and has not been authorized, sponsored, or otherwise approved by the owners of the trademarks or service marks referenced in this product.
There may be images in this book that feature models; these models do not necessarily endorse, represent, or participate in the activities represented in the images. Any screenshots in this product are for educational and instructive purposes only. Any individuals and scenarios featured in the case studies throughout this product may be real or fictitious, but are used for instructional purposes only.
09365-0
Production Credits
VP, Executive Publisher: David D. Cella
Executive Editor: Matt Kane
Acquisitions Editor: Laura Pagluica
Associate Editor: Taylor Ferracane
Associate Production Editor: Rebekah Linga
Director of Marketing: Andrea DeFronzo
Marketing Manager: Amy Langlais
VP, Manufacturing and Inventory Control: Therese Connell
Composition: S4Carlisle Publishing Services
Cover Design: Kristin E. Parker
Rights & Media Specialist: Merideth Tumasz
Media Development Editor: Shannon Sheehan
Cover Image: Fon_nongkran/Shutterstock
Printing and Binding: RR Donnelley
Cover Printing: RR Donnelley
Library of Congress Cataloging-in-Publication Data
Names: Franceschi, Herv, author.
Title: Android app development / Herve J. Franceschi, Loyola University Maryland.
Description: Burlington, Massachusetts : Jones & Bartlett Learning, [2017] | Includes bibliographical references and index.
Identifiers: LCCN 2016038890 | ISBN 9781284092127
Subjects: LCSH: Android (Electronic resource) | Mobile computing. | Application softwareDevelopment.
Classification: LCC QA76.76.A65 F73 2017 | DDC 005.3dc23
LC record available at https://lccn.loc.gov/2016038890
6048
Printed in the United States of America
20 19 18 17 16 10 9 8 7 6 5 4 3 2 1
DEDICATION
To Kristin, Hlna, and Louis
PREFACE
Purpose of This Text and Its Audience
Android App Development covers the essential topics of Android Development: XML resources, including styles, XML defined GUIs, programmatically defined GUI, event-driven programming, activity life cycle, how to manage several activities, transitions between activities, persistent data (including SQLite), how to manage orientation, fragments, how to make a device-independent app, and how to use an app within another app. It covers fun topics such as touches, swipes, graphics, sounds, and game programming. Finally, it also covers more specialized topics of interest: maps, voice recognition, how to make a content app including remote data retrieval and XML parsing, GPS, how to make a widget, in-app advertising, and encryption.
This course ideally follows a Java course. Although it is preferable that students have been exposed to event handling programming prior to taking an Android course, it is not a requirement. GUI programming and event handling are thoroughly explained.
Coverage and Approach
The approach in this book is to use an app throughout each chapter to illustrate the concepts presented. The app typically uses the Model View Controller architecture. It is constructed in a very progressive manner starting with version 0, then version 1, and so on. We progress through the app versions, adding concepts and topics as needed by the app. Thus, each app is manageable in the classroom. The instructor can choose to download the Model and explain it briefly rather than cover it in detail. The Model classes use straightforward Java code and do not need much explanation. We also try to use apps that are simple yet meaningful and that the students can easily understand and relate to. It is possible to only cover the early versions of an app if the instructor does not want to cover some of the chapters topics. Furthermore, many chapters are independent of each other and do not have to be covered in the sequence in which they are presented in this book.
Pedagogy
Within each chapter, and therefore within each app, the instructor can pick what topics he or she chooses to cover and in what depth as well as at what pace. The Model, which typically uses basic Java classes and is Android independent, can be downloaded and briefly explained. That allows the instructor to concentrate on the View and the Controller, which include Android-specific topics. Screenshots, examples, and tables are included throughout each chapter to illustrate the concepts at hand and the current state of the chapter app. Software Engineering and Common Error boxes highlight software engineering tips and common errors throughout the chapters. Chapter summaries are provided at the end of each chapter followed by exercises, problems, and projects to test students knowledge. Each chapter includes extensive multiple-choice, fill in the code, and write an app exercises.
SOFTWARE ENGINEERING: When defining an EditText
, choose the appropriate value for android:inputType
in order to match the data we expect the user will input.
COMMON ERROR: We need to add an activity element in the Android Manifest.xml file whenever we add an activity to our app. Otherwise, the app will crash when we try to go to that activity.
FIGURE 2.2 Selected layout manager classes
TABLE 2.6 The android:textSize
and android:hint
XML attributes of TextView
Next page