Jessica's Android Notes

Basics & Paradigms

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

Core Component Purpose
Activities UI screen/dialog
Services a background process w/o a UI
Broadcast Receivers receives and reacts to broadcast messages

Each of these components are activated through messages called intents (allows late binding at runtime between components and applications).

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

content provider - makes specific data from an app available to other apps.

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.

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)

Three of the core components of an application — activities, services, and broadcast receivers — are activated through messages, called intents. Intent messaging is a facility for late run-time binding between components in the same or different applications.

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

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.

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.