Thanks to visit codestin.com
Credit goes to github.com

Skip to content

kamran41/Android-Cookbook-Examples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Android Cookbook Examples

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 code is drawn from existing projects that are hosted elsewhere.

Each Directory comprises its own project, and has a name that is cited at the end of the corresponding Recipe, under the "Source Code Download" section.

NOTE As of today, there are two styles of projects:

  1. Eclipse projects with the newer Eclipse Andmore;

  2. Android Studio projects (most complete with their extraneous "app" subdirectory).

If you have used the old Google ADT, you will need to update your Eclipse config by removing ADT, then replace it with AndMore from the Eclipse Marketplace Client.

Some of the Eclipse projects have been Mavenized and some have not.

The table at the bottom of this page shows which projects are set up for which build tools.

If you open the entire repo in Eclipse with eGit, be sure to check the Import 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). This directory is already set up to be an Eclipse workspace if you want it to (the .metadata directory exists and is already in .gitignore).

Obviously the Googlezilla has spoken and we will have to migrate kicking and screaming to Android Studio and Gradle; pull requests for this would also be welcomed, as long as they don’t break support for Eclipse and Maven.

You can download this as a Zip file, but then you won’t get updates, and it will be hard to collaborate with the 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 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).

Notes about the First Edition of the book

The current version of this repo is being reorganized in preparation for a new edition of the book. 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.

If you want this repo to correspond to the last minor revision of the first edition, git checkout the tag Book-1.0.

Wishlist

There are some things I’d love it if people would contribute:

  • Maven and/or Gradle files for each project that doesn’t already have one: always automate dependencies where possible!

  • Readme file for each project, to include a link back to the recipe in the book.

What’s here?

The following list is generated (periodically) from the project folders. In the Builds With column, E for Eclipse, M for Maven, S for Android Studio, G for Gradle.

Table 1. List of projects with description and build tools
Project Builds With Function Notes

AboutInfo

E

Info about device and screen

-

AndroidPlot

E

Graphing

-

AndroidRss

E

RSS Reader

-

AppDownloader

SG

Installs another app

Downloading, package management

AutoUpdater

E

App can update itself

see AppDownloader

AutocompleteTextViewContacts

E

Contact picker with autocomplete

-

BackupManager

E

Backups

-

BluetoothDemo

E

Bluetooth Connection

-

CalAdder

E

Add appointment to Calendar

Calendar via Content Provider

CallFaker

E

Pretend a call happened, for testing

-

CheckBoxRadioButton

E

GUI demo

name says it

ContentProviderBookmarks

EM

List of bookmarks

Browser ContentProvider

ContentProviderList

E

List of ContentProviders

-

ContentProviderSample

E

Implement a ContentProvider

-

ContentProviderTest

E

Test it

-

CountDownTimerExample

E

Time-based activity

-

CurrentMoodWidget

M

Application Widget

-

CursorLoaderDemo

EM

How to load data properly using CursorLoader

-

CustomMenu

E

Menu

-

CustomToast

E

Toast

-

DialogDemos

E

Dialogs

-

DreamsDemo

E

Demo of "Dreams" (4.x screensaver)

-

EmailTextView

E

Send contents of EditText via email

-

EmailWithAttachments

E

Attach file to email

-

EpochJSCalendar

E

Java + JavaScript

-

FaceFinder

E

Face locator API in photos

-

FacebookSdk

E

Access FB API

-

FileCursor

E

Fake up a Cursor from a list of files

INCOMPLETE

FontDemo

E

Using a custom font

-

Gallery

E

Simple photo gallery

Deprecated

GcmClient

E

Google Cloud Messaging - receiver

-

GcmMockServer

E

Google Cloud Messaging - sender

-

HelloCommandLine

E

HelloWorld

SDK

HelloEclipse

E

HelloWorld

Eclipse ADT

HelloMaven

EM

HelloWorld

Maven, JayWay Plug-in

HelloTestingTarget

E

ADT Testing - subject

-

HelloTestingTestProject

E

ADT Testing - Tests

-

HomeAppListView

EM

A Home Application

Shows running a program

HotContacts

E

Add a contact

Shows ContactsContract, content provider

IconizedListView

E

List View with Icon

-

IntentsDemo

EM

Intents

-

JavaTimeDemo

SG

Demos of java.time date/time API

Actually JSR-310 API; almost same but different package

JavascriptDataDemo

E

JavaScript from Java

-

JpsTrack

-

This app has moved to its own repo

ListViewAdvanced

E

ListView

-

ListViewDemos

E

ListView

-

ListViewEmpty

E

ListView with empty list: don’t show blank screen!

-

ListViewSectionHeader

E

ListView with section headers

-

LocalBroadcastDemo

E

Local Broadcast Receiver

-

MapDemosV2

E

Google Maps V2 API

-

MarketSearch

E

Search the Play Store

-

MediaPlayerDemo

E

Play media

-

MediaRecorderDemo

E

Simple sound recorder

-

NdkDemo

E

Native Development Kit

C Code

NotificationDemo

E

Notifications

-

NumberPickers

E

UI for picking numbers

-

OSMIntro

EM

OpenStreetMap API

(free alternative to Google Maps)

OpenGlDemo

E

OpenGL graphics

-

OrientationChanges

E

Rotation

-

PdfShare

E

Create and share a PDF

-

PhoneGapDemo

E

HTML5 app using phonegap/cordova

-

PreferencesDemo

E

Preferences

-

RGraphDemo

E

Using a graphing library

-

RangeGraphDemo

E

Using a graphing library

-

Rebooter

E

How to reboot, and why you can’t

-

SQLiteDemos

EM

SQLite demos

-

SecondScreen

Multi-screen

-

SendSMS

E

Sends an SMS

-

ShareActionProviderDemo

E

ICS "Share" action

-

SimpleAccountAndSyncDemo

E

User account on device

-

SimpleCalendar

E

Calendar

-

SimpleJumper

Flixel-based gaming demo

This example still needs to be re-created.

SimplePool

E

Graphics

-

SimpleTorchLight

E

Flashlight/torch from camera flash

-

SlidingDrawer-Topdown

E

The "Sliding Drawer" view

-

SnackBarDemo

EM

Snackbar (bottom message text) demo

-

SoapDemo

E

XML SOAP Web Service

-

SoundRec

EM

Sound Recorder

-

Speaker

E

Text To Speech (TTS)

-

SpinnerDemo

EM

Drop-down Spinner Demos

-

SplashDialog

E

Splash screen

-

StandardDrawables

E

Use Existing Drawables

-

TabSwipeDemo

E

Tabbable and swipeable layout

-

TeleCorder

E

Telephone call recorder (in progress!)

-

TelephonyManager

E

Displays phone info

-

Tipster

E

Full app: compute and show restaurant bill with tip

-

TodoClient

Todo Sync Client

Moved to own repo

UniqueId

E

Find device’s unique ID

-

Vibrate

E

Make the device vibrate

-

ViewPagerDemo

E

Swipe among views

-

VolleyDemo

EM

Demo of Volley networking library

-

WindowBackgroundDemo

E

Graphical window background

-

appcompat_v7

E

Compat library Eclipse Project

-

gridlayout_v7

E

Grid Layout Compat Library for Eclipse

-

About

Collected code examples from the O'Reilly Android Cookbook. See README below!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 39.7%
  • HTML 37.8%
  • Java 21.7%
  • CSS 0.6%
  • PHP 0.2%
  • Shell 0.0%