AbsoluteLayout, 273
Action bar
custom views, 301
sample application, 303
logo, tapping, 301
Active state, 193
Activities, 237. Seealso Android activities
built-in Android map activity, 241
Bundle, 239
geo: Intent, 242
intent, 238
LaunchDemo sample application, 241
onActivityResult() callback, 239
setResult() method, 239
showMe() callback method, 240
startActivityForResult() method, 239
startActivityFromFragment() method, 239
startActivityIfNeeded() method, 239
startActivity() method, 238
String, 239
tabbed browsing
CWBrowser, 243
geo: Uri, 242
IntentTabDemo sample application, first tab, 244
IntentTabDemo sample application, second tab, 244
TabActivity, 243
TabActivity object, 242
Activities, Android, 5
Activity.onResume() method, 235
Activity.onSaveInstanceState() method, 235
Activity's life cycle, 193
instance state, 196
onCreate() method, 194
onPause() method, 195
onRestart() method, 195
onResume() method, 195
onStart() method, 195
onStop(), 195
Schrödinger's activity, 193–194
addPreferencesFromResource(), 352
addWord() method, 305
Adobe Integrated Runtime (AIR), 509
ADT. See Android Developer Tools (ADT)
ADT add-in, Eclipse, 37
AIR, 544
Alert notifications
android.notify, 440
configuration
hardware, 438
notificationmanager, 437
notify() method, 438
foreground, 445
getSystemService, 440
main view,NotifyDemo activity, 441
notification object, 441
notifications drawer, 444
NotifyDemo class, 440
onCreate() method, 445
PendingIntent, 441
setForeground() method, 445
setLatestEventInfo(), 441
startForeground() method, 445
status message, 442
stopForeground() method, 445
superimposed number notification, 443
Android, 557
activities, 5
content providers, 5
Developers web site, 557
Discuss web site, 557
Forums, 558
intents, 5
Open Mob for Android wiki, 558
Planet Android, 559
services, 5
source code, 558
StackOverflow, 558
tutorials, 557
Android activities, 53
building and running activities, 55
creating and attaching widgets to activity, 57
Now.java file, 53
src directory, 53
Android alternative environment, 507
Dalvik virtual machine, 508
garbage collection, 508
HTML5, 509
Java-based development, 508
Java-centrics strategy, 507
Java language, 508
JIT compiler, 508
J2ME, 507
NDK, 509
PhoneGap, 509
pointers, 507
rapid development and prototyping, 509
Rhodes, 509
SDK, Java development, 507
android:anyDensity attribute, 276
Android application, 7
building and running applications in Eclipse, 27
importing non-Eclipse project into Eclipse, 45
installing ADT for Eclipse, 12
configuration, 14
plug-in, 13
installing Android SDK, 9
base tools, 9
installing Apache Ant, 14
setting up device, 21
development options, 21
Mac OS X and Linux, 22
manufacturer-supplied driver, 22
Standard Android driver, 22
Stay awake option, 21
USB debugging option, 21
Windows update, 22
setting up emulator, 15
Android Virtual Device (AVD), 15
initial startup segment, 18
keyguard, 20
secondary startup segment, 19
setting up Java, 7
installing JDK, 7
learning Java, 8
supporting multiple screen sizes, 47
extra-large, 47
large, 47
normal, 47
small, 47
supports-screens element, 47
Android AVD Manager, 278
Android Compatibility Library (ACL), 309, 473
android:configChanges, 205, 210
android create project command, 248
Android Debug Bridge (adb), 502
Android Developer Tools (ADT)
installing ADT for Eclipse, 12
configuration, 14
plug-in, 13
installing Android SDK, 9
Android Developers web site, 7, 9
bugs, 554
building and running applications, 27
development options, 21
explicit feature requests, 551
AndroidManifest.xml, 551
camera, 552
gIESVersion, 552
hasSystemFeature() method, 552
PackageManager, 552
reqFiveWayNav, 552
reqHardKeyboard, 552
reqKeyboardType, 552
reqNavigation, 552
reqTouchScreen, 552
uses-configuration elements, 551
uses-feature element, 552
Google, 554
GPS (Global Positioning System), 6
implied feature requests, 553
Internet access, 6
Mac OS X and Linux, 22
manufacturer, 554
manufacturer-supplied driver, 22
market, 554
multimedia capabilities, 6
networks, 6
phone services, 6
Standard Android driver, 22
Stay awake option, 21
storage, 5
testing, 555
T-Mobile G1, 551
USB debugging option, 21
variations, 554
Windows Update, 22
Android emulators, 15
Android Virtual Device (AVD), 15
application launcher, 30
building and running applications, 27
creating, 44
do not run as XML file, 45
initial startup segment, 18
keyguard, 20
running project in emulator, 44
secondary startup segment, 19
AndroidHttpClient, 394
Android JAR, 42
android:largeScreens attribute, 276
android:layout_height, 273
android:layout_width, 273
Android list targets command, 27
AndroidManifest.xml file, 31, 33, 208–211, 234, 238, 275
application element, 35
activity element, 35
debuggable attribute, 35
intent-filter child element, 35
label attribute, 35
name attribute, 35
stock activity element, 35
importing non-Eclipse project into Eclipse, 39
manifest element, 34
namespace declaration, 34
package attribute, 34
supports-screens element, 47
uses-sdk element, 48
versionCode attribute, 34
version information, 48
versionName attribute, 34
android:normalScreens attribute, 276
ADT add-in, Eclipse, 37
alternative IDEs, 45
debugging, 45
IDEA, IntelliJ, 46
MOTODEV Studio for Android, 45
SQLite browsing, 45
AndroidManifest.xml file, 33
application element, 35
manifest element, 34
namespace declaration, 34
package attribute, 34
versionCode attribute, 34
versionName attribute, 34
build, install and run application in emulator/device, 27
Eclipse, 27
creating skeleton project, 23
in Eclipse, 23
directory tree structure, 31
bin/classes directory, 33
bin/classes.dex file, 33
bin directory, 33
bin/yourapp.ap, 33
bin/yourapp-*.apk, 33
namespace directory tree, 32
R.java file, 32
res directory, 32
res/drawable directory, 32
res/drawable-hdpi/icon.png, 33
res/drawable-hdpi suffixes, 33
res/drawable-ldpi/icon.png, 33
res/drawable-mdpi/icon.png, 33
res/layout directory, 32
res/layout/main.xml file, 33
res/menu directory, 32
res/raw directory, 32
res/values directory, 32
res/values/strings.xml file, 33
res/xml directory, 32
Src directory, 32
importing non-Eclipse project into Eclipse, 38
Android project tree, 41
creating emulator, 44
Dalvik Debug Monitor Server (DDMS), 42
do not run as XML file, 45
File menu, 38
New Android Project wizard, 40
New Project wizard, 39
Perspective menu, 43
Perspective roster, 43
Project context menu, 41
Project Properties window, 42
running project in emulator, 44
project wizards, Eclipse, 37
Android project tree, Eclipse, 41
android.provider.Contacts.CONTENT_URI, 199
android.provider.ContactsContract.Contacts.CONTENT_URI, 199
Android Repository, 10
Android scales, 276
android:screenOrientation, 211
Android SDK installation, 9
base tools, 9
Android SDK and AVD Manager
Android Virtual Devices list, 15
creating Android emulator, 44
creating AVD home screen, 15
initial startup segment, 18
installing Android SDK, 9
Android batch file, 9
Android packages, 10
Android Repository, 10
Available packages option, 9, 10
documentation, 10
Google add-ons, 11
license agreement screen, 12
license confirmation dialog box, 11
samples, 10
SDK platforms, 10
keyguard, 20
secondary startup segment, 19
android:smallScreens attribute, 276
Android-style smartphones, 3–4
android.text.Spanned interface, 247
Android Virtual Device (AVD), 15
android:xlargeScreens attribute, 276
Ant clean install command, 28, 55
Apache HttpClient library, 389
App Inventor
set up, 545
Application-instance state, 196
Application launcher, Android emulator, 30
Assets directory, 32
Available packages option, 9, 10
AVD Manager. See Android SDK and AVD Manager
Bin/classes.dex file, 33
Bin/classes directory, 33
Bin/yourapp.ap, 33
Bin/yourapp-*.apk, 33
Bitmap-scaling algorithms, 272
Box model
LinearLayout, 87
BroadcastReceiver, 235
BroadcastReceiver interface, 234–235
btn_name string, 248
Build class, 554
Build Path menu option, 41
Build tools, Android, 31
Build.xml file, 32
Bundle icicle, 55
Button class, XML-based layouts, 58, 59
CALL_PHONE permission, 553
Cascading Style Sheets (CSS), 255
Clojure, 548
close() method, 195
Command-line switches
activity, 27
package, 27
path, 27
target, 27
Commands
Android list targets command, 27
ant clean install command, 28
Communication, services
callback/listener object, 414
Messenger object, 415
notifications, 416
PendingIntent object, 415
startService method, 412
Compatibility mode, 272
Compatibility Test Suite (CTS) bugs, 555
Containers
LinearLayout
box model (see Box model)
fill model, 80
Flex and XUL, 79
gravity, 81
margins, 82
orientation, 80
weight, 81
RelativeLayout, 88
EditText, 91
Java code, 91
order of evaluation, 90
properties, 89
widget alignment, 89
ScrollView
Android emulator, 98
HorizontalScrollView, 99
ListView, 99
TableLayout, 93
collapseColumns property, 95
Java code, 96
Non-Row Children of, 94
shrinkColumns property, 95
stretchColumns property, 95
XML layout, 95
Content providers, Android, 5
CWBrowser, 243
Dalvik Debug Monitor Service (DDMS), 461, 491
browsing event log, 492
Dump HPROF option, 501
intial view, 492
location updates, 496
LogCat tab, 42
phone calls and messages, 496–499
screen capture, 495
Dalvik virtual machine (VM), 381
Dead state, 194
Debugging
MOTODEV Studio for Android, 45
USB debugging, 21
Density-based sets, 276
Density-independent pixels (dip), 274
DetailsFragment, 321
Development tools, 487
Android Debug Bridge, 502
DDMS tool, 491
browsing event log, 492
initial view, 492
location updates, 496
phone calls and messages, 496–499
screen capture, 495
Hierarchy Viewer tool, 487
main window, 488
usage, 487
view properties, 490
Devices. See Android devices
DisplayMetrics class, 277
Documentation for Android SDK, 10
doInBackground() method, 220, 227, 228
Dolphin Browser HD 4.0, 523
Downloader service, 417
design, 417
service implementation, 418–420
DownloadManager, 395, 402, 404
Eclipse, 37
ADT add-in, 37
alternative IDEs, 45
debugging, 45
IDEA, IntelliJ, 46
MOTODEV Studio for Android, 45
SQLite browsing, 45
Android project wizards, 37
building and running Android applications, 27
creating skeleton Android project, 23
application name, 25
build target, 25
create activity, 25
New Android Project wizard, 24–26
New Project dialog box, 24
package name, 25
project name, 25
drag-and-drop GUI editing, 37
extensibility of, 37
importing non-Eclipse project, 38
Android project tree, 41
creating emulator, 44
Dalvik Debug Monitor Server (DDMS), 42
do not run as XML file, 45
File menu, 38
New Android Project wizard, 40
New Project wizard, 39
Perspective menu, 43
Perspective roster, 43
Project context menu, 41
Project Properties window, 42
running project in emulator, 44
installing ADT, 12
configuration, 14
plug-in, 13
tooltip support, 37
Eclipse, running activity, 55
Emulators. See Android emulators
File accessing models
application-specific data file
getFilesDir(), 342
onPause(), 340
onResume(), 340
openFileInput() and openFileOutput(), 338, 339
ReadWriteFileDemo sample application, 340, 342
external storage, 342
getExternalStorageDirectory() method, 343
getExternalStorageState() method, 343
Linux file systems, 347
Resources object, 335
StaticFileDemo sample application, 338
static reference data, 335
StrictMode
application development, 345
conditionally being strict, 345, 346
janky code avoidance, 343
set up, 344
Threads/ReadWriteStrict sample application, 344
fill_parent and wrap_content values, 273
FindViewById method
accessing identified widgets, 60
NowRedux demo, 60
findViewById(), 304
finish() method, 194
Firefox mobile, 523
Flex, 544
Fonts
createFromAsset() method, 483, 484
Fonts/FontSampler sample project, 481–482
Java code, 483
MgOpenCosmeticaBold, 484
PNG graphics, 483
sampler application, 484
TTF, 483
Typeface object, 483
Forums, 557
Fragments, 307
Android Compatibility Library, 309
configuration changes, 322
design approach, 322
EU4You activity, 319
CountryListener interface, 320
FragmentManager, 320
Listener Interface, 318
onCreate(), 320
EU4You_6, activities, 317
fragment classes, 310
DetailsFragment, 321
DialogFragment, 316
general fragments, 310
list fragment (seeListFragment)
fragment-to-activity communication, 317
larger screen, 307
Gen directory, 32
generatePage() method, 392
getAttributeCount(), 254
getIdentifier() method, 353
getLastNonConfigurationInstance() method, 205, 228
getMenuInfo() method, 180
getProgress() method, 152, 214
getResources().getConfiguration() method, 277
getResources().getXml, 252
getStringArray() method, 256
getString() method, 246
getText() method, 247
getXml() method, 252
Global Positioning System (GPS)
ACCESS_MOCK_LOCATION, 461
addProximityAlert(), 460
callback method, 460
DDMS, 461
getBearing() method, 459
getBestProvider() method, 458
getLastKnownPosition() method, 458
getMeMyCurrentLocationNow() method, 459
getSystemService() method, 458
hasAltitude() method, 459
hasSpeed() method, 459
Intent, 461
LocationListener, 459
LocationManager, 458
LocationProvider objects, 458
mapping and location, 457
removeProximityAlert(), 461
removeUpdates(), 460
requestLocationUpdates() method, 459, 460
setAccuracy() method, 458
setAltitudeRequired() method, 458
setCostAllowed() method, 458
Wi-Fi hotspots, 457
Google add-ons, 11
Google Groups, 557
Google Maps, 463
ACCESS_FINE_LOCATION permissions, 466
add-on system, 464
Android attributes, 465
AndroidManifest.xml file, 466
built-in overlay, 470
digital signature, 465
drawing ItemizedOverlay, 468–470
onTap method, 470
SitesOverlay class, 469
fragments, 473
latest Android versions, 473
limitations, 476
onActivityCreated method, 474–475
onCreateView method, 474
generating API keys, 464
handling screen taps, 470
INTERNET permission, 466
isRouteDisplayed method, 466
licensing issues, 464
MapActivity widget, 465
MAPController
setCenter method, 467
setZoom method, 467
mapping options, 463
MD5 signature, 464
MyLocationOverlay, 471
optional/essential to application, 466
overlay classes, 468
terms and considerations, 463
testing integration of, 464
third-party application integration, 463
toggleSatellite method, 472
Google-usb_driver directory, 22
GPS (Global Positioning System), Android devices, 6
GUI builders, 58
GUI editing, 37
handleMessage() method, 217
Handlers
Handler object, 214
Handler subclass, 214
Message
handleMessage() method, 215
HandlerDemo sample application, 217
obtainMessage() method, 215
onStart() method, 217
onStop() method, 217
sendEmptyMessage() method, 215
sendMessage() method, 215
sendMessageAtFrontOfQueue() method, 215
sendMessageAtTime() method, 215
sendMessageDelayed() method, 215
Runnable, 218
HandOfCardsLayout, 274
HelpActivity, 238
Hierarchy Viewer tool
main window, 488
usage, 487
view properties, 490
HTC Nexus 1, 257
Html.fromHtml() method, 247, 249
HTML5, 511
Android SDK, 523
Chrome-like browser, 523
Dolphin Browser HD 4.0, 523
Firefox mobile, 523
limitations, 520
Android device versions, 521
distribution, 523
limited platform integration, 521
look-and-feel disparity, 522
performance and battery, 522
screen sizes and distribution, 521
offline applications
Opera mobile, 523
signing and distribution, 520
testing, 520
updates, 520
web storage, 517
localStorage object, 517
SQL Database, 519
Ice Cream Sandwich (ICS), 235
Ice Cream Sandwich and Honeycomb, 329
action bar, 329
Tablet-Only Apps, 331
@+id/ convention, XML-based layouts, 59
IDEA, IntelliJ, 46
ImageView, 251
Input method editor (IME), 103
e-mail addresses, 107
plain soft keyboard, 106
signed decimal numbers, 107, 108
Input method framework (IMF), 103
android:inputType attribute, 104
android:windowSoftInputMode attribute, 110
.com button, 107
full-screen option, historic defaults, 110
hard and soft keyboards, 103, 104
IME (see Input method editor)
InputMethod/IMEDemo1 project, 105
InputMethod/IMEDemo2 project, 108, 109, 110
InputMethodManager, 111
setDimAmount() method, 111
setSystemUiVisibility() method, 111
shrunken and scrollable layout, 111
TableLayout, 106
Installations
ADT for Eclipse, 12
configuration, 14
plug-in, 13
Android SDK, 9
base tools, 9
Apache Ant, 14
JDK, 7
Install command, ant clean, 28
Integrated development environment (IDE). See Eclipse
Intent, 231
ACTION_AIRPLANE_MODE_CHANGED, 235
ACTION_CAMERA_BUTTON, 235
ACTION_DATE_CHANGED, 235
ACTION_HEADSET_PLUG, 235
actions, 232
activities, 238
Bundle, 232
category, 232
component, 232
data, 232
extras, 232
filters
activity element, 233
Android application-building script, 233
AndroidManifest.xml file, 233
declared activity, 234
MIME type data, 234
Uri, 234
HTTP verbs, 231
ICS version 4.0, 235
MIME type, 232
Intent object, 242
Intents, Android, 5
Internet access, Android devices, 6
Internet-aware Android components
download status tracking, 398, 399
file download, 395
initial launching, 400
Internet/download application, 395
INTERNET permission, 395
mid-download status, 403
status bar and download icon, 400, 401
WRITE_EXTERNAL_STORAGE permission, 395
Internet communication
Internet-aware Android components (see Internet-aware Android components)
Janky code, 405
REST
AndroidHttpClient, 394
SOAP/XML-RPC layer, 389
SSL certificate, 394
web services, 389
Janky Code, 405
JAR file, Android, 42
Java, 7
alternative Java compilers, 8
installing JDK, 7
learning, 8
Java 2 Platform, Micro Edition (J2ME), 507
Java Build Path, 41
Java-centrics strategy, 507
Java class name, 27
Java code
android id attribute, 59
attaching widgets to, 59
creating and attaching widgets to activity, 57
Java Development Kit (JDK)
installing, 7
OpenJDK, 8
Java libraries
Ants and JARs, 381
BeanShell scripting, 383
AndShell BeanShell IDE, 384, 386
scripting languages, 386
Scripting Layer for Android (SL4A), 386
outer limits, 382
Java package name, 27
java.util.concurrent class package, 214
java.util.concurrent package, 229
Jbutton click, Swing, 55
JRuby, 544
Just-in-time (JIT) compilation, 508
keyboardHidden configuration, 206
Keyguard
Android emulator startup phases, 20
Landscape WVGA mode, 290
Launch Options dialog box, 278–279
Libs directory, 31
License agreement screen, 12
License confirmation dialog box, 11
LinearLayout, 206, See Containers
Linux
in Android devices, 22
file systems, 347
ListActivity, 280
ListFragment
backward-compatible empty style, 315
CountryAdapter, 312
CountryAdapter, EU4You_6, 314–315
CountryWrapper, 312
enablePersistentSelection() method, 315
ListAdapter, 311
ListView, 314
Lists
Adapter, resource ID, 130
Android ListView, 129
ArrayAdapter, 131
DynamicDemo application, 133
FancyLists/Static sample project, 129–130
findViewById() method, 135
getView() implementation method, 131–132, 135
holder pattern
findViewById() method, 137
getTag() and setTag() method, 137–139
ViewHolderDemo activity, 138
IconicAdapter, 132
ImageView widgets, 137
inflation
FancyLists/DynamicEx project, 134
getLayoutInflater() method, 134
LayoutInflater class, 133
View class and representation, 133
LinearLayout, 130
RatingBar widget
FancyLists/RateList sample project, 139–141
getView() implementation, 141
RateListDemo application, 143
TextView, 142
top-rated word, 143
ViewHolder, 142
StaticDemo application, 131
ListView, 280
LogCat tab, DDMS, 42
Mac OS X,in Android devices, 22Main.xml file, 59
Menus, 177
Add a Word dialog box, 184
add() function, 178
addSubMenu() function, 179
ArrayList method, 182
drop-down menu, 188
finger-friendly buttons, 177
getMenuInfo() method, 185
inflation
item and group elements, 186–187
MenuInflater, 187
Menus/Inflation project, 187–188
View objects, 185
initAdapter() method, 182
MENU_ADD/MENU_RESET, 183
MENU_CAP and MENU_REMOVE, 184–185
MenusetGroupCheckable() function, 179
MenuDemo sample application, 182–183
MenuItem#setCheckable() function, 178
Menus/Menus sample project, 180
onCreateOptionsMenu() function, 178–179
onCreatePanelMenu() method, 179
onPrepareOptionsMenu() function, 178
private add() method, 183
setQwertyMode() method, 178
TextView, 177
Mono, android, 545
MOTODEV Studio for Android, 45
Motorola
Charm, 258
XOOM, 297
Multimedia capabilities6
Music player service, 421
design, 421
service implementation, 422–423
Namespace directory tree, Android projects, 32
National Weather Service XML, 391–392
Native Development Kit (NDK), 509
Networks, Android devices, 6
New Android Project wizard, Eclipse, 24, 25, 26, 40
New Project dialog box, Eclipse, 24
New Project wizard, Eclipse, 39
Nine-patch bitmap, 275
Now files
demonstration activity, 56
java file, 53
Redux sample activity, 61
onActivityResult() callback and method, 200, 239
onConfigurationChanged() approach, 205, 208
OnCreate method, NowRedux demo, 60–61
onCreateContextMenu() method, 179
onCreateOptionsMenu(), 304
onListItemClick() method, 213
onOptionsItemSelected() method, 178–179
onPostExecute() method, 220, 228
onPreExecute() method, 220
onProgressUpdate() method, 220
onReceive() method, 234
onRestart() method, 195
onRestoreInstanceState() method, 196–198
onRetainNonConfigurationInstance(), 203–205, 210
onRetainNonConfigurationInstance() method, 227
onSaveInstanceState(), 210
onSaveInstanceState() method, 196
onStart and onStop() method, 195, 217
Open Mob for Android wiki, 558
OpenJDK, 8
Opera mobile, 523
org.xmlpull.v1 Java namespace, 252
orientation configuration, 206
Paused state, 193
Permissions require and request
ACCESS_COARSE_LOCATION, 452
ADD_VOICEMAIL, 455
Android developer, 451
AndroidManifest.xml file, 451–453
BIND_TEXT/VPN_SERVICE, 455
CALL_PHONE, 452
checkCallingPermission(), 454
description, 453
enforcing via manifest, 453
enforcing,elsewhere, 454
INTERNET, 452
label, 453
Microsoft Outlook, 451
NFC, 452
READ_PHONE_STATE method, 455
READ_PROFILE, 455
SecurityException, 452
sendBroadcast(), 454
symbolic name, 453
trial and error, 454
up front or not at all, 455
uses-permission element, 452
WRITE_EXTERNAL_STORAGE method, 452, 455
WRITE_PROFILE, 455
Phone services, Android devices, 6
Checklist application, 534
APIs, 536
device properties, 538
deviceready event, 537
Device-Ready event handler, 536
onDeviceReady function, 537–538
onload function, 537
virtual JavaScript objects, 536
creating and installing project, 528
definition, 525
distribution, 527
features, 526
information, 541
installation and limitations, 528
look and feel issues, 541
other platforms (non-Android), 527
screen sizes and density issues, 540
usage, 528
WebKit browser, 526
Planet Android, 559
Platform changes
API change, 324
class deletion, 327
conditional class loading, 328
error verification, 327
maximum and minimum SDK versions, 326
reflection, 328
targets vs. SDK vs. OS versions, 325, 326
version deletion, 327
wrapping, 327
Ice Cream Sandwich and Honeycomb. seeIce Cream Sandwich and Honeycomb
resource change, 324
view hierarchy, 323
PlayingCardLayout, 274
Pop-up messages, 189
error messages, 189
MessageDemo sample application, 192
Messages/Message, 191
Preferences
fragments and activity, 351
Backward Compatibility, 354–355
intent elements, 354
nested preference avoidance, 354
older model, 356
StockPreferenceFragment, 352–353
pop-ups
ListPreference, 363
preference UI, 364
Prefs/Dialogs sample project, 362
Selection Dialog, 365
Text Entry Dialog, 364
XML
addPreferencesFromResource(), 357
AndroidManifest.xml file, 357
Android-supplied preference UI, 357
child preference screen, 362
EditPreferences activity, 356
onCreate() and onResume(), 359
PreferenceActivity implementation, 361
PreferenceCategory and nested PreferenceScreen elements, 360, 361
ringtone preference, 358
Proguard.cfg file, 32
Project context menu, Eclipse, 41
Project Properties window, Eclipse, 42
*.Properties file, 32
publishProgress() method, 220–222
QVGA screen, 272
Qwerty, 260
R.array, 256
R.color, 256
R.drawable, 251
R.java file, NowRedux demo, 60
R.layout.main file, 59
R.string, 246
registerForContextMenu() method, 179
registerReceiver() method, 235
RelativeLayout, 273–274, See Containers
Res/drawable
directory, 32
hdpi suffixes, 33
hdpi/icon.png, 33
ldpi/icon.png, 33
mdpi/icon.png, 33
Res/layout
directory, 32
main.xml file, 33
Res/menu directory, 32
Res/raw directory, 32
Res/values directory, 32
Res/values/strings.xml file, 33, 246
Res/xml directory, 32
Resources, 245
Android documentation, 258
arrays, 256
click-wheel, 257
configuration options, 258-260
dimensions, 255
D-pad, 257
drawables, 258
HTC Nexus 1, 257
internationalization and localization, 257
keyboard, 257
layout, 245
Motorola Charm, 258
qwerty, 260
res/ directory, 245
res/values/ directory, 254
res/values/strings.xml file, 257
Samsung Galaxy Tab, 257
screen orientation, 257
screen size, 257
string theory
internationalization and localization, 246
plain strings, 246
string formats, 246
styled text. See Styled text
touchscreen, 257
types, 245
XML
Files/Static sample project code, 252–253
getXml() method, 252
next() method, 252
R.xml, 252
words.xml file, 252
XMLResourceDemo sample application, 254
Resources.getStringArray() method, 256
Rewriting project. See Android activities
Right-to-left (RTL) languages, 260–261
Root contents, 31
AndroidManifest.xml file, 31
assets directory, 32
bin directory, 31
Build.xml file, 32
gen directory, 32
libs directory, 31
proguard.cfg, 32
*.properties file, 32
res directory, 31
src directory, 31
RotationAsync class, 225
RotationAwareTask class, 225
Ruboto, 544
Run As dialog box, Eclipse
building and running applications, 27
running project in emulator, 44
Runnable objects, 218
runOnUiThread() method, 218
Samples for SDK, 10
Samsung Galaxy Tab, 257
Scala, 548
Scaled pixels (sp), 274
Schrödinger's activity, 193–194
Screen rotation, 197
accelerometer, 210
android:configChanges, 210
android:screenOrientation = "landscape", 208–209
android:screenOrientation = "portrait", 208–209
android:screenOrientation = "sensor", 210–211
AndroidManifest.xml file, 208–211
behind activity, 211
Bundle, 203
contact picking and viewing
ACTION_VIEW Intent, 200
RESULT_OK or RESULT_CANCELED, 200
RESULT_OK response, 200
startActivity() method, 199
startActivityForResult() method, 199–200
Uri values, 199
destruction philosophy, 197
DIY
onConfigurationChanged() approach, 208
Rotation/RotationThree sample application, 205–208
without Android's assistance, 205
fullSensor, 211
getLastNonConfigurationInstance(), 203–205
landscape mode, RotationFour application, 210
onCreate() method, 198
onRetainNonConfigurationInstance(), 203–205, 210
onSaveInstanceState(), 210
onSaveInstanceState() method, 198
portrait layout, 198
portrait mode, RotationFour application, 209
restoreMe(), 205
reverseLandscape and reversePortrait, 211
Rotation/RotationTwo sample project layouts, 204–205
saving state
landscape mode, RotationOne application, 203
onCreate() method, 203
onSaveInstanceState() method, 200–202
portrait mode, RotationOne application, 202
sensorLandscape and sensorPortrait, 211
slide-out keyboard, 210
T-Mobile G1, 205
user activity, 211
Screen sizes, 271
Android 1.5, 272
Android 1.6, 272
Configuration object, 277
density
FWVGA environment, 278
mobile device LCDs, 278
Motorola DROID, 278
DisplayMetrics class, 277
EU4You
Android Compatibility Library, 292
AndroidManifest.xml file, 281
browser, 292
HVGA emulator, 285
icons, 289
ListView, 281
tweaking, 282
extra screen space, 279
extra-large, 47
large, 47
normal, 47
physical dimensions, 274
"real" pixels, 274
replace menus with buttons, 280
replace tabs with simple activity, 280
resources and resource sets, 276–277
small, 47
<supports-screens> element, 47, 275–276
UI, 273
Scripting Layer for Android (SL4A), 386
ScrollView. See Containers
SDK platforms, 10
Selection widgets, 113
afterTextChanged() method, 126
Android's adapters, 113
ArrayAdapter, 114
AutoCompleteDemo sample application, 127
AutoCompleteTextView, 125
beforeTextChanged() method, 126
EditText subclass, 125
Gallery widget, 128
getCheckedItemPositions() method, 118
"get it right" constraint, 113
getListView() method, 116
GridView
configuration, 122
GridDemo sample application, 123–124
properties, 121
res/layout/cell.xml file, 123
two-dimensional grid, 121
ListActivity subclass, 114
ListView, 114
ListViewDemo sample application, 116
multiple disparate APIs, 113
multiple-select mode, 118
onListItemClick() method, 115
onTextChanged() method, 126
Selection/AutoComplete sample application, 125–126
Selection/Checklist sample project, 117
Selection/List sample project, 114–115
setAdapter() method, 114
setCellRenderer() method, 114
setChoiceMode() method, 116
setItemChecked() method, 118
setListAdapter() method, 115
setOnItemSelectedListener() method, 114
spin control
OnItemSelectedListener method, 120
Selection/Spinner sample project, 118–120
setDropDownViewResource() method, 118
setOnItemSelectedListener() method, 118
spinner drop-down list, 120–121
SpinnerDemo sample application, 120
TextView objects, 114
TextWatcher, 126
toString() method, 114
sendEmptyMessage() method, 215
sendMessage() method, 215
sendMessageAtFrontOfQueue() method, 215
sendMessageAtTime() method, 215
sendMessageDelayed() method, 215
Services and pattern
AndroidManifest.xml file, 411
communication
callback/listener object, 414
messenger object, 415
notifications, 416
pendingIntent object, 415
startService method, 412
definition, 409
functions, 409
IntentService class, 410
lifecycle methods
onCreate method, 410
onDestroy method, 410
onStartCommand method, 410, 411
onTrimMemory method, 410
Downloader, 417
design, 417
service implementation, 418–420
Music player, 421
design, 421
service implementation, 422–423
Web service interface, 424
design, 425
Forecast class, 426
rotation challenge, 425
unbind service, 435
WeatherListener object, 426
Services, Android, 5
setAlphabeticShortcut() method, 178
SetContentView method, 55
SetContentView method, NowRedux demo, 60
setGroupCheckable() method, 178
setIndeterminate() method, 214
setNumericShortcut() method, 178
SetOnClickListener method, 55
setOnEditorActionListener() method, 110
setOnSeekBarChangeListener() method, 152
setProgress() method, 214
setResult() method, 239
SetText method, 55
setText() method, 213
showMe() callback method, 240
@ Signs, XML-based layouts, 59
Size-based sets, 277
Smartphones,benefits and drawbacks and programming, 3–4
Software development kits (SDKs), 507
installing Android SDK, 9
base tools, 9
installing JDK, 7
Source code, Android, 558
SQLite, 367
Android versions, 377
browsing, MOTODEV Studio for Android, 45
Cursors
applications, 375
ConstantsBrowser activity, ListView, 376
getView() method, 376
newCursor() implementation, 377
SimpleCursorAdapter, 376
Database/Constants application, 367, 368, 369
flash memory, 377
manager extension, Firefox, 379
primer, 369
rawQuery(), 374
regular Query, 374
shipping, 378
sqlite3 program, 379
table setting, 373
delete() method, 373
execSQL(), 372
insert() method, 373
update() method, 373
startActivity() method, 200, 238–239
startActivityForResult() method, 239
startActivityFromFragment() method, 239
startActivityIfNeeded() method, 239
Stay awake option, setting up Android devices, 21
StockPreferenceFragment, 353
Stopped state, 194
Storage, Android devices, 5
String[], 256
string-array element, 256
Styled text, 246
angle brackets, 247
app_name resource, 248
applyFormat() method, 249
button, 248
funky_format, 248
getText() method, 247
Html.fromHtml(), 247
inline elements, 247
layout file, 248
onCreate() method, 249
Spanned object, 247
String.format(), 247
StringsDemo sample application with empty label, 250
StringsDemo sample application with name, 250
WebKit widget, 247
Styles, 263
activatedBackgroundIndicator, 267
android:background, 267
android:layout_width, 266
android:theme attribute, 268
bigred style, 266
container, 265
elements, 265
inheritance, 266
ProgressBar, 263
progressBarStyleHorizontal, 267
res/layout/main.xml, 265
widget, 265
Supports-screens element, 47, 281
Switch widget. See Widgets
TabActivity, 243
TableLayout. See Containers
Tablets
Android 4.0
contacts addition, 295
icons, hierarchy of actions, 296
roster of available contacts, 296
Ice Cream Sandwich, 298
Motorola XOOM, 297
SDK change, 297
vs. Android 2.x screen, 294
vs. Android 3.0, 294
Telephone calls handling
ACTION_DIAL calling, 480
ACTION_DIAL Intent, 478
Android dialer activity, 480
Android interface, 477
CALL_PHONE, 480
DialerDemo, 479
getCallState() method, 477
getPhoneType() method, 478
getSubscriberId() method, 478
Java code, 478
phone number, 478
Phone/Dialer, 478
social networking application, 477
TelephonyManager class, 477
Telephony, 553
TextUtils.htmlEncode() method, 249
TextView widgets, 261
Threads, 213
activity, 218
AsyncTask
activity, 223
AddStringTask declaration, 221–222
ANR error, 219
ArrayAdapter, 221
AsyncDemo, 224
background thread management, 219
doInBackground() method, 222
execute() method, 219
Generics and Varargs, 219
ListActivity, 220
onPostExecute() method, 223
onProgressUpdate() method, 223
stages, 220
subclass, 219
Toast, 224
Caveats,228
Handler. See Handlers
post() methods, 218
ProgressBars, 214
rotation
attach() method, 227
detach() method, 227
doInBackground() method, 228
onCreate() method, 228
onPostExecute() method, 228
onRetainNonConfigurationInstance() method, 228
ProgressBar, 225
Rotation/RotationAsync sample project, 224–25
RotationAsync Activity, 225–227
RotationAsync class, 225
RotationAwareTask, 227
RotationAwareTask class, 225
runnable, 218
runOnUiThread() method, 218
Titanium Mobile, 548
Tooltip support, ADT add-in, Eclipse, 37
TrueType (TTF) fonts, 483
Tutorials, 557
Ubuntu, 22
unregisterReceiver() method, 235
updateForecast() method, 391
UpdateTime method, 55
USB debugging option, setting up Android devices, 21
User interface (UI), 273
Uses-sdk element, 48
targetSdkVersion attribute, 49
Version-based sets, 277
Versions, Android application, 48–49
W3C DOM parser, 391
Web service interface, 424
design, 425
Forecast class, 426
rotation challenge, 425
unbind service, 435
WeatherListener object, 426
/clock URL, 174
AndroidManifest.xml, 170
BrowserDemo1 sample application, 171
BrowserDemo2 sample application, 172
BrowserDemo3 sample application, 174–175
getSettings().setJavaScriptEnabled(true); method, 171
Intent, 173
loadTime() method, 174
loadUrl() method, 171
onCreate() method, 170
settings, preferences, and options, 175
setWebViewClient() method, 173
shouldOverrideUrlLoading() method, 173
WebKit/Browser3, revised Java, 174
WebView, 242
WebView widget, 290
Widgets
accessing identified widgets, 60
attaching to Java code, 59
Basic/Label project, 64
check box, 68
CheckBoxDemo.java, 69
Java, 68
layout, 68
OnCheckedChangeListener interface, 69
color attributes, 76
complex views, 59
creating and attaching widgets to activity, 57
LabelDemo, 64
padding, 75
requestFocus(), 76
setEnabled(), 76
specification of relationships to other widgets, 57
Switch, 71
layout, 71
methods, 71
OnCheckChangedListener interface, 71, 72
sample application, 72
TextView, 63
View properties, 76
Widgets and containers, 145
AbsoluteLayout, 167
addTab() function, 158
android:targetSdkVersion and android:minSdkVersion, 156
Button and flip view, 161
Button widgets, 163
Calendar instance, 147
CheckedTextView, 167
ChronoDemo sample application, 148
Chronometer, 167
ClocksDemo sample application, 150
createTabContent() method, 157
date picker dialog box, 148–149
DateFormat formatter, 147
DatePicker and DatePickerDialog, 145
DigitalClock and AnalogClock, 150
DynamicTab application, 158, 159
ExpandableListView, 167
Fancy/Chrono sample project, 146, 147
FlipperDemo application, 162
FlipperDemo2 application, 164
FrameLayout, 153
Gallery, 168
GUI toolkits, 153
Intent, 152
JTabbedPane, 152
ListAdapter family, 167
MultiAutoCompleteTextView, 168
newTabSpec() method, 155
OnTimeSetListener function, 148
QuickContactBadge, 168
setContent() and setIndicator() method, 155
setCurrentTab() method, 155
setup() method, 154
showNext() function, 162
SlidingDrawer
Android developers, 165
android:id values, 166
closed, 166
DrawerDemo, 167
FrameLayout, 165
ImageView, 165
LinearLayout, 165
lock() and unlock() method, 167
open, 166
TabActivity, 154
TabContentFactory, 157
TabDemo sample application, 155
TabHost and TabWidget element, 153
TabSpec() method, 154
TabView, 163
TabWidget, 157
TextView, 161
time picker dialog box, 148–149
TimePicker and TimePickerDialog, 145–146
ToggleButton, 168
updateLabel() method, 147
ViewFlipper container, 160–161
Views/Chronometer API Demo, Android SDK, 151
Views/SeekBar API Demo, 152
ViewSwitcher, 168
Widgets:, 63
Wi-Fi access, 389
Wikis, 558
XML
addPreferencesFromResource(), 357
AndroidManifest.xml file, 357
Android-supplied preference UI, 357
child preference screen, 362
creating and attaching widgets to activity, 57
id attribute, 58
R.java source file, 57
reasons for using, 57
root element, 58
specification of widgets' relationships to each other, 57
EditPreferences activity, 356
Files/Static sample project code, 252–253
getXml() method, 252
layouts, 57
aapt tool, 57
android layout_height attribute, 59
android layout_width attribute, 59
android text attribute, 59
attaching widgets to Java code, 59
complex views, 59
containers, 57
@+id convention, 60
@+id/ convention, 59
@ signs, 59
next() method, 252
onCreate() and onResume(), 359
parsers, 391
PreferenceActivity implementation, 361
PreferenceCategory and nested PreferenceScreen elements, 360, 361
R.xml, 252
ringtone preference, 358
words.xml file, 252
XMLResourceDemo sample application, 254
XML-defined drawables, 275