Which three software platforms dominate the smart phone market?
Apple's iOS, Google's Android, and Microsoft's Windows Phone.
Why is Android relatively easy to port to any hardware platform?
Because the software is written in Java and executed with interpreters, similar to but not the same as the Java Virtual Machine (JVM).
What is the first required tool for Android development, and is the JRE enough?
The Java Development Kit (JDK). Just the Java Runtime Environment (JRE) is not sufficient.
Where are the other tools needed for Android development bundled?
In the Android Software Development Kit (SDK).
How does a servlet run when a Web server receives a request for it?
The servlet engine instantiates the servlet class and calls one of its methods, usually doGet or doPost (servlets act as slaves to the servlet engine).
What is an activity?
A class instance that has an associated view markup file to support user interactions. It manages one page of display. Activities are written in Java; an application includes one or more activities.
What do view files correspond to in a Web application?
To the forms in a Web application. Each activity has an associated view file.
What is an intent, and what is it used for?
A means of communications, both within applications and among applications; an instance of a Java class. Intents are used to start and stop activities, move control among activities, and pass data among activities and applications.
Name three key parts of an Android application.
Activities, views, and intents.
How are Android applications built and how is their Java code run?
As projects — single deployable systems (the simplest includes one or a few activities). The Java code is compiled to an intermediate form and interpreted, but not with a standard JVM.
When does an Android application stop executing?
When either the user starts another application or the operating system stops it because it needs its resources to run other applications that have higher priorities.
By what mechanism does Android control the execution of applications?
A collection of predefined callback methods that are implicitly called when certain events are raised by either system or user actions.
Where are an application's activities placed, and which one is in execution?
On a stack. The activity on top of the stack is the one currently in execution and whose view is displayed.
What does onCreate do, and when is it called for the main activity?
It sets the activity's interface (view), often initializes class-scope variables, and puts the activity in the created state. For the main activity it is called as soon as the user selects the application's icon.
onStart vs onResume.
onStart starts the activity and displays its view (started state); it is called as soon as onCreate finishes. onResume starts execution of the activity's code (resumed state, where the user interacts with the view); it is called as soon as onStart finishes.
Which activity states are transitional, and why?
The created and started states: onStart is called as soon as onCreate finishes, and onResume as soon as onStart finishes, so an activity cannot stay in these states for an extended period of time.
How does an activity leave the paused state, and how does it leave the stopped state (other than being destroyed)?
Paused → resumed when onResume is called on it. Stopped → started when onRestart is called on it.
Activity lifecycle: which callback leads from Resumed to Paused, from Paused to Stopped, and from Stopped to Destroyed?
onPause; onStop; onDestroy.
Activity lifecycle: how visible is an activity in the resumed, paused and stopped states?
Resumed: visible. Paused: partially visible. Stopped: hidden. (Started is also visible.)
Why are Android markup elements called views?
Because Android applications are built as Model-View-Controller (MVC) applications; the elements are all extensions of the View class.
From which class are layout managers (layouts) derived?
From the ViewGroup class.
Name the four layout managers in the Android SDK and how each arranges views.
LinearLayout: a vertical column or a horizontal row. FrameLayout: pins views around its frame. RelativeLayout: positions views relative to other views. GridLayout: a grid.
What is always the first attribute of a layout element, and what does it specify?
xmlns — it specifies the namespace of the elements and attributes used in the layout: http://schemas.android.com/apk/res/android.
What are TextView elements used for, and which four attributes do they usually include?
To define fixed text, often used for labeling other views. Attributes: id, layout_width, layout_height, and text.
In android:id = "@+id/the_name", what do @ and + mean?
@: the XML parser should parse and expand the rest of the string and identify it as a resource id. +: this is a new resource name that must be created and added to the resources (placed in the Android-generated file R.java).
Which method lets Java code refer to a view through its resource id in R.java?
findViewById.
What is EditText, and which attribute places initial text in it?
A subclass of TextView configured to allow its elements to be edited (similar to HTML textboxes and textarea, but more powerful). The hint attribute places initial text in an EditText control.
How is a keyboard shown on an Android device that normally displays no keyboard?
A standard keyboard is displayed by tapping in the text field; this also places the cursor in the text field.
How is the label of an Android button specified?
With the text attribute (e.g., android:text = "@string/button_send").
What is the event for a button click, and how is its handler registered in markup?
The event is Click. In markup, the name of the handler method is assigned to the onClick attribute of the Button element (android:onClick = "the_handler"). Handlers can also be registered in code.
What are the three steps for creating your first Android app?
1. Set up your development environment; 2. Create a new Android project in Eclipse; 3. Run it in the emulator.
What does AVD stand for, and when is it created?
Android virtual device; it is created while setting up the Android environment.
Do you need to restart the emulator for a new version of your application?
No. (The emulator may take a few minutes to start, so be patient.)
In HelloAndroid.java, which call in onCreate sets the activity's layout?
setContentView(R.layout.main), after super.onCreate(savedInstanceState).
In AndroidManifest.xml, which action and category does the HelloAndroid activity's intent-filter declare?
Action android.intent.action.MAIN and category android.intent.category.LAUNCHER.