Where can the android samples be found?

2019-04-08 03:14发布

问题:

I checked google developers website for some exercises and examples in Android Development and I found this webpage: http://developer.android.com/tools/samples/index.html which says

When the download is complete, you can find the source code for all samples at this location: /samples/android-

I didn't find that location! What should I do? And if you know a better practicing way for a beginner to learn,let me know please!

回答1:

You will need to make sure the SDK samples are installed:

This image is from the SDK Manager. Once you check off the samples for the APIs you want, and everything is installed, you can easily make an Eclipse project:

File -> New -> Other -> Android Sample Project

Or you can navigate directly to the path. You can see from my screenshot, that for me it is in Program Files\Android\android-sdk with the samples being in the samples subdirectory.



回答2:

The latest (and most convenient way) to do it is:

  1. open android studio
  2. if a project is currently opened, close it (file -> close project)
  3. on the following screen choose "Import an Android code sample".

Also see http://developer.android.com/samples/index.html



回答3:

It's in the directory where you've installed the Android SDK. If you're running on Windows, it probably looks like C:\android-sdk. Inside it there's a subdirectory called samples. That's where they are. Note however, that they don't come pre-installed with the SDK, you need to actually download samples via the Android SDK first. Just launch it, check the "samples" for the android platform you want and start the download.



回答4:

On Win8: you import samples using Android SDK Manager and they are going to be in this folder (this is the folder with android-sdk):

C:\Users\YourUserName\AppData\Local\Android\sdk\samples

This worked for me