Android for Ios Developers: Kotlin Edition 2018
Total Page:16
File Type:pdf, Size:1020Kb
Android for iOS Developers Kotlin Edition 2018 Adrian Kosmaczewski Version 2.2, 2018-10-27 Table of Contents Colophon . 1 Abstract . 5 Dedication . 7 Preface . 9 Target Audience . 9 How to Read this Book . 9 Requirements . 10 Source Code. 11 Structure . 13 Thanks . 13 About the Author . 14 Part 1: Introduction. 15 1. Toolchain . 17 1.1. TL;DR . 17 1.2. Kotlin . 18 1.3. Android Application Startup . 44 1.4. Zygote . 49 1.5. Android Studio . 50 1.6. SDK Manager . 63 1.7. AVD Manager . 63 1.8. Gradle . 76 1.9. Other Tools . 80 1.10. Summary . 85 2. Debugging . 87 2.1. TL;DR . 87 2.2. Enabling Exception Breakpoints. 87 2.3. Enabling USB Debugging. 88 2.4. Enabling WiFi Debugging . 93 2.5. Working on the Command Line . 97 2.6. Logcat and pidcat . 102 2.7. NSLogger. 105 2.8. Stetho. 109 2.9. Summary . 112 Part 2: User Interfaces . 115 3. User Interface . 117 3.1. TL;DR . 117 3.2. UI Design Guidelines . 118 3.3. Android Support Library . 120 3.4. Activities . 121 3.5. Intents . 138 3.6. Fragments. 143 3.7. Layouts . 151 3.8. Summary . 161 4. Graphics. 163 4.1. TL;DR . 163 4.2. Graphics on Android . 164 4.3. Custom Views . 177 4.4. Persisting the State of Views . 183 4.5. Gestures . 188 4.6. Animations . 190 4.7. Using PaintCode . 194 4.8. Summary . 197 Part 3: Managing Data . 199 5. Networking . 201 5.1. TL;DR . 201 5.2. Consuming REST Web Services . 202 5.3. Parsing JSON Data . 211 5.4. Parsing XML Data . 215 5.5. Displaying Data in Lists. 219 5.6. Retrofit . 227 5.7. WebView. 231 5.8. Embedding a Web Server in an Application . 234 5.9. Zeroconf . 237 5.10. Summary . 247 6. Storage . 249 6.1. TL;DR . 249 6.2. Bundled Resources . 250 6.3. Downloading Files . 253 6.4. Saving and Reading Files Locally . 256 6.5. Storing User Preferences . 259 6.6. SQLite . 261 6.7. OrmLite . 268 6.8. Realm. 273 6.9. Room . 276 6.10. Summary . 279 Part 4: Sensors and Multimedia. 281 7. Sensors . 283 7.1. TL;DR . 283 7.2. Getting a List of Sensors . 284 7.3. Using the Accelerometer. 288 7.4. Using the Compass . 292 7.5. Location Information . 294 7.6. Retrieving Address Information . 299 7.7. Summary . 302 8. Multimedia . 305 8.1. TL;DR . 305 8.2. Taking Pictures . 306 8.3. Recording Video . 308 8.4. Picking Images. 310 8.5. Recording and Playing Audio . 314 8.6. Playing Music. 318 8.7. Speech Synthesizer. 322 8.8. Summary . 323 Part 5: High Quality Apps . ..