Lollipop is Android’s biggest overhaul yet, and that can be a little overwhelming for developers. Fortunately, Google has let us know today that it added 20 new code samples to the SDK sample repository. Having access to code samples allows developers to see best practices for implementing new features that are found in the latest Android SDK.
Code samples can do much more than provide excellent examples of new feature implementations. Developers can also use these code samples as building blocks for their applications. For instance, a great foundation for a gallery app could be the “ElevationDrag” sample. This sample demonstrates drag and drop actions on different shapes and how elevation and z-translation, attributes which are new to Android developers, can be applied.
Go to File > Import Sample in order to browse the available samples, which include a description and preview for each. Once you’ve made your selection, select “Next” and a new project will be automatically created for you. Run the project on an emulator or device, and feel free to experiment with the code.
If you’d like to look at these samples yourself, you have the option to download the code straight from the new Samples Wizard in Android Studio, or you can download the zipped project file from the Samples Browser on the developers site.
Once you’ve downloaded a sample, you can snoop around the project’s source code to learn how the sample works. Try playing around with the sample a bit; change some variables or add to the sample. These sample projects are ready to be compiled in Android Studio, so you can easily install them on your device.