Professional Android, 4th Edition Code Downloads
Reto Meier and Ian Lake
Copyright 2018 John Wiley Wiley & Sons, Inc.
For each chapter that includes a sample project and/or a number of code snippets provided as "Listings", you'll find the corresponding source code within these archives for your copy/pasting pleasure.
The fully worked samples (Compass, Earthquake, EmergencyResponder, GForceMeter, Weather Station, Where Am I, Hello World, and Star Sign Picker) are named as appropriate, suffixed with the corresponding chapter number (and where necessary the revision number within the chapter), representing each stage in the project.
You can import these projects directly into Android Studio, then compile and run them.
The source code from every code listing is available in the "snippets" archives, with the chapter number suffix (Eg. Snippets_ch2). Please note that these listings have been provided within Android Studio projects to provide a simple way for you to cut and paste useful code snippets, and to provide some additional context around how several of these independent snippets may work together, but they are not intended to represent complete examples.
In both cases, it's inevitable that the version of the dependencies used within these projects -- such as the support library, Android Architecture Components, Google Play services, Gradle, and the Android SDK -- will need to be updated to match the latest versions available. We recommend always targeting the latest version of the Android SDK, and using the latest versions of external libraries.
We hope you have fun with the sample projects and that you find them and the code snippets useful in creating your own Android applications!