guide=true page.title=Sample Code @jd:body

Sometimes, the best way to learn how things are done is to look at some code. Here, you can browse the source of some sample Android applications that are included in the Android SDK.

Each version of the Android platform available for the SDK includes a full set of sample applications (which may vary between different versions of the platform). You can find the samples in your SDK at:

<sdk>/platforms/android-<version>/samples/

You can easily create new Android projects with these samples, modify them if you'd like, then run them on an emulator or device. For example, to create a project for the API Demos app from Eclipse, start a new Android Project, select "Create project from existing source", then select {@code ApiDemos} in the {@code samples/} directory. To create the API Demos project using the {@code android} tool, execute:

android update project -s -n API Demos -t <target_ID> -p <path-to-platform>/samples/ApiDemos/

The pages below provide an overview of each sample application (available with most platforms) and allow you to view the source files in your browser.

API Demos
A variety of small applications that demonstrate an extensive collection of framework topics.
Home
An application for saving notes. Similar (but not identical) to the Notepad tutorial.
JetBoy
JetBoy is a game that demonstrates the SONiVOX JET interactive music technology, with {@link android.media.JetPlayer}.
Lunar Lander
A classic Lunar Lander game.
Note Pad
An application for saving notes. Similar (but not identical) to the Notepad tutorial.
Searchable Dictionary
A sample application that demonstrates Android's search framework, including how to provide search suggestions for Quick Search Box.
Snake
An implementation of the classic game "Snake."
Soft Keyboard
An example of writing an input method for a software keyboard.

For more sample applications, check out apps-for-android, a collection of open source applications that demonstrate various Android APIs.