Index

imageA

AbsoluteLayout, 273

Action bar

custom views, 301

layout, 302, 303

sample application, 303

user input control, 304306

enabling, 299, 300

logo, tapping, 301

menu items, 300, 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

peers, 237238

setResult() method, 239

showMe() callback method, 240

startActivityForResult() method, 239

startActivityFromFragment() method, 239

startActivityIfNeeded() method, 239

startActivity() method, 238

String, 239

subactivities, 237238

tabbed browsing

CWBrowser, 243

geo: Uri, 242

IntentTabDemo sample application, first tab, 244

IntentTabDemo sample application, second tab, 244

TabActivity, 243

TabActivity object, 242

TabHost, 243, 244

TabView, 242243

XML layout, 239240

Activities, Android, 5

Activity.onResume() method, 235

Activity.onSaveInstanceState() method, 235

Activity's life cycle, 193

instance state, 196

onCreate() method, 194

onDestroy() method, 194195

onPause() method, 195

onRestart() method, 195

onResume() method, 195

onStart() method, 195

onStop(), 195

Schrödinger's activity, 193194

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

icons, 438439

notificationmanager, 437

notify() method, 438

fakeplayer, 445446

FLAG_AUTO_CANCEL, 441, 444

foreground, 445

getSystemService, 440

honeycomb, 446448

icecream, 446448

main view,NotifyDemo activity, 441

notification object, 441

notifications drawer, 444

NotifyDemo class, 440

onCreate() method, 445

PendingIntent, 441

redux, 445446

sandwich, 446448

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

Google Groups, 557, 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

dissecting Java code, 5455

Now.java file, 53

src directory, 53

Android alternative environment, 507

Caveat developer, 509, 510

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

and Add-ons, 912

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 home screen, 19, 20

Android Virtual Device (AVD), 15

creating new AVD file, 1517

initial startup segment, 18

keyguard, 20

secondary startup segment, 19

setting up Java, 7

installing JDK, 7

learning Java, 8

specifying versions, 4849

supporting multiple screen sizes, 47

extra-large, 47

large, 47

normal, 47

small, 47

supports-screens element, 47

Android Asset Studio, 502504

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

Android devices, 21, 551

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 home screen, 19, 20

Android Virtual Device (AVD), 15

application launcher, 30

building and running applications, 27

creating, 44

creating new AVD file, 1517

do not run as XML file, 45

initial startup segment, 18

keyguard, 20

Run As dialog box, 44, 45

running project in emulator, 44

secondary startup segment, 19

Android home screen, 19, 20

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, 208211, 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

Android packages, 10, 324

Android project, 23, 31

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

command line, 2830

Eclipse, 27

creating skeleton project, 23

command line, 2627

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

root contents, 3132

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

Run As dialog box, 44, 45

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

Add ons, 912

base tools, 9

Android SDK and AVD Manager

Android home screen, 19, 20

Android Virtual Devices list, 15

creating Android emulator, 44

creating AVD home screen, 15

creating new AVD file, 1517

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

third party add-ons, 10, 11

keyguard, 20

secondary startup segment, 19

android:smallScreens attribute, 276

Android-style smartphones, 34

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

Blocks Editor, 546, 547

designer view, 545, 546

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

imageB

Bin/classes.dex file, 33

Bin/classes directory, 33

Bin directory, 31, 33

Bin/yourapp.ap, 33

Bin/yourapp-*.apk, 33

Bitmap-scaling algorithms, 272

Box model

LinearLayout, 87

XML file layout, 86, 87

BroadcastReceiver, 235

BroadcastReceiver interface, 234235

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

imageC

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

bindService method, 413414

broadcast intents, 414415

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

GridLayout, 99, 100

LinearLayout

box model (see Box model)

fill model, 80

Flex and XUL, 79

gravity, 81

Java code, 83, 84

margins, 82

orientation, 80

RadioGroup containers, 8486

weight, 81

XML layout file, 82, 83

RelativeLayout, 88

EditText, 91

Java code, 91

order of evaluation, 90

overlap, 92, 93

properties, 89

widget alignment, 89

widget position, 88, 89

XML layout, 90, 91

ScrollView

Android emulator, 98

HorizontalScrollView, 99

ListView, 99

XML layout file, 97, 98

TableLayout, 93

collapseColumns property, 95

Java code, 96

Non-Row Children of, 94

shrinkColumns property, 95

stretchColumns property, 95

Tablerow, 93, 94

XML layout, 95

Content providers, Android, 5

CWBrowser, 243

imageD

Dalvik Debug Monitor Service (DDMS), 461, 491

allocation tracker, 500501

browsing event log, 492

Dump HPROF option, 501

file push and pull, 494495

intial view, 492

location updates, 496

LogCat tab, 42

logging filter, 493494

memory management, 499501

phone calls and messages, 496499

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 Asset Studio, 502504

Android Debug Bridge, 502

DDMS tool, 491

allocation tracker, 500501

browsing event log, 492

file push and pull, 494495

initial view, 492

location updates, 496

logging filter, 493494

memory management, 499501

phone calls and messages, 496499

screen capture, 495

Hierarchy Viewer tool, 487

Layout View, 488489

main window, 488

Pixel Perfect View, 490491

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, 418420

user interface, 420421

DownloadManager, 395, 402, 404

imageE

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, 2426

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

Run As dialog box, 44, 45

running project in emulator, 44

installing ADT, 12

configuration, 14

plug-in, 13

tooltip support, 37

Eclipse, running activity, 55

EditText widgets, 261, 304

Emulators. See Android emulators

imageF

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

space efficiency, 336, 337

StaticFileDemo sample application, 338

static reference data, 335

static XML file, 335, 336

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

Flash, 509, 544

Flex, 544

Fonts

createFromAsset() method, 483, 484

Fonts/FontSampler sample project, 481482

glyph, 484485

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

layout, 317, 318

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

solution, 308, 309

imageG

Gen directory, 32

General fragments, 310, 311

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, 468470

onTap method, 470

SitesOverlay class, 469

fragments, 473

latest Android versions, 473

limitations, 476

MapActivity class, 475476

onActivityCreated method, 474475

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

GridLayout, 99, 100

GUI builders, 58

GUI editing, 37

imageH

handleMessage() method, 217

Handlers

Handler object, 214

Handler subclass, 214

Message

handleMessage() method, 215

HandlerDemo sample application, 217

layout, 215216

obtainMessage() method, 215

onStart() method, 217

onStop() method, 217

ProgressBar, 216218

sendEmptyMessage() method, 215

sendMessage() method, 215

sendMessageAtFrontOfQueue() method, 215

sendMessageAtTime() method, 215

sendMessageDelayed() method, 215

Runnable, 218

HandOfCardsLayout, 274

HelpActivity, 238

Hierarchy Viewer tool

Layout View, 488489

main window, 488

Pixel Perfect View, 490491

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

cache manifest, 511, 512

Checklist, 512517

Opera mobile, 523

signing and distribution, 520

testing, 520

updates, 520

web storage, 517

Checklist, 518, 519

localStorage object, 517

SQL Database, 519

imageI

Ice Cream Sandwich (ICS), 235

Ice Cream Sandwich and Honeycomb, 329

action bar, 329

API level, 329, 330

code isolation, 330, 331

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

and Add-ons, 912

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

narrow receivers, 234235

Uri, 234

HTTP verbs, 231

ICS version 4.0, 235

MIME type, 232

pause caveat, 235236

routing, 232233

Intent object, 242

Intents, Android, 5

Internet access, Android devices, 6

Internet-aware Android components

download request, 397, 398

download status tracking, 398, 399

file download, 395

initial launching, 400

Internet/download application, 395

INTERNET permission, 395

layout, 396, 397

limitations, 404, 405

LogCat, 403, 404

mid-download status, 403

notification drawer, 401, 402

ProgressBar widget, 401, 402

status bar and download icon, 400, 401

toast, 402, 403

WRITE_EXTERNAL_STORAGE permission, 395

Internet communication

Internet-aware Android components (see Internet-aware Android components)

Janky code, 405

REST

AndroidHttpClient, 394

HTTP operations, 390, 391

parsers, 391, 392, 393

SOAP/XML-RPC layer, 389

SSL certificate, 394

web services, 389

Internet-enabled phones, 34

imageJ

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

XML layout, 383, 384

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

imageK

keyboardHidden configuration, 206

Keyguard

Android emulator startup phases, 20

imageL

Landscape WVGA mode, 290

Launch Options dialog box, 278279

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, 314315

CountryWrapper, 312

enablePersistentSelection() method, 315

list of countries, 313314

ListAdapter, 311

ListView, 314

Lists

Adapter, resource ID, 130

Android ListView, 129

ArrayAdapter, 131

convertView, 135137

DynamicDemo application, 133

FancyLists/Static sample project, 129130

findViewById() method, 135

getView() implementation method, 131132, 135

holder pattern

findViewById() method, 137

getTag() and setTag() method, 137139

holder classes, 137138

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, 139141

getView() implementation, 141

RateListDemo application, 143

TextView, 142

top-rated word, 143

ViewHolder, 142

StaticDemo application, 131

ListView, 280

LogCat tab, DDMS, 42

imageM

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

context, 179180

drop-down menu, 188

finger-friendly buttons, 177

getMenuInfo() method, 185

inflation

item and group elements, 186187

MenuInflater, 187

Menus/Inflation project, 187188

View objects, 185

XML structure, 185186

initAdapter() method, 182

ListView sample, 180182

MENU_ADD/MENU_RESET, 183

MENU_CAP and MENU_REMOVE, 184185

MenusetGroupCheckable() function, 179

MenuDemo sample application, 182183

MenuItem#setCheckable() function, 178

Menus/Menus sample project, 180

onCreateOptionsMenu() function, 178179

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, 422423

user interface, 423424

imageN

Namespace directory tree, Android projects, 32

National Weather Service XML, 391392

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 demo, 6061

Redux sample activity, 61

imageO

onActivityResult() callback and method, 200, 239

onClick() method, 55, 213

OnClickListener, 5455

onConfigurationChanged() approach, 205, 208

OnCreate method, NowRedux demo, 6061

onCreate() method, 194, 213

onCreateContextMenu() method, 179

onCreateOptionsMenu(), 304

onDestroy() method, 194195

onListItemClick() method, 213

onOptionsItemSelected() method, 178179

onPause() method, 195, 235

onPostExecute() method, 220, 228

onPreExecute() method, 220

onProgressUpdate() method, 220

onReceive() method, 234

onRestart() method, 195

onRestoreInstanceState() method, 196198

onResume() method, 195, 235

onRetainNonConfigurationInstance(), 203205, 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

imageP

Paused state, 193

Peer activities, 237238

Permissions require and request

ACCESS_COARSE_LOCATION, 452

ADD_VOICEMAIL, 455

Android developer, 451

AndroidManifest.xml file, 451453

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

PhoneGap, 510, 525

applications, 525526

build tools, 529533

Checklist application, 534

APIs, 536

device properties, 538

deviceready event, 537

Device-Ready event handler, 536

HTML5 application, 534536

onDeviceReady function, 537538

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

security issues, 539540

usage, 528

WebKit browser, 526

Pixel Perfect View, 490491

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

AlertDialog box, 190191

error messages, 189

MessageDemo sample application, 192

Messages/Message, 191

Toasts message, 189190

Preferences

fragments and activity, 351

Backward Compatibility, 354355

headers, 351352

intent elements, 354

nested preference avoidance, 354

older model, 356

StockPreferenceFragment, 352353

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

SimplePrefsDemo, 357359

ProgressBar,message, 216217

Proguard.cfg file, 32

Project context menu, Eclipse, 41

Project Properties window, Eclipse, 42

*.Properties file, 32

publishProgress() method, 220222

imageQ

QVGA screen, 272

Qwerty, 260

imageR

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, 273274, See Containers

Res directory, 3132

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

colors, 255256

configuration options, 258-260

dimensions, 255

directories, 258259

D-pad, 257

drawables, 258

HTC Nexus 1, 257

images, 251252

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

RTL languages, 260261

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, 252253

getXml() method, 252

next() method, 252

R.xml, 252

START_TAG event, 252253

words.xml file, 252

XmlPullParser, 252253

XMLResourceDemo sample application, 254

Resources.getStringArray() method, 256

Rewriting project. See Android activities

RGB values, 255256

Rhodes, 543544

Right-to-left (RTL) languages, 260261

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, 227228

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

imageS

Samples for SDK, 10

Samsung Galaxy Tab, 257

Scala, 548

Scaled pixels (sp), 274

Schrödinger's activity, 193194

Screen rotation, 197

accelerometer, 210

android:configChanges, 210

android:screenOrientation = "landscape", 208209

android:screenOrientation = "portrait", 208209

android:screenOrientation = "sensor", 210211

AndroidManifest.xml file, 208211

behind activity, 211

Bundle, 203

contact picking and viewing

ACTION_PICK Intent, 199200

ACTION_VIEW Intent, 200

RESULT_OK or RESULT_CANCELED, 200

RESULT_OK response, 200

startActivity() method, 199

startActivityForResult() method, 199200

Uri values, 199

destruction philosophy, 197

DIY

onConfigurationChanged() approach, 208

Rotation/RotationThree sample application, 205208

without Android's assistance, 205

fullSensor, 211

getLastNonConfigurationInstance(), 203205

landscape layout, 198199

landscape mode, RotationFour application, 210

onCreate() method, 198

onRetainNonConfigurationInstance(), 203205, 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, 204205

saving state

landscape mode, RotationOne application, 203

onCreate() method, 203

onSaveInstanceState() method, 200202

portrait mode, RotationOne application, 202

restoreMe() method, 202203

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

business rules, 273274

Configuration object, 277

density

adjustment, 278279

FWVGA environment, 278

mobile device LCDs, 278

Motorola DROID, 278

DisplayMetrics class, 277

EU4You

Android Compatibility Library, 292

AndroidManifest.xml file, 281

browser, 292

EU members, 282285

fonts, 287289

HVGA emulator, 285

icons, 289

ListView, 281

QVGA screen, 285286

space, 289291

tweaking, 282

WVGA emulator, 285286

extra screen space, 279

extra-large, 47

large, 47

multiple activities, 280281

normal, 47

physical dimensions, 274

"real" pixels, 274

replace menus with buttons, 280

replace tabs with simple activity, 280

resources and resource sets, 276277

scalable drawables, 274275

small, 47

<supports-screens> element, 47, 275276

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, 123124

Java code, 122123

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, 125126

Selection/Checklist sample project, 117

Selection/List sample project, 114115

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, 118120

setDropDownViewResource() method, 118

setOnItemSelectedListener() method, 118

spinner drop-down list, 120121

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

bindService method, 413414

broadcast intents, 414415

callback/listener object, 414

messenger object, 415

notifications, 416

pendingIntent object, 415

startService method, 412

definition, 409

functions, 409

IntentService class, 410

lifecycle methods

onBind method, 410, 411

onCreate method, 410

onDestroy method, 410

onStartCommand method, 410, 411

onTrimMemory method, 410

Downloader, 417

design, 417

service implementation, 418420

user interface, 420421

Music player, 421

design, 421

service implementation, 422423

user interface, 423424

Web service interface, 424

design, 425

Forecast class, 426

rotation challenge, 425

State management, 433435

unbind service, 435

WeatherBinder class, 427429

WeatherDemo activity, 430433

WeatherListener object, 426

WeatherService class, 429430

Services, Android, 5

setAlphabeticShortcut() method, 178

SetContentView method, 55

SetContentView method, NowRedux demo, 60

setGroupCheckable() method, 178

setIndeterminate() method, 214

setMax() method, 214217

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, 34

Software development kits (SDKs), 507

installing Android SDK, 9

and Add-ons, 912

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

DatabaseHelper class, 370371

flash memory, 377

manager extension, Firefox, 379

OpenHelper, 369, 372

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

Src directory, 3132

StackOverflow, 557, 558

startActivity() method, 200, 238239

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

StrictWrapper, 34546

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

Java code, 248249

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

DIY DRY, 263265

elements, 265

inheritance, 266

ProgressBar, 263

progressBarStyleHorizontal, 267

res/layout/main.xml, 265

widget, 265

Supports-screens element, 47, 281

Switch widget. See Widgets

imageT

TabActivity, 243

TabHost, 243, 244, 280

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

principle, 293, 294

SDK change, 297

vs. Android 2.x screen, 294

vs. Android 3.0, 294

TabView, 24243

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, 221222

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

sample project code, 220221

stages, 220

subclass, 219

Toast, 224

Caveats,228

Handler. See Handlers

main application, 213214

post() methods, 218

ProgressBars, 214

rotation

attach() method, 227

detach() method, 227

doInBackground() method, 228

events flow, 227228

onCreate() method, 228

onPostExecute() method, 228

onRetainNonConfigurationInstance() method, 228

ProgressBar, 225

Rotation/RotationAsync sample project, 22425

RotationAsync Activity, 225227

RotationAsync class, 225

RotationAwareTask, 227

RotationAwareTask class, 225

TextView, 224, 225

runnable, 218

runOnUiThread() method, 218

Titanium Mobile, 548

Tooltip support, ADT add-in, Eclipse, 37

TrueType (TTF) fonts, 483

Tutorials, 557

imageU

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

imageV

Version-based sets, 277

Versions, Android application, 4849

imageW

W3C DOM parser, 391

Web service interface, 424

design, 425

Forecast class, 426

rotation challenge, 425

State management, 433435

unbind service, 435

WeatherBinder class, 427429

WeatherDemo activity, 430433

WeatherListener object, 426

WeatherService class, 429430

WebKit browser, 169, 389

/clock URL, 174

AndroidManifest.xml, 170

BrowserDemo1 sample application, 171

BrowserDemo2 sample application, 172

BrowserDemo3 sample application, 174175

getSettings().setJavaScriptEnabled(true); method, 171

Intent, 173

loadData() method, 171172

loadTime() method, 174

loadUrl() method, 171

onCreate() method, 170

settings, preferences, and options, 175

setWebViewClient() method, 173

shouldOverrideUrlLoading() method, 173

Water navigation, 172173

WebKit/Browser3, revised Java, 174

WebView widget, 169170

WebView, 242

WebView widget, 290

Widgets

accessing identified widgets, 60

attaching to Java code, 59

Basic/Label project, 64

Button, 6465

check box, 68

CheckBoxDemo.java, 69

Java, 68

layout, 68

OnCheckedChangeListener interface, 69

sample application, 6970

color attributes, 76

complex views, 59

creating and attaching widgets to activity, 57

EditText widge, 6668

fleeting images, 65, 66

LabelDemo, 64

padding, 75

radio buttons, 7374

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, 148149

DateFormat formatter, 147

DatePicker and DatePickerDialog, 145

DigitalClock and AnalogClock, 150

DynamicTab application, 158, 159

ExpandableListView, 167

Fancy/Chrono sample project, 146, 147

Fancy/Tab, 153, 154

FlipperDemo application, 162

FlipperDemo2 application, 164

FrameLayout, 153

Gallery, 168

GUI toolkits, 153

Intent, 152

JTabbedPane, 152

layout XML, 157158

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, 148149

TimePicker and TimePickerDialog, 145146

ToggleButton, 168

updateLabel() method, 147

ViewFlipper container, 160161

Views/Chronometer API Demo, Android SDK, 151

Views/SeekBar API Demo, 152

ViewSwitcher, 168

Widgets:, 63

Wi-Fi access, 389

Wikis, 558

Wizards, 3940

imageX, Y, Z

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

NowRedux demo, 6061

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, 252253

getXml() method, 252

layouts, 57

aapt tool, 57

android id attribute, 58, 59

android layout_height attribute, 59

android layout_width attribute, 59

android text attribute, 59

attaching widgets to Java code, 59

Button class, 58, 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

ProgressBar,message, 21617

R.xml, 252

ringtone preference, 358

SimplePrefsDemo, 357359

START_TAG event, 252253

words.xml file, 252

XmlPullParser, 252253

XMLResourceDemo sample application, 254

XML-defined drawables, 275

XmlPullParser, 252, 253

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

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