• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/23

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

23 Cards in this Set

  • Front
  • Back

Three possible states of an activity in its lifecycle

running, paused, stopped

Methods that handle transitions and notify Activity of changes in its state

onCreate(Bundle savedInstanceState)


onStart()


onResume()


onPause()


onStop()


onDestroy()

Do you ever call onCreate or any Activity lifecycle methods yourself?

No. You override them, and then Android will call them at the appropriate times

What class sends log messages to a shared system-level log? What method will we use most often to log messages?

android.util.Log




public static int d(String tag, String msg)


//d stands for "debug" --> refers to level of the log message

public static int d(String tag, String msg);




describe the tag parameter and msg parameter (what they do, how to use them)

TAG: TAG constant with classname as its value. Add private static final String TAG = "ClassName" to java file for class, and then override transition methods to add to log with a message

Launching an app does what to an activity?

creates, starts, and resumes

Pressing the back button does what to an activity?

pauses, stops, destroys




(tells Android you're exiting and not coming back)

Pressing the home button does what to an activity?

pauses, stops but tries not to destroy


(tells Android you're leaving but might come back. If the system needs more memory, it will be destroyed)

Pressing the recent button after leaving does what to an activity?

resumes and starts but does not create (as long as it wasn't destroyed)

What states does the app transition through when you rotate a device?

all of them. the old activity is paused, stopped, and destroyed, and a new one is created, started, and resumed

device configuration

set of characteristics that describes the current state of an individual device. includes screen orientation, screen density, screen size, keyboard type, dock mode, language, etc.

What do applications typically do to match different device configurations?

provide alternate resources. app will choose the appropriate resource. some resources can change at runtime (orientation) while others cannot (screen density)

How do you create a landscape layout and a regular layout so that the app can choose based on orientation?

create a new layout folder for orientation. copy the original xml file into the new layout folder, making sure it has the same name so it can be referenced with the same id, and make any necessary changes

the -land suffix is an example of a

configuration qualifier

frame layout and gravity

frame layout is the simplest layout. child views are arranged according to their gravity

What does android do to activities whenever a runtime configuration change occurs?

destroys the current activity and creates a new one

How can you save data across a runtime configuration change?

1. Add a constant in the activity class that will be the key for the key-value pair in the bundle


2. Override onSaveInstanceState(Bundle) to write the value along with its key


3. in onCreate(Bundle), check whether savedInstanceState is null. If not, then get the saved value

What types can you save to and restore from a bundle?

primitives


objects that implement serializable

What happens when your activity is stashed?

The activity was in the paused or stopped state. It no longer exists because Android needed more memory, but the activity record was saved in the OS

When are activity records discarded?

When the user presses the "back" button, on reboot, when it hasn't been used for a long time

If you are overriding onSaveInstanceState(Bundle), how do you test on an emulator that the activity is being saved and restored as expected?

Use the back button, or go to Settings > check "Don't keep activities"

Five different log levels, each of which has a different priority

error: Log.e


warning: Log.w


info: Log.i


debug: Log.d


verbose: Log.v



What does this code do?




try {


question = mAnswerKey[mCurrentIndex];


} catch (ArrayIndexOutOfBoundsException ex) {


Log.e(TAG, "Index was out of bounds", ex);


}

Logs a message at "error" log level, along with an exception stack trace