Android How to Program - Paul J. Deitel, Harvey Deitel

Android How to Program

Buch | Hardcover
912 Seiten
2012
Pearson (Verlag)
978-0-13-299054-7 (ISBN)
139,95 inkl. MwSt
zur Neuauflage
  • Titel erscheint in neuer Auflage
  • Artikel merken
Zu diesem Artikel existiert eine Nachauflage
The Deitels' App-Driven, Live Code Approach is simply the best way to master Android programming! The Deitels teach Android programming through sixteen complete, working Android Apps. Each chapter presents new concepts through a single App. The authors first discuss what the App does, show screen shots, test drive the App, and present an overview of the technologies and architecture used to build it. Next, the authors walk through building the App, presenting complete code and providing a detailed "Live Code" walkthrough. As part of the code walkthrough, they discuss essential programming concepts, and demonstrate the functionality of relevant Android 2.x APIs. Readers will gain hands-on experience with a wide spectrum of essential Android APIs. The book also has an extensive introduction to programming using the Java language, making this book appropriate for Java courses that want to add an app-programming flavor.

Paul J. Deitel, CEO and Chief Technical Officer of Deitel & Associates, Inc., is a graduate of the MIT Sloan School of Management, where he studied Information Technology. He holds the¿Java Certified Programmer and¿Java Certified Developer professional certifications, and has been designated by Sun Microsystems as a Java Champion—"a prominent member of the Java community whose input is solicited by the company in order to improve the Java platform." He has delivered programming language courses to clients including numerous Fortune 1000 companies, government organizations and the military. Paul is one of the world's most experienced corporate trainers. He has also lectured on C and Java for the Boston Chapter of the Association for Computing Machinery. The Deitels are the world's best-selling programming language textbook authors. Dr. Harvey M. Deitel, Chairman and Chief Strategy Officer of Deitel & Associates, Inc., has 46 years of academic and industry experience in the¿computer field. Dr. Deitel earned B.S. and M.S. degrees from the Massachusetts Institute of¿Technology and a Ph.D. from Boston University. He has 20 years of college teaching experience, including earning tenure and serving as the Chairman of the¿Computer Science Department at Boston College before founding Deitel & Associates, Inc. He and Paul are the co-authors of several dozen books and multimedia packages. With translations published in many languages, the Deitels' texts have earned international recognition and are used in over 150 countries. Dr. Deitel has delivered hundreds of professional seminars to major corporations, academic institutions, government organizations and the military.

Preface xviii
Before You Begin xix
1 Introduction to Android 1
1.1 Introduction 2
1.2 Android Overview 4
1.3 Android 2.2 (Froyo) 7
1.4 Android 2.3 (Gingerbread) 10
1.5 Android 3.0 (Honeycomb) 12
1.6 Android 4.0 (Ice Cream Sandwich) 15
1.7 Downloading Apps from the Android Market 17
1.8 Packages 18
1.9 Android Software Development Kit (SDK) 20
1.10 Object Technology: A Quick Refresher 22
1.11 Test-Driving the Doodlz App in an Android Virtual Device (AVD) 24
1.12 Deitel Resources 33
1.13 Android Development Resources 34
1.14 Wrap-Up 35
2 Android Market and App Business Issues 39
2.1 Introduction 40
2.2 Building Great Android Apps 40
2.3 Android Best Practices 42
2.3.1 Compatibility 42
2.3.2 Supporting Multiple Screens 44
2.3.3 Android User Interface Guidelines 44
2.4 Registering at Android Market 48
2.5 Setting Up a Google Checkout Merchant Account 48
2.6 AndroidManifest.xml File 49
2.7 Preparing Your Apps for Publication 50
2.8 Uploading Your Apps to Android Market 55
2.9 Other Android App Marketplaces 57
2.10 Pricing Your App: Free or Fee 58
2.11 Monetizing Apps with In-App Advertising 60
2.12 Monetizing Apps: Using In-App Billing to Sell Virtual Goods in Your Apps 60
2.13 Launching the Market App from Within Your App 63
2.14 Managing Your Apps in Android Market 63
2.15 Marketing Your App 63
2.16 Other Popular App Platforms 68
2.17 Android Developer Documentation 69
2.18 Android Humor 70
2.19 Wrap-Up 71
3 Welcome App 74
3.1 Introduction 75
3.2 Technologies Overview 75
3.3 Eclipse IDE 76
3.4 Creating a New Project 77
3.5 Building the Welcome App’s GUI with the ADT’s Visual Layout Editor 80
3.6 Examining the main.xml File 93
3.7 Running the Welcome App 95
3.8 Wrap-Up 95
4 Tip Calculator App 98
4.1 Introduction 99
4.2 Test-Driving the Tip Calculator App 100
4.3 Technologies Overview 101
4.4 Building the App’s GUI 101
4.4.1 TableLayout Introduction 101
4.4.2 Creating the Project and Adding the TableLayout and Components 102
4.4.3 Reviewing the Layout So Far 106
4.4.4 Customizing the Components to Complete the Design 106
4.4.5 Final XML Markup for the Tip Calculator GUI 109
4.4.6 strings.xml 113
4.5 Adding Functionality to the App 113
4.6 Wrap-Up 123
5 Favorite Twitter® Searches App 127
5.1 Introduction 128
5.2 Test-Driving the Favorite Twitter Searches App 129
5.3 Technologies Overview 131
5.4 Building the App’s GUI and Resource Files 133
5.4.1 main.xml TableLayout 133
5.4.2 Creating the Project 134
5.4.3 Creating the Resource Files 134
5.4.4 Adding the TableLayout and Components 136
5.4.5 Creating a TableRow That Displays a Search and an Edit Button 140
5.5 Building the App 141
5.6 AndroidManifest.xml 152
5.7 Wrap-Up 153
6 Flag Quiz Game App 158
6.1 Introduction 159
6.2 Test-Driving the Flag Quiz Game App 163
6.3 Technologies Overview 163
6.4 Building the App’s GUI and Resource Files 165
6.4.1 main.xml LinearLayout 165
6.4.2 Creating the Project 165
6.4.3 Creating and Editing the Resource Files 166
6.4.4 Adding the Components to the LinearLayout 167
6.4.5 Creating a Button That Can Be Dynamically Inflated 170
6.4.6 Creating the Flag Shake Animation 170
6.5 Building the App 172
6.6 AndroidManifest.xml 186
6.7 Wrap-Up 187
7 Cannon Game App 191
7.1 Introduction 192
7.2 Test-Driving the Cannon Game App 193
7.3 Technologies Overview 194
7.4 Building the App’s GUI and Resource Files 196
7.4.1 Creating the Project 196
7.4.2 AndroidManifest.xml 196
7.4.3 strings.xml 197
7.4.4 main.xml 197
7.4.5 Adding the Sounds to the App 198
7.5 Building the App 198
7.5.1 Line Class Maintains a Line’s Endpoints 198
7.5.2 CannonGame Subclass of Activity 198
7.5.3 CannonView Subclass of View 201
7.6 Wrap-Up 218
8 SpotOn Game App 223
8.1 Introduction 224
8.2 Test-Driving the SpotOn Game App 225
8.3 Technologies Overview 226
8.4 Building the App’s GUI and Resource Files 227
8.4.1 AndroidManifest.xml 227
8.4.2 main.xml RelativeLayout 227
8.4.3 untouched.xml ImageView for an Untouched Spot 228
8.4.4 life.xml ImageView for a Life 228
8.5 Building the App 229
8.5.1 SpotOn Subclass of Activity 229
8.5.2 SpotOnView Subclass of View 231
8.6 Wrap-Up 243
9 Doodlz App 247
9.1 Introduction 248
9.2 Test-Driving the Doodlz App 249
9.3 Technologies Overview 250
9.4 Building the App’s GUI and Resource Files 251
9.4.1 Creating the Project 251
9.4.2 AndroidManifest.xml 252
9.4.3 strings.xml 252
9.4.4 main.xml 253
9.4.5 color_dialog.xml 253
9.4.6 width_dialog.xml 255
9.5 Building the App 256
9.5.1 Doodlz Subclass of Activity 256
9.5.2 DoodleView Subclass of View 269
9.6 Wrap-Up 278
10 Address Book App 282
10.1 Introduction 283
10.2 Test-Driving the Address Book App 285
10.3 Technologies Overview 286
10.4 Building the GUI and Resource Files 287
10.4.1 Creating the Project 288
10.4.2 AndroidManifest.xml 288
10.4.3 styles.xml 288
10.4.4 textview_border.xml 289
10.4.5 AddressBook Activity’s Layout: contact_list_item.xml 290
10.4.6 ViewContact Activity’s Layout: view_contact.xml 290
10.4.7 AddEditContact Activity’s Layout: add_contact.xml 290
10.4.8 Defining the App’s MenuItems with menu Resources in XML 292
10.5 Building the App 293
10.5.1 AddressBook Subclass of ListActivity 293
10.5.2 ViewContact Subclass of Activity 299
10.5.3 AddEditContact Subclass of Activity 305
10.5.4 DatabaseConnector Utility Class 308
10.6 Wrap-Up 314
11 Route Tracker App 318
11.1 Introduction 319
11.2 Test-Driving the Route Tracker App 321
11.3 Technologies Overview 323
11.4 Building the GUI and Resource Files 325
11.4.1 Creating the Project 325
11.4.2 AndroidManifest.xml 325
11.4.3 Route Tracker Layout: main.xml 326
11.5 Building the App 327
11.5.1 RouteTracker Subclass of MapActivity 327
11.5.2 BearingFrameLayout Subclass of FrameLayout 338
11.5.3 RouteOverlay Subclass of Overlay 341
11.6 Wrap-Up 345
12 Slideshow App 349
12.1 Introduction 350
12.2 Test-Driving the Slideshow App 353
12.3 Technologies Overview 354
12.4 Building the GUI and Resource Files 357
12.4.1 Creating the Project 357
12.4.2 Using Standard Android Icons in the App’s GUI 357
12.4.3 AndroidManifest.xml 357
12.4.4 Layout for ListView Items in the Slideshow ListActivity 358
12.4.5 Slideshow ListActivity’s Menu 358
12.4.6 Layout for the EditText in the Set Slideshow Name Dialog 359
12.4.7 Layout for the SlideshowEditor ListActivity 359
12.4.8 Layout for ListView Items in the SlideshowEditor ListActivity 360
12.4.9 Layout for the SlideshowPlayer Activity 360
12.5 Building the App 361
12.5.1 SlideshowInfo Class 361
12.5.2 Slideshow Subclass of ListActivity 362
12.5.3 SlideshowEditor Subclass of ListActivity 373
12.5.4 SlideshowPlayer Subclass of ListActivity 381
12.6 Wrap-Up 388
13 Enhanced Slideshow App 392
13.1 Introduction 393
13.2 Test-Driving the Enhanced Slideshow App 394
13.3 Technologies Overview 395
13.4 Building the GUI and Resource Files 396
13.4.1 Creating the Project 397
13.4.2 AndroidManifest.xml 397
13.4.3 SlideshowEditor ListActivity’s Modified Layout 398
13.4.4 PictureTaker Activity’s Layout 398
13.4.5 SlideshowPlayer Activity’s Modified Layout 398
13.5 Building the App 399
13.5.1 MediaItem Class 399
13.5.2 SlideshowInfo Class 400
13.5.3 Slideshow Class 402
13.5.4 SlideshowEditor Class 407
13.5.5 PictureTaker Subclass of Activity 410
13.5.6 SlideshowPlayer Class 416
13.6 Wrap-Up 421
14 Weather Viewer App 424
14.1 Introduction 425
14.2 Test-Driving the Weather Viewer App 427
14.3 Technologies Overview 428
14.4 Building the App’s GUI and Resource Files 430
14.4.1 AndroidManifest.xml 430
14.4.2 WeatherViewerActivity’s main.xml Layout 431
14.4.3 Default Cities and ZIP Codes in arrays.xml 432
14.4.4 WeatherViewerActivity’s actionmenu.xml Menu Layout 432
14.4.5 WeatherProvider App Widget Configuration and Layout 433
14.5 Building the App 433
14.5.1 Class WeatherViewerActivity 434
14.5.2 Class CitiesFragment 449
14.5.3 Class AddCityDialogFragment 456
14.5.4 Class ForecastFragment 459
14.5.5 Class SingleForecastFragment 459
14.5.6 Class ReadLocationTask 466
14.5.7 Class ReadForecastTask 470
14.5.8 Class FiveDayForecastFragment 476
14.5.9 Class ReadFiveDayForecastTask 481
14.5.10 Class DailyForecast 486
14.5.11 Class WeatherProvider 487
14.6 Wrap-Up 493

A Introduction to Java Applications 498
A.1 Introduction 499
A.2 Your First Program in Java: Printing a Line of Text 499
A.3 Modifying Your First Java Program 503
A.4 Displaying Text with printf 505
A.5 Another Application: Adding Integers 505
A.6 Memory Concepts 509
A.7 Arithmetic 510
A.8 Decision Making: Equality and Relational Operators 513
A.9 Wrap-Up 517
B Introduction to Classes, Objects, Methods and Strings 522
B.1 Introduction 523
B.2 Declaring a Class with a Method and Instantiating an Object of a Class 523
B.3 Declaring a Method with a Parameter 526
B.4 Instance Variables, set Methods and get Methods 529
B.5 Primitive Types vs. Reference Types 533
B.6 Initializing Objects with Constructors 534
B.7 Floating-Point Numbers and Type double 536
B.8 Wrap-Up 540
C Control Statements 544
C.1 Introduction 545
C.2 Algorithms 545
C.3 Pseudocode 546
C.4 Control Structures 546
C.5 if Single-Selection Statement 547
C.6 if…else Double-Selection Statement 547
C.7 while Repetition Statement 550
C.8 Case Study: Counter-Controlled Repetition 550
C.9 Case Study: Sentinel-Controlled Repetition 554
C.10 Case Study: Nested Control Statements 559
C.11 Compound Assignment Operators 562
C.12 Increment and Decrement Operators 562
C.13 Primitive Types 564
C.14 Essentials of Counter-Controlled Repetition 565
C.15 for Repetition Statement 566
C.16 Examples Using the for Statement 568
C.17 do…while Repetition Statement 570
C.18 switch Multiple-Selection Statement 571
C.19 break and continue Statements 578
C.20 Logical Operators 578
C.21 Wrap-Up 581
D Methods: A Deeper Look 589
D.1 Introduction 590
D.2 Program Modules in Java 590
D.3 static Methods, static Fields and Class Math 591
D.4 Declaring Methods with Multiple Parameters 593
D.5 Notes on Declaring and Using Methods 596
D.6 Method-Call Stack and Activation Records 597
D.7 Argument Promotion and Casting 597
D.8 Java API Packages 598
D.9 Introduction to Random-Number Generation 599
D.9.1 Scaling and Shifting of Random Numbers 600
D.9.2 Random-Number Repeatability for Testing and Debugging 601
D.10 Case Study: A Game of Chance; Introducing Enumerations 602
D.11 Scope of Declarations 606
D.12 Method Overloading 608
D.13 Wrap-Up 611
E Arrays and ArrayLists 618
E.1 Introduction 619
E.2 Arrays 619
E.3 Declaring and Creating Arrays 620
E.4 Examples Using Arrays 621
E.5 Case Study: Card Shuffling and Dealing Simulation 630
E.6 Enhanced for Statement 634
E.7 Passing Arrays to Methods 635
E.8 Case Study: Class GradeBook Using an Array to Store Grades 639
E.9 Multidimensional Arrays 644
E.10 Case Study: Class GradeBook Using a Two-Dimensional Array 648
E.11 Class Arrays 654
E.12 Introduction to Collections and Class ArrayList 656
E.13 Wrap-Up 659
F Classes and Objects: A Deeper Look 664
F.1 Introduction 665
F.2 Time Class Case Study 665
F.3 Controlling Access to Members 669
F.4 Referring to the Current Object’s Members with the this Reference 670
F.5 Time Class Case Study: Overloaded Constructors 672
F.6 Default and No-Argument Constructors 678
F.7 Composition 679
F.8 Enumerations 682
F.9 Garbage Collection 684
F.10 static Class Members 685
F.11 final Instance Variables 689
F.12 Packages 689
F.13 Package Access 690
F.14 Wrap-Up 690
G Object-Oriented Programming: Inheritance and Polymorphism 693
G.1 Introduction to Inheritance 694
G.2 Superclasses and Subclasses 695
G.3 protected Members 696
G.4 Relationship between Superclasses and Subclasses 697
G.4.1 Creating and Using a CommissionEmployee Class 697
G.4.2 Creating and Using a BasePlusCommissionEmployee Class 702
G.4.3 Creating a CommissionEmployee—BasePlusCommissionEmployee Inheritance Hierarchy 707
G.4.4 CommissionEmployee—BasePlusCommissionEmployee Inheritance Hierarchy Using protected Instance Variables 710
G.4.5 CommissionEmployee—BasePlusCommissionEmployee Inheritance Hierarchy Using private Instance Variables 713
G.5 Class Object 718
G.6 Introduction to Polymorphism 719
G.7 Polymorphism: An Example 720
G.8 Demonstrating Polymorphic Behavior 721
G.9 Abstract Classes and Methods 724
G.10 Case Study: Payroll System Using Polymorphism 725
G.10.1 Abstract Superclass Employee 726
G.10.2 Concrete Subclass SalariedEmployee 729
G.10.3 Concrete Subclass HourlyEmployee 731
G.10.4 Concrete Subclass CommissionEmployee 732
G.10.5 Indirect Concrete Subclass BasePlusCommissionEmployee 734
G.10.6 Polymorphic Processing, Operator instanceof and Downcasting 735
G.10.7 Summary of the Allowed Assignments Between Superclass and Subclass Variables 740
G.11 final Methods and Classes 741
G.12 Case Study: Creating and Using Interfaces 742
G.12.1 Developing a Payable Hierarchy 743
G.12.2 Interface Payable 744
G.12.3 Class Invoice 745
G.12.4 Modifying Class Employee to Implement Interface Payable 747
G.12.5 Modifying Class SalariedEmployee for Use in the Payable Hierarchy 749
G.12.6 Using Interface Payable to Process Invoices and Employees Polymorphically 751
G.13 Common Interfaces of the Java API 752
G.14 Wrap-Up 753
H Exception Handling: A Deeper Look 757
H.1 Introduction 758
H.2 Example: Divide by Zero without Exception Handling 758
H.3 Example: Handling ArithmeticExceptions and InputMismatchExceptions 760
H.4 When to Use Exception Handling 765
H.5 Java Exception Hierarchy 765
H.6 finally Block 768
H.7 Stack Unwinding and Obtaining Information from an Exception Object 772
H.8 Wrap-Up 775
I GUI Components and Event Handling 778
I.1 Introduction 779
I.2 Nimbus Look-and-Feel 779
I.3 Text Fields and an Introduction to Event Handling with Nested Classes 780
I.4 Common GUI Event Types and Listener Interfaces 786
I.5 How Event Handling Works 787
I.6 JButton 789
I.7 JComboBox; Using an Anonymous Inner Class for Event Handling 793
I.8 Adapter Classes 796
I.9 Wrap-Up 797
J Other Topics 798
J.1 Introduction 799
J.2 Collections Overview 799
J.3 Type-Wrapper Classes for Primitive Types 800
J.4 Interface Collection and Class Collections 800
J.5 Lists 801
J.5.1 ArrayList and Iterator 801
J.5.2 LinkedList 803
J.5.3 Views into Collections and Arrays Method asList 806
J.6 Collections Methods 808
J.6.1 Method sort 808
J.6.2 Method shuffle 810
J.7 Interface Queue 811
J.8 Sets 811
J.9 Maps 812
J.10 Introduction to Files and Streams 815
J.11 Class File 816
J.12 Introduction to Object Serialization 817
J.13 Introduction to Multithreading 818
J.14 Creating and Executing Threads with the Executor Framework 819
J.15 Overview of Thread Synchronization 823
J.16 Concurrent Collections Overview 824
J.17 Multithreading with GUI 824
J.18Wrap-Up 831
K Operator Precedence Chart 834
L Primitive Types 836
Index 837

Chapters on the Web
The following chapters are located on the book’s Companion Website at www.pearsonhighered.com/deitel
15 Pizza App
Text-to-Speech, Speech-to-Text and Telephony
16 Voice Recorder App
Audio Recording and Playback
17 Enhanced Address Book App
Bluetooth
18 3D Art App
OpenGL ES 3D Rendering

Sprache englisch
Maße 178 x 232 mm
Gewicht 1098 g
Themenwelt Informatik Software Entwicklung Mobile- / App-Entwicklung
Mathematik / Informatik Informatik Web / Internet
Informatik Weitere Themen Smartphones / Tablets
ISBN-10 0-13-299054-7 / 0132990547
ISBN-13 978-0-13-299054-7 / 9780132990547
Zustand Neuware
Haben Sie eine Frage zum Produkt?
Mehr entdecken
aus dem Bereich
Das umfassende Handbuch

von Jürgen Sieben

Buch | Hardcover (2023)
Rheinwerk (Verlag)
89,90
Das große Handbuch zum JavaScript-Framework

von Christoph Höller

Buch | Hardcover (2022)
Rheinwerk (Verlag)
39,90