Index

imagesSymbols and Numerics

@ symbol

entering e-mail address, 120

XML layout file, 25, 27

@+id notation, 47

@id notation, 48

12- and 24-hour modes, 95

imagesA

aapt tool, 23

AbsoluteLayout container, 116, 332

accelerometers

handling iPhone rotation, 196

ACCESS_COARSE_LOCATION, 303

accessing files see file access

accessory button, EditText, 121

ACTION_DIAL

making phone call, 312

ACTION_EDIT, 172

ACTION_PICK

handling screen rotation, 188

intents, 172

getting Uri handles, 260

starting intents, 179

ACTION_VIEW, 172, 178

actions, intents, 172

active state, activities, 167

handling screen rotation, 185

activities, 3, 19, 177

attaching widgets to, 23

binding to services, 286

blocking rotation of, 193

building and running, 2022

custom handling of screen rotation, 191

embedding second activity in main activity UI, 351

getPreferences method, 213

getSharedPreferences method, 213

handling screen rotation, 185

invoking onCreate method, 19

killing off activity as nonresponsive, 155

knowing, or not, when launched activity ends, 177

launching, 177181

life cycle, 167

not rotating activities, 193195

peer activities, 178, 179

permissions, 277

preferences, 213

relative importance of, 167

replacing tabs with, 340

Schroedinger's Activity, 167

starting, 178181

states, 167

saving application-instance state, 169

transitions between, 168169

subactivities, 177

supplying fully qualified class name of main activity, 7

TabActivity, 103

trapping button clicks within, 19

Activity class

creating Android projects, 7

runOnUiThread method, 159

tabbed browsing, 182

activity classes

ListActivity, 60, 61

TabActivity, 103

MapActivity, 302, 303

activity element, 10, 173

activityCreator script, 173

ActivityManager, 155

adapters, 5960

ArrayAdapter, 60, 76, 84

controlling appearance of rows, 62

CursorAdapter, 60, 94

ListAdapter, 89, 90, 93

ListView with icons and text, 76, 77, 78

setAdapter method, 60, 64, 67, 70

setListAdapter method, 61

setting list adapter, 61

SimpleAdapter, 60

SimpleCursorAdapter, 261, 262

AdapterWrapper class, 90

adb logcat command, 322

adb pull command, 235, 323

adb push command, 236, 323

adb shell command, 235, 324

Add Constant dialog, 226

add method, options menu, 126

addId method, Uri class, 260

addMenu method, 127

addPreferencesFromResource method, 215

addProximityAlert method, 298

AddStringTask class, 161164

class declaration, 163

doInBackground method, 163

execute method, 164

onPostExecute method, 164

onProgressUpdate method, 163

addSubMenu method, 127

addTab method, 105

AlertDialog, 150

alerts, 150

see also notifications

MessageDemo example, 151153

alignment

widgets, 47

alignment, RelativeLayout container

layout_alignParentXyz properties, 47

layout_alignXyz properties, 48

alphabeticShortcut attribute, item element

describing menus via XML files, 135

AnalogClock widget, 99

Android

accessing binary data, 264

accessing REST-style web services, 253

building content provider, 265274

creating card image, 328329

file access, 237

Google Maps, 302

handling API changes, 362366

handling multiple screen sizes, 331351

handling platform changes, 359366

handling work on UI/background threads, 159165

indicating API level to, 5

international deployment, 140

invoking onClick method, 19

Java using Dalvik VM, 246

making friendly background threads, 155

objective of, 2

online help, 367

operating system changes, 360361

permission system, 275

preferences framework, 214215, 219220

source code, 368

SQLite in runtime, 227

states, transitions between, 168169

storage, 237

targets, 1215

using BeanShell on, 247

using Java third-party libraries, 245

WebKit browser, 141

when Android dislikes font, 139

Android adapters see adapters

Android applications see applications

Android AVD Manager see AVD Manager

Android browser, 143

Android build system, 6

creating R.java, 7

android command

building and running activities, 20

using AVD Manager, 13

android create avd command, 13

android create project command, 6, 17

Android devices see devices

Android emulator see emulators

Android Google Groups, 367

Android handsets

handling screen rotation, 185

Android help, 367

Android launcher see launcher

android list targets command, 13

Android map activity, 181

Android Market, 355

APK files, 362

avoiding for user testing, 339

first child of manifest bug, 12

minSdkVersion attribute, 11

versions of Android affecting, 5

Android package files see APK files

Android packaging tool, 2022

Android programming, 1, 19

Android projects see projects

Android Scripting Environment (ASE), 251

Android SDK, 315

documentation, 367

Android technology, future uses of, 1

Android UI architecture, 177

Android Virtual Device see AVD

Android widgets see widgets

ANDROID_ID

Archos 5 Android Internet Tablet, 356

android:id attribute, XML, 25

android:layout see layout properties

android:text attribute, XML, 25

AndroidManifest.xml file, 5, 6, 812

adding service to, 281

allowing users to set preferences, 215

blocking rotation of activities, 193

creating intents, 178

custom handling of screen rotation, 191

declaring intent receivers, 174

enforcing permissions via, 277278

EU4You application, 340

getting map into application, 303

intent-filter elements, adding, 173

minSdkVersion attribute, 11

permission element, 277

requesting permission to access Internet, 142

requesting permission to use data, 275

securing application using permissions, 277

specifying hardware requirements, 353

supports-screens element, 334

updating for content provider, 273

uses-configuration element, 353

uses-feature element, 354

uses-permission element, 275

uses-sdk element, 11

versionCode attribute, 12

versionName attribute, 12

animateXyz methods, SlidingDrawer, 115

ant build tool, 6, 2022

Ants

using Java third-party libraries, 246

anyDensity attribute, supports-screens, 335

ap file, bin folder, 8

Apache HttpClient, 254255

Apache HttpComponents, 253

Apache Software License 2.0, 355

API keys, generating, 308, 309

API level, indicating, 5

apiKey attribute, 302, 309

APIs

deprecated API, 362

handling API changes, 362366

wrapping API, 362366

APK (Android package) files, 5

Android Market, 362

static application reference data, 237

apk file, bin folder, 8

application element, 10

updating manifest for content provider, 273

application menus see options menu

application-level preferences, 213

applications

see also projects

access to external storage, 244

building, 515

components used in, 2

enforcing permissions via manifest, 277278

explicitly specifying hardware requirements, 353354

generating API keys, 308

getting map into, 302

handling platform changes, 359366

making data available, 265

manifest file, 8

permissions, 275

preferences, 213

requesting permission to use data, 275

saving instance state, 169

securing application using permissions, 277

skeleton application, creating, 17

starter manifest, 8

static reference data, 237240

table of contents, 5

testing with emulator, 5

writeable data files, 240244

applications, list of

see also projects, list of

AsyncDemo, 162

Browser1, 141, 143

Browser2, 144

Browser3, 145, 146

Constants, 226

ConstantsPlus, 261, 265

Dialer, 312

DialerDemo, 313

EU4You, 340, 346, 348, 349

FontSampler, 137, 139

HandlerDemo, 158

ImagesDemo, 204

IntentTabDemo, 184

LaunchDemo, 181

MenuDemo, 130

NooYawk, 302

ReadWrite, 315

ReadWriteFileDemo, 243

RotationFour, 193, 194

RotationOne, 186, 188, 189

RotationThree, 191

RotationTwo, 190

StaticFileDemo, 240

StringsDemo, 201

WeatherDemo, 257

WeatherPlus, 285

XMLResourceDemo, 206

applyFormat method, string, 201

applyMenuChoice method, 130

Archos 5 Android Internet Tablet, 355

ANDROID_ID, 356

buttons, 354

ArrayAdapter class, 60

combining RatingBar with ListView, 84, 86

controlling appearance of rows, 62

creating views, 68

ListView with icons and text, 76

arrays, resources, 208

assets folder

Android project root directory, 7

using different fonts, 138

AsyncDemo application, 162

AsyncTask class, 159161

see also AddStringTask class

broadcast intents, 283, 284

creating subclass of, 160

doInBackground method, 160, 163

generics, 160

handling work on UI/background threads, 159165

onPostExecute method, 161, 164

onPreExecute method, 161

onProgressUpdate method, 161, 163

overrideable methods, 160

publishProgress method, 161, 163, 164

varargs, 160

authentication

launching activities, 177

authorities property

updating manifest for content provider, 273

authority, content Uri, 266

auto_fit value, numColumns, GridView, 66

AutoCompleteTextView widget, 6972

autocorrection

entering text on soft keyboard, 120

automatic flipping, 113114

autoText property, EditText, 32

AVD (Android Virtual Device)

adding AVD through GUI, 13

Google Maps API, 302

showing list of available AVDs, 13

testing applications with emulator, 5

using Android emulator, 1215

AVD Manager

adjusting density, 338

building and running activities, 20

Launch Options dialog, 338

showing list of available AVDs, 13

using, 13

imagesB

BACKFLIP see Motorola BACKFLIP

background attribute, widgets, 38, 42

background threads, 155

avoiding sluggish/pointless code, 165

communicating safely with, 165

communicating with Handler, 155

doInBackground method, 160

encountering error during processing, 165

handling work on, 159165

interacting with UI on UI thread, 155

making Android-friendly, 155

modifying UI from, 155

ProgressBar widget, 101

risk that activity is killed off, 165

users interacting with activity's UI, 165

base Uri, content providers, 259, 260

BaseColumns class, 272

BeanShell scripting, 246250

beforeTextChanged method, 71

bin folder

Android project root directory, 7

subdirectories, 8

binary large objects (BLOBs), 264

BIND_AUTO_CREATE flag, 286

Binder class, 281

binding

communicating with services, 286

service exposing API, 281

bindService method, 286, 287

bindView method, CursorAdapter, 94

bitmaps, 334

blinking light

hardware notifications, 290

BLOBs (binary large objects), 264

box model, 39

BoxLayout, Java/Swing, 39

broadcast intents

activity receiving/using broadcast, 287288

BroadcastReceiver interface, 174

enforcing permissions, 278

services alerting activities, 283284

BROADCAST_ACTION, intents, 284

BroadcastReceiver interface

activity receiving/using broadcast, 288

intents, 174, 175

onReceive method, 174

Browser1 application, 141, 143

Browser2 application, 144

Browser3 application, 145, 146

browsers see web browsers

BrowserTab activity, 183

browsing

tabbed browsing, 182184

build system, Android, 6

build.xml file, 6

Builder class, 150

MessageDemo example, 152

builders, SQLite

SQLiteQueryBuilder class, 233234

buildForecasts method

W3C DOM parser, 255

buildQuery method, SQLite, 234

bulkInsert method, content providers, 263

bundles

handling screen rotation, 185, 191

saving application-instance state, 170

starting intents, 179

button clicks

invoking onClick method, 19

Button widget, 3031

additional properties/methods, 3738

XML layout file, 24

buttons

Android operating system changes, 361

hardware devices, 354

taking advantage of larger screens, 339

imagesC

Calendar object, updating, 97

calendars

READ_CALENDAR permission, 276

WRITE_CALENDAR permission, 276

CALL_STATE_XYZ values, TelephonyManager, 311

callbacks

binding to services, 286

services alerting activities, 283

transitions between states, 168169

calls see phone calls

camera

specifying device requirements, 354

canGoBack method, WebView, 145

canGoBackOrForward method, 145

canGoForward method, WebView, 145

capitalize property, EditText, 32

card image

creating, 328329

emulator using SD card image, 329

category, Intent objects, 172

cell tower triangulation, 295

cells, TableLayout container, 52

check method, RadioGroup, 36, 37

CheckBox widget, 3335

additional properties/methods, 3738

disabling widgets based on, 38

checkCallingPermission method, 278

choice identifier, menus, 126

Chronometer, 100

classes

Activity, 7

AddStringTask, 161164

AnalogClock, 99

ArrayAdapter, 60

AsyncTask, 159161

AutoCompleteTextView, 6972

Button, 3031

CheckBox, 3335

ColorStateList, 38

CompoundButton, 36

ConstantsBrowser, 261

CursorAdapter, 60

DatabaseHelper, 228

DatePicker, 95

DigitalClock, 99

EditText, 3233

Gallery, 72

GridView, 6669

Handler, 155158

HashMap, 363

ImageButton, 31

ImageView, 31

InputStream, 237, 239, 240

ListActivity, 60, 61

ListView, 6063, 7594

MapActivity, 302, 303

NotificationManager, 289, 292

OutputStream, 240

Overlay, 305, 307

ProgressBar, 101

R class, 25

RadioButton, 3537

RadioGroup, 36

RatingBar, 8494

SeekBar, 101

SimpleAdapter, 60

Spinner, 6366

supplying fully qualified class name for main activity, 7

TabActivity, 103

TabSpec, 104, 105

TabWidget, 103, 106

TextView, 2930

TimePicker, 95

Toast, 150

WebSettings, 147

WebView, 141

classes folder (bin/classes/), 8

classes.dex file (bin/classes.dex), 8

clear method, preferences, 214

clearCache method, WebView, 145

clearCheck method, RadioGroup, 36

clearHistory method, WebView, 145

clickable attribute

getting map into application, 302

CLIQ see Motorola CLIQ/DEXT

clocks

AnalogClock/DigitalClock widgets, 99

close method, cursors, SQLite, 234

close method, SlidingDrawer, 115

collapseColumns property, TableLayout, 53

collection Uri, content providers, 259

color attributes, widgets, 38

colors

hardware notifications, 290

resources, 206, 207208

textColor property, TextView, 29

ColorStateList class, 38

columns, TableLayout container

collapseColumns property, 53

determining number of columns, 52

layout_column property, 52

layout_span property, 52

shrinkColumns property, 53

stretchColumns property, 53

columnWidth property, GridView, 66, 67

command line

creating projects from, 6

commit method, preferences, 214

compatibility mode

automatically scaling UI to screen size, 334

screen sizes and resolutions, 331, 332

completionThreshold property, AutoCompleteTextView, 70

components, Intent objects, 172

CompoundButton class, 36

configChanges entry, android

blocking rotation of activities, 195

custom handling of screen rotation, 191

Configuration object

finding screen size class, 336

console interfaces

using Java third-party libraries, 246

Constants application, 226

ConstantsBrowser

creating SimpleCursorAdapter, 262

inserting constant into content providers, 263

onCreate method, 262

querying content provider, 261

showing list of physical constants, 263

ConstantsPlus application, 265

querying content provider, 261

constraints, SQLite, 227

contacts

handling phone calls, 311

MOTOBLUR, 356

READ_CONTACTS permission, 276

WRITE_CONTACTS permission, 276

containers, 39

AbsoluteLayout, 116

adding tabs during runtime, 106

containing SlidingDrawer, 114

FrameLayout, 103, 104

LinearLayout, 3945

positioning widgets relative to, 47

RelativeLayout, 4651

ScrollView, 5457, 123

SlidingDrawer, 114116

TabHost, 102, 103, 104

TableLayout, 5154, 119

TabWidget, 103, 104, 106

ViewFlipper, 109114

content

setContentView method, 25, 26

content providers

accessing binary data, 264

accessing data inside, 265

accessing query results, 261

Android application components, 3

AndroidManifest.xml file, 10

base Uri of, 259

building, 265274

content Uri, 265266

creating provider class, 267272

declaring properties, 272

delete method, 271

getType method, 271

insert method, 269

MIME types, 266

notify-on-change support, 273

onCreate method, 267

query method, 267269

supplying Uri, 272

update method, 270

updating manifest, 273

ConstantsPlus application, 261, 265

construction of content Uri, 259

data encapsulation, 259

deleting data from, 264

description, 259

getting Uri handles, 260

inserting data into, 263

permissions, 276, 278

properties for, 261

querying base Uri, 260

using SQLiteQueryBuilder, 233

content Uri, 265266

accessing binary data, 264

construction of, 259

Content Uri templates

intent routing, 172

contentIntent field, notifications, 290

ContentProvider class, 267

context menus, 125, 127

MenuDemo application, 130, 132

convertView

combining RatingBar with ListView, 86

ListView with icons and text, 8081, 84

CREATE INDEX statement, SQLite, 230

create method, AlertDialog, 150

Create New AVD dialog, 13

CREATE TABLE statement, SQLite, 230

createFromAsset method, Typeface class, 139

createFromFile method, Typeface class, 140

createTabContent method, 106

creating activities see onCreate method

Criteria object

requirements for LocationProvider, 296

CRUD (create, read, update, delete) operations, 259

Cursor object

managedQuery method returning, 261

SimpleCursorAdapter class, 261, 262

Cursor object, SQLite, 234235

creating custom Cursor subclass, 235

rawQuery method returning, 232

CursorAdapter class, 60

methods, 94

imagesD

Dalvik Debug Monitor Service see DDMS

Dalvik virtual machine (VM), 245

Android with Java using, 246

just-in-time (JIT) compilation, 249

string formats, 198

using Java third-party libraries, 245

data

content provider abstraction of, 3

intents, 172

making available to other applications, 265

requesting permission to use, 275

using tabs to hold information, 102

data connection type, finding, 312

data encapsulation, content providers, 259

data type path, content Uri, 266

data typing, SQLite, 227

DatabaseHelper class, 228

onCreate method, 230

databases

Constants application, 226

getting database off device, 235

inspecting and manipulating contents, 235

SQLite, 225, 227236

creating database, 227230

storing modified database on device, 236

date

entering on soft keyboard, 120

inputting, 95

DateFormat formatter, 97

DatePicker widget, 95

DatePickerDialog, 95, 97

days of month

DatePicker/DatePickerDialog, 95

DDMS (Dalvik Debug Monitor Service), 299, 321327

File Explorer, 323

File Manager, 235

incoming SMS messages, 327328

launching, 321

location updates, 325

logging, 322

screen capture, 324

screenshots, 324

simulating incoming calls, 326327

Telephony Actions group, 326

with emulator selected, 322

ddms program, 321

dead state, activities, 168

debug certificate, MD5 digest of, 309

debug key, apk file, 8

decimal numeric input

entering on soft keyboard, 119, 121

default.properties file, 7

DejaVu free fonts, 140

delete method, ContentProvider, 264

building content provider, 271

delete method, SQLite

managing data in tables, 231

density see screen density

density-based resource sets

screen size/density independence, 335

density-independent pixels, 333

deprecated API, 362

destroying activities see onDestroy method

development features, Android devices, 3

development tools

Android SDK, 315

Dalvik Debug Monitor Service, 321327

Hierarchy Viewer tool, 315320

DeviceAnywhere

testing on actual devices, 338

device-independent pixels, 207

devices

button requirements, 354

development features, 3

device-specific issues, 353357

explicitly specifying hardware requirements, 353354

getting database from, 235

Google Maps, 301

Hierarchy Viewer tool, 315

identifying location, 295

Internet access, 253

phones, 311

SD cards, 328329

smartphone programming, 1

storing modified database on, 236

testing on, 338

"with Google" branding, 359

dex file (bin/classes.dex), 8

DEXT see Motorola CLIQ/DEXT

Dialer application, 312

DialerDemo application, 313

dialogs

AlertDialog, 150

DatePickerDialog, 95, 97

TimePickerDialog, 95, 97

value for limited-input devices, 95

dialogs

Add Constant, 226

AlertDialog, 150

Create New AVD, 13

DatePickerDialog, 95, 97

Launch Options, 20, 338

modal dialogs, 150

pop-up dialogs, 221224

TimePickerDialog, 95, 97

value for limited-input devices, 95

DigitalClock widget, 99

digits property, EditText, 32

dimen element, 207

dimensions

automatically scaling UI to screen size, 333

Motorola DROID bugs, 351

resources, 206, 207

documentation, Android SDK, 367

doInBackground method, AsyncTask, 160

background work with AddStringTask, 163

dot notation

referencing classes, 282

D-pad

Motorola CLIQ/DEXT, 356

Motorola DROID/Milestone, 356

moving around focusable elements, 143

rotating through options, 73

scrolling, 57

drawable folder (res/drawable/), 8

referencing images, 202, 203

types of resources, 197

drawable resources

EU4You_3 project, 348

screen size/density independence, 335

drawers

SlidingDrawer container, 114116

drawSelectorOnTop property

Gallery, 73

Spinner, 64

DROID see Motorola DROID/Milestone

Droid fonts, 137

when Android dislikes font, 139

drop-down selector

setDropDownViewResource method, 64, 65

Spinner widget, 63

DynamicDemo class, 77

imagesE

Eclipse projects, 5, 6

edit method, preferences, 214

EditPreferences activity, 215

EditText widget, 3233

accessory button, 121

additional properties/methods, 3738

attributes to control style of input, 118

default settings, 121

imeOptions attribute, 121

input method editor (IME), 117, 118

inputType attribute, 118120

properties, 32

setOnEditorActionListener, 123

EditTextPreference element, 222

ellipsis, substituting text with, 140

ellipsize attribute, TextView, 140

e-mail addresses

entering on soft keyboard, 119, 120

emulators

adjusting density, 337

Android targets, 12

Dalvik Debug Monitor Service, 322

EU4You application, 345

Hierarchy Viewer tool, 317

identifying location, 299

simulating incoming calls, 326327

simulating incoming SMS messages, 327, 328

testing applications with emulator, 5

testing screen size and density, 337

using, 1215

using SD card image, 329

enabled attribute, items/groups

describing menus via XML files, 134

Enter key

changing purpose of soft keys, 121

Environment object

getExternalStorageDirectory method, 244

errors

AlertDialog, 150

"application not responding", 159

background processing, 165

VerifyError, 364

escaping values, strings.xml file, 198

EU4You application, 340

fonts, 346

icons, 348

EU4You_2 project, 346

EU4You_3 project, 348

EU4You_4 project, 349

exceptions

SecurityException, 276

StackOverflowException, 360

execSQL method, SQLite, 230

execute method

AddStringTask class, 164

HttpClient handling HTTP requests, 254

ExpandableListView, 116

expanded mode, options menu, 125

external storage, 244

extras, Intent objects, 172

imagesF

fancy lists

ListView with icons and text, 7584

ListView with ratings and text, 8494

feeds

making data available to other applications, 265

notify-on-change support, 274

Planet Android, 368

FetchForecastTask class, 283

fields see EditText widget

file access, 237

static application reference data, 237240

writeable application data files, 240244

File Explorer

Dalvik Debug Monitor Service, 323

fill model, LinearLayout container, 40

fill_parent rule

automatically scaling UI to screen size, 332

LinearLayout container, 40, 43

filters

declaring intent filters, 173

findViewById method

accessing widgets, 26

additional methods for widgets, 38

finding MapView, 303

finding TabHost, 105

ListView with icons and text, 80, 81, 82

XML layout file, 27

finger-friendly screens

Archos 5 Android Internet Tablet, 356

automatically scaling UI to screen size, 333

emulating screens, 337

resistive or capacitive, 356

Firefox

SQLite Manager extension, 236

five-way navigation pointing device

specifying hardware requirements, 353

FlipperDemo class, 110

flipping, 109114

adding contents at runtime, 112113

automatic flipping, 113114

manual flipping, 110111

ViewFlipper container, 109114

FlowLayout, Java/Swing, 39

focus

isFocused method, 38

requestFocus method, 38

fonts, 137

custom fonts, 140

Droid series of fonts, 137

EU4You application, 346

glyphs, 140

setDefaultFontSize method, 147

setFantasyFontFamily method, 147

typeface attribute, 138

using different fonts, 138140

when Android dislikes font, 139

FontSampler application, 137, 139

formats

string formats, 198

styled string formats, 199202

FrameLayout container, 103, 104

containing SlidingDrawer, 114

fromHtml method

styled string formats, 201

fully qualified class name

supplying for main activity, 7

FWVGA screens, emulating, 337

imagesG

Galileo, 295

Gallery widget, 72

gen folder, 7

generatePage method, 256

generics, 160, 163

GeoPoint, 304

GET requests, 254

getAltitude method, 297

getAttributeCount method, 206

getAttributeName method, 206

getBearing method, 297

getBestProvider method, 296

getCallState method, 311

getCheckedItemPositions method, 62

getCheckedRadioButtonId method, 36

getColumnIndex method, 234

getColumnNames method, 234

getConfiguration method

finding screen size class, 336

getContentResolver method, 274

getCount method, SQLite, 234

getDefaultSharedPreferences method, 213, 214

getExternalStorageDirectory method, 244

getInputStream method

accessing binary data, 264

getLastKnownPosition method, 296

getLastNonConfigurationInstance method

handling screen rotation, 189, 191

getLatitude method, 255

getListView method, 62

getLongitude method, 255

getMapController method, 303

getMenuInfo method, 127

getNetworkType method, 312

getOutputStream method

accessing binary data, 264

getOverlays method, MapView, 305

getParent method, 38

getPhoneType method, 312

getPreferences method, 213

getProgress method

ProgressBar, 101

SeekBar, 102

getProviders method, LocationManager, 296

getReadableDatabase method, 230

getRequiredColumns method, 270

getResources method

static application reference data, 237

xml resources, 204

getService method, Binder, 281

getSettings method, WebView, 143, 147

getSharedPreferences method, 213

getSpeed method, Location object, 297

getString method, 198, 199

getStringArray method, 208

getSubscriberId method, 312

getSystemService method

identifying location, 296

notifications, 289

getTag method, View objects

combining RatingBar with ListView, 86

ListView with icons and text, 82

wrapping API, 362, 363, 364, 366

getType method, ContentProvider, 271

getView method

combining RatingBar with ListView, 86, 89

creating views, 68

CursorAdapter, 94

ListView with icons and text, 77, 78, 80

getWriteableDatabase method, 230

getXml method, 204

GIF format

Android support for images, 202

automatically scaling UI to screen size, 334

glEsVersion attribute, 354

glyphs, 140

goBack method, WebView, 144

goBackOrForward method, 145

goForward method, WebView, 145

Google

Android Market, 355

"with Google" branding, 359

Google Code Search, 368

Google Maps, 301, 302

map overlays, 305306

Google/HTC Nexus One, 357

GPS (global positioning system), 4

GPS services, 295

gravity, LinearLayout, 41

grid model, TableLayout, 39

GridView widget, 6669

group element, menus, 134, 135

group identifier, menus, 126

GUI definition

using XML layout file, 24

imagesH

handleMessage method, 156, 157

Handler class, 155158

background threads communicating with, 155

handleMessage method, 156, 157

Message objects communicating with, 156158

obtainMessage method, 156

passing Runnable objects to, 158

postXyz methods, 158

sending Message to Handler, 156158

sendMessage method, 156

sendMessageXyz methods, 156

updating ProgressBar via, 156, 157

HandlerDemo application, 158

handlers

threads, 155158

handles

getting Uri handles, 260

SlidingDrawer container, 115

Handmade Typewriter font, 140

handsets

handling screen rotation, 185

hardware

buttons, 354

explicitly specifying requirements, 353354

hasAltitude method, 297

hasBearing method, 297

HashMap class

wrapping API, 363

hasSpeed method, 297

help, 367

Hierarchy Viewer tool, 315320

emulators, 317

Keyguard window, 317

Launcher window, 317

launching, 315

Layout view, 317, 318, 361

Load View Hierarchy window, 317

Loupe view, 320

Pixel Perfect view, 319, 320

view hierarchies, 360

view properties, 319

windows, 317

hierarchyviewer program, 315

holder pattern

ListView with icons and text, 8184

horizontal orientation, LinearLayout, 40

horizontalSpacing property, GridView, 66

hours

TimePicker/TimePickerDialog, 95

HTC Dream see T-Mobile G1

HTC Magic, 354

emulating, 12

keyboards, 117

rotating, 195

HTC Nexus One, 357

htmlEncode method

styled string formats, 201

HTTP (Hypertext Transfer Protocol), 171

operations via Apache HttpClient, 254255

HTTP requests

accessing REST-style web services, 253

Apache HttpClient handling, 254

HttpClient, Apache

HTTP operations via, 254255

Secure Sockets Layer, 257

threading, 257

HttpComponents library, Apache, 253

HVGA screens

EU4You application, 345, 347

screen sizes, 331

imagesI

icon attribute, item element, 134

icon mode, options menu, 125

icons

Android operating system changes, 361

EU4You application, 348

ListView with icons and text, 7584

notifications, 290, 292

id

findViewById method, 26, 27

R.id, 26, 27

id attribute

@+id, 25, 47

@id, 48

describing menus via XML files, 134

SlidingDrawer container, 115

XML layout file, 25

identifiers, 47, 48

ImageButton widget, 31

additional properties/methods, 3738

images, 202204

accessing binary data, 264

Android support for, 202

automatically scaling UI to screen size, 334

Gallery widget, 73

res/drawable/ folder, 8

setImageURI method, 31

types of resources, 197

ImagesDemo application, 204

ImageView widget, 31

accessing binary data, 264

additional properties/methods, 3738

ListView with icons and text, 79

SlidingDrawer container, 115

IME (input method editor)

creating an IME, 124

entering e-mail addresses, 120

entering signed decimal numbers, 121

entering text, 120

keyboards, 117

shrunken, scrollable layout, 124

imeOptions attribute, EditText, 121

IMF (input method framework), 117

see also soft keyboard

implicit routing, intents, 173

inches (in)

automatically scaling UI to screen size, 333

resource dimensions, 207

indexes, creating, SQLite, 230

input method editor see IME

input method framework see IMF

InputStream class, 237, 239, 240

inputType attribute, 32, 118120, 121

insert method

content providers, 263, 269

SQLite, 231

instance identifier, 266

instance Uri, 259, 260, 268, 269, 271

instrumentation elements, 9

intent-filter element, 10, 173

intent filters, declaring, 173

Intent objects

other criteria placed inside intents, 172

registering/unregistering receivers, 175

intent receivers, 174175

permissions, 277, 278

intents, 109, 171175, 178

ACTION_DIAL, 312

ACTION_XYZ, 172

actions, 172

Android application components, 3

Android UI architecture, 177

broadcast intents, 174, 283284, 287288

communicating with services, 286

components of, 172

creating, 178

data, 172

declaring intent filters, 173

handling clicks on links, 145

implicit routing, 173

notifications, 290

other criteria placed inside, 172

PendingIntent, 290, 292, 298

routing, 172

starting activities, 178181

starting, 178

tabbed browsing, 182, 183

using as message bus, 175

IntentTabDemo application, 184

interfaces

using Java third-party libraries, 246

international deployment, 140

internationalization (I18N), 208

Internet access

Android development features, 3

Android devices, 253

HttpComponents library, 253

moving to background thread, 283

operations via HttpClient, 254255

parsing responses, 255257

requesting permission, 142

web browsers, 143

INTERNET permission, 276

getting map into application, 303

Internet/Weather project, 254

Interpreter class, BeanShell, 247

I/O

writeable application data files, 240244

IPC (interprocess communication)

exposing service API through binding, 281

starting services, 279

iPhone

handling screen rotation, 195196

isChecked method, CheckBox, 34

isCollectionUri method, 270, 271

isEnabled method, 38

isFocused method, 38

isRouteDisplayed method, 303

item element

describing menus via XML files, 134

ItemizedOverlay class, 305

onTap method, 307

imagesJ

JARs

using Java third-party libraries, 246

jarsigner utility, 8

generating API keys, 309

Java

attaching XML layout file, 25

Dalvik virtual machine, 245, 246

not working on Android and Dalvik, 250

using different fonts, 139

Java SE classes, 19

Java third-party libraries, 245

Java Virtual Machine (JVM), 245

Java/Swing, 39

JavaScript, 143

setJavaScriptEnabled method, 143, 147

JButton click, Swing, 19

joins, SQLite, 227

JPEG format, 202

JPG format, 334

JSON parser, 255

just-in-time (JIT) compilation, 249

imagesK

key/value pairs

preferences, 213

keyboardHidden configuration

handling screen rotation, 192

keyboards

Motorola BACKFLIP, 357

scenarios requiring different resources, 209

soft keyboard, 117124

specifying hardware requirements, 353, 354

Keyguard window, Hierarchy Viewer, 317

keytool utility, Java, 309

imagesL

labels see TextView widget

landscape layout

EU4You application, 348, 350

handling screen rotation, 186

languages

international deployment, 140

scenarios requiring different resources, 209

largeScreens attribute, 335

Launch Options dialog

AVD Manager, 338

building/running activities, 20

LaunchDemo application, 181

launcher

activity element, 10

Android UI architecture, 177

AndroidManifest.xml file, 8, 10

launching activities, 177181

LAUNCHER category

intent-filter element, 173

intents, 172

Launcher window, Hierarchy Viewer, 317

layers

map overlays, 305306

layout containers

AbsoluteLayout, 116

automatically scaling UI to screen size, 333

FrameLayout, 103, 104, 114

LinearLayout, 3945

RelativeLayout, 4651

ScrollView, 123

TableLayout, 5154, 119

layout folder (res/layout/), 8

referencing string resource, 198

XML layout file, 23

attaching to Java, 25

layout management

see also containers

embedding second activity in main activity UI, 351

layout properties (android:)

collapseColumns, TableLayout, 53

layout_above, RelativeLayout, 48

layout_alignParentXyz, RelativeLayout, 47

layout_alignXyz, RelativeLayout, 48, 50

layout_below, RelativeLayout, 48

layout_centerXyz, RelativeLayout, 47

layout_column, TableLayout, 52

layout_gravity, LinearLayout, 41

layout_height, Button, 25

layout_height, LinearLayout, 40

layout_height, RelativeLayout, 332

layout_marginXyz, LinearLayout, 42

layout_span, TableLayout, 52

layout_toXyzOf, RelativeLayout, 48, 50

layout_weight, LinearLayout, 40

layout_width, Button, 25

layout_width, LinearLayout, 40

layout_width, RelativeLayout, 50, 332

shrinkColumns, TableLayout, 53

stretchColumns, TableLayout, 53

Layout view, Hierarchy Viewer, 317, 318

LayoutInflater class

combining RatingBar with ListView, 92

ListView with icons and text, 78, 79

layouts

BoxLayout, Java/Swing, 39

FlowLayout, Java/Swing, 39

Hierarchy Viewer tool, 315320

R.layout.main file, 7

res folder, 7

libs folder, 7

licenses

Apache Software License 2.0, 355

life cycle, activities, 167

transitions between states, 168169

LinearLayout container, 3945

containing SlidingDrawer, 114

example, 4245

fill model, 40

gravity, 41

layout_gravity property, 41

layout_height property, 40

layout_marginXyz properties, 42

layout_weight property, 40

layout_width property, 40

margins, 42

orientation property, 40

padding property, 41

setGravity method, 41

setOrientation method, 40

setPadding method, 41

weight, 40

with AutoCompleteTextView, 70

with GridView, 67

with ImageView, 75, 76, 79

with ListView, 61

with RatingBar, 87, 92

with Spinner, 64

with ViewFlipper, 109

links, handling clicks on, 145

ListActivity class, 60, 61, 62, 302

ListAdapter interface

combining RatingBar with ListView, 89, 90, 93

listeners

callbacks, services alerting activities, 283

LocationListener object, 297

OnCheckedChangeListener, 34

OnClickListener, 97

OnDateChangedListener, 95

OnDateSetListener, 95, 97

OnTimeChangedListener, 95

OnTimeSetListener, 95, 97

setOnEditorActionListener method, 123

setOnItemSelectedListener method, 60, 64, 65, 67

setOnSeekBarChangeListener method, 102

ListPreference element, pop-up dialogs, 222

ListView widget, 6063

combining RatingBar with, 8494

controlling appearance of rows, 62

enhancing, 7594

with icons and text, 7584

with ratings and text, 8494

with rows contain interactive child widgets, 84

getCheckedItemPositions method, 62

getting ListView from ListActivity, 62

setChoiceMode method, 62

tracking (multiple) selections, 62

Load View Hierarchy window, 317

loadData method, WebView, 143144

loadTime method, 146

loadUrl method, WebView, 142, 143

local services, 284, 285

local.properties file, 7

localization (L10N), 209

location, 295

Location object

methods, 297

location providers, 295297

location service, 296

location updates

Dalvik Debug Monitor Service, 325

LocationListener class, 297

removeUpdates method, 298

LocationManager class

addProximityAlert method, 298

creating services, 280

getBestProvider method, 296

getProviders method, 296

identifying location, 296

removeProximityAlert method, 298

requestLocationUpdates method, 297

LocationProvider class

getLastKnownPosition method, 296

identifying location, 296

location updates using DDMS, 325

lock method, SlidingDrawer, 115

logcat command, adb, 322

logging

Dalvik Debug Monitor Service, 322

Loupe view, Hierarchy Viewer, 320

imagesM

makeText method, Toast class, 150, 152

managedQuery method, 260, 261

manifest element, 9, 10

manifest file see AndroidManifest.xml file

manifest typing, SQLite, 227

manual flipping, 110111

map activity, Android, 181

MapActivity class, 302, 303

MapController, 304

maps

centering, 304

generating API keys, 308

getting map into application, 302

Google Maps, 301

MyLocationOverlay instance, 308

NooYawk application, 302

OpenStreetMap, 301

overlays, 305306

zooming in on, 304

MapView widget

finding, 303

getMapController method, 303

getOverlays method, 305

getting map into application, 302

toggleSatellite method, 304

margins

LinearLayout container, 42

MD5 digest of debug certificate, 309

MD5 signature

generating API keys, 309

measurement, units of

resource dimensions, 207

media players

handling platform changes, 359366

memory

dead state, 168

using Java third-party libraries, 245

menu element

describing menus via XML files, 134

menu folder (res/menu/), 8

Menu object

describing menus via XML files, 134

setGroupCheckable method, 126

setGroupEnabled method, 134

setGroupVisible method, 135

menuCategory attribute, 134

MenuDemo application, 130

context menu, 130, 132

options menu, 130, 131

MenuItem class

describing menus via XML files, 134

getMenuInfo method, 127

setCheckable method, 126

setEnabled method, 134

setVisible method, 135

menus

add method, 126

addMenu method, 127

addSubMenu method, 127

applyMenuChoice method, 130

choice identifier, 126

context menus, 125, 127

describing menus via XML files, 133135

getMenuInfo method, 127

group identifier, 126

onContextItemSelected method, 127, 130

onCreate method, 125, 130

onCreateContextMenu method, 127, 130

onCreateOptionsMenu method, 125, 127, 130

onCreatePanelMenu method, 127

onOptionsItemSelected method, 126, 127, 130

onPrepareOptionsMenu method, 126

options menu, 125127

order identifier, 126

populateMenu method, 130

registerForContextMenu method, 127

setAlphabeticShortcut method, 126

setCheckable method, 126

setGroupCheckable method, 126

setNumericShortcut method, 126

setQwertyMode method, 126

taking advantage of larger screens, 339

message bus

using Intent framework as, 175

Message objects

communicating with Handler, 156158

MessageDemo example, 151153

messages

advisory messages, 149

alerts, 150

handleMessage method, 156, 157

intents, 171

obtainMessage method, 156

pop-up messages, 149150

sending Message to Handler, 156158

sendMessage method, 156

sendMessageXyz methods, 156

toasts, 149150

validation message, 150

Method-based reflection, 366

Milestone see Motorola DROID/Milestone

millimeters (mm)

automatically scaling UI to screen size, 333

resource dimensions, 207

MIME types

building content provider, 266

getType method, 271

getting content into WebView, 144

Intent objects, 172

declaring intent filters, 174

intent routing, 172, 173

minutes

TimePicker/TimePickerDialog, 95

minSdkVersion attribute, 11

mksdcard utility, 329

mobile phones

smartphone programming, 1

modal dialogs, 150

months

DatePicker/DatePickerDialog, 95

MOTOBLUR, 356

Motorola BACKFLIP, 357

Motorola CLIQ/DEXT, 356

Motorola DROID/Milestone, 356

bugs, 351

Droid fonts, 137, 139

emulating, 337

moveToXyz methods, SQLite, 234

multimedia

Android development features, 4

multiple resource directories, 209

MyLocationOverlay instance, 308

imagesN

name property, 273, 354

National Weather Service XML format, 256

navigation

specifying hardware requirements, 353

WebView widget, 144

netbooks, Android

handling platform changes, 359366

networks

Android development features, 3

getNetworkType method, 312

newCursor method, SQLite, 235

newView method, CursorAdapter, 94

nextFocusXyz properties, 37

Nexus One see Google/HTC Nexus One

nine-patch bitmaps

automatically scaling UI to screen size, 334

NooYawk application, 302

normalScreens attribute, 335

NotificationManager class, 289, 292

notifications, 289294

see also alerts

contentIntent, 290

encountering error during background processing, 165

hardware notifications, 290

icons, 290

notify method, 290

paused state, 167

PendingIntent, 290

raising notifications, 289

services alerting activities, 282

setLatestEventInfo method, 290

status bar icons, 289

stopped state, 168

tickerText, 290

notify method, notifications, 290

Notify1 project, 290

notifyChange method, 274

NotifyDemo activity, 292

notifyMe method, 292

notify-on-change support, 273, 274

Now.java file, 17, 18

NowRedux project, 24, 26

numColumns property, GridView, 66

numericShortcut attribute, item element, 135

imagesO

obtainMessage method, 156

onActivityResult callback, intents, 179

onBind method, services, 280

communicating with services, 286

exposing API through binding, 281

OnCheckedChangeListener, 34

LinearLayout example, 44

onClick attribute, buttons, 30

onClick method, 19

OnClickListener, 30

alert example, 152

date and time, 97

trapping button clicks within activity, 19

onConfigurationChanged method, 191, 193

onContextItemSelected method, menus, 127, 130

onCreate method

ConstantsBrowser, 262

ContentProvider, 267

handling screen rotation, 185, 189, 193

invoking loadUrl() on WebView, 142

invoking, activities, 19

LinearLayout example, 44

menus, 125, 130

services, 280

SQLite, 228, 230

transitions between states, 168

onCreateContextMenu method, 127, 130

onCreateOptionsMenu method, 125, 127, 130

onCreatePanelMenu method, 127

OnDateChangedListener, 95

OnDateSetListener, 95, 97

onDestroy method

services, 280

transitions between states, 168

OnItemSelectedListener, 65

online help, 367

onListItemClick method

changes to list selection, 61

combining RatingBar with ListView, 86

onOptionsItemSelected method, 126, 127, 130

onPause method

activity receiving/using broadcast, 288

transitions between states, 169

unregistering receivers, 175

updating locations/directions, 308

writeable application data files, 243

onPostExecute method, AsyncTask, 161, 164

onPreExecute method, AsyncTask, 161

onPrepareOptionsMenu method, 126

onProgressUpdate method, AsyncTask, 161, 163

onRatingBarChanged method, 92

onRatingChanged method, 86

onReceive method, intents, 174

onRestart method, 169

onRestoreInstanceState method

handling screen rotation, 185

reapplying application-instance state, 170

onResume method

activity receiving/using broadcast, 288

HttpClient handling HTTP requests, 254

registering receivers, 175

transitions between states, 169

updating locations/directions, 308

writeable application data files, 243

onRetainNonConfigurationInstance method, 189, 191

onSaveInstanceState method

handling screen rotation, 185, 187, 188, 189

saving application-instance state, 170

unregistering receivers, 175

onServiceConnected method, 286

onStart method, 158

services, 280

setting up background thread, 157

transitions between states, 169

onStop method, 169

onTap method, Overlay class, 307

onTextChanged method, 71

OnTimeChangedListener, 95

OnTimeSetListener, 95, 97

onUpgrade method, SQLite, 228

open method, SlidingDrawer, 115

Open Mob for Android wiki, 367

open source, 353

Apache Software License 2.0, 355

openFileInput/Output methods

accessing application-specific data files, 244

writeable application data files, 240, 243

OpenGL

specifying device requirements, 354

openRawResource method, 237

OpenStreetMap, 301

operating system changes, 360361

options menu, 125127

adding menu choices and submenus, 126127

creating, 125

describing menus via XML files, 134

expanded mode, 125

icon mode, 125

MenuDemo application, 130, 131

Oracle, SQLite and, 227

order identifier, menus, 126

orderInCategory attribute, item element, 134

orientation

see also rotation

custom handling of screen rotation, 191193

handling screen rotation, 185191

not rotating activities, 193195

scenarios requiring different resources, 209

orientation configuration changes, 192

orientation property, LinearLayout, 40

OutputStream class, 240

Overlay class, 305

onTap method, 307

OverlayItem instances, 305

overlays, maps, 305306

getOverlays method, MapView, 305

ItemizedOverlay class, 305

MyLocationOverlay instance, 308

updating locations/directions, 307

imagesP

package attribute, 9

package declaration, 18

padding

LinearLayout, 43

RelativeLayout, 49, 50

padding property, LinearLayout, 41

parse method, Uri object, 260

parsing

parsing responses, 255257

resources, 197

XML parsers, 255

XmlPullParser object, 204, 206

paused state, activities, 167

handling screen rotation, 185

pausing activities see onPause method

peer activities, 178

starting intents, 179

PendingIntent

identifying location, 298

notifications, 290, 292

performance

scripting languages, 250

using Java third-party libraries, 245

permission attribute, 277

permission elements, 9, 277

permissions, 5, 9, 10

ACCESS_COARSE_LOCATION, 303

accessing Internet, 142

applications, 275

confirming, 276

declaring, 277

documenting for public APIs, 278

enforcing, 277278

checkCallingPermission method, 278

sendBroadcast method, 278

via manifest, 277278

INTERNET, 276, 303

location providers, 296

READ_CALENDAR, 276

READ_CONTACTS, 250, 276

requesting to access Internet, 142

requesting to use application data, 275

scripting languages, 250

securing application using, 277

security and privacy, 276

starting/binding to services, 282

system permissions, 276

VIBRATE, 290

working with external storage, 244

WRITE_CALENDAR, 276

WRITE_CONTACTS, 276

phone calls

Dalvik Debug Monitor Service, 326327

handling, 311

making phone call, 312314

phone services, 4

phone type, finding, 312

phones

Android devices, 311

Dialer application, 312

TelephonyManager class, 311

Pixel Perfect view, Hierarchy Viewer, 319, 320

pixels

automatically scaling UI to screen size, 333

density-independent pixels, 333

device-independent pixels, 207

resource dimensions, 207

scaled pixels, 334

scale-independent pixels, 207

scenarios requiring different resources, 209

placeholders, strings, 198

Planet Android, 368

platform APIs

using Java third-party libraries, 245

platform changes, handling, 359366

PNG format, 202, 334

points (pt)

resource dimensions, 207

populateDefaultValues method, 270

populateMenu method, 130

pop-ups

alerts, 150

preferences, 221224

toasts, 149150

portrait layout

handling screen rotation, 186

positioning widgets

automatically scaling UI to screen size, 332

LinearLayout, 3945

RelativeLayout, 4651

TableLayout, 5154

POST requests, HTTP, 254

postXyz methods, Handler, 158, 159

preferences, 213224

accessing, 213

activity-specific preferences, 213

allowing users to set preferences, 215218

application-level preferences, 213

editing, 214

key/value pairs, 213

pop-up dialogs, 221224

web browsers, 147

preferences framework, 214215, 219220

PreferenceCategory element, 219

PreferenceScreen element, 215, 219

PreferencesManager

getDefaultSharedPreferences method, 213

primary key column, SQLite, 230

privacy

security and permissions, 276

programming, 1, 19

ProgressBar widget, 101

creating, 156

thread safety, 158

updating via Handler, 156, 157

projects, 68

see also applications

android create project command, 6, 17

AndroidManifest.xml file, 6

assets folder, 7

bin folder, 7, 8

build.xml file, 6

building Android applications, 5

creating project from command line, 6

activity element, 10

default.properties file, 7

developing using Eclipse, 6

gen folder, 7

libs folder, 7

local.properties file, 7

manifest file, 5, 6

project structure, 68

res folder, 7

root directory, 67

src folder, 7

supplying fully qualified class name of main activity, 7

tests folder, 7

projects, list of

see also applications, list of

Eclipse, 5, 6

EU4You, 340, 346, 348, 349

FontSampler, 137, 139

Notify1, 290

NowRedux, 24, 26

Weather, 254

properties

declaring for content provider, 272

Hierarchy Viewer tool, 319

querying content provider, 261

provider class

creating for content provider, 267272

provider elements, 10

publishProgress method, AsyncTask, 161, 163, 164

pull command, adb, 235, 323

push command, adb, 236, 323

imagesQ

queries, content providers

accessing query results, 261

querying base Uri, 260

queries, SQLite

buildQuery method, 234

Cursor object, 234

query method, 232

rawQuery method, 232

SQLiteQueryBuilder class, 233234

query method, ContentProvider

building content provider, 267269

query method, SQLite

retrieving data, 232

queryWithFactory method, SQLite, 235

QVGA screens

EU4You application, 345, 346, 348

ignoring screen sizes and resolutions, 332

screen sizes, 331

qwerty keyboard

see also keyboards

scenarios requiring different resources, 209, 212

setQwertyMode method, 126

imagesR

R class, 25

R.array

resource arrays, 208

R.id, 26, 27

R.java file

aapt tool, 23

Android build system creating, 7

modifying, 7

XML layout file, 27

R.layout

ListView with icons and text, 76, 79

R.layout.main file, 7

XML layout file, 26

RadioButton widget, 3537

additional properties/methods, 3738

disabling widgets based on, 38

LinearLayout example, 43

methods, 36

preset radio button to checked, 37

properties, 36

RadioGroup class, 36

LinearLayout example, 43, 44, 45

RateableWrapper class, 90, 92, 93

RateListDemo class, 84, 92, 93

RateListView class, 89, 93, 94

RatingBar widget, 8494

ratings

ListView with ratings and text, 8494

raw folder (res/raw/), 8

static application reference data, 237

types of resources, 197

rawQuery method, SQLite, 232

rawQueryWithFactory method, SQLite, 235

READ_CALENDAR permission, 276

READ_CONTACTS permission, 276

readPermission attribute, 278

ReadWrite application, 241, 315

ReadWriteFileDemo application, 243

receivers, intents, 174175

RecyclingDemo class, 80

reference data, static application, 237240

reflection

wrapping API, 362, 364, 366

registerContentObserver method, 274

registerForContextMenu method, 127

registerReceiver method, intents, 175

RelativeLayout container, 4651

automatically scaling UI to screen size, 332

containing SlidingDrawer, 114

evaluation order, 49

example, 4951

layout_above property, 48

layout_alignParentXyz properties, 47

layout_alignXyz properties, 48

layout_below property, 48

layout_centerXyz properties, 47

layout_toXyzOf properties, 48

with AnalogClock/DigitalClock, 99

reload method, WebView, 144

remote services, 284

remove method, preferences, 214

removeProximityAlert method, 298

removeUpdates method, 298

reqFiveWayNav property, 353

reqHardKeyboard property, 354

reqKeyboardType property, 354

reqNavigation property, 354

reqTouchScreen property, 354

requery method, cursors

content providers, 264

SQLite, 234

requestFocus method, 38

requestLocationUpdates method, 297

res folder, 7

attaching XML layout file to Java, 25

subdirectories, 7, 197

XML layout file, 23

resolutions

ignoring screen sizes and, 331

resource sets

density-based, 335

size-based, 336

version-based, 336

resources

Android operating system changes, 361

arrays, 208

colors, 206, 207208

description, 197

dimensions, 206, 207

drawable, 197

images, 197, 202204

multiple criteria for, 209

multiple resource directories, 209

parsing, 197

raw, 197

scenarios requiring different, 208212

strings, 198202

values folder (res/values/), 197, 206208

XML, 197, 204206

XML layout file, 23

resources.arsc file, 8

resources element, strings.xml, 198

Resources object

static application reference data, 237

ResponseHandler class

HttpClient handling HTTP requests, 254

responses, parsing, 255257

restarting activities see onRestart method

restoreMe method, 188, 191

REST-style web services, accessing, 253

RESULT_XYZ codes, intents, 179

resuming activities see onResume method

RGB values, colors, 207

ringtone preference, setting, 216

RingtonePreference element, 215

root directory, 67, 8

getRootView method, 38

rotation

see also orientation

blocking rotation of activities, 193

custom handling of screen rotation, 191193

handling iPhone rotation, 195196

handling screen rotation, 185191

not rotating activities, 193195

RotationFour application, 193, 194

RotationOne application, 186, 188, 189

RotationThree application, 191

RotationTwo application, 190

routing, intents, 172

RowModel objects, 86

rows, TableLayout, 52

rule-based model, RelativeLayout, 39

rules

automatically scaling UI to screen size, 332, 333

Runnable objects, 158, 159

runOnUiThread method, 159

imagesS

SAX parser, 255

scaled pixels, 334

scale-independent pixels, 207

scheme, content Uri, 266

Schroedinger's Activity, 167

screen capture

Dalvik Debug Monitor Service, 324

screen density

adjusting, 337

anyDensity attribute, 335

density-based resource sets, 335

emulators testing, 337

EU4You application, 346

finding, 336

Google/HTC Nexus One, 357

Motorola DROID/Milestone, 356

screen density-independence, 334337

resource sets, 335336

supports-screens element, 334335

screen orientation

scenarios requiring different resources, 209

screen rotation

custom handling of, 191193

handling, 185191

iPhone, 195196

not rotating activities, 193195

screen size-independence, 334337

resource sets, 335336

supports-screens element, 334335

screen sizes

automatically scaling UI, 332334

embedding second activity in main activity UI, 351

emulators testing, 337

EU4You application, 346

finding screen density, 336

finding screen size class, 336

handling multiple screen sizes, 331351

HVGA screens, 331

ignoring, 331

QVGA screens, 331

scenarios requiring different resources, 209

size-based resource sets, 336

taking advantage of larger screens, 339

consolidating multiple activities, 340

replacing menus with buttons, 339

replacing tabs with activity, 340

testing on actual devices, 338

WVGA screens, 331

screen tapping

onTap method, 307

screenOrientation, android

blocking rotation of activities, 193

handling iPhone rotation, 195

screenshots

Dalvik Debug Monitor Service, 324

ScreenSizes/EU4You application, 340

scripting languages

Android Scripting Environment, 251

Android with Java using Dalvik VM, 246250

just-in-time (JIT) compilation, 249

performance, 250

ScrollView container, 5457, 123

SD cards

Android devices, 328329

creating card image, 328329

emulator using SD card image, 329

seconds

TimePicker/TimePickerDialog, 95

security

enforcing permissions, 277278

privacy and permissions, 276

SecurityException

permissions, 276

SeekBar widget, 101

SELECT statement, SQLite

clauses of SELECT, 232

retrieving data, 232233

selection widgets

adapters, 5960

AutoCompleteTextView, 6972

finding out when list selection changes, 61

Gallery, 72

GridView, 6669

ListView, 6063

setAdapter method, 60, 64, 67, 70

setOnItemSelectedListener method, 60, 64, 65, 67

Spinner, 6366

sendBroadcast method

broadcast intents, 284

enforcing permissions, 278

sendMessage method, 156

sendMessageAtFrontOfQueue method, 156

sendMessageAtTime method, 156

sendMessageDelayed method, 156

Service class, 279

service elements, 11

ServiceConnection instance, 286

services

accessing location-based services, 295

accessing service object, 280

adding to AndroidManifest.xml, 281

Android application components, 3

asynchronously alerting activities, 282

binding to, 286

broadcast intents, 283284

callbacks, 283

creating, 279282

description, 279

exposing API through binding, 281

exposing service object, 281

GPS services, 295

implementation of singleton pattern, 281

invoking, 285

life-cycle methods, 279

local services, 284, 285

location service, 296

permissions, 277

remote services, 284

running costs, 279

starting, 279, 286

stopping, 286

setAccuracy method, LocationProvider, 296

setAdapter method

AutoCompleteTextView widget, 70

combining RatingBar with ListView, 93

GridView widget, 67

ListView widget, 60

Spinner widget, 64

setAlphabeticShortcut method, menus, 126

setAltitudeRequired method, 296

setBuiltInZoomControls method, 304

setCenter method, MapController, 304

setCheckable method, MenuItem, 126

setChecked method

CheckBox, 34

RadioButton, 37

setChoiceMode method, ListView, 62

setColumnXyz method, TableLayout, 53

setContent method, TabSpec, 104, 105, 106

setContentView method

attaching XML layout file to Java, 25

creating skeleton application, 19

XML layout file, 26

setCostAllowed method, 296

setCurrentTab method, 105

setDefaultFontSize method, 147

setDropDownViewResource method, 64, 65

setEnabled method, 38

MenuItem class, 134

setFantasyFontFamily method, 147

setFlipInterval method, 113

setGravity method, LinearLayout, 41

setGroupCheckable method, 126

setGroupEnabled method, 134

setGroupVisible method, Menu, 135

setIcon method, Builder, 150

setImageURI method, 31

setIndeterminate method, ProgressBar, 101

setIndicator method, TabSpec, 104, 105

setJavaScriptEnabled method, 143, 147

setLatestEventInfo method, 290, 292

setListAdapter method, 61

setMessage method, Builder, 150

setNegativeButton method, Builder, 150

setNeutralButton method, Builder, 150, 152

setNumericShortcut method, menus, 126

setOnCheckedChangeListener method, 44

setOnClickListener

adding tabs during runtime, 107

writeable application data files, 243

setOnEditorActionListener, 123

setOnItemSelectedListener method, 64, 65

GridView widget, 67

ListView widget, 60

setOnSeekBarChangeListener, 102

setOrientation method, 40

setPadding method, 41

setPositiveButton method, Builder, 150

setProgress method, 101

setQwertyMode method, menus, 126

setResult method, intents, 179

setTag method, View objects

combining RatingBar with ListView, 87

ListView with icons and text, 82, 83

wrapping API, 362, 363, 364, 366

setTitle method, Builder, 150, 152

setTypeface method, TextView, 139

setup method, TabHost, 104, 105

setupViews method, 193

setUserAgent method, 147

setVisible method, MenuItem, 135

setWebViewClient method, 145

setZoom method, MapController, 304

SharedPreferences object, 214

pop-up dialogs, 222

shell command, adb, 235, 324

shortcuts

setAlphabeticShortcut method, 126

setNumericShortcut method, 126

shouldOverrideUrlLoading method, 145, 146

show method, 150

showNext method, ViewFlipper, 110

shrinkColumns property, TableLayout, 53

SIM ID (IMSI), 312

SimpleAdapter class, 60

SimpleCursorAdapter class, 261, 262

SimplePrefsDemo activity, 216, 217

singleLine property, EditText, 32

SitesOverlay class, 307

size-based resource sets, 336

skeleton application, creating, 17

SlidingDrawer container, 114116

smallScreens attribute, 335

smartphone programming, 1

SMS messages

Dalvik Debug Monitor Service, 327328

SOAP, 253

soft keyboard, 117124

accommodating changes to layout, 123

changing purpose of soft keys, 121

determining keys available on, 118

entering date on, 120

entering e-mail addresses on, 119, 120

entering numbers on, 119, 121

entering text on, 117

autocorrection, 120

multiline input, 120

plain text-entry, 119, 120

shrunken, scrollable layout, 124

input method editor (IME), 117

input method framework (IMF), 117

scrolling, 123

sound

hardware notifications, 290

source code, 368

spacing property, Gallery, 73

spacingWidth value, stretchMode, GridView, 66, 67

Spinner widget, 6366

drawSelectorOnTop property, 64

spinnerSelector property, Gallery, 73

SQLite, 225, 227236

creating database, 227230

creating tables and indexes, 230

Cursor object, 232, 234235

data typing, 227

manifest typing, 227

manipulating database, 235

putting data into tables, 230231

query method, 232

rawQuery method, 232

retrieving data, 232235

SQLite Manager extension, 236

sqlite3 program, 235

SQLiteOpenHelper class, 227, 230

SQLiteQueryBuilder class

building content provider, 268, 269

retrieving data, 233234

src attribute, images, 31

src folder, 7

creating skeleton application, 17

SSL (Secure Sockets Layer)

HttpClient, Apache, 257

StackOverflowException, 360

startActivity method, intents, 179

making phone call, 312

startActivityForResult method, 179

startFlipping method, 113

starting activities see onStart method

startService method, 286

states, activities, 167

active state, 167

dead state, 168

handling screen rotation, 185

paused state, 167

saving application-instance state, 169

stopped state, 168

transitions between, 168169

static application reference data, 237240

StaticDemo class, 76

StaticFileDemo application, 240

status bar icons, notifications, 289, 292, 293

status panels

automatic flipping, 114

stopped state, activities, 168

stopping activities see onStop method

stopSelf method

binding to services, 287

stopService method, 286, 287

storage, Android, 3, 237

reading/writing files on external storage, 244

stretchColumns property, TableLayout, 53

stretchMode property, GridView, 66

string element, 198

string formats, 198

styled string formats, 199202

string-array element, 208

strings, 198202

arrays, 208

placeholders, 198

referencing from layout file, 198

styled text, 199

strings.xml file, 198, 200, 337

StringsDemo application, 201

styled text, 198, 199

styled string formats, 199202

sub activities, 177

supports-screens element

EU4You application, 341, 348

screen size/density independence, 334335

Swing

JButton click, 19

using Java third-party libraries, 245

imagesT

TabActivity class, 103, 182, 183

tabbed browsing, 182184

TabHost container, 102, 103, 104, 105

table of contents

Android applications, 5

TableLayout container, 5154, 119

collapseColumns property, 53

determining number of columns, 52

example, 5354

layout_column property, 52

layout_span property, 52

other child elements of, 53

putting cells in rows, 52

setColumnXyz methods, 53

shrinkColumns property, 53

stretchColumns property, 53

TableRow container, 52

tables, SQLite, 230231

tablets, Android

handling platform changes, 359366

tabs, 102108

adding tabs during runtime, 106

replacing tabs with activity, 340

using tabs to hold information, 102

TabSpec class, 104, 105

TabWidget container, 103, 104, 106

tapping screen

onTap method, 307

target ID system, 353

targets, 1215

finding out available API targets, 13

intent routing, 172

telephone calls

making phone call, 312314

Telephony Actions group, DDMS

incoming calls or SMS messages, 326

TelephonyManager class, 311

getXyz methods, 311, 312

testing applications with emulator, 5

tests folder, 7

text

ellipsize attribute, 140

entering on soft keyboard, 119, 120

entering text on soft keyboard, 117

makeText method, Toast, 150

styled text, 198, 199

text attribute, XML layout file, 25

text messages

Dalvik Debug Monitor Service, 327328

text property, TextView, 29

textColor attribute, widgets, 38

textColor property, TextView, 29

textStyle property, TextView, 29

TextView widget, 2930

additional properties/method, 3738

changing color of, 38

creating views, 68

ellipsize attribute, 140

ListView with icons and text, 76

properties, 29

setTypeface method, 139

XML layout file, 25

TextWatcher class, 70, 71

third-party libraries, Java, 245

thread safety

ProgressBar widget, 158

threads

see also background threads; UI threads

handlers, 155158

HttpClient, Apache, 257

ProgressBar widget, 101

where is current code execution, 159

tickerText, 290

time

displaying, 99

inputting, 95

loadTime method, 146

TimePicker widget, 95

TimePickerDialog, 95, 97

title attribute, item element, 134

T-Mobile G1

buttons, 354

emulating, 12

keyboards, 117

rotating, 185, 191, 196

SD card, 328

T-Mobile myTouch 3G, 354

Toast class, 150

makeText method, 150, 152

show method, 150

toasts, 149150

MessageDemo example, 151153

toggle method

CheckBox, 34

SlidingDrawer, 115

toggleSatellite method, MapView, 304

touchpads

Motorola BACKFLIP, 357

touchscreens

resistive or capacitive, 356

scenarios requiring different resources, 209, 212

specifying hardware requirements, 354

transactions, SQLite, 227

tutorials, Android, 367

typeface attribute, fonts, 138

Typeface class

createFromAsset method, 139

createFromFile method, 140

typeface property, TextView, 29

imagesU

UI (user interface)

automatically scaling to screen size, 332334

embedding second activity in main activity UI, 351

handling multiple screen sizes, 331351

modifying from background threads, 155

screen size/density independence, 334337

resource sets, 335336

supports-screens element, 334335

UI architecture, Android, 177

UI threads, 155

background threads interacting with UI on, 155

handling work on, 159165

onPostExecute method, AsyncTask, 164

passing Runnables to Handler, 158

runOnUiThread method, Activity, 159

where is current code execution, 159

unbindService method, 287

Unicode

ZERO WIDTH NO-BREAK SPACE character, 140

units of measurement

automatically scaling UI to screen size, 333

resource dimensions, 207

unlock method, SlidingDrawer, 115

unregisterReceiver method, intents, 175

unsigned apk file, 8

update method

ContentProvider, 270

SQLite, 231

updateForecast method

HttpClient handling HTTP requests, 254, 255

identifying location, 298

updateLabel method, 97

updateTime method, 19

Uri object

addId method, 260

base Uri, 259, 260

content providers, 259, 260, 261, 263, 264

building, 265274

content Uri, 259, 264, 265266

getting Uri handles, 260

handling rotation, 188, 191

instance Uri, 259, 260, 268, 269, 271

intents, 172, 174, 178

parse method, 260

setImageURI method, 31

tabbed browsing, 182

user agents

setUserAgent method, 147

user interface see UI

user interface elements see widgets

users

allowing to set preferences, 215218

handling clicks on links, 145

uses-configuration element, manifest, 353

uses-feature element, manifest, 354

uses-library element, manifest, 9

uses-permission element, manifest, 9, 10, 275

uses-sdk element, manifest, 9, 11

Android Market bug, 12

imagesV

validation message

AlertDialog, 150

valueOf method, ColorStateList, 38

values folder (res/values/), 8, 206208

languages requiring different resources, 209

strings.xml file, 198

types of resources, 197

varargs, AsyncTask, 160

doInBackground method, 160, 163

onProgressUpdate method, 161, 164

VerifyError, 364

version-based resource sets, 336

versionCode attribute, manifest, 12

versionName attribute, manifest, 12

versions

handling API changes, 362

vertical orientation, LinearLayout, 40

verticalSpacing property, GridView, 66

vibration

hardware notifications, 290

View class

additional properties/methods for widgets, 3738

Android widgets, 19

creating widgets as subclasses of, 24

findViewById method, 38

getParent method, 38

getRootView method, 38

getTag method, 82

hierarchy, XML layout file, 23

isEnabled method, 38

isFocused method, 38

nextFocusXyz properties, 37

OnClickListener interface, 30

postXyz methods, 159

requestFocus method, 38

setEnabled method, 38

setTag method, 82

visibility property, 37

view definition

using XML layout file, 24

view hierarchies, 360

view methods

bindView, 94

findViewById, 26, 27

getListView, 62

getView, 68

newView, 94

setContentView, 19, 25, 26

setDropDownViewResource, 64, 65

setupViews, 193

setWebViewClient, 145

view objects

AutoCompleteTextView, 6972

ExpandableListView, 116

GridView, 6669

ImageView, 31

ListView, 6063

MapView, 302, 303, 304, 305

RateListView, 89, 93, 94

ScrollView, 5457, 123

TextView, 2930

WebView, 141147

WebViewClient, 145, 146

view properties

Hierarchy Viewer tool, 319

ViewFlipper container, 109114

adding contents at runtime, 112113

automatic flipping, 113114

setFlipInterval method, 113

showNext method, 110

startFlipping method, 113

view-flipping see flipping

views

convertView parameter, 8081, 84, 86

flipping, 109114

intents, 109

tabs, 102108

ViewWrapper class

combining RatingBar with ListView, 86, 87, 92

ListView with icons and text, 82, 83, 84

ViewWrapperDemo class, 83

visibility property, 37

visible attribute, items/groups, 135

VM see Dalvik virtual machine

imagesW

W3C DOM parser, 255

Weather project, 254

WeatherDemo application, 257

parsing responses, 255

WeatherPlus application, 285

WeatherPlus class, 286

WeatherPlusService class, 279, 286

web browsers

Android browser, 143

Internet access, 143

settings/preferences, 147

tabbed browsing, 182184

WebKit browser, 141

WebView widget, 141

getting content into, 143

web page, loading, 142

web services

accessing REST-style web services, 253

WebKit, 141

Browser1 app, 141, 143

Browser2 app, 144

Browser3 app, 145, 146

HTTP operations via Apache HttpClient, 254, 255

styled text, 199

WebSettings class

adjusting settings of WebView, 147

persistence of settings, 147

setDefaultFontSize method, 147

setJavaScriptEnabled method, 143, 147

setUserAgent method, 147

WebView widget, 141147

adjusting settings of, 147

canGoBack method, 145

canGoBackOrForward method, 145

canGoForward method, 145

clearCache method, 145

clearHistory method, 145

enabling JavaScript, 143

getSettings method, 143, 147

getting content into, 143

goBack method, 144

goBackOrForward method, 145

goForward method, 145

handling clicks on links, 145

JavaScript default setting, 143

loadData method, 143144

loadUrl method, 142, 143

navigation, 144

permission to access the Internet, 276

persistence of settings, 147

reload method, 144

setWebViewClient method, 145

tabbed browsing, 182

WebViewClient class

shouldOverrideUrlLoading method, 145, 146

weight, LinearLayout container, 40

widgets

@+id/widgetname notation, 47

@id/widgetname notation, 48

adapters, 5960

additional properties/methods, 3738

alignment, 47, 48

AnalogClock, 99

attaching to activity, 23

AutoCompleteTextView, 6972

Button, 3031

CheckBox, 3335

color attributes, 38

containers, 39

creating, 24

DatePicker, 95

DigitalClock, 99

EditText, 3233

Gallery, 72

GridView, 6669

handling clicks on links, 145

Hierarchy Viewer tool, 319

ImageButton, 31

ImageView, 31

LinearLayout container, 3945

ListView, 6063, 7594

with icons and text, 7584

with ratings and text, 8494

positioning relative to container, 47

positioning relative to other widgets, 48

ProgressBar, 101

RadioButton, 3537

RatingBar, 8494

RelativeLayout container, 4651

ScrollView container, 5457

SeekBar, 101

Spinner, 6366

TableLayout container, 5154

TabWidget, 103, 106

TextView, 2930

TimePicker, 95

using different fonts, 139

value for limited-input devices, 95

View class, 19

WebView, 141

XML layout file, 23

attaching to Java, 25

Wi-Fi hotspots

identifying location, 295

wikis

Open Mob for Android wiki, 367

windows

automatically scaling UI to screen size, 332

Hierarchy Viewer tool, 317

wrap_content rule

automatically scaling UI to screen size, 332

LinearLayout container, 40, 43

wrapping API, 362366

WRITE_CALENDAR permission, 276

WRITE_CONTACTS permission, 276

writePermission attribute, content providers, 278

WVGA screens

Archos 5 Android Internet Tablet, 355

EU4You application, 345, 347, 349, 350

Google/HTC Nexus One, 357

ignoring screen sizes and resolutions, 332

Motorola DROID/Milestone, 356

reading font, EU4You, 346

screen sizes, 331

imagesX

XML files

describing menus via, 133135

xml folder (res/xml/), 8, 204206

framework for managing preferences, 214

types of resources, 197

XML layout file

@ signs, 25, 27

aapt tool, 23

attaching to Java, 25

attaching widgets to activity, 23

attributes as widget properties, 23

creating labels in, 29

description, 23

ImageView with icons and text, 76

Layouts/NowRedux project, 24

NowRedux project, 26

R.layout, 76

reasons for using, 24

XML parsers, Android, 255

XML pull parser, 255

XML-defined drawables

automatically scaling UI to screen size, 334

XmlPullParser object, 204, 206

XMLResourceDemo application, 206

XML-RPC client APIs, 253

imagesY

years

DatePicker/DatePickerDialog, 95

imagesZ

ZERO WIDTH NO-BREAK SPACE character, 140

zooming, 304

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.79.206