[PDF] android cheat sheet
[PDF] android client server
[PDF] android client server communication example
[PDF] android concurrency pdf
[PDF] android cookbook 2019
[PDF] android create id in xml
[PDF] android database best practices pdf
[PDF] android design patterns and best practices
[PDF] android design patterns and best practices pdf
[PDF] android design patterns book
[PDF] android design patterns example
[PDF] android design patterns interview questions
[PDF] android design patterns pdf
[PDF] android design patterns tutorial
[PDF] android developer fundamentals (version 2)
ptg11524036 ptg11524036 Learning Mobile App
Development
97803e21947864_Book 1.indb i11/21/13 2:56 PM
ptg11524036This page intentionally left blank ptg11524036 Upper Saddle River, NJ € Boston € Indianapolis € San Francisco New York € Toronto € Montreal € London € Munich € Paris € Madrid Cape Town € Sydney € Tokyo € Singapore € Mexico City
Learning Mobile App
Development
A Hands-on Guide to Building
Apps with iOS and Android
Jakob Iversen
Michael Eierman
97803e21947864_Book 1.indb iii11/21/13 2:56 PM
ptg11524036 Editor-in-Chief
Mark Taub
Senior Acquisitions Editor
Trina MacDonald
Senior Development Editor
Chris Zahn
Managing Editor
Kristy Hart
Project Editor
Andy Beaster
Copy Editor
Barbara Hacha
Indexer
Heather McNeill
Proofreader
Sara Schumacher
Technical Reviewers
Frank McCown
Aileen Pierce
Ray Rischpater
Valerie Shipbaugh
Editorial Assistant
Olivia Basegio
Media Producer
Dan Scherf
Interior Designer
Gary Adair
Cover Designer
Chuti Prasertsith
Compositor
Nonie Ratcliff Many of the designations used by manufacturers and sellers to distinguis h their products are claimed as trademarks. Where those designations appear in t his book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The authors and publisher have taken care in the preparation of this boo k, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for inci dental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in qu antity for bulk purchases or special sales, which may include electronic versio ns and/or custom covers and content particular to your business, training g oals, marketing focus, and branding interests. For more information, please co ntact:
U.S. Corporate and Government Sales
(800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United States, please contact:
International Sales
international@pearsoned.com
Visit us on the Web: informit.com/aw
Library of Congress Control Number: 2013951436
Copyright © 2014 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publi cation is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval s ystem, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. To obtain permission to use materi al from this work, please submit a written request to Pearson Education, In c., Permissions Department, One Lake Street, Upper Saddle River, New Jersey
07458, or you may fax your request to (201) 236-3290.
ISBN-13: 978-0-321-94786-4
ISBN-10: 0-321-94786-X
Text printed in the United States on recycled paper at R.R. Donnelley in
Crawfordsville, Indiana.
First printing: December 2013
97803e21947864_Book 1.indb iv11/21/13 2:56 PM
ptg11524036
Dedicated to Kim, Katja, Rebecca, and Natasja.
Dedicated to my wife, Theresa, and daughters,
Lindsey and Kyra.
97803e21947864_Book 1.indb v11/21/13 2:56 PM
ptg11524036viContentsviContents
Contents
Preface xiv
Part I Overview of Mobile App Development 1
1 Why Mobile Apps? 3
Transformative Devices 3
Reaching Customers 4
Changing Business Process 6
Making Money 9
Summary 10
Exercises 10
2 App Design Issues and Considerations 13
App Design 13
Operating System Design Issues 13
Screen Size and Orientation Issues 17
Connectivity Issues 18
Battery Issues 19
Hardware Issues 19
Device Differences 21
Android 21
iOS 23
Introducing Your First App 23
Contact Screen 24
Contact List Screen 24
Map Screen 25
Settings Screen 26
Summary 26
Exercises 27
Part II Developing the Android App 29
3 Using Eclipse for Android Development 31
Starting a New Project 31
Setting Up the Workspace 32
Creating the Project 32
97803e21947864_Book 1.indb vi11/21/13 2:56 PM
ptg11524036viiContentsviiContents
Components of the IDE 35
The Android Manifest 37
Configuring the Emulator 39
Coding the Interface 42
Coding App Behavior 50
Adding Code 52
Summary 54
Exercises 54
4 Android Navigation and Interface Design 55
Activities, Layouts, and Intents 55
The
Activity Class 56
Layout 56
Intents 57
Creating the Interface 57
Create the Project 58
Create the Navigation Bar 59
Create the Contact Layout 64
Activating the Interface 78
Code the Navigation Bar 78
Code the Toggle Button 80
Code the
DatePicker Dialog 82
Summary 86
Exercises 87
5 Persistent Data in Android 89
Preferences, Files, and Database 89
Preferences 89
Files 90
Database 90
Creating the Database 91
Create the Database Helper Class 91
Create the Data Source Class 93
Using the Database 98
Capture User-Entered Data 99
Save User-Entered Data 101
Use the Debugger 105
97803e21947864_Book 1.indb vii11/21/13 2:56 PM
ptg11524036viiiContentsviiiContents
Using Preferences 107
Create the Settings Layout 107
Code the Pages Behavior 109
Summary 113
Exercises 114
6 Lists in Android: Navigation and Information
Display 115
Lists and Adapters 115
Lists 115
Adapters 116
Simple Lists 116
Create the Data Source Method 116
Create the Layout 118
Code the Activity 118
Complex Lists 121
Create the Data Source Method 121
Create the Layout 123
Create the Custom Adapter 125
Code the Activity 127
Add Delete Functionality 128
Completing the
ContactList Activity 135
Populating the
ContactActivity Screen 135
Coding the Add Button 138
Sort the Contacts List 139
Set
ContactListActivity as the Default Activity 141
Set
ContactActivity as Default Activity with no
Contacts in Database 142
Summary 143
Exercises 143
7 Maps and Location in Android 145
Location Sensors, Maps, and Fragments 145
Location Sensors 145
Maps 146
Fragments 146
Setting Up for Maps 146
Passing Data Between Controllers 151
97803e21947864_Book 1.indb viii11/21/13 2:56 PM
ptg11524036ixContentsixContents
Finding Your Location 152
Geocoding: Get Coordinates from an Address 152
Get Coordinates from the GPS Sensor 155
Get Coordinates from Network Sensor 159
Get Coordinates from the Map 161
Displaying Your Contacts Locations 164
Summary 170
Exercises 171
8 Access to Hardware and Sensors in Android 173
Sensors, Managers, and Other Hardware 173
Sensors 173
Managers 174
Other Hardware 174
Monitoring the Battery 174
Using Sensors to Create a Compass 177
Using the Phone 181
Using the Camera 183
Summary 189
Exercise 190
Part III Developing the iOS App 191
9 Using Xcode for iOS Development
193
Creating the Xcode Project 193
Project Settings 196
Creating the User Interface 199
Running the App in the Simulator 200
Adding App Behavior 202
Dismissing the Keyboard 205
App Icons and Launch Images 208
Summary 211
Exercises 211
10 iOS Navigation and Interface Design 213
Views and Controllers 213
View Controller 213
Tab Bar Controller 214
Navigation Controller 215
97803e21947864_Book 1.indb ix11/21/13 2:56 PM
ptg11524036xContentsxContents
Creating the Interface 215
Creating the Project 215
Creating the Views 216
Design the Contacts Screen 222
Add Navigation Controller for the Date Screen 226
Activating the Interface 230
Summary 233
Exercises 233
11 Persistent Data in iOS 235
File Data Storage 235
User Defaults 236
quotesdbs_dbs4.pdfusesText_8