ebook img

Murach’s Android Programming PDF

683 Pages·2015·163.61 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Murach’s Android Programming

murach's 2ND EDITION Joel Murach TRAINING & REFERENCE muracrvs 2ND EDITION Joel Murach MIKE MURACH & ASSOCIATES, INC. 4340 N. Knoll Ave. • Fresno, CA 93722 www.murach.com • [email protected] Author: Joel Murach Editors: Mike Urban Ray Halliday Android Consultant: Leo Landau Production: Maria Spera Books for Java programmers Murach’s Java Servlets and JSP (3rd Edition ) Murach’ s Android Programming (2nd Edition) Murach’s Beginning Java with NetBeans Murach’s Beginning Java with Eclipse Murach’s Java Programming (4th Edition) Books for database programmers Murach’s MySQL ( 2nd Edition) Murach’s Oracle SQL and PL/SQL for Developers (2nd Edition) Murach’s SQL Server 2012 for Developers Books for web developers Murach’s HTML5 and CSS3 (3rd Edition) Murach’s JavaScript (2nd Edition) Murach’s jQuery (2nd Edition) Murach’s PHP and MySQL (2nd Edition) Books for .NET programmers Murach’s C# 2012 Murach’s ASPNET 4,5 Web Programming with C# 2012 Murach’s Visual Basic 2012 Murach’s ASPNET 4.5 Web Programming with VB 2012 For more on Murach books, please visit us at www.murach.com © 2015, Mike Murach & Associates, Inc. All rights reserved. Printed in the United States of America 109 87 65 43 2 1 ISBN: 978-1-890774-93-6 Content Introduction xv Section 1 Get started fast with Android Chapter 1 An introduction to Android and Android Studio 3 Chapter 2 How to start your first Android app 29 Chapter 3 How to finish your first Android app 55 Chapter 4 How to test and debug an Android app 95 Section 2 Essential Android skills Chapter 5 How to work with layouts and widgets 119 Chapter 6 How to handle events 165 Chapter 7 How to work with themes and styles 197 Chapter 8 How to work with menus and preferences 227 Chapter 9 How to work with fragments 259 Section 3 The News Reader app Chapter 10 How to work with threads, files, adapters, and intents 287 Chapter 11 How to work with services and notifications 339 Chapter 12 How to work with broadcast receivers 381 Section 4 The Task List app Chapter 13 How to work with SQLite databases 397 Chapter 14 How to work with tabs and custom adapters 435 Chapter 15 How to work with content providers 467 Chapter 16 How to work with app widgets 501 Section 5 Advanced Android skills Chapter 17 How to deploy an app 523 Chapter 18 How to work with locations and maps 543 Appendixes Appendix A How to set up Windows for this book 601 Appendix B How to set up Mac OS X for this book 619 Appendix C How to set up Linux for this book 637 Expanded contents VII Expanded contents Section 1 Get started fast with Android Chapter 1 An introduction to Android and Android Studio An overview of Android 4 Types of devices 4 Types of apps 6 A brief history 8 Versions 10 System architecture 12 How apps are compiled and run 14 An introduction to Android Studio 16 How to work with the Welcome page 16 How to open an existing project 16 How to view the user interface for an app 18 How to view the code for an app 20 How to run an app on a physical device 22 How to run an app on an emulator 22 The user interface 24 Chapter 2 How to start your first Android app The Tip Calculator app 30 The user interface 30 How to create a new project 32 How to develop the user interface 34 How to work with a layout 34 How to add widgets to a layout 36 How to set the display text 38 How to work with resource files 42 How to set properties 44 Common properties 46 The XML for the user interface 48 Chapter 3 How to finish your first Android app How to write the Java code 56 How to work with an activity .56 How to remove the v7 appcompat support library .58 How to get references to w'idgets .60 How to handle the EditorAction event .62 How to get and set the text for widgets .66 The lifecycle of an activity .70 How to save and restore values .72 The Java code for the app .74 More skills for finishing an app 80 How to work with the Gradle build script .80 How to work with dependencies .82 How to work with the Android manifest .84 How to set the launcher icon for an app .86 How to use the documentation for the Android API .88 VIM Expanded contents Chapter 4 How to test and debug an Android app Basic skills for testing and debugging 96 Typical test phases 96 How to check the layout 98 How to handle runtime errors 100 How to trace code execution 102 How to use LogCat .102 How to use toasts .104 How to use the debugger 106 How to set and remove breakpoints 106 How to step through code 108 How to inspect variables 108 How to inspect the stack trace 108 How to create emulators 110 How to create an emulator for a tablet 110 How to create an emulator for a phone with a hard keyboard and DPad 112 Section 2 Essential Android skills Chapter 5 How to work with layouts and widgets An introduction to layouts and widgets 120 A summary of layouts .120 A summary of widgets .120 The View hierarchy .122 How to work with layouts 124 How to use a linear layout .124 How to use a table layout .128 How to use a frame layout .130 How to nest layouts .132 How to provide a landscape layout .134 How to work with widgets 136 How to use editable text views .136 How to use check boxes .140 How to use radio buttons .142 How to use spinners .144 How to use seek bars .148 How to display images .150 How to show and hide widgets .152 How to add scroll bars .154 How to display web content .156 Chapter 6 How to handle events A summary of listeners 166 High-level events .166 Low-level .166 events Four techniques for handling events 168 How to use the current class as the listener .168 How to use a named class as the listener .168 How to use an anonymous class as the listener .170 Expanded contents IX How to use an anonymous inner class as the listener 170 When to use each technique 170 How to handle high-level events 172 How to handle events for check boxes and radio buttons 172 How to handle events for radio groups 174 How to handle events for spinners 176 How to handle events for seek bars 178 How to handle low-level events 180 How to handle Key events 180 How to handle Touch events 182 The Tip Calculator app 184 The user interface 184 The Java code for the activity 186 Chapter 7 How to work with themes and styles An introduction to themes and styles 198 Three common themes 198 How to supply different themes for different APIs 200 How to convert an existing project to the AppCompat theme 202 How to work with styles 204 How to define a style 204 How to apply a style 206 How to create a style sheet 208 How to work with themes 210 How to modify a built-in theme 210 How to modify the AppCompat theme 212 How to modify a theme depending on the API 214 How to modify the text appearance for a theme 216 A summary of built-in themes 218 How to apply themes 220 How to work with colors 222 How to define colors 222 How to apply colors 222 Chapter 8 How to work with menus and preferences How to work with menus 228 An introduction to menus 228 How to define a menu 232 How to display an options menu 234 How to handle option menu events 234 How to start a new activity 236 How to work with preferences 238 An introduction to preferences 238 How to define preferences 240 How to display preferences 242 How to get preferences 244 How to use preferences 246 More skills for working with preferences 248 How to group preferences 248 How to enable and disable preferences 250 How to use Java to work with preferences 252 X Expanded contents Chapter 9 How to work with fragments An introduction to fragments 260 Single-pane and multi-pane layouts ,260 The lifecycle methods of a fragment ,262 How to use single-pane layouts for small screens 264 How to create the layout for a fragment ,264 How to create the class for a fragment ,266 How to display a fragment in an activity ,268 How to create a preference fragment ,270 How to display a preference fragment in an activity ,270 How to use multi-pane layouts for large screens... 272 How to add multiple fragments to a layout ,272 How to detect screen width ,274 How to control the soft keyboard ,276 Other skills for working with fragments 278 How' to get a reference to a fragment ,278 How to replace one fragment with another ,280 Section 3 The News Reader app Chapter 10 How to work with threads, files, adapters, and intents An introduction to the News Reader app 288 The user interface 288 The XML for an RSS feed 290 How to work with threads 292 How threads work 292 How to execute asynchronous tasks 294 How to execute timed tasks 298 How to update the UI thread 300 How to work with files 302 How to download a file from the Internet 302 How to parse an XML file 304 The RSSFeedHandler class 306 The RSSFeed class 310 The RSSItem class 310 How to work with adapters 314 How to create the layout for a list view 314 How to use an adapter to display data in a list view 316 How to handle events for an adapter 318 How to work with intents 320 How to pass data between activities 320 How to view a URL in a web browser 322 How to dial or call a phone number 322 The News Reader app 324 The activity_items layout 324 The ItemsActivity class 326 The FilelO class 330 The activity_item layout 330 The ItemActivity class 334

Description:
Want to learn how to develop Android apps? Then dont miss our new book: Murachs Android Programming (2nd Edition). It teaches you how to develop high-quality apps like the ones you can find in the Google Play store. The only prerequisite is a basic knowledge of Java. Everything else, including softw
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.