Android From Scratch: Exploring Android Sample Apps

One of the most daunting tasks when developing for Android, for both beginners and experts, is figuring out where to start when using a new feature. Luckily, Google has provided a number of open sourced sample applications that you can import into Android Studio and play with to figure out how things work. This tutorial shows you how to use the built-in sample importer in Android Studio and how to find additional samples from Google.

Do you find it easier to learn with video? Why not check out our course:

1. Android Studio's Sample Importer

One of the fastest ways to get up and running with an Android feature is by using the Import an Android code sample option in Android Studio. While there are a lot of samples provided, it should be noted that not every Android sample produced by Google is available through this quick start menu. To import code samples in Android Studio, open the IDE to bring up the welcome screen.

Android Studio Welcome Screen

Under the Quick Start section, you can see an option titled Import an Android code sample. Selecting that option takes you to a screen titled Browse Samples, which, as the name implies, lets you browse through sample apps that you can download and open.

Android Studio Samples List

If you are looking for a particular topic, you can use the search bar on the left, or just scroll through the list of sample applications. Notice that the right section contains two tabs, Description and Preview.

The Description tab contains a simple description for the sample and a link to the source code on GitHub, with a more detailed description of the project.

Android Studio Sample Description

The Preview tab contains screenshots of the project, which can be useful for more user interface focused samples.

Android Studio Sample Preview

Once you have selected a sample to import, click Next to go to the final Sample Setup window. Here you choose a project name and path for setting up the project. Click Finish to import the code sample.

Android Studio Sample Setup

After the project has finished importing, you are able to view the source files in Android Studio. This is a major advantage when learning because you are able to remove or modify blocks of code to see how the sample app changes or breaks.

You are also able to install the sample onto a physical device, so you can see how your code may interact with particular phones and tablets.

Sample Application Running On A Phone

2. Other Android Samples

While the samples available directly through Android Studio are useful, Google offers more code samples for Android developers. For a more comprehensive collection of sample projects from Google, you can visit the Google Samples GitHub page. You will notice that this GitHub page doesn't only contain Android samples, but also web and iOS projects.

Even though the official Google Samples GitHub page contains a large number of sample projects, there are still plenty that are spread across the internet and more difficult to find. You can find some of these samples linked in the official Android documentation for a particular topic that you're interested in, or in the repositories for official Google libraries, such as the Google Maps Utils library.

There are also employees at Google, known as Developer Advocates, who create their own sample projects and are worth following to keep up with the latest in Android development. Fine examples include a sample for the Design Support Library by Chris Banes and a live wallpaper library by Roman Nurik.

Finally, most Envato Tuts+ articles and courses are accompanied by source code that can be cloned from GitHub. This makes it easy to review the project's code as you follow along with a tutorial and learn the topics that are covered in the tutorial.

Conclusion

In this quick tip, you have learned how to import Android sample code into a new test project so that you can incorporate new features into your own applications. You also learned about additional sample projects that you can review to improve your apps and create enjoyable experiences for your users.

Tags:

Comments

Related Articles