Android-Cookbook-Examples 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
Android-Cookbook-Examples 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
Android-Cookbook-Examples 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 View license
开发语言 Java
操作系统 跨平台
软件类型 开源软件
所属分类 手机/移动开发
开源组织
地区 不详
投 递 者 首席测试
适用人群 未知
收录时间 2021-11-26

软件简介

Android Cookbook Examples

This repo is among the largest collections of Android code samples anywhere; it contains around a hundred and fifty compilable source code examples from the O’Reilly Android Cookbook, 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 some 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.

Some older started-in-Eclipse projects also have configuration files to allow them to be opened in Android Studio. During the runup to the second edition of the book, AndMore appeared to be a viable project to maintain Android Eclipse development. However, over time, it has become clear that AndMore has not attracted enough developer talent to remain viable. Accordingly, the newest projects here are Android-Studio-Only. And Issue #1 calls for moving the existing mass of projects to Studio-only format. For reference, a "canonical" project would look something like this:

README.txt
app/
├── app.iml
├── build/
├── build.gradle
├── libs
├── proguard-rules.pro
└── src
    ├── androidTest
    │   └── java
    │       └── com
    │           └── darwinsys
    │               └── circleviewgroup
    │                   └── ExampleInstrumentedTest.java
    ├── main
    │   ├── AndroidManifest.xml
    │   ├── java
    │   │   └── com
    │   │       └── androidcookbook
    │   │           └── some_project_name
    │   │               └── MainActivity.java
    │   └── res
    │       ├── drawable
    │       ├── layout
    │       │   └── activity_main.xml
    │       ├── mipmap-hdpi
    │       │   ├── ic_launcher.png
    │       │   └── ic_launcher_round.png
    │       ├── mipmap-*
    │       └── values
    │           ├── colors.xml
    │           ├── strings.xml
    │           └── styles.xml
    └── test
        └── java
            └── com
                └── darwinsys
                    └── circleviewgroup
                        └── ExampleUnitTest.java
build.gradle
gradlew, gradlew.bat
local.properties
settings.gradle

The table List of Projects shows lists each project, its author, and a short summary.

*Note that, since Gradle and the Gradle Android Plugin need to be updated just about every time your run Android Studio, there is no attempt made to keep things up-to-date here; just let Studio do its upgrade thing for you and all will be well. They promise.

DELETED PROJECTS

JpsTrack and the ToDo applications have graduated to their own github projects, under https://github.com/IanDarwin.

List of Projects

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. The Author names have recently been added; if I have missed or mis-attributed any, please let me know and I will happily correct them. You (and I) know who you are.

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

AboutBoxDemo

Ian Darwin

A re-usable About dialog.

-

AboutInfo

Ian Darwin

Info about device and screen

-

ActionBarCompat

Ian Darwin

Simple ActionBar demo(s)

-

AddContact

Ian Darwin

Add a contact

Shows ContactsContract, content provider

AdMobDemo

Ian Darwin

Using AdMob with interstitial (inter-Activity) ads.

-

Analytics

Ian Darwin

Ashwini’s Google Analytics for Android Demo, slightly updated.

-

AndroidPlot

Rachee Singh

Graphing

-

AndroidRss

Wagied Davids

RSS Reader

Works under Maven; Eclipse fails w/ Maven Configuration Problem

AppDownloader

Ian Darwin

Installs another app

Downloading, package management

AppShortcutsDemo

Ian Darwin

Shows App Shortcuts, which appear with long-press on app’s launcher icon.

-

AppSingleton

Ian Darwin

Compilable example of the Application Singleton pattern recipe.

-

AutocompleteTextViewContacts

Ian Darwin

Contact picker with autocomplete

-

AutoUpdater

Ian Darwin

App can update itself

see AppDownloader

BackupManager

Ian Darwin

Use Android Backup scheme.

-

BluetoothDemo

Ian Darwin

Bluetooth Connection

-

CalAdder

Ian Darwin

Add appointment to Calendar

Calendar via Content Provider

CallFaker

Ian Darwin

Pretend a call happened, for testing

-

CallInterceptorIncoming

Johan Pelgrim

Intercept an incoming phone call.

-

CallInterceptorOutgoing

Johan Pelgrim

Intercept outgoing phone calls.

Compiles and runs, but doesn’t intercept the call.

CameraIntent

Ian Darwin

CameraIntent - get the camera to take a picture, by startActivityForResult()

-

CardDemo

Ian Darwin

Demonstation of Card widget.

-

CheckBoxRadioButton

Ian Darwin

GUI demo

name says it

CircleViewGroup

Ian Darwin

Attempt at a custom layout manager.

-

ContentProviderBookmarks

Ian Darwin

List of bookmarks from Bookmarks Content Provider

Browser ContentProvider

ContentProviderList

Ian Darwin

List of ContentProviders

-

ContentProviderSample

Ashwini Shahapurkar

Implement a ContentProvider

-

ContentProviderTest

Ian Darwin

Test it

-

CordovaDemo

Ian Darwin

Simple Cordova cross-platform (web-based) toolkit demo.

-

CountDownTimerExample

Wagied Davids

Time-based activity

-

CurrentMoodWidget

Ian Darwin

Application Widgets have a live display on the home page, like the standard Clock program.

-

CursorLoaderDemo

Ian Darwin

How to load data properly using CursorLoader

-

CustomMenu

Ian Darwin

Menu

-

CustomSubMenu

Ian Darwin

Submenu, created programmatically

-

CustomToast

Rachee Singh

Toast

-

DatabaseFromFile

Ian Darwin

Create a database from an SQLite .db file in 'assets'.

-

DataToCursor

Ian Darwin

Fake up a Cursor from a list of files

-

DateFormatDemo

Ian Darwin

Example of various DateFormat usages (the Android one, not java.text nor java.time).

-

DialogDemos

Ian Darwin

Dialogs

-

DragDropDemo

Ian Darwin

A simple Drag-and-drop example.

-

DreamsDemo

Ian Darwin

Demo of "Dreams" (4.x screensaver)

-

EmailTextView

Wagied Davids

Send contents of EditText via email

-

EmailWithAttachments

Marco Dinacci

Attach file to email

-

EpochJSCalendar

Wagied Davids

Java + JavaScript Epoch Calendar

-

EventListenersDemo

Daniel Fowler

5 Ways to Wire an Event Listener.

-

FacebookSdk

N/R. Pending check.

Access FB API

-

FaceFinder

Wagied Davids

Face locator API in photos

-

FileProviderDemo

Ian Darwin

Demo of FileProvider.

-

FilesystemDemos

Ian Darwin

Internal and external files.

-

FindMeX

Ian Darwin

Find Me X

IllegalArgumentException: Incomplete location object, missing timestamp or accuracy, Progress:334

FloatingActionButtonSnackbarDemo

Ian Darwin

Demo of 'fab' Floating Abstract Button

-

FontDemo

Ian Darwin

Using a custom font

You need to provide the font file! Example uses Iceberg font…​

FragmentsDemos

Ian Darwin

Simple Fragment and List-Detail Fragments in one project

-

Gallery

Ian Darwin

Simple Photo Gallery example.

Deprecated

GcmClient

Ian Darwin

Google Cloud Messaging - receiver

-

GcmMockServer

Ian Darwin

Google Cloud Messaging - sender

-

GeneralPrompter

Ian Darwin

A program that shows the Storage Facility to prompt for all files.

-

HapticFeedback

Ian Darwin

Haptic Feedback recipe.

-

HelloCommandLine

Ian Darwin

HelloWorld

SDK

HelloEclipse

Ian Darwin

HelloWorld

Eclipse ADT

HelloEspressoTesting

Ian Darwin

HelloWorld of EspressoTesting

-

HelloGradle

Ian Darwin

Hello World with Gradle but NOT Studio.

-

HelloMaven

Ian Darwin

HelloWorld using Maven with android-maven-plugin.

-

HelloStudioTesting

Ian Darwin

HelloWorld of StudioTesting

-

HelloTestingTarget

Adrián Santalla

ADT Testing - subject

-

HelloTestingTestProject

Ian Darwin

ADT Testing - Tests

-

HomeAppListView

Ian Darwin

A Home Application

Shows running a program

IconizedListView

Ian Darwin

List View with Icon

-

ImageButtonDemo

Ian Darwin

ImageButtons!

-

IntentsDemo

Ian Darwin

Intents

-

IPCDemo

Ian Darwin

IPC - Inter-Process Communication, simplified demo (2 versions, alas).

-

IpcServiceDemo

Rupesh Chavan

IPC - Inter-Process Communication, simplified demo (2 versions, alas).

-

JavascriptDataDemo

Ian Darwin

Getting data from Java to JavaScript and back.

-

JavaTimeDemo

Ian Darwin

Demos of java.time date/time API

Actually JSR-310 API; almost same but different package

JSONParsing

Ian Darwin

Simple example of JSON parsing using built-in JSONObject.

-

KotlinVolleyDemo

Ian Darwin

Kotlin version of Volley demo

-

LayoutBorder

Ian Darwin

Layout Border Demo Project Source for Android

-

ListViewAdvanced

Marco Dinacci

ListView

-

ListViewDemos

Ian Darwin

ListView

-

ListViewEmpty

Rachee Singh

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

-

ListViewSectionHeader

Ian Darwin

ListView with section headers

-

LocalBroadcastDemo

Ian Darwin

Local Broadcast Receiver

-

MapDemosV2

Ian Darwin

This is the Google API Maps V2 Demo.

-

MapsV2AddToProject

Ian Darwin

Adding a Google Maps V2 MapActivity to a project

You must ask for permission from Google (get and provide your own Google API key).

MarketSearch

Ian Darwin

Search the Play Store

-

MaterialDemos

Ian Darwin

MaterialDesign demos

-

MediaPlayerDemo

Ian Darwin

Play media

-

MediaPlayerInteractive

Ian Darwin

Media Player demo from Marco Dinacci, thanks.

-

MediaRecorderDemo

Marco Dinacci

Simple sound recorder

-

MenuAction

Ian Darwin

Menu Action Handling

-

NativeFunctFromJS

Ian Darwin

Try to invoke native code from JavaScript.

-

NdkDemo

Ian Darwin

Native Development Kit

C Code

NotificationDemo

Ian Darwin

Notifications

-

NumberPickers

Ian Darwin

UI for picking numbers

-

OAuth2Demo

Ian Darwin

Demo of OAuth2 to Google Tasks.

-

OpenGlDemo

Marco Dinacci

OpenGL graphics

-

OrientationChanges

Wagied Davids

Rotation

-

OSMIntro

Rachee Singh

Basic OSM map app demo.

Builds with Maven, not with Eclipse. Maybe m2e aar support, isn’t, yet.

OSMOverlay

Ian Darwin

OSM Map with a map marker overlay

Compiles, runs, doesn’t load map tiles; needs upgrading to osmdroid-android 5.5

OSMTouchEvents

Ian Darwin

OSM Map with touch event handling.

Builds with Maven, not with Eclipse. Maybe m2e aar support, isn’t, yet.

PdfShare

Ian Darwin

Create and share a PDF

-

PermissionRequest

Ian Darwin

Shows asking for permissions at runtime, i.e,. "the new way"

-

PhoneGapDemo

Shraddha Shravagi

HTML5 app using phonegap/cordova

-

PinchAndZoom

Ian Darwin

Pinch-and-zoom graphics demo

-

PreferencesDemo

Ian Darwin

Preferences

-

ProgressDialogDemo

Ian Darwin

Demo of a pop-up indefinite progress dialog.

-

RangeGraphDemo

Ian Darwin

Using a graphing library

-

RatingBarDemo

Ian Darwin

Show use of 5-star RatingBar as used in rankings, surveys, &c.

-

Rebooter

Ian Darwin

How to reboot, and why you can’t

-

RecipeList

Ian Darwin

= RecipeList - use an AsyncTask to download data over the 'net via HTTP.

-

RecyclerViewDemo

Ian Darwin

Demo of RecyclerView, the faster ListView.

-

RemoteSystemsTempFiles

Ian Darwin

This folder is created automatically by Eclipse and can be ignored.

-

RGraphDemo

Wagied Davids

Using a graphing library

-

RoomDemo

Ian Darwin

Demo of Room, the official Android ORM.

-

RuntimeLog

Ian Darwin

A simpe runtime log facility

-

ScanBarcode

Ian Darwin

Scan barcode using ZXing app via Intent

-

SecondScreen

Ian Darwin

Trivial example of one Activity (screen) starting another.

-

SendSMS

Colin Wilcox

Sends an SMS

-

SensorShakeDetection

Thomas Manthey

Use Accellerometer to detect if the user has shaken the device.

-

SensorUpOrDown

Rachee Singh

Code for r2051, Checking Whether a Device Is Facing Up or Down

-

ShareActionProviderDemo

Ian Darwin

ICS "Share" action

-

ShellCommand

Ian Darwin

Run a Unix/Linux command via Runtime.exec, capture the output.

-

SimpleAccountAndSyncDemo

Ian Darwin

User account on device

-

SimpleCalendar

Ian Darwin

Calendar

-

SimpleDialer

Ian Darwin

Trivial Dialer - launches Dialer app via Intent

-

SimpleJumper

Wagied Davids

Common code for flixel-gdx-based gaming demo.

Game starts, can move left-right only, no scenery. Fails on Intel phone/emulator

SimplePool

Wagied Davids

Start of a pool/billiards game using AndEngine.

-

SimpleTorchLight

Saketkumar Srivastav

Simple Torchlight/Flashlight example.

(Most devices now have a built-in control for this)

SlidingDrawer-Topdown

Wagied Davids

The main code is from the "Sliding Drawer - Top Down" recipe

-

SMSReceive

Ian Darwin

Receive an incoming SMS.

-

SnackBarDemo

Ian Darwin

Snackbar (bottom message text) demo

-

SoapDemo

Ian Darwin

XML SOAP Web Service

-

SoftKeyboardEnterNext

Jonathan Fuerth

Change the Enter key to "Next" on one-line text fields.

-

SoundRec

Ian Darwin

Sound Recorder

-

Speaker

Ian Darwin

Text To Speech (TTS)

-

SpeechRecognizerDemo

Ian Darwin

Speech Recognizer.

-

SpinnerDemo

Ian Darwin

Drop-down Spinner Demos

-

SpinningCubeDemo

Marco Dinacci

OpenGL Spinning Cube, from Marco Dinacci

-

SplashDialog

Rachee Singh

Splash screen

-

SQLiteDemos

Ian Darwin

SQLite demos

-

StandardDrawables

Ian Darwin

Use Existing Drawables

-

StaticFileRead

Ian Darwin

StaticFileRead - read a file from the application

-

StringsXML

Daniel Fowler

Demos for "Nuances of Strings.xml" recipe.

-

TabHostDemo

Ian Darwin

TabHost Demo: Demo of the TabHost widget, in a Dialog.

-

TabSwipeDemo

Ian Darwin

Tabbable and swipeable layout

-

TeleCorder

Ian Darwin

Telephone call recorder (in progress!)

-

TelephonyManager

Pratik Rupwal

Displays phone info

-

Tipster

Sunit Katkar

Full app: compute and show restaurant bill with tip

-

UniqueId

Ian Darwin

Find device’s unique ID

-

Vibrate

Rachee Singh

Make the device vibrate

-

ViewPagerDemo

Ian Darwin

Swipe among views

-

VolleyDemo

Ian Darwin

Demo of Volley networking library

-

WheelPickerDemo

Wagied Davids

Apple-style Wheel Picker Demo

-

WindowBackgroundDemo

Ian Darwin

Graphical window background

-

展开阅读全文

代码

评论 (0)

加载中
更多评论
暂无内容
发表了博客
2019/01/31 11:27

Android Activity

1. <activity android:icon="...">//设置Activity的action-bar上面的图标 <activity android:screenOrientation="portrait"/>//portrait 竖屏(默认),landscape 横屏,sensor 重力感应 name、label、theme 2. TextView tv = new TextView(this); tv.setText("..."); tv.setTextSize(25f); tv.setTextColor(Color.BLUE); tv.setGravity(Gravity.CENTER); tv.setPadding(10,10,10,10); setContentView(tv);//界面中只有一个控件...

0
0
发表了博客
2014/11/14 10:45

android_Activity

Activity的生命周期 Activity四种启动模式 1.Standared(默认)激活该Activity,则会向任务栈中加入新创建的实例,退出Activity则会在任务栈中销毁该实例 2.SingleTop这种模式会考虑当前要激活的Activity实例在任务栈中是否正处于栈顶,如果处于栈顶则无需重新创建新的实例,会重用已存在的实例,否则会在任务栈中创建新的实例。 3.SingleTask如果任务栈中存在该模式的Activity实例,则把栈中该实例以上的Activity实例全部移除,调...

0
0
发表了博客
2014/01/07 21:40

Android--Activity

Activity是android四大组件之一(Activity、Service、Broadcast Receiver、Content Provider) 应用程序中,一个Activity通常就是一个单独的屏幕,但也有时比屏幕小,浮动在其他窗体上,它上面可以显示一些控件也可以监听并处理用户的事件做出响应。Acitivity之间通过Intent进行显性通信。也可以通过IntentFilter进行隐形通信。 可以通过startActivity()/startActivityForResult()来激活新的Activity 通过显性的Intent(新Activ...

0
0
发表了博客
2014/05/12 11:23

Android:Activity(四):Activity生命周期

Activity生命周期 Activity有4种状态: 1.活动状态:当Activity位于前台,用户可见,可获得焦点,此时的Activity位于栈顶. 2.暂停状态:其他Activity位于前台,该Activity依然可见,只是不能获得焦点. 3.停止状态:当Activity不可见,失去焦点. 4.销毁状态:当Activity结束,或Activity所在的Dalvik进程结束. 在Activity生命周期中,如下方法会被系统调用: 1.onCreate(Bundle savedStatus):创建Activity时被回调,该方法只会被调用...

0
0
发表了博客
2013/04/29 09:13

android Activity 组件

详解 Android 的 Activity 组件 Activity 的生命周期 和 J2ME 的 MIDlet 一样,在 android 中,Activity 的生命周期交给系统统一管理。与 MIDlet 不同的是安装在 android 中的所有的 Activity 都是平等的。 Activity 的状态及状态间的转换 在 android 中,Activity 拥有四种基本状态: Active/Runing一个新 Activity 启动入栈后,它在屏幕最前端,处于栈的最顶端,此时它处于可见并可和用户交互的激活状态。 Paused 当 Activity...

0
3
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
暂无内容
0 评论
0 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部