blob: 267c273c0ed13da278240fc94ebf032d7c518159 [file] [log] [blame]
Dirk Doughertyb6bc0202013-07-09 13:18:15 -07001page.title=Samples
Joe Fernandeze26c4d22014-10-09 21:16:03 -07002page.tags="examples","code"
Joe Fernandezc779c012013-10-30 23:22:52 -07003
Dirk Doughertyb6bc0202013-07-09 13:18:15 -07004@jd:body
5
Dirk Doughertyb6bc0202013-07-09 13:18:15 -07006
Rich Slogar7cc83982014-12-15 15:51:28 -08007<p>Welcome to code samples for Android developers. Here you can browse sample code and learn how to
8build different components for your applications. Use the categories on the left to browse the
9available samples.</p>
Joe Fernandezc779c012013-10-30 23:22:52 -070010
11<p>Each sample is a fully functioning Android app. You can browse the resources, source files and
Rich Slogar7cc83982014-12-15 15:51:28 -080012see the overall project structure. You can copy and paste the code you need, and if you want to
13share 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
19recommended 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 &gt; 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
40GitHub</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
45categories on the left to browse the available samples and learn how to build different components
46for your applications.</p>
Joe Fernandezc779c012013-10-30 23:22:52 -070047
48<p>If you want to download a complete project, just click on any source file in the project and
Rich Slogar7cc83982014-12-15 15:51:28 -080049 click the <strong>Download</strong> link in the upper right of the source page.</p>
Joe Fernandezc779c012013-10-30 23:22:52 -070050
Joe Fernandez24807d72013-10-31 09:26:43 -070051<p>To import a downloaded project:<p>
52
Joe Fernandez24807d72013-10-31 09:26:43 -070053 <ol>
54 <li>Unpack the downloaded project package.</li>
55 <li>In <a href="{@docRoot}sdk/installing/studio.html">Android Studio</a>, chose
Rich Slogar7cc83982014-12-15 15:51:28 -080056 <strong>File &gt; Import Project</strong> and select the root folder of the unpacked project.
Joe Fernandez24807d72013-10-31 09:26:43 -070057 <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 Slogar7cc83982014-12-15 15:51:28 -080064<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 Fernandez24807d72013-10-31 09:26:43 -070070
Joe Fernandezc779c012013-10-30 23:22:52 -070071<p class="note">
72 <strong>Note:</strong> At this time, the downloadable projects are designed for use with Gradle
Rich Slogar7cc83982014-12-15 15:51:28 -080073 and Android Studio.
Joe Fernandezc779c012013-10-30 23:22:52 -070074</p>
75