1 guide=true 2 page.title=Sample Code 3 @jd:body 4 5 6 <p>Sometimes, the best way to learn how things are done is to look at some code. 7 Here, you can browse the source of some sample Android applications that are included 8 in the Android SDK.</p> 9 10 <p>Each version of the Android platform available for the SDK includes a full set of sample 11 applications (which may vary between different versions of the platform). 12 You can find the samples in your SDK at:</p> 13 14 <p style="margin-left:2em"> 15 <code><em><sdk></em>/platforms/android-<em><version></em>/samples/</code> 16 </p> 17 18 <p>You can easily create new Android projects with these samples, modify them 19 if you'd like, then run them on an emulator or device. For example, to create 20 a project for the API Demos app from Eclipse, 21 start a new Android Project, select "Create project from existing source", then select 22 {@code ApiDemos} in the {@code samples/} directory. To create the API Demos project 23 using the {@code android} tool, execute:</p> 24 <pre> 25 android update project -s -n API Demos -t <em><target_ID></em> -p <em><path-to-platform></em>/samples/ApiDemos/ 26 </pre> 27 28 <p>The pages below provide an overview of each sample application (available with most 29 platforms) and allow you to view the source files in your browser. </p> 30 31 <div class="special"> 32 <p>Some of the samples in this listing are not yet available in the 33 SDK. While we work to update the SDK, you can 34 <a href="{@docRoot}shareables/latest_samples.zip">download the latest samples</a> as a ZIP 35 archive.</p> 36 </div> 37 38 <dl> 39 40 <dt><a href="{@docRoot}resources/samples/ApiDemos/index.html">API Demos</a></dt> 41 <dd>A variety of small applications that demonstrate an extensive collection of 42 framework topics.</dd> 43 44 <dt><a href="{@docRoot}resources/samples/BackupRestore/index.html">Backup and Restore</a></dt> 45 <dd>An simple example that illustrates a few different ways for an application to 46 implement support for the Android data backup and restore mechanism.</dd> 47 48 <dt><a href="{@docRoot}resources/samples/BluetoothChat/index.html">Bluetooth Chat</a></dt> 49 <dd>An application for two-way text messaging over Bluetooth.</dd> 50 51 <dt><a href="{@docRoot}resources/samples/ContactManager/index.html">Contact Manager</a></dt> 52 <dd>An application that demonstrates how to query the system contacts provider 53 using the <code>ContactsContract</code> API, as 54 well as insert contacts into a specific account.</dd> 55 56 <dt><a href="{@docRoot}resources/samples/Home/index.html">Home</a></dt> 57 <dd>A home screen replacement application.</dd> 58 59 <dt><a href="{@docRoot}resources/samples/JetBoy/index.html">JetBoy</a></dt> 60 <dd>JetBoy is a game that demonstrates the SONiVOX JET interactive music technology, 61 with {@link android.media.JetPlayer}.</dd> 62 63 <dt><a href="{@docRoot}resources/samples/LunarLander/index.html">Lunar Lander</a></dt> 64 <dd>A classic Lunar Lander game.</dd> 65 66 <dt><a href="{@docRoot}resources/samples/MultiResolution/index.html">Multiple Resolutions</a></dt> 67 <dd>A sample application that shows how to use resource directory qualifiers to 68 provide different resources for different screen configurations.</dd> 69 70 <dt><a href="{@docRoot}resources/samples/NotePad/index.html">Note Pad</a></dt> 71 <dd>An application for saving notes. Similar (but not identical) to the 72 <a href="{@docRoot}resources/tutorials/notepad/index.html">Notepad tutorial</a>.</dd> 73 74 <dt><a href="{@docRoot}resources/samples/SearchableDictionary/index.html">Searchable Dictionary</a></dt> 75 <dd>A sample application that demonstrates Android's search framework, 76 including how to provide search suggestions for Quick Search Box.</dd> 77 78 <dt><a href="{@docRoot}resources/samples/Snake/index.html">Snake</a></dt> 79 <dd>An implementation of the classic game "Snake."</dd> 80 81 <dt><a href="{@docRoot}resources/samples/SoftKeyboard/index.html">Soft Keyboard</a></dt> 82 <dd>An example of writing an input method for a software keyboard.</dd> 83 84 <dt><a href=""{@docRoot}resources/samples/Wiktionary/index.html">Wiktionary</a></dt> 85 <dd>An example of creating interactive widgets for display on the Android 86 home screen.</dd> 87 88 <dt><a href="{@docRoot}resources/samples/WiktionarySimple/index.html">Wiktionary (Simplified)</a></dt> 89 <dd>A simple Android home screen widgets example.</dd> 90 91 </dl> 92 93 94 <div class="special"> 95 <p>For more sample applications, check out 96 <a href="http://code.google.com/p/apps-for-android/">apps-for-android</a>, a 97 collection of open source applications that demonstrate various Android APIs. 98 </p> 99 </div> 100 101 102