Dirk Dougherty | b6bc020 | 2013-07-09 13:18:15 -0700 | [diff] [blame] | 1 | page.title=Samples |
Joe Fernandez | e26c4d2 | 2014-10-09 21:16:03 -0700 | [diff] [blame] | 2 | page.tags="examples","code" |
Joe Fernandez | c779c01 | 2013-10-30 23:22:52 -0700 | [diff] [blame] | 3 | |
Dirk Dougherty | b6bc020 | 2013-07-09 13:18:15 -0700 | [diff] [blame] | 4 | @jd:body |
| 5 | |
Dirk Dougherty | b6bc020 | 2013-07-09 13:18:15 -0700 | [diff] [blame] | 6 | |
Rich Slogar | 7cc8398 | 2014-12-15 15:51:28 -0800 | [diff] [blame] | 7 | <p>Welcome to code samples for Android developers. Here you can browse sample code and learn how to |
| 8 | build different components for your applications. Use the categories on the left to browse the |
| 9 | available samples.</p> |
Joe Fernandez | c779c01 | 2013-10-30 23:22:52 -0700 | [diff] [blame] | 10 | |
| 11 | <p>Each sample is a fully functioning Android app. You can browse the resources, source files and |
Rich Slogar | 7cc8398 | 2014-12-15 15:51:28 -0800 | [diff] [blame] | 12 | see the overall project structure. You can copy and paste the code you need, and if you want to |
| 13 | share a link to a specific line you can double-click it to the get the URL.</p> |
| 14 | |
| 15 | |
| 16 | <h2>Import Samples from GitHub</h2> |
| 17 | |
| 18 | <p>Android Studio provides easy access to import Android code samples from GitHub and is the |
| 19 | recommended method to retrieve Android code samples.</p> |
| 20 | |
| 21 | <p>To import a code sample into Android Studio:<p> |
| 22 | |
| 23 | <ol> |
| 24 | <li>In the Android Studio menu, select <strong>File > Import Sample</strong> to open the |
| 25 | Import Sample wizard.</li> |
| 26 | <li>Select a sample to import and click <strong>Next</strong>.</li> |
| 27 | <li>Specify the application name and project location if different from the displayed settings.</li> |
| 28 | <li>Click <strong>Finish</strong>. |
| 29 | <p>The sample project opens in a new Android Studio project.</p></li> |
| 30 | </ol> |
| 31 | |
| 32 | <p class="note"> |
| 33 | <strong>Note:</strong> When starting Android Studio, you can also select <strong>Import an |
| 34 | Android code sample</strong> in the Welcome to Android Studio wizard to import a sample project |
| 35 | from GitHub as a new project. |
| 36 | </p> |
| 37 | |
| 38 | <p>For more information about importing samples, see |
| 39 | <a href="{@docRoot}tools/studio/index.html#git-samples">Easy access to Android code samples on |
| 40 | GitHub</a>.</p> |
| 41 | |
| 42 | <h2>Download Samples</h2> |
| 43 | |
| 44 | <p>Although importing samples from Android Studio is the recommended method, you can also use the |
| 45 | categories on the left to browse the available samples and learn how to build different components |
| 46 | for your applications.</p> |
Joe Fernandez | c779c01 | 2013-10-30 23:22:52 -0700 | [diff] [blame] | 47 | |
| 48 | <p>If you want to download a complete project, just click on any source file in the project and |
Rich Slogar | 7cc8398 | 2014-12-15 15:51:28 -0800 | [diff] [blame] | 49 | click the <strong>Download</strong> link in the upper right of the source page.</p> |
Joe Fernandez | c779c01 | 2013-10-30 23:22:52 -0700 | [diff] [blame] | 50 | |
Joe Fernandez | 24807d7 | 2013-10-31 09:26:43 -0700 | [diff] [blame] | 51 | <p>To import a downloaded project:<p> |
| 52 | |
Joe Fernandez | 24807d7 | 2013-10-31 09:26:43 -0700 | [diff] [blame] | 53 | <ol> |
| 54 | <li>Unpack the downloaded project package.</li> |
| 55 | <li>In <a href="{@docRoot}sdk/installing/studio.html">Android Studio</a>, chose |
Rich Slogar | 7cc8398 | 2014-12-15 15:51:28 -0800 | [diff] [blame] | 56 | <strong>File > Import Project</strong> and select the root folder of the unpacked project. |
Joe Fernandez | 24807d7 | 2013-10-31 09:26:43 -0700 | [diff] [blame] | 57 | <p>Android Studio may ask you to choose the type of project you are importing. |
| 58 | If this is the case, make sure to choose <strong>Import project from |
| 59 | external model</strong> and select the <strong>Gradle</strong> option. |
| 60 | </p> |
| 61 | </li> |
| 62 | </ol> |
| 63 | |
Rich Slogar | 7cc8398 | 2014-12-15 15:51:28 -0800 | [diff] [blame] | 64 | <p class="note"> |
| 65 | <strong>Note:</strong> When starting Android Studio, you can also select <strong>Import |
| 66 | Non-Android Studio project</strong> in the Welcome to Android Studio wizard to import a |
| 67 | downloaded sample project. |
| 68 | </p> |
| 69 | |
Joe Fernandez | 24807d7 | 2013-10-31 09:26:43 -0700 | [diff] [blame] | 70 | |
Joe Fernandez | c779c01 | 2013-10-30 23:22:52 -0700 | [diff] [blame] | 71 | <p class="note"> |
| 72 | <strong>Note:</strong> At this time, the downloadable projects are designed for use with Gradle |
Rich Slogar | 7cc8398 | 2014-12-15 15:51:28 -0800 | [diff] [blame] | 73 | and Android Studio. |
Joe Fernandez | c779c01 | 2013-10-30 23:22:52 -0700 | [diff] [blame] | 74 | </p> |
| 75 | |