|
Table of Contents |
5 |
|
|
About the Author |
10 |
|
|
About the Technical Reviewer |
11 |
|
|
Acknowledgments |
12 |
|
|
Introduction |
13 |
|
|
Chapter 1: Introduction |
15 |
|
|
History |
15 |
|
|
Statistics |
16 |
|
|
Operating System |
17 |
|
|
Chapter 2: Android Studio |
19 |
|
|
Android Studio Setup |
20 |
|
|
macOS |
20 |
|
|
Windows |
20 |
|
|
Linux |
21 |
|
|
Configuring Android Studio |
22 |
|
|
Hardware Acceleration |
28 |
|
|
The Android Studio IDE |
29 |
|
|
Chapter 3: Application Fundamentals |
32 |
|
|
Creating a Project |
32 |
|
|
Using Android Studio |
37 |
|
|
Compilation and Runtime |
47 |
|
|
Android Components |
48 |
|
|
Components |
49 |
|
|
Activities |
51 |
|
|
Services |
51 |
|
|
Content Providers |
52 |
|
|
Broadcast Receivers |
52 |
|
|
Chapter 4: Activities and Layouts |
53 |
|
|
Building the Hello Screen |
53 |
|
|
The Layout File |
54 |
|
|
Main Java Program |
57 |
|
|
Views and Layout |
60 |
|
|
Chapter 5: Handling Events |
67 |
|
|
Overview of Event Handling |
67 |
|
|
Declarative Event Handling |
69 |
|
|
Programmatic Event Handling |
71 |
|
|
Working with Text and Buttons |
76 |
|
|
More Event Handling Code |
82 |
|
|
Using an Inner Class as a Listener |
84 |
|
|
Using MainActivity as the Listener |
88 |
|
|
Chapter 6: Working with Multiple Activities |
95 |
|
|
Component Activation |
95 |
|
|
Launching a Specific Activity |
97 |
|
|
Demo Project |
97 |
|
|
Pass Data to Another Activity |
107 |
|
|
About the GCF Algorithm |
107 |
|
|
Returning Results from Other Activities |
119 |
|
|
Project Setup |
120 |
|
|
Program Files |
123 |
|
|
Implicit Intents |
126 |
|
|
Demo Project |
127 |
|
|
Opening an http Request |
129 |
|
|
Activity Life Cycle |
132 |
|
|
Chapter 7: UI Elements |
136 |
|
|
UI Elements |
136 |
|
|
Themes and Colors |
136 |
|
|
Colors |
137 |
|
|
Themes |
141 |
|
|
AppBar |
143 |
|
|
Demo App |
145 |
|
|
Fragments |
153 |
|
|
Project Setup |
155 |
|
|
Adding Fragments Programmatically |
162 |
|
|
Chapter 8: Running in the Background |
167 |
|
|
Long Running Tasks |
167 |
|
|
Demo Project |
168 |
|
|
AsyncTask |
172 |
|
|
Chapter 9: Debugging |
178 |
|
|
Syntax Errors |
179 |
|
|
Runtime Exceptions |
180 |
|
|
Logic Errors |
182 |
|
|
Chapter 10: Data Persistence |
185 |
|
|
SharedPreferences |
187 |
|
|
Demo Project |
187 |
|
|
Verifying the File |
193 |
|
|
Application Level SharedPreferences |
195 |
|
|
Internal Storage |
203 |
|
|
How to Work with Internal Storage |
203 |
|
|
Demo Project |
204 |
|
|
Chapter 11: App Distribution |
210 |
|
|
Preparing the App for Release |
211 |
|
|
Prepare Materials and Assets for Release |
211 |
|
|
Configure the App for Release |
211 |
|
|
Build a Release-Ready Application |
212 |
|
|
Releasing the App |
217 |
|
|
Appendix A:Introduction to Java |
220 |
|
|
The Java Language |
220 |
|
|
Virtual Machine |
221 |
|
|
Editions |
221 |
|
|
Setup |
222 |
|
|
Hello World |
223 |
|
|
Program Structure |
225 |
|
|
Other Considerations |
229 |
|
|
Variables and Data Types |
230 |
|
|
Primitive Types |
231 |
|
|
Reference Types |
231 |
|
|
Operators |
232 |
|
|
Program Flow |
235 |
|
|
Decisions |
235 |
|
|
if then else |
235 |
|
|
switch Statement |
237 |
|
|
Loops |
239 |
|
|
Simple Application of Control Structures |
241 |
|
|
The FizzBuzz Problem |
241 |
|
|
How to Print a 5×5 Multiplication Table |
242 |
|
|
Methods |
243 |
|
|
Object Oriented Programming |
246 |
|
|
More Details on Classes |
249 |
|
|
Constructors |
250 |
|
|
Overloading |
251 |
|
|
Packages |
252 |
|
|
Multiple Types in a Package |
253 |
|
|
When We Don’t Need “import” |
253 |
|
|
Inheritance |
254 |
|
|
Object as the Root Class |
255 |
|
|
Single Rooted Class Inheritance |
256 |
|
|
Polymorphism |
256 |
|
|
Interfaces |
257 |
|
|
Multiple Inheritance |
258 |
|
|
Exceptions |
259 |
|
|
Index |
262 |
|