Jessica’s Android Notes

Much of this information is adapted from the Android Developer’s Guide

App Components

Core Component Purpose
Activities UI screen/dialog
Services a background process w/o a UI
Broadcast Receivers receives and reacts to broadcast messages
Content Provider makes specific data available to other apps

Definitions

An activity presents a visual user interface for one focused endeavor the user can undertake.

A service doesn’t have a visual user interface, but rather runs in the background for an indefinite period of time.

A broadcast receiver is a component that does nothing but receive and react to broadcast announcements.

A content provider makes a specific set of the application’s data available to other applications.

How these compenents are activated

Content providers are activated when they’re targeted by a request from a ContentResolver. The other three components — activities, services, and broadcast receivers — are activated by asynchronous messages called intents.

Intents

An Intent object is passed to Context.startActivity() or Activity.startActivityForResult() to launch an activity or get an existing activity to do something new.

Intents are asynchronous messages.

Intent messaging is a facility for late run-time binding between components in the same or different applications.

Activities

Launching an activity: Intent should be passed to Context.startActivity() or Activity.startActivityForResult().

Activation: Content providers are activated when they’re targeted by a request from a ContentResolver. The other three components — activities, services, and broadcast receivers — are activated by asynchronous messages called intents.

Resources

Layout for an activity
Look in \res\layout\ at the corresponding .xml file
R.java is a generated file representing constants related to layout (generated from the res\layout stuff)

Resources are compiled into the final APK file. Android creates a wrapper class, called R, that you can use to refer to these resources in your code. R contains subclasses named according to the path and file name of the source file

Many resources included with the system are available to applications. All such resources are defined under the class “android.R”

if a resource were named this:
MyApp/res/drawable-port-mdpi/myimage.png
It would be referenced as this:
R.drawable.myimage (code)
@drawable/myimage (XML)