This repo contains about seventy source code examples from the recipes published in the O’Reilly Android Cookbook (see http://androidcookbook.com/), a great source of tutorial material for the Android Developer. Not all recipes in the book or online have code accompanying them; this repo features code that was either linked by the contributor, or in a few cases, re-constructed as a New Project by the editor, for your convenience.
Further note that not all programs used in the book/online appear here; some of the examples in the book/online are only program fragments taken from other programs that can’t be included. And of course some projects used as examples in the book/online are routinely hosted elsewhere.
Each Directory comprises its own Eclipse project, and has a name that is cited at the end of the corresponding Recipe, under the "Source Code Download" section. If you open the repo in Eclipse with eGit, be sure to check the "create all projects" checkbox. If you want to keep these mini-projects separate from your "regular" work, you may want to use the Git repo as an Eclipse workspace (use File→Switch Workspace→Other→Browse). The .metadata directory is already in .gitignore.
You can download this as a Zip file, but then you won’t get updates, and it will be hard to collaborate with the Editor and other contributors. If you’re new to Git, see the page on GitHub about how to collaborate. You can either send diff/patch files or, if you forked your own copy, send a pull request. Remember that GitHub is a free service for public projects!
If you open the repo as an Eclipse Workspace and no projects appear, despair not! Just do File→Import…→General→Existing Projects Into Workspace, browse to the top of the repo (the list of projects should appear), be sure "Import projects into workspace" is NOT checked, and click Finish; wait a bit.
Many of the projects may (depending on your version of Eclipse) give you some noise when you first open them due to bin and/or gen being missing. The Eclipse plug-in will usually create them but not notify that it’s done so, meaning you just have to do Refresh (F5), failing that, close and re-open the project. Does not happen with current Eclipse, last I tried.
There is neither a Wiki or a Tracker for this project, since bugs and suggestions about the code should be made on the Android Cookbook web site (http://androidcookbook.com/). Bugs or suggesions on the published edition of the book should go to http://shop.oreilly.com/product/0636920010241.do; you can also purchase the book there (which helps fund my continued work on this code base).
N.B. There have been quite a few projects added since the first published edition of the book, and a few renamed, so if you have the printed edition prior to December, 2012 you should rummage around here before re-typing anything that looks like a full example, and you will need to make the following adjustments:
There are some things I’d love it if people would contribute:
Maven pom files for each project that doesn't already have one. Readme file for each project, to include a link back to the recipe in the book.
Project | Function | What it shows | |
---|---|---|---|
AndroidPlot |
Graphing |
plotting library |
|
AndroidRss |
RSS Reader |
- |
|
AppDownloader |
Installs another app |
Downloading, package management |
|
AutocompleteTextViewContacts |
Contact picker with autocomplete |
- |
|
BackupManager |
- |
- |
|
BluetoothDemo |
Bluetooth Connection |
- |
|
CalAdder |
Add appointment to Calendar |
Calendar via Content Provider |
|
CheckBoxRadioButton |
GUI demo |
name says it |
|
ContentProviderBookmarks |
List of bookmarks |
Browser ContentProvider |
|
ContentProviderList |
List of ContentProviders |
- |
|
ContentProviderSample |
- |
- |
|
ContentProviderTest |
- |
- |
|
CountDownTimerExample |
- |
- |
|
CurrentMoodWidget |
- |
- |
|
CustomMenu |
- |
- |
|
CustomToast |
- |
- |
|
DialogDemos |
- |
- |
|
DigitalClock |
- |
- |
|
DisplayInfo |
- |
- |
|
DreamsDemo |
- |
- |
|
EmailTextView |
- |
- |
|
EmailWithAttachments |
- |
- |
|
EpochJSCalendar |
- |
- |
|
FaceFinder |
- |
- |
|
FacebookSdk |
- |
- |
|
FontDemo |
- |
- |
|
GcmClient |
Google Cloud Messaging - receiver |
- |
|
GcmMockServer |
Google Cloud Messaging - sender |
- |
|
HelloCommandLine |
HelloWorld |
SDK |
|
HelloEclipse |
HelloWorld |
Eclipse ADT |
|
HelloMaven |
HelloWorld |
Maven, JayWay Plug-in |
|
HelloTestingTarget |
ADT Testing - subject |
- |
|
HelloTestingTestProject |
ADT Testing - Tests |
- |
|
HomeAppListView |
- |
- |
|
HoneycombGallery |
- |
- |
|
HotContacts |
- |
- |
|
IconizedListView |
- |
- |
|
IntentsDemo |
- |
- |
|
JavascriptDataDemo |
- |
- |
|
JpsTrack |
- |
- |
|
ListViewAdvanced |
- |
- |
|
ListViewDemos |
- |
- |
|
ListViewEmpty |
- |
- |
|
ListViewSectionHeader |
- |
- |
|
LocalBroadcastDemo |
- |
- |
|
MapDemosV2 |
- |
- |
|
MarketSearch |
- |
- |
|
MediaPlayerDemo |
- |
- |
|
MediaRecorderDemo |
- |
- |
|
MyAccountAndSyncDemo |
- |
- |
|
NdkDemo |
- |
- |
|
NotificationDemo |
- |
- |
|
NumberPickers |
- |
- |
|
OpenGlDemo |
- |
- |
|
OrientationChanges |
- |
- |
|
PdfShare |
- |
- |
|
PhoneGapDemo |
- |
- |
|
PreferencesDemo |
- |
- |
|
RGraphDemo |
- |
- |
|
RangeGraphDemo |
- |
- |
|
Rebooter |
- |
- |
|
RemoteSystemsTempFiles |
- |
- |
|
SecondScreen |
- |
- |
|
SendSMS |
- |
- |
|
ShareActionProviderDemo |
- |
- |
|
SimpleCalendar |
- |
- |
|
SimpleJumper |
- |
- |
|
SimplePool |
- |
- |
|
SimpleTorchLight |
- |
- |
|
SlidingDrawer-Topdown |
- |
- |
|
SoapDemo |
- |
- |
|
Speaker |
- |
- |
|
SplashDialog |
- |
- |
|
TelephonyManager |
- |
- |
|
Tipster |
- |
- |
|
TodoModel |
- |
- |
|
TodoSyncClient |
- |
- |
|
TodoSyncServer |
- |
- |
|
UniqueId |
- |
- |
|
Vibrate |
- |
- |
|
ViewPagerDemo |
- |
- |
|
WindowBackgroundDemo |
- |
- |