Index

A

accelerometer, 393

accessing

Android Virtual Device Manager, 5

images, 53

action bar, 68-70, 120

ActionBar tabs for Photos and Favorites, 270-272

drop-down navigation, 120-121

fragments, 134-136

tab navigation, 122-124

when to use, 124-125

ACTION_EDIT, 296

ACTION_INSERT, 296

ACTION_INSERT_OR_EDIT, 296

ACTION_PICK, 296

ACTION_SEND, 35-37

ActionBar. See action bar

ActionBarSherlock, 125, 391

actions. See also action bar

animations in, 388-390

coding, 15-17

in loaders, 247

activities. See also intents

back stack, 26-27

CustomCameraActivity.java, 341-345

CustomVideoActivity.java, 345

explained, 19-20

fragment and activity interaction, 136-138

Launch, 27-28

lifecycle, 19, 38-40

passing information between, 28

extras and bundles, 28-30

intents, 37

returning results, 30-33

preference activities, generating, 183

SettingsActivity, creating, 183

starting

back stack, 26-27

Launch activity, 27-28

starting one activity from another, 20-25

starting IntentService from, 386

activity_main.xml file, 45

adapters, 104-105

custom adapters, 253

BaseAdapter, 253-254

custom CursorAdapters, 257

ViewHolder pattern, 255-256

ListCursorAdapter

bindView() method, 264-266, 270

getFlinging() method, 266-267

image loading, 267-269

newView() method, 263

onClick() event handling, 269-270

sync adapters, 285

AdapterViewFlipper, 166-167

Add() method, 130

AddToBackStack() method, 131

ad-supported apps, 409

ADT (Android Developer Tools) bundle

downloading, 3-4

folder structure, 4

alert dialogs, 151-154

creating, 151-152

custom views, 154

lists, 152-153

AlertDialog, 151-154

creating, 151-152

custom views, 154

lists, 152-153

alerts, ProximityAlerts, 311-312

alpha level, 353

alternative resources, 63-64

Amazon, publishing apps on, 408

Android 4.2 folder, 44

Android Beam, 396

Android Compatibility package, 70-71

Android dependencies folder, 44, 46

Android developer documentation, 393

Android Developer Tools bundle. See ADT (Android Developer Tools) bundle

Android Device Chooser, 73

Android history, 59-60

Android Studio, 3

Android versions

action bar, 68-70

fragments, 68-70

strategy for device support, 72

support library, 70-71

table of, 68

Android Virtual Device. See AVD (Android Virtual Device)

Android Virtual Device Manager, accessing, 5

android:configChanges, 66-67

AndroidManifest.xml file, 43

content providers, 231

Facebook apps, 372

intent filters, 35

preparing for release, 400-401

service definitions, 385

animations, adding, 55, 388-390

API Explorer, 190-191

APIs (Application Programming Interfaces), 189

API levels, 68

calendar API, 283-284

Calendar Content Provider, 285-288

calendar events, listing, 289-292

calendar updates with intents, 293

CalendarContract tables, 284

event data, accessing, 292-293

contacts API, 294-295

contact intents, 296-297

ContactsContract class, 294-295

querying contacts, 295-296

Maps API, 311

remote APIs, 189

background downloads with AsyncTask, 197-200

connectivity, checking, 202

JSON-formatted data, 194-197

lists, displaying in fragments, 200

remote data, fetching, 190-193

in-app payments, 410

Application Programming Interfaces (APIs). See APIs (Application Programming Interfaces)

application resources, referencing, 47-48

apps

ad-supported apps, 409

APIs (Application Programming Interfaces). See APIs (Application Programming Interfaces)

in-app payments, 410

Bluetooth support, 396

camera app, 338

associating camera with SurfaceView, 339-340

CameraPreview class, 338-340

CustomCameraActivity.java, 341-345

CustomVideoActivity.java, 345

displaying previews, 341-343

permissions for capturing media, 338

SurfaceHolder.Callback implementation, 340

development

determining app functionality, 259-263

planning, 262-263

wireframe diagrams, 260-262

Facebook photo upload app

app IDs, 372

app implementation, 374-375

creating, 366-368

Facebook permissions, 373

Facebook requests, 375-376

login and session management, 374

Flickr app. See Flickr app

free apps, 409

internationalization strategies

forgoing app internationalization, 324-325

implementing robust internationalization, 325-326

limiting app internationlization, 325

launching

on devices, 72-74

with intents, 38

monetizing, 409-410

NFC (Near Field Communication), 396

open source

ActionBarSherlock, 391

including in apps, 392

NineOldAndroids, 390-391

Picasso, 391-392

ViewPageIndicator, 391

OpenGL ES graphics API, 395

paid apps, 409

preparing for release, 399

Android manifest file, 400-401

signing apps, 401-405

projects

creating, 6-8, 21

files at project creation, 43-45

folders at project creation, 43-45

publishing, 405

on Amazon, 408

on Google Play, 405-408

OUYA and other markets, 409

responsive apps with IntentService, 383-388

reviewing in multiple languages, 322

running, 11-12

sensors, 393

signing, 401-405

certificate file export, 404-405

with command-line tools, 403-404

with Eclipse, 402

package testing, 405

source code, viewing, 10-11

speech to text conversion, 395

styles, 394-395

text to speech (TTS) conversion, 395

themes, 394-395

user interface. See user interface

views. See views

XML layout, 10-11

ArrayAdapter, 104-105

arrays, JSONArrays, 195

assets folder, 44, 56-57

associating camera with SurfaceView, 339-340

AsyncTask class, 108-109, 197-200

AsyncTaskLoader class, 246

attendees (event), returning list of, 292

audio, playing with MediaPlayer, 361

AudioFocus class, 362

AudioManager class, 362

AudioTrack class, 362

AutoCompleteTextView, 106

AVD (Android Virtual Device), creating, 5, 11-12

avoiding OOM (out of memory) exception, 353-355

B

background downloads with AsyncTask, 197-200

BaseAdapter, 253-254

Beam, 396

bin folder, 45

bindView() method, 257, 264-266, 270

Bitmap class, 353-355

BitmapFactory class, 353

BitmapFactoryOptions class, 354-355

Bluetooth support, 396

BroadcastReceiver, 386-388

build dependencies, resolving, 370

bundles, adding to intent, 28-30

Button control, 100-103

buttons, 15-17, 100-103

C

cached images, saving, 222-224

calendar API, 283-284

Calendar Content Provider, 285-288

calendar events, listing, 289-292

calendar updates with intents, 293

CalendarContract tables, 284

event data, accessing, 292-293

Calendar Content Provider, 285-288

calendar events, listing, 289-292

CalendarContract tables, 284

CalendarListFragment, 286

camera app, 338

associating camera with SurfaceView, 339-340

CameraPreview class, 338-340

CustomCameraActivity.java, 341-345

CustomVideoActivity.java, 345

displaying previews, 341-343

permissions for capturing media, 338

SurfaceHolder.Callback implementation, 340

taking pictures, 343-345

CameraPreview class, 338-340, 341-343

cameras, 329. See also media

camera app, 338

associating camera with SurfaceView, 339-340

CameraPreview class, 338-340

CustomCameraActivity.java, 341-345

CustomVideoActivity.java, 345

displaying previews, 341-343

permissions for capturing media, 338

SurfaceHolder.Callback implementation, 340

taking pictures, 343-345

intents

advantages of, 338

taking photos with, 332-336

taking video with, 336-338

launching with intents, 333-334

media capture, 329-330

media scanner, invoking, 331-332

media storage file, specifying, 330-331

URIs (Uniform Resource Identifiers), creating, 331-332

Canvas, drawing on, 356-357

capturing media, 329-330

with intents, 336-338

media scanner, invoking, 331-332

media storage file, specifying, 330-331

photos. See photos

URIs (Uniform Resource Identifiers), creating, 331-332

certificate file, exporting, 404-405

changing

LinearLayout control properties, 85-86

locales, 319

CheckBoxPreference, 175-177

checking connectivity, 202

child views

layouts, 86-88

gravity, 88

layout margins, 87

padding, 86-87

weight, 88

classes. See individual classes

close() method, 208-209

closing dialogs, 144

cloud access. See remote APIs

colors, 50

command-line tools

jarsigner, 403-404

keytool, 403-404

Commit() method, 131

compress() method, 224

connectivity, checking, 202

constants, creating, 30

contact intents, 296-297

ContactListFragment, 296

contacts API, 294-295

contact intents, 296-297

ContactsContract class, 294-295

querying contacts, 295-296

Contacts table, 295

ContactsContract class, 294-295

contains() method, 173

content providers, 227

adding to apps, 236-237

building, 228-235

AndroidManifest.xml file, 231

declarations, 229-230

delete() method, 235

getType() method, 233-234

insert() method, 234-235

query() method, 231-233

shell, 228-229

update() method, 235

requesting files from, 237-242

file support implementation, 238-239

image retrieval, 239-241

Uniform Resource Identifiers (URIs), 227-228

ContentObserver, 241-242

controls

adapters, 104-105

input controls, 98

buttons, 100-103

EditText, 98-100

TextView, 98-100

layout controls, 82-83

FrameLayout, 89

LinearLayout, 84-86

RelativeLayout control, 89-91

spinner control, 105-106

getting data from, 106

setting up, 105

converting

speech to text, 395

text to speech, 395

createBitmap() methods, 356

createLoader() method, 247

createPhoto() method, 209-210

criteria for location providers, 302-303

currencies, handling, 327

Currency class, 327

CursorAdapter

with CursorLoader class, 248-252

ListCursorAdapter

bindView() method, 264-266, 270

getFlinging() method, 266-267

image loading, 267-269

newView() method, 263

CursorLoader class

CursorAdapter, 248-252

overview, 246

cursors, 212-215

custom adapters, 253

BaseAdapter, 253-254

custom CursorAdapters, 257

ListCursorAdapter

bindView() method, 264-266, 270

getFlinging() method, 266-267

image loading, 267-269

newView() method, 263

onClick() event handling, 269-270

ViewHolder pattern, 255-256

custom buttons, 103

custom view controls, 395

custom views

in alert dialogs, 154

ListFragments, 159-161

CustomCameraActivity.java, 341-345

CustomVideoActivity.java, 345

D

data access

content providers, 227

adding to apps, 236-237

building, 228-230, 235

requesting files from, 237-242

Uniform Resource Identifiers (URIs), 227-228

custom adapters, 253

BaseAdapter, 253-254

custom CursorAdapters, 257

ViewHolder pattern, 255-256

loaders

actions, 247

creating, 247

CursorLoader with CursorAdapter, 248-252

explained, 245

initializing, 247

loader classes, 246

loader states, 246-252

resetting, 248

remote APIs, 189

background downloads with AsyncTask, 197-200

connectivity, checking, 202

JSON-formatted data, 194-197

lists, displaying in fragments, 200

remote data, fetching, 190-193

SQLite databases. See SQLite databases

Data table, 295

data types in SharedPreferences, 173-174

DatabaseHelper class, 207

databases (SQLite). See SQLite databases

date picker dialogs, 146-149

date strings, formatting, 326

DateFormat class, 326

DatePickerDialog, 146-149

declarations for content providers, 229-230

decodeFile() method, 223, 353

decodeResource() method, 353

decodeStream() method, 224, 353

deep linking, 378

default resources, specifying, 321

defining IntentService, 385-386

DelayReceiver, 388

delete() method, 235

deletePhoto() method, 211-212

deleting photos from database, 211-212

density (screen)

density-independent pixels, 61

explained, 60

handling, 61-62

designing layouts, 80

detecting device features, 67

detecting flinging, 266-267

determining

app functionality, 259-263

location, 299-300

criteria for location providers, 302-303

last known location, 303-305

Location object, 302

location settings, 305

LocationManager, 300-301

system locale, 325-326

developer documentation, 393

developing apps

determining app functionality, 259-263

Facebook development, 366

planning, 262-263

wireframe diagrams, 260-262

development of Android, 59-60

devices

display, 60

orientation, 63-67

screen density, 60-62

screen size, 61-63

features, detecting, 67-68

launching apps on, 72-74

platform versions and compatibility levels

action bar, 68-70

fragments, 68-70

strategy for device support, 72

support library, 70-71

table of Android versions, 68

dialogs

alert dialogs, 151-154

creating, 151-152

custom views, 154

lists, 152-153

closing, 144

date picker dialogs, 146-149

displaying, 142-143

explained, 141-142

opening, 144

ProgessDialog, 146

time picker dialogs, 149-150

dimensions, 50-51

dismiss() method, 143

display, 60

orientation

explained, 65

handling, 65

screen density

explained, 60

handling, 61-62

screen size

explained, 61

handling, 61-63

displaying

camera previews, 341-343

dialogs, 142-143

fragments

dynamically, 129-131

with layouts, 128-129

options menus, 114-119

photos

Flickr app, 275-276

ImageViews, 348

displays, external, 396

documentation (Android), 393

doInBackground() method, 198-199, 223

Dom parser, 202

dots-per-inch (DPI), 61

downloading Facebook SDK, 368

DPI (dots-per-inch), 61

drawable resources, 51-52

in buttons, 102

images

accessing, 53

supported image formats, 52

ninepatch, 52

shapes, 53-54

drawable-* folders, 45, 52

drawing on Canvas, 356-357

drop-down navigation, action bar, 120-121

E

Eclipse

Eclipse folder, 4

running projects from, 73-74

signing apps, 402

editing layouts, 81

EditText control, 98-100

EditTextPreference, 179

elements

<include/>, 82

<support-screens>, 63

<uses-feature>, 67

event handling, user gestures, 394

events, calendar events, listing, 289-292

explicit intents, 34

exporting certificate file, 404-405

external display, Presentation class, 396

extras

accessing from intent, 29

adding to intent, 28-29

naming conventions, 30

F

Facebook apps

app IDs, 372

creating, 366-368

Facebook photo upload app

app IDs, 372

app implementation, 374-375

creating, 366-368

Facebook permissions, 373

Facebook requests, 375-376

login and session management, 374

Facebook SDK, 365

deep linking, 378

downloading, 368

explained, 365-366

Facebook development websites, 366

Facebook photo upload app

app IDs, 372

app implementation, 374-375

creating, 366-368

Facebook permissions, 373

Facebook requests, 375-376

login and session management, 374

including in projects, 370-373

installing, 368-370

libraries, creating, 379

overview, 378

fade-in animations, 55

fadein.xml file, 55

favorites, handling, 276-277

Favorites fragment, 270-272

features of devices, detecting, 67-68

fetchFavorites() method, 212

fetching remote data, 190

API calls, 190-191

app structure, 193

HttpUrlConnection, 192-193

files

activity_main.xml, 45

AndroidManifest.xml, 43

AndroidManifest.xml file

content providers, 231

Facebook apps, 372

preparing for release, 400-401

service definitions, 385

certificate file, exporting, 404-405

fadein.xml, 55

Ic_launcher-web.png, 45

image files, saving, 218

cached images, 222-224

retrieving item from Flickr, 221-222

MainActivity.java, 44

media storage file, specifying, 330-331

MP3 audio files, playing with MediaPlayer, 361

Proguard-project.txt, 45

project.properties, 45

requesting from content providers, 237-242

ContentObserver, 241-242

file support implementation, 238-239

image retrieval, 239-241

resource files. See resources

R.java, 44-46

strings.xml, 45

styles.xml, 45

filters (intent), 35

findViewById() method, 81

FiveSecondService.java, 385

flags (intent), 26-27

Flickr app. See also SQLite databases

API Explorer, 190-191

background downloads with AsyncTask, 197-200

content providers

adding, 236-237

building, 228-235

ContentObserver, 241-242

requesting files from, 237-242

Uniform Resource Identifiers (URIs), 227-228

custom adapters, 253

BaseAdapter, 253-254

ViewHolder pattern, 255-256

development

determining app functionality, 259-263

planning, 262-263

wireframe diagrams, 260-262

final app inventory, 277

FlickrPhoto class, 205-206

FlickrPhotoDbAdapter, 206-209

JSON-formatted data, 194-197

ListCursorAdapter

bindView() method, 264-266, 270

getFlinging() method, 266-267

image loading, 267-269

newView() method, 263

onClick() event handling, 269-270

lists, displaying in fragments, 200

loaders

actions, 247

creating, 247

CursorLoader with CursorAdapter, 248-252

explained, 245

initializing, 247

loader classes, 246

loader states, 246-252

resetting, 248

Photo and Favorite photo fragments, 270-272

PhotoGridFragment, 272-275

PhotoListFragment, 272-274

photos

deleting, 211-212

displaying in list or grid, 272-275

displaying single image, 275-276

favorites, 276-277

getting from database, 212-215

image files, saving, 218-224

inserting into database, 209-210, 215-216

retrieving from Flickr, 221-222

titles, displaying, 216-218

updating, 210-211

remote data, fetching, 190-193

retrieving items from, 221-222

FlickrPhoto class, 196-197, 206

FlickrPhotoDbAdapter class, 206-209, 215

FlickrPhotoProvider, 229-230

adding to app, 236-237

building, 228-235

AndroidManifest.xml file, 231

declarations, 229-230

delete() method, 235

getType() method, 233-234

insert() method, 234-235

query() method, 231-233

shell, 228-229

update() method, 235

requesting files from, 237-242

ContentObserver, 241-242

file support implementation, 238-239

image retrieval, 239-241

Uniform Resource Identifiers (URIs), 227-228

flinging, detecting, 266-267

flipping views, 166-167

folders

Android 4.2, 44

Android dependencies folder, 44, 46

assets, 44, 56-57

bin, 45

drawable-*, 45

Eclipse, 4

libs, 44

res, 11, 45

sdk, 4

src, 44

forgoing app internationalization, 324-325

formatting date and time strings, 326

FormControlActivity class, 100

fragments, 68-70

with action bars, 134-136

AdapterViewFlipper, 166-167

CalendarListFragment, 286

ContactListFragment, 296

content providers, adding, 236-237

displaying

dynamically, 129-131

layouts, 128-129

explained, 127-128

fragment and activity interaction, 136-138

galleries, 164-166

grid views, 162-163

ListFragments, 157

creating, 158-159

customizing, 159-161

lists in, 200

navigating between, 132-134

Photo and Favorite photo fragments, 270-272

PhotoGridFragment, 251-252, 272-275

PhotoListFragment, 200, 216-218, 272-274

PreferencesFragment

CheckBoxPreference, 175-177

creating, 174-175

EditTextPreference, 179

ListPreference, 177-179

reading preferences, 182

titles, adding, 180-181

support package, 131

FragmentTransaction object, 130-131

FrameLayout control, 82, 89

free apps, 409

Froyo, 68

G

galleries, 164-166

Gallery widget, 164-166

generating preference activities, 183

geo intent, 309-310

Geocoder class, 306-309

geocoding, 306-309

gestures, 394

getActivity() method, 134

getAll() method, 173

getArguments() method, 138

getBoolean() method, 172

getCacheDir() method, 220

getColor() method, 50

getColumnIndex() method, 214

getConfiguration() method, 326

getContentResolver() method, 277

getCount() method, 253

getDialog() method, 142

getDrawable() method, 53

getExternalFilesDir() method, 220

getExternalStorageDirectory() method, 220

getExternalStoragePublicDirectory() method, 220, 330-331

getFilesDir() method, 220

getFlinging() method, 266-267

getFloat() method, 173

getFromLocation() method, 308

getFromLocationName() method, 307

getInt() method, 173, 214

getItem() method, 253

getItemId() method, 253

getLastKnownLocation() method, 303

getLatitude() method, 307

getLoaderManager() method, 247

getLocality() method, 309

getLong() method, 173

getLongitude() method, 307

getPackageManager() method, 67-68

getPhotoFromCursor() method, 218

getPhotos() method, 197

getProvider() method, 302-303

getRecentLocation() method, 304

getResources() method, 47-48

getSelectedItem() method, 106

getSelectedItemPosition() method, 106

getSharedPreferences() method, 171-172

getString() method, 173, 214

getStringSet() method, 173

getSupportFragmentManager() method, 131

getSystem() method, 48

getText() method, 99, 102

getTime() method, 304

getType() method, 233-234

getView() method, 253, 255-256

getWriteableDatabase() method, 208-209

Gingerbread, 68

global positioning system. See GPS (global positioning system)

Google Play, publishing apps to, 405-408

Google Play services, 312-315

Google Street View support, 310

Google TV, 60

GPS (global positioning system), 299. See also location-based services

determining location

criteria for location providers, 302-303

last known location, 303-305

Location object, 302

location settings, 305

LocationManager, 300-301

geo intent, 309-310

geocoding, 306-309

Google Play services, 312-315

Maps API, 311

ProximityAlerts, 311-312

gradients, 53-54

graphics

OpenGL ES graphics API, 395

photos. See photos

gravity, 88

grid views, 162-163, 272-275

Groups table, 295

Gson, 196

H

hiding images from media scanner, 331

hint property (EditText control), 98

hints, showing in EditText view, 98

history of Android, 59-60

Honeycomb, 68

HorizontalScrollView, 168

HTC Dream phone, 59

HttpUrlConnection, 192-193

I

Ic_launcher-web.png file, 45

Ice Cream Sandwich, 68

icons, adding to menu items, 117

IDs (app), 372

image files, saving, 218

cached images, 222-224

retrieving item from Flickr, 221-222

ImageButton control, 100-103

images

accessing, 53

Bitmap class, 353-355

Canvas, drawing on, 356-357

image files, saving, 218

cached images, 222-224

retrieving item from Flickr, 221-222

ImageViews, 110, 347

alpha level, 353

displaying images, 348

rotating images, 351-352

ScaleTypes in, 348-351

photos. See photos

supported image formats, 52

ImageViews, 110, 347

alpha level, 353

displaying images, 348

rotating images, 351-352

ScaleTypes in, 348-351

implicit intents, 34-37

<include/> element, 82

initializing loaders, 247

initLoader() method, 247

inJustDecodeBounds option (BitmapFactoryOptions), 354

input controls, 98

buttons, 100-103

EditText, 98-100

TextView, 98-100

inputStreamToString() method, 56

inputType property (EditText control), 99

inSampleSize option (BitmapFactoryOptions), 354

insert() method, 234-235

installing Facebook SDK, 368-370

IntelliJ, 3

intents

ACTION_SEND intent, handling, 35-37

advantages of, 338

bundles, adding, 28-30

contact intents, 296-297

creating, 22

explained, 34-37

explicit intents, 34

extras

accessing, 29

adding, 28-29

naming conventions, 30

geo intent, 309-310

implicit intents, 34-37

intent filters, 35

intent flags, 26-27

launching apps with, 38

launching cameras with, 333-334

passing information with, 37

taking photos with, 332-336

taking video with, 336-338

updating calendar with, 293

IntentService

BroadcastReceiver, 386-388

defining, 385-386

explained, 383-384

starting from activity, 386

interfaces

onDateEnteredListener, 149

onNavigationListener, 120-121

internationalization, 323-324. See also localization

principles, 317-318

strategies

forgoing app internationalization, 324-325

implementing robust internationalization, 325-326

limiting app internationlization, 325

isFavorite value, 276-277

isOnline() method, 202

J

jarsigner, 403-404

Java code, viewing, 10-11

Jelly Bean, 68

JSONArrays, 195

JSON-formatted data, 194

JSONArrays, 195

JSONObjects, 194

JsonReader, 195

parsing, 196-197

JSONObjects, 194

JsonReader, 195

K

keytool, 403-404

Kindle Fire, 60, 72

L

language-specific resources, specifying, 321

large images, handling, 353-355

last known location, determining, 303-305

Launch activity, 27-28

launching

apps, 11-12

on devices, 72-74

with intents, 38

cameras with intents, 333-334

Layout Resource Editor, 80

layout_gravity property, 88

layout_weight property, 88

layouts

child views, 86-88

gravity, 88

layout margins, 87

padding, 86-87

weight, 88

designing, 80

editing, 81

explained, 79-80

for fragments, 128-129

FrameLayout control, 82, 89

Layout Resource Editor, 80

LinearLayout control, 82-84

changing properties of, 85-86

common attributes, 84

RelativeLayout control, 82, 89-91

TableLayout control, 82

using programmatically, 81

VideoViews, 357

libraries

ActionBarSherlock, 391

creating, 379

Facebook SDK. See Facebook SDK

Gson, 196

support library, 70-71, 131

ViewPageIndicator, 391

libs folder, 44

lifecycle

of activities, 19, 38-40

of services, 383

light sensor, 393

limiting app internationlization, 325

LinearLayout control, 82-84

changing properties of, 85-86

common attributes, 84

links, deep linking, 378

ListCursorAdapter

bindView() method, 264-266, 270

getFlinging() method, 266-267

image loading, 267-269

newView() method, 263

onClick() event handling, 269-270

ListFragments, 157

creating, 158-159

customizing, 159-161

PhotoListFragment, 200, 216-218, 236-237

listing calendar events, 289-292

ListPreference, 177-179

lists

in alert dialogs, 152-153

CalendarListFragment, 286

ContactListFragment, 296

displaying in fragments, 200

ListFragments, 157

creating, 158-159

customizing, 159-161

PhotoListFragment, 200, 216-218

Loader class, 246

LoaderManager class, 246

LoaderManagerCallbacks class, 246

loaders

actions, 247

creating, 247

CursorLoader with CursorAdapter, 248-252

explained, 245

initializing, 247

loader classes, 246

loader states, 246-252

resetting, 248

LoadImage() method, 222

loading

images, 267-269

video, 358

locales

changing, 319

default resources, 321

determining system locale, 325-326

explained, 317

handling, 317-320

localization, 317

Android support for, 318

currencies, handling, 327

date and time string formatting, 326

general internationalization principles, 317-318

internationalization strategies, 323-324

forgoing app internationalization, 324-325

implementing robust internationalization, 325-326

limiting app internationlization, 325

language-specific resources, specifying, 321

locales

changing, 319

default resources, 321

determining system locale, 326

explained, 317

handling, 317-320

region-specific resources, specifying, 322

reviewing apps in multiple languages, 322

Location object, 302

location providers, criteria for, 302-303

location settings, 305

location-based services, 299

determining location, 299-300

criteria for location providers, 302-303

last known location, 303-305

Location object, 302

location settings, 305

LocationManager, 300-301

geo intent, 309-310

geocoding, 306-309

Google Play services, 312-315

Maps API, 311

ProximityAlerts, 311-312

LocationManager, 300-301

logcat, monitoring, 12

login management (Facebook apps), 374

M

magnetic field sensor, 393

MainActivity.java file, 44

makePhotoList() method, 197

Manifest file

content providers, 231

Facebook apps, 372

intent filters, 35

preparing for release, 400-401

service definitions, 385

Maps API, 311

margins, child views, 87

Matrix class, 351-352

media, 347. See also cameras

Android classes, 362

audio, playing with MediaPlayer, 361

Bitmap class, 353-355

Canvas, drawing on, 356-357

capturing, 329-330

with intents, 336-338

media scanner, invoking, 331-332

media storage file, specifying, 330-331

URIs (Uniform Resource Identifiers), creating, 331-332

ImageViews, 347

alpha level, 353

displaying images, 348

rotating images, 351-352

ScaleTypes in, 348-351

MediaController, 359

photos. See photos

VideoViews

layout, 357

listeners, 358-359

loading video, 358

showing video, 358-359

starting, pausing, and positioning video, 358

media scanner, invoking, 331-332

media storage file, specifying, 330-331

MediaController, 359

MediaPlayer, 361-362

MediaStore, 329

menus, options menus, 113

adding icons to, 117

displaying, 114-119

responding to, 119-120

when to use, 124-125

methods. See individual methods

Miracast, 396

monetizing apps, 409-410

monitoring logcat, 12

moveToFirst() method, 214

moveToLast() method, 214

moveToNext() method, 214

moveToPosition() method, 214

moveToPrevious() method, 214

MP3 audio files, playing with MediaPlayer, 361

N

naming conventions

extras, 30

packages, 7

navigation

action bar

drop-down navigation, 120-121

tab navigation, 122-124

when to use, 124-125

buttons, 15-17, 100-103

fragments

action bars, 134-136

navigating between fragments, 132-134

options menus, 113

displaying, 114-119

responding to, 119-120

when to use, 124-125

paging controls, 167-168

Near Field Communication (NFC), 396

newView() method, 257, 263

NFC (Near Field Communication), 396

NineOldAndroids, 390-391

ninepatch, 52

notifyChange() method, 219

O

ObjectAnimator, 388-390

ODK (OUYA Developer Kit), 409

onActivityCreated() method, 163, 236-237, 240-241, 290

onActivityResult() method, 332, 335-336, 337-338

onAnswerSelected() method, 138

onAnswerSelectedListener() method, 136-137

onAttach() method, 137-138

onClick() method, 17

onClickListener() method, 17, 336-337

onCompletionListener() method, 358-359

onConfigurationChanged() method, 66-67

onCreate() method, 10, 24-25, 39-40, 207, 293

onCreateDialog() method, 142, 150, 154

onCreateLoader() method, 246, 272, 275, 287, 291

onCreateOptionsMenu() method, 10, 114-119

onCreateView() method, 159-167

onDateEnteredListener interface, 149

onDateSet() method, 146-149

onDestroy() method, 40, 218

onDoubleTap, 394

onDoubleTapEvent, 394

onDown, 394

onFling, 394

onHandleIntent() method, 383

onListItemClick() method, 159, 218, 288

onLoaderReset() method, 246, 248, 287

onLoadFinished() method, 246, 247, 275, 287

onLocationChanged() method, 300-301, 308

onLongPress, 394

onNavigationListener interface, 120-121

onOptionsItemsSelected() method, 119-120

onPause() method, 39-40, 361, 387

onPostExecute() method, 199-200

onPreparedListener() method, 358-359

onResume() method, 39-40, 361, 387

onScroll, 394

onSessionStateChanged() method, 374

onShowPress, 394

onSingleTapConfirmed, 394

onSingleTapUp, 394

onStart() method, 39-41

onStop() method, 39-41

onUpgrade() method, 207

OOM (out of memory) exception, avoiding, 353-355

open() method, 208-209

open source

ActionBarSherlock, 391

in apps, 392

NineOldAndroids, 390-391

Picasso, 391-392

ViewPageIndicator, 391

openFile() method, 238

openFileInput() method, 219

OpenGL ES graphics API, 395

opening dialogs, 144

openRawResource() method, 56

options menus, 113

adding icons to, 117

displaying, 114-119

responding to, 119-120

when to use, 124-125

orientation, handling, 65-67

android:configChanges, 66-67

retaining data across configuration changes, 66

orientation sensor, 393

out of memory (OOM) exception, avoiding, 353-355

outHeight option (BitmapFactoryOptions), 354

outWidth option (BitmapFactoryOptions), 354

OUYA Developer Kit (ODK), 409

P

PackageManager class, 67-68

packages

Android Compatibility, 70-71

names, 7

testing, 405

padding child views, 86-87

paging controls, 167-168

paid apps, 409

ParcelFileDescriptor, 239

parsing JSON-formatted data, 196-197

passing information between activities, 28

extras and bundles, 28-30

intents, 37

returning results, 30-33

pausing video, 358

permissions (Facebook), 373

permissions for capturing media, 338

personalizing

actions, 15-17

user interface, 13-14

PhoneLookups table, 295

PhotoContentObserver, 241-242

photoDbAdapter variable, 215

PhotoGridFragment, 251-252, 272-275

PhotoListFragment, 200, 216-218, 236-237, 272-274

photos

ActionBar tabs for Photos and Favorites, 270-272

alpha level, 353

deleting, 211-212

displaying

ImageViews, 348

in list or grid, 272-275

photo titles from database, 216-218

single image, 275-276

Facebook photo upload app

app implementation, 374-375

Facebook permissions, 373

Facebook requests, 375-376

login and session management, 374

favorites, 276-277

getting from database, 212-215

image files, saving, 218

cached images, 222-224

retrieving item from Flickr, 221-222

inserting into database, 209-210, 215-216

loading with ListCursorAdapter, 267-269

retrieving from Flickr, 221-222

retrieving from FlickrPhotoProvider, 239-241

rotating, 351-352

taking, with camera app, 343-345

taking with intents, 332-336

titles, displaying, 216-218

updating in database, 210-211

Photos fragment, 270-272

Picasso, 391-392

PictureCallback() method, 344

PieAdapter, 253-254

planning apps, 262-263

platform tools, 5

platform versions and compatibility levels

action bar, 68-70

fragments, 68-70

strategy for device support, 72

support library, 70-71

table of Android versions, 68

playing audio with MediaPlayer, 361

positioning video, 358

postPhoto() method, 375-376

preference activities, generating, 183

preferences, 171

SharedPreferences, 171

data types, 173-174

methods, 173-174

reading from, 172-173

setting preferences, 171-172

user preferences, 174

CheckBoxPreference, 175-177

EditTextPreference, 179

ListPreference, 177-179

preference activities, 183

PreferencesFragment, creating, 174-175

reading, 182

titles, adding, 180-181

PreferencesFragment

CheckBoxPreference, 175-177

creating, 174-175

EditTextPreference, 179

ListPreference, 177-179

reading preferences, 182

titles, adding, 180-181

preparing for release, 399

Android manifest file, 400-401

signing apps, 401-405

certificate file export, 404-405

with command-line tools, 403-404

with Eclipse, 402

package testing, 405

Presentation class, 362, 396

previews, displaying (camera), 341-343

ProgessDialog, 146

progress bars, 107, 109-110

ProgressBars, 107, 109-110

Proguard-project.txt file, 45

project.properties file, 45

projects

Android dependencies folder, 46

creating, 6-8, 21

files

files at project creation, 43-45

R.java, 44-46

folders at project creation, 43-45

resources, 47

advantages of, 47

alternative resources, 63-64

animations, 55

application resources, referencing, 47-48

colors, 50

dimensions, 50-51

images, 52-53

ninepatch, 52

raw resource files, 56

shapes, 53-54

storing in assets folder, 56-57

strings, 49

styles, 55-56

system resources, referencing, 48

running from Eclipse, 73-74

proximity sensor, 393

ProximityAlerts, 311-312

publishing apps, 405

on Amazon, 408

on Google Play, 405-408

OUYA and other markets, 409

putExtra() method, 37, 293, 387

Q

query() method, 231-233

querying

contacts, 295-296

database data, 212-215

R

raw resource files, 56

RawContacts table, 295

reading

SharedPreferences, 172-173

user preferences, 182

RECORD_AUDIO permission, 338

rectangles, 53-54

recurring event definitions, 291

referencing

application resources, 47-48

system resources, 48

region-specific resources, specifying, 322

registerOnSharedPreferenceChangeListener() method, 174

registerReceiver() method, 388

RelativeLayout control, 82-83, 89-91

release, preparing apps for, 399

Android manifest file, 400-401

signing apps, 401-405

certificate file export, 404-405

with command-line tools, 403-404

with Eclipse, 402

package testing, 405

remote APIs, 189

background downloads with AsyncTask, 197-200

connectivity, checking, 202

JSON-formatted data, 194

JSONArrays, 195

JSONObjects, 194

JsonReader, 195

parsing, 196-197

lists, displaying in fragments, 200

remote data, fetching, 190

API calls, 190-191

app structure, 193

HttpUrlConnection, 192-193

remote data, fetching, 190

API calls, 190-191

app structure, 193

HttpUrlConnection, 192-193

Remove() method, 130

removeUpdates() method, 305

Replace() method, 130

requesting files from content providers, 237-242

ContentObserver, 241-242

file support implementation, 238-239

image retrieval, 239-241

requestLocationUpdates() method, 305

requests (Facebook), 375-376

res folder, 11, 45

reset() method, 361

resetting loaders, 248

resolving build dependencies, 370

resources, 11, 47

advantages of, 47

alternative resources, 63-64

animations, adding, 55

application resources, referencing, 47-48

in buttons, 102

colors, 50

default resources, specifying, 321

dimensions, 50-51

images

accessing, 53

supported image formats, 52

language-specific resources, specifying, 321

ninepatch, 52

raw resource files, 56

region-specific resources, specifying, 322

shapes, 53-54

storing in assets folder, 56-57

strings, 49

styles, 55-56

system resources, referencing, 48

results, returning, 30-33

RetrieveImage() method, 239-240

retrieving item from Flickr, 221-222

returning results, 30-33

reverse-geocoding, 308-309

reviewing apps in multiple languages, 322

R.java file, 44-46

robust internationalization, 325-326

rotating images, 351-352

Run Configurations screen, 74

running. See launching

S

saving image files, 218

cached images, 222-224

retrieving item from Flickr, 221-222

SAX parser, 202

ScaleTypes, 348-351

screen density

explained, 60

handling, 61-62

screen size

explained, 61

handling, 61-63

alternative resources, 63-64

<support-screens> element, 63

scrolling controls, 167-168

sdk folder, 4

SeekBars, 107, 110

sendBroadcast() method, 331, 386-388

sensors, 393

services

explained, 383

Google Play services, 312-315

IntentService

BroadcastReceiver, 386-388

defining, 385-386

explained, 383-384

starting from activity, 386

lifecycle, 383

location-based services, 299

determining location, 299-305

geocoding, 306-309

translation services, 322

session management (Facebook apps), 374

setCompoundDrawablesWithIntrinsicBounds() method, 102

setContentView() method, 46, 81

setData() method, 331

setImageAlpha() method, 353

setImageBitmap() method, 348

setImageDrawable() method, 348

setImageResource() method, 348

setImageUri() method, 348

setItems() method, 153

setMessage() method, 153

setOutputFile() method, 345

setScaleType() method, 351

setText() method, 102

setting preferences, SharedPreferences, 171-172

SettingsActivity, creating, 183

setTitle() method, 153

SetTransition() method, 131

ShapeDrawable class, 53-54

shapes, 53-54

SharedPreferences, 171

data types, 173-174

methods, 173-174

reading from, 172-173

setting preferences, 171-172

shootVideoButton, 336-337

show() method, 144

showAsAction attribute (onCreateOptionsMenu() method), 115-116

showFragmentA() method, 132-134

showFragmentB() method, 132-134

showGrid() method, 273

showing video, 358-359

showList() method, 200, 271, 273

signing apps, 401-405

certificate file export, 404-405

with command-line tools, 403-404

package testing, 405

simple resources

colors, 50

dimensions, 50-51

strings, 49

SimpleDateFormat() method, 331

size of screen

explained, 61

handling, 61-63

SoundPool class, 362

source code, viewing, 10-11

specifying

default resources, 321

language-specific resources, 321

media storage file, 330-331

region-specific resources, 322

speech to text conversion, 395

spinner control, 105-106

getting data from, 106

setting up, 105

SQLite databases, 205

adding to apps, 215-218

cursors, 212-215

PhotoListFragment, 216-218

photos

deleting, 211-212

image files, saving, 218-224

inserting, 209-210, 215-216

querying, 212-215

updating, 210-211

SQLiteOpenHelper, 206-209

tables, 205-206

SQLiteOpenHelper, 206-209

src folder, 44

StartActivityForResult() method, 30-33, 332, 375

starting

activities

back stack, 26-27

Launch activity, 27-28

starting one activity from another, 20-25

IntentService, 386

video, 358

startService() method, 386

states, loader states, 246-252

StatusUpdates table, 295

strings

data and time string formatting, 326

explained, 49

strings.xml file, 45

styles, 55-56, 394-395

styles.xml file, 45

support library, 70-71, 131

<support-screens> element, 63

surfaceChanged() method, 340

surfaceCreated() method, 340

surfaceDestroyed() method, 340

SurfaceHolder.Callback implementation, 340

SurfaceView, associating camera with, 339-340

swapCursor() method, 247, 287

sync adapters, 285

system locale, determining, 325-326

system resources, referencing, 48

T

tab navigation, action bar, 122-124

TableLayout control, 82

tables, 205-206

CalendarContract tables, 284

ContactsContract tables, 295

TabListener() method, 122-124

takePhotoButton, 333-334

takePicture() method, 343-345

taking photos

with camera app, 343-345

with intents, 332-336

taking video. See capturing media

temperature sensor, 393

testing packages, 405

text to speech (TTS) conversion, 395

TextView control, 98-100

themes, 394-395

time picker dialogs, 149-150

time strings, formatting, 326

TimePickerDialog, 149-150

titles, adding to user preferences, 180-181

translation services, 322

T-Store, 409

U

UiLifecycleHelper, 374

Uniform Resource Identifiers (URIs), 227-228, 331-332

unregisterOnSharedPreferenceChangeListener() method, 174

unregisterReceiver() method, 388

update() method, 235

updatePhoto() method, 210-211

updating

calendar with intents, 293

photos, 210-211

user interface, 13-14

uploads, Facebook photo upload app

app implementation, 374-375

Facebook permissions, 373

Facebook requests, 375-376

login and session management, 374

Uri.fromFile() method, 331

URIs (Uniform Resource Identifiers), 227-228, 331-332

Uri.withAppendedPath() method, 275

user gestures, 394

user interface. See also views

action bar, 120

drop-down navigation, 120-121

tab navigation, 122-124

when to use, 124-125

adapters, 104-105

AsyncTask class, 108-109

AutoCompleteTextView, 106

demo app, setting up, 95-97

dialogs

alert dialogs, 151-154

closing, 144

date picker dialogs, 146-149

displaying, 142-143

explained, 141-142

opening, 144

ProgessDialog, 146

time picker dialogs, 149-150

fragments

with action bars, 134-136

AdapterViewFlipper, 166-167

displaying dynamically, 129-131

displaying with layouts, 128-129

explained, 127-128

fragment and activity interaction, 136-138

galleries, 164-166

grid views, 162-163

ListFragments, 157-161

navigating between, 132-134

support package, 131

Hour1App, 13-14

ImageViews, 110

input controls, 98

buttons, 100-103

EditText, 98-100

TextView, 98-100

layouts

child views, 86-88

designing, 80

editing, 81

explained, 79-80

for fragments, 128-129

FrameLayout control, 82, 89

Layout Resource Editor, 80

LinearLayout control, 82-84

RelativeLayout control, 82, 89-91

TableLayout control, 82

using programmatically, 81

ListFragments

creating, 158-159

customizing, 159-161

options menus, 113

adding icons to, 117

displaying, 114-119

responding to, 119-120

when to use, 124-125

paging controls, 167-168

ProgressBars, 107, 109-110

SeekBars, 107, 110

spinner control, 105-106

getting data from, 106

setting up, 105

user gestures, 394

user preferences, 174

CheckBoxPreference, 175-177

EditTextPreference, 179

ListPreference, 177-179

preference activities, 183

PreferencesFragment, creating, 174-175

reading, 182

titles, adding, 180-181

<uses-feature>, 401

<uses-feature> element, 67

V

versions of Android

action bar, 68-70

fragments, 68-70

strategy for device support, 72

support library, 70-71

table of, 68

video

capturing with intents, 336-338

CustomVideoActivity.java, 345

loading, 358

showing, 358-359

starting, pausing, and positioning, 358

VideoViews

layout, 357

listeners, 358-359

loading video, 358

showing video, 358-359

starting, pausing, and positioning video, 358

ViewFlipper, 168

ViewGroup controls, customizing, 395

ViewHolder pattern, 255-256

viewing source code, 10-11

ViewPageIndicator, 391

ViewPager, 168

ViewPropertyAnimator, 388-390

views

AdapterViewFlipper, 166-167

AutoCompleteTextView, 106

child views, 86-88

custom view controls, 395

custom views in alert dialogs, 154

flipping, 166-167

grid views, 162-163

HorizontalScrollView, 168

ImageView, 110

ImageViews, 347

alpha level, 353

displaying images, 348

rotating images, 351-352

ScaleTypes in, 348-351

starting, pausing, and positioning video, 358

styles, 55-56

SurfaceView, associating camera with, 339-340

VideoViews

layout, 357

listeners, 358-359

loading video, 358

showing video, 358-359

ViewFlipper, 168

ViewPager, 168

ViewPropertyAnimator, 388-390

virtual devices. See AVD (Android Virtual Device)

visual editor, 97

W-X-Y-Z

weight (child views), 88

Wharton, Jake, 391

wireframe diagrams, 260-262

WRITE_EXTERNAL_STORAGE permission, 338

XML layout, 10-11

XMLPullParser, 202

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

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