summaryrefslogtreecommitdiffstats
path: root/docs/html/guide/topics
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commit54b6cfa9a9e5b861a9930af873580d6dc20f773c (patch)
tree35051494d2af230dce54d6b31c6af8fc24091316 /docs/html/guide/topics
downloadframeworks_base-54b6cfa9a9e5b861a9930af873580d6dc20f773c.zip
frameworks_base-54b6cfa9a9e5b861a9930af873580d6dc20f773c.tar.gz
frameworks_base-54b6cfa9a9e5b861a9930af873580d6dc20f773c.tar.bz2
Initial Contribution
Diffstat (limited to 'docs/html/guide/topics')
-rw-r--r--docs/html/guide/topics/data/contentproviders.jd608
-rw-r--r--docs/html/guide/topics/data/data-storage.jd166
-rw-r--r--docs/html/guide/topics/drawing/opengl.jd53
-rw-r--r--docs/html/guide/topics/geo/lbs.jd73
-rw-r--r--docs/html/guide/topics/geo/mapkey.jd28
-rw-r--r--docs/html/guide/topics/index.html8
-rw-r--r--docs/html/guide/topics/intents/intents-filters.jd459
-rw-r--r--docs/html/guide/topics/manifest/manifest.jd183
-rw-r--r--docs/html/guide/topics/media/media.jd171
-rw-r--r--docs/html/guide/topics/processes/process-lifecycle.jd120
-rw-r--r--docs/html/guide/topics/providers/content-providers.jd847
-rw-r--r--docs/html/guide/topics/resources/available-resources.jd1211
-rwxr-xr-xdocs/html/guide/topics/resources/resources-i18n.jd699
-rw-r--r--docs/html/guide/topics/security/security.jd394
-rw-r--r--docs/html/guide/topics/views/binding.jd80
-rw-r--r--docs/html/guide/topics/views/custom-views.jd440
-rw-r--r--docs/html/guide/topics/views/hierarchy.jd47
-rw-r--r--docs/html/guide/topics/views/index.jd45
-rw-r--r--docs/html/guide/topics/views/layout.jd188
-rw-r--r--docs/html/guide/topics/views/themes.jd88
-rw-r--r--docs/html/guide/topics/views/ui-events.jd31
-rw-r--r--docs/html/guide/topics/views/ui-xml.jd131
22 files changed, 6070 insertions, 0 deletions
diff --git a/docs/html/guide/topics/data/contentproviders.jd b/docs/html/guide/topics/data/contentproviders.jd
new file mode 100644
index 0000000..343ed84
--- /dev/null
+++ b/docs/html/guide/topics/data/contentproviders.jd
@@ -0,0 +1,608 @@
+page.title=Accessing Content Providers
+@jd:body
+
+<p>If you want to make your data public, you can create (or call) a content
+provider. This is an object that can store and retrieve data accessible by all
+applications. This is the only way to share data across packages; there is no
+common storage area that all packages can share. Android ships with a number
+of content providers for common data types (audio, video, images, personal
+contact information, and so on). You can see some of
+Android's native content providers in the {@link android.provider provider} package.</p>
+
+<p>How a content provider actually stores its data under the covers is up to
+the implementation of the content provider, but all content providers must
+implement a common convention to query for data, and a common convention to
+return results. However, a content provider can implement custom helper
+functions to make data storage/retrieval simpler for the specific data that it
+exposes.</p>
+
+<p>This document covers two topics related to Content Providers:</p>
+<ul>
+ <li><a href="#usingacp">Using a Content Provider</a></li>
+ <li><a href="#creatingacontentprovider">Creating a Content Provider</a></li>
+</ul>
+
+<h2>Using a Content Provider to Store and Retrieve Data <a name="usingacp"
+id="usingacp"></a></h2>
+
+<p>This section describes how to store and retrieve data using a content
+provider implemented by you or anyone else. Android exposes a number of
+content providers for a wide range of data types, from music and image files
+to phone numbers. You can see a list of content providers exposed through the
+convenience classes in the {@link android.provider android.provider} package.</p>
+
+<p>Android's content providers are loosely linked to their clients. Each
+content provider exposes a unique string (a URI) identifying the type of data
+that it will handle, and the client must use that string to store or retrieve
+data of that type. We'll explain this more in <a href="#querying">Querying for
+Data</a>.</p>
+
+<p>This section describes the following activities:</p>
+
+<ul>
+ <li>
+ <a href="#querying">Querying for Data</a>
+
+ <ul>
+ <li>Making the query</li>
+
+ <li>What the query returns</li>
+
+ <li>Querying for files</li>
+
+ <li>Reading retrieved data</li>
+ </ul>
+ </li>
+
+ <li><a href="#modifyingdata">Modifying Data</a></li>
+
+ <li><a href="#addingrecord">Adding a Record</a></li>
+
+ <li><a href="#deletingrecord">Deleting a Record</a></li>
+</ul>
+
+<a name="querying" id="querying"></a>
+<h4>Querying for Data</h4>
+
+<p>Each contact provider exposes a unique public URI (wrapped by {@link android.net.Uri})
+that is used by a client to query/add/update/delete data on that content
+provider. This URI has two forms: one to indicate all values of that type
+(e.g., all personal contacts), and one form to indicate a specific record of
+that type (e.g., Joe Smith's contact information).</p>
+
+<ul>
+ <li><strong>content://contacts/people/</strong> is the URI that would return a list of all contact names on the device.</li>
+
+ <li><strong>content://contacts/people/23</strong> is the URI string that would return a single result row, the contact with ID = 23. .</li>
+</ul>
+
+<p>An application sends a query to the device that specifies a general type of
+item (all phone numbers), or a specific item (Bob's phone number), to
+retrieve. Android then returns a Cursor over a recordset of results, with a
+specific set of columns. Let's look at a hypothetical query string and a
+result set (the results have been trimmed a bit for clarity):</p>
+
+<p>query = <code>content://contacts/people/</code></p>
+
+<p>Results:</p>
+
+<table border="1">
+ <tbody>
+ <tr>
+ <th scope="col">_ID</th>
+
+ <th scope="col">_COUNT</th>
+
+ <th scope="col">NUMBER</th>
+
+ <th scope="col">NUMBER_KEY</th>
+
+ <th scope="col">LABEL</th>
+
+ <th scope="col">NAME</th>
+
+ <th scope="col">TYPE</th>
+ </tr>
+
+ <tr>
+ <td>13</td>
+
+ <td>4</td>
+
+ <td>(425) 555 6677</td>
+
+ <td>425 555 6677</td>
+
+ <td>Kirkland office</td>
+
+ <td>Bully Pulpit</td>
+
+ <td>Work</td>
+ </tr>
+
+ <tr>
+ <td>44</td>
+
+ <td>4</td>
+
+ <td>(212) 555-1234</td>
+
+ <td>212 555 1234</td>
+
+ <td>NY apartment</td>
+
+ <td>Alan Vain</td>
+
+ <td>Home</td>
+ </tr>
+
+ <tr>
+ <td>45</td>
+
+ <td>4</td>
+
+ <td>(212) 555-6657</td>
+
+ <td>212 555 6657</td>
+
+ <td>Downtown office</td>
+
+ <td>Alan Vain</td>
+
+ <td>Work</td>
+ </tr>
+
+ <tr>
+ <td>53</td>
+
+ <td>4</td>
+
+ <td>201.555.4433</td>
+
+ <td>201 555 4433</td>
+
+ <td>Love Nest</td>
+
+ <td>Rex Cars</td>
+
+ <td>Home</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>Note that the query string isn't a standard SQL query string, but instead a
+URI string that describes the type of data to return. This URI consists of
+three parts: the string "content://"; a segment that describes what kind of
+data to retrieve; and finally an optional ID of a specific item of the
+specified content type. Here are a few more example query strings:</p>
+
+<ul>
+ <li><strong>content://media/internal/images</strong> is the URI string that would return a list of all
+ the internal images on the device.</li>
+
+ <li><strong>content://media/external/images</strong> is the URI string that would return a list of all
+ the images on the "primary" external storage (e.g., the SD card).</li>
+
+ <li><strong>content://contacts/people/</strong> is the URI that would return a list of all contact names on the device.</li>
+
+ <li><strong>content://contacts/people/23</strong> is the URI string that would return a single result row, the contact with ID = 23.</li>
+</ul>
+
+<p>Although there is a general form, these query URIs are somewhat arbitrary and
+confusing. Therefore, Android provides a list of helper classes in the {@link
+android.provider} package that
+define these query strings so you should not need to know the actual URI value
+for different data types. These helper classes define a string (actually,
+a {@link android.net.Uri Uri} object)
+called CONTENT_URI for a specific data type.</p>
+
+<p>Typically you will use the defined CONTENT_URI object to make a query,
+instead of writing the full URI yourself.
+So, each of the example query strings listed above (except for the last one that specifies the record ID)
+ can be acquired with the following Uri references:</p>
+
+<ul>
+ <li>{@link android.provider.MediaStore.Images.Media#INTERNAL_CONTENT_URI
+ MediaStore.Images.Media.INTERNAL_CONTENT_URI}</li>
+
+ <li>{@link android.provider.MediaStore.Images.Media#EXTERNAL_CONTENT_URI
+ MediaStore.Images.Media.EXTERNAL_CONTENT_URI}</li>
+
+ <li>{@link android.provider.Contacts.People#CONTENT_URI
+ Contacts.People.CONTENT_URI}</li>
+</ul>
+
+<p>To query a specific record ID (e.g., content://contacts/people/23),
+you'll use the same CONTENT_URI, but must append the specific ID value that you want.
+This is one of the few times you should need to examine or modify the URI string.
+So, for example, if you were looking for record 23 in the people contacts, you might run a query
+as shown here:</p>
+<pre>
+// Get the base URI for contact with _ID=23.
+// This is same as Uri.parse("content://contacts/people/23");
+Uri myPerson = ContentUris.withAppendedId(People.CONTENT_URI, 23);
+// Query for this record.
+Cursor cur = managedQuery(myPerson, null, null, null);
+</pre>
+<p class="note"><strong>Tip:</strong> You can also append a string to a Uri, using
+{@link android.net.Uri#withAppendedPath(Uri,String)}.</p>
+
+<p>This query returns a cursor over a database query result set. What columns
+are returned, what they're called, and what they are named are discussed next.
+For now, though, know that you can specify that only certain columns be
+returned, the sort order, and a SQL WHERE clause.</p>
+
+<p>You should use the {@link
+android.app.Activity#managedQuery(android.net.Uri,java.lang.String[],java.lang.String,java.lang.String[],java.lang.String) Activity.managedQuery()}
+method to retrieve a managed cursor. A managed cursor handles all the niceties
+such as unloading itself when the application pauses, and requerying itself
+when the application restarts. You can ask Android to manage an unmanaged
+cursor for you by calling {@link
+android.app.Activity#startManagingCursor(android.database.Cursor) Activity.startManagingCursor()}.</p>
+
+<p>Let's look at an example query to retrieve a list of contact names and their primary phone
+numbers.</p>
+<pre>
+// An array specifying which columns to return.
+string[] projection = new string[] {
+ People._ID,
+ People.NAME,
+ People.NUMBER,
+};
+
+// Get the base URI for People table in Contacts content provider.
+// ie. content://contacts/people/
+Uri mContacts = People.CONTENT_URI;
+
+// Best way to retrieve a query; returns a managed query.
+Cursor managedCursor = managedQuery( mContacts,
+ projection, //Which columns to return.
+ null, // WHERE clause--we won't specify.
+ People.NAME + " ASC"); // Order-by clause.
+</pre>
+
+<p>This query will retrieve data from the people table of
+the Contacts content provider. It will retrieve the name, primary phone number, and unique record ID for
+each contact. </p>
+
+<p><strong>What the query returns</strong></p>
+
+<p>A query returns a set of zero or more database records. The column names,
+order, and type are specific to the content provider, but every query includes
+a column called _id, which is the ID of the item in that row. If a query can
+return binary data, such as a bitmap or audio file, it will have a column with
+any name that holds a content:// URI that you can use to get this data (more
+information on how to get the file will be given later). Here is a tiresome
+example result set for the previous query:</p>
+
+<table border="1">
+ <tbody>
+ <tr>
+ <th scope="col">_id</th>
+
+ <th scope="col">name</th>
+
+ <th scope="col">number</th>
+
+
+ </tr>
+
+ <tr>
+ <td>44</td>
+
+ <td>Alan Vain</td>
+
+ <td>212 555 1234</td>
+
+
+ </tr>
+
+ <tr>
+ <td>13</td>
+
+ <td>Bully Pulpit</td>
+
+ <td>425 555 6677</td>
+
+
+ </tr>
+
+ <tr>
+ <td>53</td>
+
+ <td>Rex Cars</td>
+
+ <td>201 555 4433</td>
+
+
+ </tr>
+ </tbody>
+</table>
+
+<p>This result set demonstrates what is returned when we specified a subset of
+columns to return. The optional subset list is passed in the
+<em>projection</em> parameter of the query. A content manager should list
+which columns it supports either by implementing a set of interfaces
+describing each column (see {@link
+android.provider.Contacts.People.Phones Contacts.People.Phones},
+which extends {@link android.provider.BaseColumns BaseColumns}, {@link
+android.provider.Contacts.PhonesColumns PhonesColumns}, and {@link
+android.provider.Contacts.PeopleColumns PeopleColumns}), or by
+listing the column names as constants. Note that you need to
+know the data type of a column exposed by a content provider in order to be
+able to read it; the field reading method is specific to the data type, and a
+column's data type is not exposed programmatically.</p>
+
+<p>The retrieved data is exposed by a {@link
+android.database.Cursor Cursor} object that can be used to
+iterate backward or forward through the result set. You can use this cursor to
+read, modify, or delete rows. Adding new rows requires a different object
+described later.</p>
+
+<p>Note that by convention, every recordset includes a field named _id, which
+is the ID of a specific record, and a _count field, which is a count of
+records in the current result set. These field names are defined by {@link
+android.provider.BaseColumns BaseColumns}.</p>
+
+<p><strong>Querying for Files</strong></p>
+
+<p>The previous query result demonstrates how a file is returned in a data
+set. The file field is typically (but not required to be) a string path to the
+file. However, the caller should never try to read and open the file directly
+(permissions problems for one thing can make this fail). Instead, you should
+call {@link
+android.content.ContentResolver#openInputStream(android.net.Uri) ContentResolver.openInputStream()}
+/ {@link
+android.content.ContentResolver#openOutputStream(android.net.Uri)
+ContentResolver.openOutputStream()},
+or one of the helper functions from a content provider.</p>
+
+<p><strong>Reading Retrieved Data</strong></p>
+
+<p>The Cursor object retrieved by the query provides access to a recordset of
+results. If you have queried for a specific record by ID, this set will
+contain only one value; otherwise, it can contain multiple values. You can
+read data from specific fields in the record, but you must know the data type
+of the field, because reading data requires a specialized method for each type
+of data. (If you call the string reading method on most types of columns,
+Android will give you the String representation of the data.) The Cursor lets
+you request the column name from the index, or the index number from the
+column name.</p>
+
+<p>If you are reading binary data, such as an image file, you should call
+{@link
+android.content.ContentResolver#openOutputStream(android.net.Uri) ContentResolver.openOutputStream()}
+on the string content:// URI stored in a column name.</p>
+
+<p>The following snippet demonstrates reading the name and phone number from
+our phone number query:</p>
+<pre>
+private void getColumnData(Cursor cur){
+ if (cur.moveToFirst()) {
+
+ String name;
+ String phoneNumber;
+ int nameColumn = cur.getColumnIndex(People.NAME);
+ int phoneColumn = cur.getColumnIndex(People.NUMBER);
+ String imagePath;
+
+ do {
+ // Get the field values
+ name = cur.getString(nameColumn);
+ phoneNumber = cur.getString(phoneColumn);
+
+ // Do something with the values.
+ ...
+
+ } while (cur.moveToNext());
+
+ }
+}
+</pre>
+
+<h3>Modifying Data<a name="modifyingdata" id="modifyingdata"></a></h3>
+
+<p>To batch update a group of records (for example, to change "NY" to "New
+York" in all contact fields), call the {@link
+android.content.ContentResolver#update(android.net.Uri,android.content.ContentValues,java.lang.String,java.lang.String[]) ContentResolver.update()}
+method with the columns and values to change.</p>
+
+<h3>Adding a New Record <a name="addingrecord" id="addingrecord"></a></h3>
+
+<p>To add a new record, call ContentResolver.insert() with the URI of the type
+of item to add, and a Map of any values you want to set immediately on the new
+record. This will return the full URI of the new record, including record
+number, which you can then use to query and get a Cursor over the new
+record.</p>
+
+<pre>
+ContentValues values = new ContentValues();
+Uri phoneUri = null;
+Uri emailUri = null;
+
+values.put(Contacts.People.NAME, "New Contact");
+//1 = the new contact is added to favorites
+//0 = the new contact is not added to favorites
+values.put(Contacts.People.STARRED,1);
+
+//Add Phone Numbers
+Uri uri = getContentResolver().insert(Contacts.People.CONTENT_URI, values);
+
+//The best way to add Contacts data like Phone, email, IM is to
+//get the CONTENT_URI of the contact just inserted from People's table,
+//and use withAppendedPath to construct the new Uri to insert into.
+phoneUri = Uri.withAppendedPath(uri, Contacts.People.Phones.CONTENT_DIRECTORY);
+
+values.clear();
+values.put(Contacts.Phones.TYPE, Phones.TYPE_MOBILE);
+values.put(Contacts.Phones.NUMBER, "1233214567");
+getContentResolver().insert(phoneUri, values);
+
+//Add Email
+emailUri = Uri.withAppendedPath(uri, ContactMethods.CONTENT_DIRECTORY);
+
+values.clear();
+//ContactMethods.KIND is used to distinguish different kinds of
+//contact data like email, im, etc.
+values.put(ContactMethods.KIND, Contacts.KIND_EMAIL);
+values.put(ContactMethods.DATA, "test@example.com");
+values.put(ContactMethods.TYPE, ContactMethods.TYPE_HOME);
+getContentResolver().insert(emailUri, values);
+
+</pre>
+
+<p>To save a file, you can call ContentResolver().openOutputStream() with the
+URI as shown in the following snippet:
+</p>
+<pre>
+// Save the name and description in a map. Key is the content provider's
+// column name, value is the value to save in that record field.
+ContentValues values = new ContentValues(3);
+values.put(MediaStore.Images.Media.DISPLAY_NAME, "road_trip_1");
+values.put(MediaStore.Images.Media.DESCRIPTION, "Day 1, trip to Los Angeles");
+values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
+
+// Add a new record without the bitmap, but with the values.
+// It returns the URI of the new record.
+Uri uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
+
+try {
+ // Now get a handle to the file for that record, and save the data into it.
+ // sourceBitmap is a Bitmap object representing the file to save to the database.
+ OutputStream outStream = getContentResolver().openOutputStream(uri);
+ sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 50, outStream);
+ outStream.close();
+} catch (Exception e) {
+ Log.e(TAG, "exception while writing image", e);
+}
+</pre>
+
+<h3>Deleting a Record <a name="deletingrecord" id="deletingrecord"></a></h3>
+
+<p>To delete a single record, call {@link
+android.content.ContentResolver#delete(android.net.Uri,java.lang.String,java.lang.String[]) ContentResolver.delete()}
+with the URI of a specific row.</p>
+
+<p>To delete multiple rows, call ContentResolver.delete() with the URI of the
+type of record to delete (for example,
+android.provider.Contacts.People.CONTENT_URI) and a SQL WHERE clause defining
+which rows to delete (<em>Warning</em>: be sure to include a valid WHERE
+clause if deleting a general type using ContentResolver.delete(), or else you
+risk deleting more records than you intended!).</p>
+
+<h2>Creating a Content Provider<a name="creatingacontentprovider"
+id="creatingacontentprovider"></a> </h2> <p>Here is how to create your own
+content provider to act as a public source for reading and writing a new data
+type:</p>
+<ol>
+ <li>Extend
+ {@link android.content.ContentProvider ContentProvider}.</li>
+ <li>Define a <code>public static final {@link android.net.Uri Uri} </code>named
+ CONTENT_URI. This is the string that represents the full "content://" URI
+ that your content provider handles. You must define a unique string for this
+ value; the best solution is to use the fully-qualified class name of your
+ content provider (lowercase). So, for example: <br>
+
+ <code>public static final Uri CONTENT_URI = Uri.parse(
+ "content://com.google.codelab.rssprovider");</code></li>
+ <li>Create your system for storing data. Most content providers store their
+ data using Android's file storage methods or SQLite databases, but you can
+ store your data any way you want, so long as you follow the calling and return
+ value conventions.</li>
+ <li>Define the column names that you will return to your clients. If you are
+ using an underlying database, these column names are typically identical
+ to the SQL database column names they represent. In any case, you should include
+ an integer column named <code>_id</code> to
+ define a specific record number. If using the SQLite database, this should
+ be type <code>INTEGER
+ PRIMARY KEY AUTOINCREMENT</code>.
+ The <code>AUTOINCREMENT</code> descriptor
+ is optional, but by default, SQLite
+ autoincrements an ID counter field to the next number above the largest
+ existing number in the table. If you delete the last row, the next row added
+ will have the same ID as the deleted row. To avoid this by having SQLite
+ increment to the next largest value whether deleted or not, then assign your
+ ID column the following type: INTEGER PRIMARY KEY AUTOINCREMENT. (<strong>Note</strong> You
+ should have a unique _id field whether or not you have another field (such
+ as a URL) that is also unique among all records.) Android provides the
+ {@link android.database.sqlite.SQLiteOpenHelper SQLiteOpenHelper}
+
+ class to help you create and manage versions of your database. </li>
+ <li>If you are exposing byte data, such as a bitmap file, the field that stores
+ this data should actually be a string field with a content:// URI for that
+ specific file. This is the field that clients will call to retrieve this
+ data. The content provider for that content type (it can be the same content
+ provider or another content provider &mdash; for example, if you're storing a photo
+ you would use the media content provider) should implement a field named
+ _data for that record. The _data field lists the exact file path on the device
+ for that file. This field is not intended to be read by the client, but by
+ the ContentResolver. The client will call {@link
+ android.content.ContentResolver#openOutputStream(android.net.Uri) ContentResolver.openOutputStream()} on the user-facing field holding the URI
+ for the item (for example, the column named photo might have a value content://media/images/4453).
+ The ContentResolver will request the _data field for that record, and because
+ it has higher permissions than a client, it should be able to access
+ that file directly and return a read wrapper for that file to the client. </li>
+ <li>Declare public static
+ Strings that clients can use to specify which columns to return, or to specify
+ field values from the cursor. Carefully document the data type of each
+ field. Remember that file fields, such as audio or bitmap fields, are typically
+ returned as string path values </li>
+ <li>Return a {@link android.database.Cursor Cursor} object over a recordset in
+ reply to a query. This means implementing the query(), update(), insert(),
+ and delete() methods. As a courtesy, you might want to call {@link android.content.ContentResolver#notifyChange(android.net.Uri,android.database.ContentObserver) ContentResolver.notifyChange()} to notify
+ listeners about updated information. </li>
+
+ <li>Add a <code>&lt;provider&gt;</code> tag to AndroidManifest.xml, and use its
+ <em>authorities</em> attribute to define the authority part of the content type it should
+ handle. For example, if your content type is content://com.example.autos/auto
+ to request a list of all autos, then <em>authorities</em> would be <code>com.example.autos</code>.
+ Set the <em>multiprocess</em> attribute to true if data does not need to
+ be synchronized between multiple running versions of the content provider. </li>
+
+ <li>If you are handling a new data type, you must define a new MIME type to return
+ for your implementation of {@link android.content.ContentProvider#getType(android.net.Uri) android.ContentProvider.getType(url)}. This type corresponds to the <code>content://</code> URI
+ submitted to getType(), which will be one of the content types handled by
+ the provider. The MIME type for each content type has two forms: one for
+ a specific record, and one for multiple records. Use the {@link android.net.Uri Uri} methods to help determine what is being requested. Here is
+ the general format for each:
+<ul>
+<li><code>vnd.android.cursor.item/vnd.<em>yourcompanyname.contenttype</em></code>
+for a single row. For example, a request for train record 122 using
+<pre>content://com.example.transportationprovider/trains/122</pre>
+might return the MIME type
+<code>vnd.android.cursor.item/vnd.example.rail</code>
+</li>
+<li><code>vnd.android.cursor.dir/vnd.<em>yourcompanyname.contenttype</em></code>
+for multiple rows. For example, a request for all train records using
+<pre>content://com.example.transportationprovider/trains</pre>
+might return the MIME type
+<code>vnd.android.cursor.dir/vnd.example.rail</code>
+</li>
+</ul>
+
+ </li>
+</ol>
+<p>For an example of a private content provider implementation, see the NodePadProvider
+ class in the notepad sample application that ships with the SDK. </p>
+<p>Here is a recap of the important parts of a content URI:</p>
+<p><img src="../../images/content_uri.png" alt="Elements of a content URI" height="80" width="528"> </p>
+<ol type="A">
+ <li>Standard required prefix. Never modified. </li>
+ <li>Authority part. For third-party applications, this should be a fully-qualified
+ class to ensure uniqueness. This corresponds to the value in
+ the <code>&lt;provider&gt;</code> element's <em>authorities</em> attribute:
+ <code>&lt;provider class="TransportationProvider"
+ authorities="com.example.transportationprovider"
+ /&gt;</code> </li>
+
+ <li>The path that the content provider uses to determine what kind of data is
+ being requested. This can be zero or more segments: if the content provider
+ exposes only one type of data (only trains, for example), this can be absent.
+ If it provides several types, including subtypes, this can be several elements
+ long: e.g., "<code>land/bus</code>, <code>land/train</code>, <code>sea/ship</code>,
+ and <code>sea/submarine</code>" to give four possibilities.</li>
+ <li>A specific record being requested, if any. This is the _id value of a specific
+ record being requested. If all records of a specific type are being requested,
+ omit this and the trailing slash: <code>content://com.example.transportationprovider/trains</code> </li>
+</ol>
+
diff --git a/docs/html/guide/topics/data/data-storage.jd b/docs/html/guide/topics/data/data-storage.jd
new file mode 100644
index 0000000..2b3491c
--- /dev/null
+++ b/docs/html/guide/topics/data/data-storage.jd
@@ -0,0 +1,166 @@
+page.title=Data Storage
+@jd:body
+
+<p>
+A typical desktop operating system provides a common file system that any
+application can use to store files that can be read by other
+applications (perhaps with some access control settings). Android uses a
+different system: On Android, all application data (including files) are
+private to that application.
+
+<p>
+However, Android also provides a standard way for an application to expose
+its private data to other applications &mdash; through a content providers.
+A content provider is an
+optional component of an application that exposes read/write access to the
+application's data, subject to whatever restrictions it might impose.
+Content providers implement a standard syntax for requesting and modifying
+data, and a standard mechanism for reading the returned data. Android supplies
+a number of content providers for standard data types, such as image, audio,
+and video files and personal contact information. For more information on
+using content providers, see a separate document,
+<a href="{@docRoot}devel/data/contentproviders.html">Content Providers</a>.
+
+<p>
+Whether or not you want to export your application's data to others,
+you need a way to store it. Android provides the following four mechanisms
+for storing and retrieving data:
+
+<dl>
+<dd><a href="#pref">Preferences</a>
+<dd><a href="#files">Files</a>
+<dd><a href="#db">Databases</a>
+<dd><a href="#netw">Network</a>
+</dl>
+
+<dl>
+<dt><a name="pref"></a><b>Preferences</b></dt>
+<dd>A lightweight mechanism to store and retrieve key-value pairs of primitive
+data types. It is typically used to store application preferences, such as a
+default greeting or a text font to be loaded whenever the application is started. Call
+<code>{@link android.content.Context#getSharedPreferences(java.lang.String,int)
+Context.getSharedPreferences()}</code> to read and write values. Assign a name to
+your set of preferences if you want to share them with other components in the same
+application, or use <code>{@link android.app.Activity#getPreferences(int)
+Activity.getPreferences()}</code> with no name to keep them private to the calling
+activity. You cannot share preferences across applications (except by using a
+content provider).
+
+<p>
+Here is an example of setting user preferences for silent keypress mode for a
+calculator:
+
+<pre>
+import android.app.Activity;
+import android.content.SharedPreferences;
+
+public class Calc extends Activity {
+public static final String PREFS_NAME = "MyPrefsFile";
+ . . .
+
+ &#64;Override
+ protected void onCreate(Bundle state){
+ super.onCreate(state);
+
+ . . .
+
+ // Restore preferences
+ SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
+ boolean silent = settings.getBoolean("silentMode", false);
+ setSilent(silent);
+ }
+
+ &#64;Override
+ protected void onStop(){
+ super.onStop();
+
+ // Save user preferences. We need an Editor object to
+ // make changes. All objects are from android.context.Context
+ SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
+ SharedPreferences.Editor editor = settings.edit();
+ editor.putBoolean("silentMode", mSilentMode);
+
+ // Don't forget to commit your edits!!!
+ editor.commit();
+ }
+}
+</pre></dd>
+
+<p>
+<dt><a name="files"></a><b>Files</b></dt>
+<dd>You can store files directly on the mobile device or on a removable
+storage medium. By default, other applications cannot access these files.
+
+<p>
+To read data from a file, call {@link android.content.Context#openFileInput
+Context.openFileInput()} and pass it the local name and path of the file.
+It returns a standard Java {@link java.io.FileInputStream} object. To write
+to a file, call {@link android.content.Context#openFileOutput
+Context.openFileOutput()} with the name and path. It returns a {@link
+java.io.FileOutputStream} object. Calling these methods with name and path
+strings from another application will not work; you can only access local
+files.
+
+<p>
+If you have a static file to package with your application at compile time,
+you can save the file in your project in <code>res/raw/<em>myDataFile</em></code>,
+and then open it with {@link
+android.content.res.Resources#openRawResource(int) Resources.openRawResource
+(R.raw.<em>myDataFile</em>)}. It returns an {@link java.io.InputStream}
+object that you can use to read from the file.
+</dd>
+
+<dt><a name="db"></a><b>Databases</b></dt>
+<dd>The Android API contains support for creating and using SQLite databases.
+Each database is private to the application that creates it.
+
+<p>
+The {@link android.database.sqlite.SQLiteDatabase} object represents a database
+and has methods for interacting with it &mdash; making queries and managing the
+data. To create the database, call <code>{@link
+android.database.sqlite.SQLiteDatabase#create SQLiteDatabase.create()}</code>
+and also subclass {@link android.database.sqlite.SQLiteOpenHelper}.
+
+<p>
+As part of its support for the SQLite database system, Android exposes
+database management functions that let you store complex collections of data
+wrapped into useful objects. For example, Android defines a data type
+for contact information; it consists of many fields including a first and last
+name (strings), an address and phone numbers (also strings), a photo (bitmap
+image), and much other information describing a person.
+
+<p>
+Android ships with the sqlite3 database tool, which enables you to browse
+table contents, run SQL commands, and perform other useful functions on SQLite
+databases. See <a href="{@docRoot}reference/adb.html#sqlite">Examine databases
+(sqlite3)</a> to learn how to run this program.
+
+<p>
+All databases, SQLite and others, are stored on the device in
+<code>/data/data/<em>package_name</em>/databases</code>.
+
+<p>
+Discussion of how many tables to create, what fields they contain, and how
+they are linked, is beyond the scope of this note, but Android does not
+impose any limitations beyond the standard SQLite concepts. We do recommend
+including an autoincrement value key field that can be used as a unique ID to
+quickly find a record. This is not required for private data, but if you
+implement a content provider, you must include such a unique ID field. See the
+<a href="{@docRoot}devel/data/contentproviders.html">Content Providers</a>
+document for more information on this field and the NotePadProvider class
+in the NotePad sample code for an example of creating and populating a
+new database. Any databases you create will be accessible by name to any other
+class in the application, but not outside the application.</p>
+</dd>
+
+<dt><a name="netw"></a><b>Network</b></dt>
+<dd>You can also use the network to store and retrieve data (when it's available).
+To do network operations, use the classes in the following packages:
+<dl>
+ <dd><code>{@link java.net java.net.*}</code></dd>
+ <dd><code>{@link android.net android.net.*}</code></dd>
+</dl>
+</dd>
+
+</dl>
+
diff --git a/docs/html/guide/topics/drawing/opengl.jd b/docs/html/guide/topics/drawing/opengl.jd
new file mode 100644
index 0000000..e22a251
--- /dev/null
+++ b/docs/html/guide/topics/drawing/opengl.jd
@@ -0,0 +1,53 @@
+page.title=OpenGL
+@jd:body
+
+<p>Android includes support for 3D hardware acceleration. This functionality is
+accessed via the OpenGL API &mdash; specifically, the OpenGL ES API.</p>
+
+<p>OpenGL ES is a flavor of the OpenGL specification intended for embedded
+devices. Versions of OpenGL ES are loosely peered to versions of the primary
+OpenGL standard. Android currently supports OpenGL ES 1.0, which corresponds
+to OpenGL 1.3. So, if the application you have in mind is possible with OpenGL
+1.3 on a desktop system, it should be possible on Android.</p>
+
+<p>The specific API provided by Android is similar to the J2ME JSR239 OpenGL
+ES API. However, it may not be identical, so watch out for deviations.</p>
+
+<h2>Using the API</h2>
+
+<p>Here's how to use the API at an extremely high level:</p>
+
+<ol>
+<li>Write a custom View subclass.</li>
+<li>Obtain a handle to an OpenGLContext, which provides access to the OpenGL functionality.</li>
+<li>In your View's onDraw() method, get a handle to a GL object, and use its methods to perform GL operations.</li>
+</ol>
+
+<p>For an example of this usage model (based on the classic GL ColorCube),
+see
+<a href="{@docRoot}samples/ApiDemos/src/com/example/android/apis/graphics/GLView1.html">com.android.samples.graphics.GLView1.java</a>
+in the ApiDemos sample code project. A slightly more sophisticated version showing how to use
+it with threads can be found in
+<a href="{@docRoot}samples/ApiDemos/src/com/example/android/apis/graphics/GLSurfaceViewActivity.html">com.android.samples.graphics.GLSurfaceViewActivity.java</a>.
+</p>
+
+<p>Writing a summary of how to actually write 3D applications using OpenGL is
+beyond the scope of this text and is left as an exercise for the reader.</p>
+
+<h2>Links to Additional Information</h2>
+
+<p>Information about OpenGL ES can be
+found at <a title="http://www.khronos.org/opengles/"
+href="http://www.khronos.org/opengles/">http://www.khronos.org/opengles/</a>.</p>
+
+<p>Information specifically
+about OpenGL ES 1.0 (including a detailed specification) can be found
+at <a title="http://www.khronos.org/opengles/1_X/"
+href="http://www.khronos.org/opengles/1_X/">http://www.khronos.org/opengles/1_X/</a>.</p>
+
+<p>The documentation for the Android {@link javax.microedition.khronos.opengles.GL
+OpenGL ES implementations} are also available.</p>
+
+<p>Finally, note that though Android does include some basic support for
+OpenGL ES 1.1, the support is <strong>not complete</strong>, and should not be relied
+upon at this time.</p>
diff --git a/docs/html/guide/topics/geo/lbs.jd b/docs/html/guide/topics/geo/lbs.jd
new file mode 100644
index 0000000..981f6fe
--- /dev/null
+++ b/docs/html/guide/topics/geo/lbs.jd
@@ -0,0 +1,73 @@
+page.title=Location-based Service APIs
+@jd:body
+
+<p>The Android SDK includes two packages that provide Android's primary support
+for building location-based services:
+{@link android.location} and com.google.android.maps.
+Please read on below for a brief introduction to each package.</p>
+
+<h2>android.location</h2>
+
+<p>This package contains several classes related to
+location services in the Android platform. Most importantly, it introduces the
+{@link android.location.LocationManager}
+service, which provides an API to determine location and bearing if the
+underlying device (if it supports the service). The LocationManager
+should <strong>not</strong> be
+instantiated directly; rather, a handle to it should be retrieved via
+{@link android.content.Context#getSystemService(String)
+getSystemService(Context.LOCATION_SERVICE)}.</p>
+
+<p>Once your application has a handle to the LocationManager, your application
+will be able to do three things:</p>
+
+<ul>
+ <li>Query for the list of all LocationProviders known to the
+ LocationManager for its last known location.</li>
+ <li>Register/unregister for periodic updates of current location from a
+ LocationProvider (specified either by Criteria or name).</li>
+ <li>Register/unregister for a given Intent to be fired if the device comes
+ within a given proximity (specified by radius in meters) of a given
+ lat/long.</li>
+</ul>
+
+<p>However, during initial development, you may not have access to real
+data from a real location provider (Network or GPS). So it may be necessary to
+spoof some data for your application, with some mock location data.</p>
+
+<p class="note"><strong>Note:</strong> If you've used mock LocationProviders in
+previous versions of the SDK (m3/m5), you can no longer provide canned LocationProviders
+in the /system/etc/location directory. These directories will be wiped during boot-up.
+Please follow the new procedures below.</p>
+
+
+<h3>Providing Mock Location Data</h3>
+
+<p>When testing your application on the Android emulator, there are a couple different
+ways to send it some spoof location data: with the DDMS tool or the "geo" command.</p>
+
+<h4 id="ddms">Using DDMS</h4>
+<p>With the DDMS tool, you can simulate location data a few different ways:</p>
+<ul>
+ <li>Manually send individual longitude/latitude coordinates to the device.</li>
+ <li>Use a GPX file describing a route for playback to the device.</li>
+ <li>Use a KML file describing individual placemarks for sequenced playback to the device.</li>
+</ul>
+<p>For more information on using DDMS to spoof location data, see the
+<a href="{@docRoot}reference/ddms.html#emulator-control">Using DDMS guide</a>.
+
+<h4 id="geo">Using the "geo" command</h4>
+<p>Launch your application in the Android emulator and open a terminal/console in
+your SDK's <code>/tools</code> directory. Now you can use:</p>
+<ul><li><code>geo fix</code> to send a fixed geo-location.
+ <p>This command accepts a longitude and latitude in decimal degrees, and
+ an optional altitude in meters. For example:</p>
+ <pre>geo fix -121.45356 46.51119 4392</pre>
+ </li>
+ <li><code>geo nmea</code> to send an NMEA 0183 sentence.
+ <p>This command accepts a single NMEA sentence of type '$GPGGA' (fix data) or '$GPRMC' (transit data).
+ For example:</p>
+ <pre>geo nmea $GPRMC,081836,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E*62</pre>
+ </li>
+</ul>
+
diff --git a/docs/html/guide/topics/geo/mapkey.jd b/docs/html/guide/topics/geo/mapkey.jd
new file mode 100644
index 0000000..6442940
--- /dev/null
+++ b/docs/html/guide/topics/geo/mapkey.jd
@@ -0,0 +1,28 @@
+page.title=Obtaining a MapView API Key
+@jd:body
+
+<p>MapView is a very useful class that lets you easily integrate Google Maps into your application. It provides built-in map downloading, rendering, and caching, as well as a variety of display options and controls. It provides a wrapper around the Google Maps API that lets your application request and manipulate Google Maps data through class methods, and it lets you work with Maps data as you would other types of Views. </p>
+
+<p>Because MapView gives you access to Google Maps data, you need to register your application with the Google Maps service and agree to the applicable Terms of Service, before your MapView will be able to obtain data from Google Maps. This will apply whether you are developing your application on the emulator or preparing your application for deployment to mobile devices. </p>
+
+<p>Registering your application is simple, and has two parts: </p>
+
+<ol>
+<li>Registering a public key fingerprint from the certificate that you will use to sign the .apk. The registration service then provides you a Maps API Key that is associated with your application's signer certificate. </li>
+<li>Adding the Maps API Key to a special attribute of the MapView element &mdash; <code>android:apiKey</code>. You can use the same Maps API Key for any MapView in any application, provided that the application's .apk is signed with the certificate whose fingerprint you registered with the service. </li>
+</ol>
+
+<p>Once you have registered your application as described above, your MapView will be able to retrieve data from the Google Maps servers. </p>
+
+<div class="special">
+<p>The MapView registration service is not yet active and Google Maps is not yet enforcing the Maps API Key requirement. The registration service will be activated soon, so that MapViews in any application deployed to a mobile device will require registration and a valid Maps API Key.</p>
+
+<p>As soon as the registration service becomes available, this page (<a href="http://code.google.com/android/toolbox/apis/mapkey.html">http://code.google.com/android/toolbox/apis/mapkey.html</a>) will be updated with details about how and where to register and how to add your Maps API Key to your application. </p>
+
+<p>In the meantime, you can continue developing your MapView without registration, provided that you:</p>
+<ol type="a">
+<li>Add the attribute "android:apiKey" to the MapView element in your layout XML, with any value. Or</li>
+<li>Include an arbitrary string in the <code>apikey</code> parameter of the MapView constructor, if creating the MapView programmatically. </li>
+</ol>
+
+<p>When the Maps API Key checking is activated in the service, any MapViews that do not have a properly registered apiKey will stop working. The map data (tile images) of the MapView will never load (even if the device is on the network). In this case, go to the page linked above and read about how to register your certificate fingerprint and obtain a Maps API Key. </p>
diff --git a/docs/html/guide/topics/index.html b/docs/html/guide/topics/index.html
new file mode 100644
index 0000000..4881acf
--- /dev/null
+++ b/docs/html/guide/topics/index.html
@@ -0,0 +1,8 @@
+<html>
+<head>
+<meta http-equiv="refresh" content="0;url=../index.html">
+</head>
+<body>
+<a href="../index.html">click here</a> if you are not redirected.
+</body>
+</html> \ No newline at end of file
diff --git a/docs/html/guide/topics/intents/intents-filters.jd b/docs/html/guide/topics/intents/intents-filters.jd
new file mode 100644
index 0000000..39ca589
--- /dev/null
+++ b/docs/html/guide/topics/intents/intents-filters.jd
@@ -0,0 +1,459 @@
+page.title=Intents and Intent Filters
+@jd:body
+
+<p>
+Three of the core components of an application &mdash; activities, services, and
+broadcast receivers &mdash; are activated through messages, called <i>intents</i>.
+Intent messaging is a facility for late run-time binding between components in the same
+or different applications. The intent itself, an {@link android.content.Intent}
+object, is a passive data structure holding an abstract description of an operation
+to be performed &mdash; or, in the case of broadcasts, a description of something
+that has happened and is being announced. There are separate mechanisms for
+delivering intents to each type of component:
+
+<ul>
+
+<p><li>An Intent object is passed to <code>{@link android.content.Context#startActivity
+Context.startActivity()}</code> or <code>{@link android.app.Activity#startActivityForResult
+Activity.startActivityForResult()}</code> to launch an activity or get an existing
+activity to do something new.
+
+<p><li>An Intent object is passed to <code>{@link android.content.Context#startService
+Context.startService()}</code> to initiate a service or deliver new instructions to an
+ongoing service. Similarly, an intent can be passed to <code>{@link
+android.content.Context#bindService Context.bindService()}</code> to establish a
+connection between the calling component and a target service. It initiates the
+service if it's not already running.
+
+<p><li>Intent objects passed to any of the broadcast methods (such as <code>{@link
+android.content.Context#sendBroadcast(Intent) Context.sendBroadcast()}</code>,
+<code>{@link android.content.Context#sendOrderedBroadcast(Intent, String)
+Context.sendOrderedBroadcast()}</code>, or <code>{@link
+android.content.Context#sendStickyBroadcast Context.sendStickyBroadcast()}</code>)
+are delivered to all interested broadcast receivers. Many kinds of broadcasts
+originate in system code.
+
+</ul>
+
+<p>
+In each case, the Android system finds the appropriate activity, service, or set
+of broadcast receivers to respond to the intent, instantiating them if necessary.
+There is no overlap within these messaging systems: Broadcast intents are delivered
+only to broadcast receivers, never to activities or services. An intent passed to
+{@code startActivity()} is delivered only to an activity, never to a service or
+broadcast receiver, and so on.
+
+<p>
+Intents can be divided into two groups:
+
+<ul>
+
+<p><li><i>Explicit intents</i> designate the target component by its class name.
+They're typically used for application-internal messages &mdash; such as
+an activity starting a subordinate service or launching a sister activity
+&mdash; since component names would generally not be known to developers
+of other applications.
+
+<p><li><i>Implicit intents</i> do not name the target. Instead, the
+Android system determines the best component (or components) to respond
+to the message. It compares the contents of the Intent object with
+<i>intent filters</i>, structures associated with components that can
+potentially receive intents. Filters advertise the capabilities of a
+component and delimit the intents it can handle.
+
+
+</ul>
+
+<p>
+This document describes the rules Android uses to map intents to components &mdash;
+how it determines which component should receive an intent message.
+It begins with a description of Intent objects, and then describes intent filters
+and how intents are tested against the filters.
+
+
+<h2>Intent Objects</h2>
+
+<p>
+An {@link android.content.Intent} object is a bundle of information. It contains
+information of interest to the component that receives the intent (such as the action
+to be taken and the data to act on) plus information
+of interest to the Android system (such as the category of component that should handle
+the intent and instructions on how to launch a target activity). Principally, it can contain
+the following:
+
+<dl>
+
+<p><dt><b>Component class name</b></dt>
+<dd>The fully qualified class name of the component that should handle the intent
+&mdash; for example "{@code com.example.project.FreneticActivity}".
+This field is optional (and it would not normally be set for broadcast intents, since
+broadcasts are intended for more than a single receiver). However, if a class name
+is specified, nothing else in the Intent
+object matters for determining which component should get the intent; it will be
+delivered to the named component. (Of course, the other contents of the intent will
+matter to the component that receives it.)
+
+<p>
+The component class is set by <code>{@link android.content.Intent#setComponent
+setComponent()}</code>, <code>{@link android.content.Intent#setClass
+setClass()}</code>, or <code>{@link android.content.Intent#setClassName(String, String)
+setClassName()}</code> and read by <code>{@link android.content.Intent#getComponent
+getComponent()}</code>.
+
+<p><dt><b>Action</b></dt>
+<dd>A string naming the action to be performed &mdash; or, in the case of broadcast
+intents, the action that took place and is being reported. This is the only field
+in the object that must be set. The Intent class defines a number of action constants,
+including these:
+
+<p><table>
+<tr>
+ <th>Constant</th>
+ <th>Target component</th>
+ <th>Action</th>
+</tr><tr>
+ <td>{@code ACTION_CALL}
+ <td>activity
+ <td>Initiate a phone call.
+</tr><tr>
+ <td>{@code ACTION_EDIT}
+ <td>activity
+ <td>Display data for the user to edit.
+</tr><tr>
+ <td>{@code ACTION_MAIN}
+ <td>activity
+ <td>Start up as the initial activity of a task.
+</tr><tr>
+ <td>{@code ACTION_SYNC}
+ <td>activity
+ <td>Synchronize data on a server with data on the mobile device.
+</tr><tr>
+ <td>{@code ACTION_BATTERY_LOW}
+ <td>broadcast receiver
+ <td>A warning that the battery is low.
+</tr><tr>
+ <td>{@code ACTION_HEADSET_PLUG}
+ <td>broadcast receiver
+ <td>A headset has been plugged into the device, or unplugged from it.
+</tr><tr>
+ <td>{@code ACTION_SCREEN_ON}
+ <td>broadcast receiver
+ <td>The screen has been turned on.
+</tr><tr>
+ <td>{@code ACTION_TIMEZONE_CHANGED}
+ <td>broadcast receiver
+ <td>The setting for the time zone has changed.
+</tr>
+</table>
+
+<p>
+See the {@link android.content.Intent} class description for a full list of pre-defined action constants.
+
+<p>
+You can define action strings of your own. Those you define should include the
+application package as a prefix &mdash; for example:
+"<code>com.example.project.DEBIT_ACCT</code>". The action in an Intent object
+is set by the <code>{@link android.content.Intent#setAction setAction()}</code>
+method and read by <code>{@link android.content.Intent#getAction getAction()}</code>.
+
+<p><dt><b>Data</b></dt>
+<dd>The data to be acted on. Different actions are paired with different kinds
+of data specifications. For example, if the action field is {@code ACTION_EDIT},
+the data field would contain the URI of the document to be displayed for editing.
+If the action is {@code ACTION_CALL}, the data field would be a {@code tel:} URI
+with the number to call. Similarly, if the action is {@code ACTION_VIEW} and the
+data field is a {@code mailto:} URI, the receiving activity would be called upon
+to display a screen for composing an e-mail message, with the address filled in
+from the URI.
+
+<p>
+It's often important to know the type of data (its MIME type) in addition to its URI.
+Typically, the type is inferred from the URI. But it can also be explicitly set.
+The <code>{@link android.content.Intent#setData setData()}</code> method specifies
+data only as a URI, <code>{@link android.content.Intent#setType setType()}</code>
+specifies it only as a MIME type, and <code>{@link
+android.content.Intent#setDataAndType setDataAndType()}</code> specifies it as both
+a URI and a MIME type. The data and type are read by <code>{@link
+android.content.Intent#getData getData()}</code> and <code>{@link
+android.content.Intent#getType getType()}</code>.
+
+
+<p><dt><b>Category</b></dt>
+<dd>A string containing additional information about the kind of component
+that should handle the intent. Categories generally apply only to activities.
+
+<p>
+Any number of category descriptions can be placed in an Intent object. As it does for actions, the Intent class defines a number of category constants, including these:
+
+<p><table>
+<tr>
+ <th>Constant</th>
+ <th>Meaning</th>
+</tr><tr>
+ <td>{@code CATEGORY_BROWSABLE}
+ <td>The target activity can be safely invoked by the browser to display data
+ referenced by a link &mdash; for example, an image or an e-mail message.
+</tr><tr>
+ <td>{@code CATEGORY_GADGET}
+ <td>The activity can be embedded inside of another activity that hosts gadgets.
+</tr><tr>
+ <td>{@code CATEGORY_HOME}
+ <td>The activity displays the home screen, the first screen the user sees when
+ the device is turned on or when the HOME key is pressed.
+</tr><tr>
+ <td>{@code CATEGORY_LAUNCHER}
+ <td>The activity can be the initial activity of a task and is listed in
+ the top-level application launcher.
+</tr><tr>
+ <td>{@code CATEGORY_PREFERENCE}
+ <td>The target activity is a preference panel.
+</tr>
+</table>
+
+<p>
+In addition to the role categories play in Intent objects, they have an
+independent function in intent filters. As the examples above suggest, they
+instruct the Android system how to treat the activity that owns the filter. For
+example, {@code CATEGORY_HOME} defines the home activity.
+
+<p>
+See the {@link android.content.Intent} class description for the full list of
+categories.
+
+<p>
+The <code>{@link android.content.Intent#addCategory addCategory()}</code> method
+places a category in an Intent object, <code>{@link android.content.Intent#removeCategory
+removeCategory()}</code> deletes a category previously added, and <code>{@link android.content.Intent#getCategories getCategories()}</code> gets the set of all
+categories currently in the object.
+
+<p><dt><b>Extras</b></dt>
+<dd>Key-value pairs for additional information that should be delivered to the
+component handling the intent. Just as some actions are paired with particular
+kinds of data URIs, some are paired with particular extras. For example, an
+{@code ACTION_TIMEZONE_CHANGED} intent has a "{@code time-zone}" extra that
+identifies the new time zone, and {@code ACTION_HEADSET_PLUG} has a
+"{@code state}" extra indicating whether the headset is now plugged in or
+unplugged, as well as a "{@code name}" extra for the type of headset.
+
+<p>
+The Intent object has a series of {@code put...()} methods for inserting various
+types of extra data and a similar set of {@code get...()} methods for reading
+the data. These methods parallel those for {@link android.os.Bundle} objects.
+In fact, the extras can be installed and read as a Bundle using the <code>{@link
+android.content.Intent#putExtras putExtras()}</code> and <code>{@link
+android.content.Intent#getExtras getExtras()}</code> methods.
+
+<p><dt><b>Launch instructions</b></dt>
+<dd>Flags that instruct the Android system how to launch an activity (for
+example, which task the activity should belong to) and how to treat it after
+it's launched (for example, whether it belongs in the list of recent activities).
+All these flags are defined in the Intent class.
+
+</dl>
+
+<p>
+The Android system and the applications that come with the platform employ
+Intent objects both to send out system-originated broadcasts and to activate
+system-defined components. To see how to structure an intent to activate a
+system component, consult the
+<a href="{@docRoot}../reference/available-intents.html">list of intents</a>
+in the reference.
+For example, the component that initiates phone calls can be activated by an
+{@code ACTION_CALL} intent with a {@code tel:} URI specifying the phone number.
+
+
+<h2>Intent Filters</h2>
+
+<p>
+If an intent explicitly names a component class, Android delivers the intent to
+an instance of that class, creating the instance if necessary. However, if the
+intent does not designate a target by name, Android must find the appropriate
+component to handle the request &mdash; a single activity or service to perform
+the requested action or the set of broadcast receivers to respond to the
+broadcast announcement. It does so by comparing the Intent object against
+components' intent filters.
+
+<p>
+To inform the system which intents they can handle, activities, services, and
+broadcast receivers can have one or more intent filters.
+Each filter describes a capability of the component, a set of intents that
+the component is willing to receive. It, in effect, filters out unwanted
+intents. An implicit intent (one that doesn't name a target class) is delivered
+to a component only if it can pass through one of the component's filters.
+If a component lacks any intent filters, it can be activated only by explicit
+intents (those that specifically name its class).
+
+<p>
+A component has separate filters for each job it can do, each face it can
+present to the user. For example, if an activity can either display
+a list of items that the user can select or display the full details of one of
+the items, it would have a separate filter for each of these possibilities.
+
+<p>
+An intent filter is an instance of the {@link android.content.IntentFilter} class.
+However, since the Android system must know about the capabilities of a component
+before it can launch that component, intent filters are generally not set up in
+Java code, but in the application's manifest file (AndroidManifest.xml) as
+{@code &lt;intent-filter&gt;} elements. (The one exception would be filters for
+broadcast receivers that are registered dynamically by calling <code>{@link android.content.Context#registerReceiver(BroadcastReceiver, IntentFilter, String,
+Handler) Context.registerReceiver()}</code>; they are directly created as
+IntentFilter objects.)
+
+<p>
+A filter has fields that parallel the action, data, and category fields of an
+Intent object. A new intent is tested against the filter in all three areas.
+To be delivered to the component that owns the filter, it must pass all three tests.
+If it fails even one of them, the Android system won't deliver it to the
+component &mdash; at least not on the basis of that filter. However, since a
+component can have multiple intent filters, an arriving intent that does not pass
+through one of a component's filters might make it through on another.
+
+<p>
+Each of the three tests is described in detail below:
+
+<dl>
+
+<p>
+<dt><b>Action test</b></dt>
+<dd>An {@code &lt;intent-filter&gt;} element in the manifest file lists actions
+as {@code &lt;action&gt;} subelements. For example:
+
+<pre>&lt;intent-filter . . . &gt;
+ &lt;action android:name="com.example.project.SHOW_CURRENT" /&gt;
+ &lt;action android:name="com.example.project.SHOW_RECENT" /&gt;
+ &lt;action android:name="com.example.project.SHOW_PENDING" /&gt;
+ . . .
+&lt;/intent-filter&gt;</pre>
+
+<p>
+As the example shows, while an Intent object names just a single action,
+a filter may list more than one &mdash; or it may not list any at all.
+
+<p>
+To pass this test, the action specified in the {@link android.content.Intent}
+object must match one of the actions listed in the filter. However, if the
+filter doesn't list any actions, all actions are accepted, so all intents pass
+the test.
+
+<p>
+<dt><b>Category test</b></dt>
+<dd>An {@code &lt;intent-filter&gt;} element also lists categories as subelements.
+For example:
+
+<pre>&lt;intent-filter . . . &gt;
+ &lt;category android:name="android.intent.category.DEFAULT" /&gt;
+ &lt;category android:name="android.intent.category.BROWSABLE" /&gt;
+ . . .
+&lt;/intent-filter&gt;</pre>
+
+<p>Note that the constants described earlier for actions and categories are not
+used in the manifest file. The full string values are used instead. For
+instance, the "{@code android.intent.category.BROWSABLE}" string in the example
+above corresponds to the {@code CATEGORY_BROWSABLE} constant mentioned earlier
+in this document. Similarly, the string "{@code android.intent.action.EDIT}"
+corresponds to the {@code ACTION_EDIT} constant.
+
+<p>
+Many categories tell the Android system how to treat the component. For example,
+"{@code android.intent.category.LAUNCHER}" (the {@code CATEGORY_LAUNCHER} constant
+in code) instructs the system to include the activity in the screen showing
+applications the user can launch. Some categories &mdash; like "{@code
+android.intent.category.DEFAULT}" in the example above &mdash typically appear
+only in filters, not in Intent objects.
+
+<p>
+For an intent to pass the category test, every category in the Intent object
+must match a category in the filter. The filter can list additional categories,
+but it cannot omit any in the intent. An intent with no
+categories always passes this test, regardless of what's in the filter.
+
+<p>
+<dt><b>Data test</b></dt>
+<dd>Like the action and categories, the data specification for an intent filter
+is contained in a subelement. And, as in those cases, the subelement can appear
+multiple times, or not at all. For example:
+
+<pre>&lt;intent-filter . . . &gt;
+ &lt;data android:scheme="content"
+ android:host="com.example"
+ android:path="folder/*" . . . /&gt;
+ &lt;data android:scheme="content"
+ android:type="image/jpeg" . . . /&gt;
+ . . .
+&lt;/intent-filter&gt;</pre>
+
+<p>
+Each {@code &lt;data&gt;} element can specify a URI and a data type (MIME type).
+There are separate attributes &mdash; {@code scheme}, {@code host}, {@code port},
+and {@code path} &mdash; for each part of the URI:
+
+<dl><dd>{@code scheme://host:port/path}</dd></dl>
+
+<p>
+For example, in the following URI,
+
+<dl><dd>{@code content://com.example.project:200/folder/subfolder/etc}</dd></dl>
+
+<p> the scheme is "{@code content}", the host is "{@code com.example.project}",
+the port is "{@code 200}", and the path is "{@code folder/subfolder/etc}".
+The host and port together constitute the URI <i>authority</i>; if a host is
+not specified, the port is ignored.
+
+<p>
+Each of these attributes is optional, but they are not independent of each other:
+For an authority to be meaningful, a scheme must also be specified.
+For a path to be meaningful, both a scheme and an authority must be specified.
+
+<p>
+When the URI in an Intent object is compared to a URI specification in a filter,
+it's compared only to the parts of the URI actually specified in the filter.
+For example, if a filter specifies only a scheme, all URIs with that scheme match
+the filter. If a filter specifies a scheme and an authority but no path, all URIs
+with the same scheme and authority match, regardless of their paths. If a filter
+specifies a scheme, an authority, and a path, only URIs with the same scheme,
+authority, and path match. However, a path specification in the filter can
+contain wildcards to require only a partial match of the path.
+
+<p>
+A {@code &lt;data&gt;} element specifies a MIME type with the {@code type} attribute.
+Both the Intent object and the filter can use the '*" wildcard for the subtype field
+&mdash; for example, "{@code text/*}" or "{@code image/*}" &mdash; indicating any
+subtype matches.
+
+<p>
+The data test compares both the URI and the data type in the Intent object to a URI
+and data type specified in the filter. The rules are as follows:
+
+<ul>
+
+<p><li>An Intent object that contains neither a URI nor a data type passes the
+test only if the filter likewise does not specify any URIs or data types.
+
+<p><li>An Intent object that contains a URI but no data type (and a type cannot
+be inferred from the URI) passes the test only if its URI matches a URI in the
+filter and the filter likewise does not specify a type. This will be the case
+only for URIs like {@code mailto:} and {@code tel:} that do not refer to actual data.
+
+<p><li>An Intent object that contains a data type but not a URI passes the test
+only if the filter lists the same data type and similarly does not specify a URI.
+
+<p><li>An Intent object that contains both a URI and a data type (or a data type
+can be inferred from the URI) passes the data type part of the test only if its
+type matches a type listed in the filter. It passes the URI part of the test
+either if its URI matches a URI in the filter or if it has a {@code content:}
+or {@code file:} URI and the filter does not specify a URI. In other words,
+a component is presumed to support {@code content:} and {@code file:} data if
+its filter list only a data type.
+
+</ul>
+
+<p>
+If an intent can pass through the filters of more than one component, the user
+may be asked which component to activate.
+
+
+
+
+
+
+
diff --git a/docs/html/guide/topics/manifest/manifest.jd b/docs/html/guide/topics/manifest/manifest.jd
new file mode 100644
index 0000000..2cf1976
--- /dev/null
+++ b/docs/html/guide/topics/manifest/manifest.jd
@@ -0,0 +1,183 @@
+page.title=The Manifest File (AndroidManifest.xml)
+@jd:body
+
+<p>Every Android application has a <em>manifest file</em> that declares global values for the application.
+For example, the manifest file declares the appliication's fully qualified package name, as well as the application components (activities, services, etc) it exposes, the implementation classes for each, the kinds of data each can handle,
+and where they can be launched. </p>
+
+<p>The manifest is an XML file that is always stored under the name <code>AndroidManifest.xml</code> in the root folder of the application. Only one manifest file is allowed per application package. As part of developing your android application, you will be creating the application's manifest file using the XML vocabulary described in this document. </p>
+
+<p>An important aspect of this file is the <em>intent filters</em> that it includes.
+ These filters describe where and when that activity can be started. When an activity
+ (or the operating system) wants to perform an action such as open a Web page
+ or open a contact picker screen, it creates an {@link android.content.Intent
+ Intent} object. This object can hold several descriptors describing what you
+ want to do, what data you want to do it to, the type of data, and other bits
+ of information. Android compares the information in an Intent object with the
+ intent filter exposed by every application and finds the activity most appropriate
+ to handle the data or action specified by the caller. More details
+ on intents is given in the {@link android.content.Intent
+ Intent} reference page.</p>
+
+<p>Besides declaring your application's activities, content providers, services,
+and intent receivers, you can also specify permissions and instrumentation
+(security control and testing) in AndroidManifest.xml. For a reference of the tags and
+their attributes, please see {@link android.R.styleable#AndroidManifest}.</p>
+
+<p>A simple AndroidManifest.xml looks like this:</p>
+
+<pre>
+&lt;?xml version="1.0" encoding="utf-8"?&gt;
+
+&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.my_domain.app.helloactivity"&gt;
+
+ &lt;application android:label="@string/app_name"&gt;
+
+ &lt;activity android:name=".HelloActivity"&gt;
+ &lt;intent-filter&gt;
+ &lt;action android:name="android.intent.action.MAIN"/&gt;
+ &lt;category android:name="android.intent.category.LAUNCHER"/&gt;
+ &lt;/intent-filter&gt;
+ &lt;/activity&gt;
+
+ &lt;/application&gt;
+
+&lt;/manifest&gt;
+</pre>
+
+<p>Some general items to note:</p>
+
+<ul>
+<li> <p>Almost every AndroidManifest.xml (as well as many other Android
+XML files) will include the namespace declaration
+<code>xmlns:android="http://schemas.android.com/apk/res/android"</code> in
+its first element. This makes a variety of standard Android attributes
+available in the file, which will be used to supply most of the data for
+elements in that file.</code>
+<li> <p>Most manifests include a single <code>&lt;application&gt;</code>
+element, which defines all of the application-level components and
+properties that are available in the package.</p>
+<li> <p>Any package that will be presented to the user as a top-level
+application available from the program launcher will need to include at
+least one {@link android.app.Activity} component that supports the
+{@link android.content.Intent#ACTION_MAIN MAIN} action and
+{@link android.content.Intent#CATEGORY_LAUNCHER LAUNCHER} category as
+shown here.</p>
+</ul>
+
+<p>Here is a detailed outline of the structure of an AndroidManifest.xml file,
+describing all tags that are available.</p>
+
+<dl>
+ <dt>{@link android.R.styleable#AndroidManifest &lt;manifest&gt;}</dt>
+ <dd>The root node of the file, describing the complete contents of
+ the package. Under it you can place:
+ <dl>
+ <dt>{@link android.R.styleable#AndroidManifestUsesPermission &lt;uses-permission&gt;}</dt>
+ <dd>Requests a security permission that your package must be granted in
+ order for it to operate correctly. See the
+ <a href="{@docRoot}devel/security.html">Security Model</a>
+ document for more information on permissions. A manifest can
+ contain zero or more of these elements.</dd>
+ <dt>{@link android.R.styleable#AndroidManifestPermission &lt;permission&gt;}</dt>
+ <dd>Declares a security permission that can be used to restrict which
+ applications can access components or features in your (or
+ another) package. See the
+ <a href="{@docRoot}devel/security.html">Security Model</a>
+ document for more information on permissions. A manifest can
+ contain zero or more of these elements.</dd>
+ <dt>{@link android.R.styleable#AndroidManifestInstrumentation &lt;instrumentation&gt;}</dt>
+ <dd>Declares the code of an instrumentation component that is available
+ to test the functionality of this <em>or another</em> package.
+ See {@link android.app.Instrumentation} for more details. A manifest can
+ contain zero or more of these elements.</dd>
+ <dt>{@link android.R.styleable#AndroidManifestApplication &lt;application&gt;}</dt>
+ <dd>Root element containing declarations of the application-level
+ components contained in the package. This element can also
+ include global and/or default attributes for the application,
+ such as a label, icon, theme, required permission, etc. A manifest
+ can contain zero or one of these elements (more than one application
+ tag is not allowed). Under it you can place zero or more of
+ each of the following component declarations:
+ <dl>
+ <dt>{@link android.R.styleable#AndroidManifestActivity &lt;activity&gt;}</dt>
+ <dd>An {@link android.app.Activity} is the primary facility for
+ an application to interact with the user. The initial screen
+ the user sees when launching an application is an activity,
+ and most other screens they use will be implemented as
+ separate activities declared with additional activity tags.
+
+ <p><em><strong>Note:</strong></em> Every
+ Activity must have an &lt;activity&gt; tag in the manifest whether it is exposed
+ to the world or intended for use only within its own package. If an Activity
+ has no matching tag in the manifest, you won't be able to launch it.
+
+ <p>Optionally, to support late runtime lookup of your
+ activity, you can include one or more &lt;intent-filter&gt;
+ elements to describe the actions the activity supports.
+ <dl>
+ <dt><a name="intent-filter">
+ {@link android.R.styleable#AndroidManifestIntentFilter &lt;intent-filter&gt;}</a></dt>
+ <dd>Declares a specific set of {@link android.content.Intent} values
+ that a component supports, in the form of an
+ {@link android.content.IntentFilter}. In addition to the
+ various kinds of values
+ that can be specified under this element, attributes
+ can be given here to supply a unique label, icon, and
+ other information for the action being described.
+ <dl>
+ <dt>{@link android.R.styleable#AndroidManifestAction &lt;action&gt;}</dt>
+ <dd>An {@link android.content.IntentFilter#addAction Intent action}
+ that the component supports.</dd>
+ <dt>{@link android.R.styleable#AndroidManifestCategory &lt;category&gt;}</dt>
+ <dd>An {@link android.content.IntentFilter#addCategory Intent category}
+ that the component supports.</dd>
+ <dt>{@link android.R.styleable#AndroidManifestData &lt;data&gt;}</dt>
+ <dd>An {@link android.content.IntentFilter#addDataType Intent data MIME type},
+ {@link android.content.IntentFilter#addDataScheme Intent data URI scheme},
+ {@link android.content.IntentFilter#addDataAuthority Intent data URI authority}, or
+ {@link android.content.IntentFilter#addDataPath Intent data URI path}
+ that the component supports.</dd>
+ </dl>
+ </dl>
+
+ <p>You can also optionally associate one or more pieces of meta-data
+ with your activity that other clients can retrieve to find
+ additional arbitrary information about it:</p>
+ <dl>
+ <dt><a name="meta-data">
+ {@link android.R.styleable#AndroidManifestMetaData &lt;meta-data&gt;}</a></dt>
+ <dd>Adds a new piece of meta data to the activity, which clients
+ can retrieve through
+ {@link android.content.pm.ComponentInfo#metaData
+ ComponentInfo.metaData}.
+ </dl>
+ <dt>{@link android.R.styleable#AndroidManifestReceiver &lt;receiver&gt;}</dt>
+ <dd>An {@link android.content.BroadcastReceiver} allows an application
+ to be told about changes to data or actions that happen,
+ even if it is not currently running. As with the activity
+ tag, you can optionally include one or more &lt;intent-filter&gt;
+ elements that the receiver supports or &lt;meta-data&gt; values;
+ see the activity's
+ <a href="#intent-filter">&lt;intent-filter&gt;</a> and
+ <a href="#meta-data">&lt;meta-data&gt;</a> descriptions
+ for more information.</dd>
+ <dt>{@link android.R.styleable#AndroidManifestService &lt;service&gt;}</dt>
+ <dd>A {@link android.app.Service} is a component that can run in
+ the background for an arbitrary amount of time. As with the activity
+ tag, you can optionally include one or more &lt;intent-filter&gt;
+ elements that the service supports or &lt;meta-data&gt; values;
+ see the activity's
+ <a href="#intent-filter">&lt;intent-filter&gt;</a> and
+ <a href="#meta-data">&lt;meta-data&gt;</a> descriptions
+ for more information.</dd>
+ <dt>{@link android.R.styleable#AndroidManifestProvider &lt;provider&gt;}</dt>
+ <dd>A {@link android.content.ContentProvider} is a component that
+ manages persistent data and publishes it for access by other
+ applications. You can also optionally attach one or more
+ &lt;meta-data&gt; values, as described in the activity's
+ <a href="#meta-data">&lt;meta-data&gt;</a> description.</dd>
+ </dl>
+ </dl>
+</dl>
diff --git a/docs/html/guide/topics/media/media.jd b/docs/html/guide/topics/media/media.jd
new file mode 100644
index 0000000..16ad2b7
--- /dev/null
+++ b/docs/html/guide/topics/media/media.jd
@@ -0,0 +1,171 @@
+page.title=Media Capabilities
+@jd:body
+
+<div class="sidebox">
+
+<h3>Media Quickview</h3>
+
+<h4>Built-in capabilities</h4>
+<ul>
+<li>Audio playback and record</li>
+<li>Video playback</li>
+</ul>
+
+<h4>Data sources</h4>
+<ul>
+<li>Raw resources</li>
+<li>Data files</li>
+<li>Streams</li>
+</ul>
+
+<h4>Media Formats</h4>
+<ul>
+<li>See appendix <a href="{@docRoot}devguide/appendix/media_formats.html">Android 1.0 Media Formats</a></li>
+</ul>
+
+<h4>Key APIs</h4>
+<ul>
+<li>{@link android.media.MediaPlayer} (playback, all audio and video formats)</li>
+<li>{@link android.media.MediaRecorder} (record, all audio formats)</li>
+</ul>
+
+<p>The Android platform offers built-in encoding/decoding for a variety of common media types,
+so that you can easily integrate audio, video, and images into your applications. Accessing the platform's media
+capabilities is fairly straightforward &mdash you do so using the same intents and
+activities mechanism that the rest of Android uses.</p>
+
+<p>Android lets you play audio and video from several types of data sources. You can play audio or video from media files stored in the application's resources (raw resources), from standalone files in the filesystem, or from a data stream arriving over a network connection. To play audio or video from your application, use the {@link android.media.MediaPlayer} class.</p>
+
+<p>The platform also lets you record audio, where supported by the mobile device hardware. Recording of video is not currently supported, but is planned for a future release. To record audio, use the
+{@link android.media.MediaRecorder} class. Note that the emulator doesn't have hardware to capture audio, but actual mobile devices are likely to provide these capabilities that you can access through MediaRecorder. </p>
+
+<p>For a list of the media formats for which Android offers built-in support, see the <a href="{@docRoot}devguide/appendix/media_formats.html">Android Media Formats</a> appendix. </p>
+
+<h2>Playing Audio and Video</h2>
+<p>Media can be played from anywhere: from a raw resource, from a file from the system,
+or from an available network (URL).</p>
+
+<p>You can play back the audio data only to the standard
+output device; currently, that is the mobile device speaker or Bluetooth headset. You
+cannot play sound files in the conversation audio. </p>
+
+<h3>Playing from a Raw Resource</h3>
+<p>Perhaps the most common thing to want to do is play back media (notably sound)
+within your own applications. Doing this is easy:</p>
+<ol>
+ <li>Put the sound (or other media resource) file into the <code>res/raw</code>
+ folder of your project, where the Eclipse plugin (or aapt) will find it and
+ make it into a resource that can be referenced from your R class</li>
+ <li>Create an instance of <code>MediaPlayer</code>, referencing that resource using
+ {@link android.media.MediaPlayer#create MediaPlayer.create}, and then call
+ {@link android.media.MediaPlayer#start() start()} on the instance:<br><br></li>
+</ol>
+<pre>
+ MediaPlayer mp = MediaPlayer.create(context, R.raw.sound_file_1);
+ mp.start();
+</pre>
+<p>To stop playback, call {@link android.media.MediaPlayer#stop() stop()}. If
+you wish to later replay the media, then you must
+{@link android.media.MediaPlayer#reset() reset()} and
+{@link android.media.MediaPlayer#prepare() prepare()} the MediaPlayer object
+before calling {@link android.media.MediaPlayer#start() start()} again.
+(<code>create()</code> calls <code>prepare()</code> the first time.)</p>
+<p>To pause playback, call {@link android.media.MediaPlayer#pause() pause()}.
+Resume playback from where you paused with
+{@link android.media.MediaPlayer#start() start()}.</p>
+
+<h3>Playing from a File or Stream</h3>
+<p>You can play back media files from the filesystem or a web URL:</p>
+<ol>
+ <li>Create an instance of the <code>MediaPlayer</code> using <code>new</code></li>
+ <li>Call {@link android.media.MediaPlayer#setDataSource setDataSource()}
+ with a String containing the path (local filesystem or URL)
+ to the file you want to play</li>
+ <li>First {@link android.media.MediaPlayer#prepare prepare()} then
+ {@link android.media.MediaPlayer#start() start()} on the instance:<br><br></li>
+</ol>
+<pre>
+ MediaPlayer mp = new MediaPlayer();
+ mp.setDataSource(PATH_TO_FILE);
+ mp.prepare();
+ mp.start();
+</pre>
+<p>{@link android.media.MediaPlayer#stop() stop()} and
+{@link android.media.MediaPlayer#pause() pause()} work the same as discussed
+above.</p>
+ <p class="note"><strong>Note:</strong> It is possible that <code>mp</code> could be
+ null, so good code should <code>null</code> check after the <code>new</code>.
+ Also, <code>IllegalArgumentException</code> and <code>IOException</code> either
+ need to be caught or passed on when using <code>setDataSource()</code>, since
+ the file you are referencing may not exist.</p>
+<p class="note"><strong>Note:</strong>
+If you're passing a URL to an online media file, the file must be capable of
+progressive download.</p>
+
+<h2>Recording Media Resources</h2>
+<p>Recording media is a little more involved than playing it back, as you would
+probably expect, but it is still fairly simple. There is just a little more set
+up to do</p>
+<ol>
+ <li>Create a new instance of {@link android.media.MediaRecorder
+ android.media.MediaRecorder} using <code>new</code></li>
+ <li>Create a new instance of {@link android.content.ContentValues
+ android.content.ContentValues} and put in some standard properties like
+ <code>TITLE</code>, <code>TIMESTAMP</code>, and the all important
+ <code>MIME_TYPE</code></li>
+ <li>Create a file path for the data to go to (you can use {@link
+ android.content.ContentResolver android.content.ContentResolver} to
+ create an entry in the Content database and get it to assign a path
+ automatically which you can then use)</li>
+ <li>Set the audio source using {@link android.media.MediaRecorder#setAudioSource
+ MediaRecorder.setAudioSource()}. You will probably want to use
+ <code>MediaRecorder.AudioSource.MIC</code></li>
+ <li>Set output file format using {@link
+ android.media.MediaRecorder#setOutputFormat MediaRecorder.setOutputFormat()}
+ </li>
+ <li>Set the audio encoder using
+ {@link android.media.MediaRecorder#setAudioEncoder MediaRecorder.setAudioEncoder()}
+ </li>
+ <li>Finally, {@link android.media.MediaRecorder#prepare prepare()} and
+ {@link android.media.MediaRecorder#start start()} the recording.
+ {@link android.media.MediaRecorder#stop stop()} and
+ {@link android.media.MediaRecorder#release release()} when you are done</li>
+</ol>
+<p>Here is a code example that will hopefully help fill in the gaps:</p>
+<p><strong>Start Recording</strong></p>
+<pre>
+ recorder = new MediaRecorder();
+ ContentValues values = new ContentValues(3);
+
+ values.put(MediaStore.MediaColumns.TITLE, SOME_NAME_HERE);
+ values.put(MediaStore.MediaColumns.TIMESTAMP, System.currentTimeMillis());
+ values.put(MediaStore.MediaColumns.MIME_TYPE, recorder.getMimeContentType());
+
+ ContentResolver contentResolver = new ContentResolver();
+
+ Uri base = MediaStore.Audio.INTERNAL_CONTENT_URI;
+ Uri newUri = contentResolver.insert(base, values);
+
+ if (newUri == null) {
+ // need to handle exception here - we were not able to create a new
+ // content entry
+ }
+
+ String path = contentResolver.getDataFilePath(newUri);
+
+ // could use setPreviewDisplay() to display a preview to suitable View here
+
+ recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
+ recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
+ recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
+ recorder.setOutputFile(path);
+
+ recorder.prepare();
+ recorder.start();
+</pre>
+<p><strong>Stop Recording</strong></p>
+<pre>
+ recorder.stop();
+ recorder.release();
+</pre>
+
diff --git a/docs/html/guide/topics/processes/process-lifecycle.jd b/docs/html/guide/topics/processes/process-lifecycle.jd
new file mode 100644
index 0000000..0380f94
--- /dev/null
+++ b/docs/html/guide/topics/processes/process-lifecycle.jd
@@ -0,0 +1,120 @@
+page.title=Processes and Application Life Cycle
+@jd:body
+
+<p>In most cases, every Android application runs in its own Linux process.
+This process is created for the application when some of its code needs to
+be run, and will remain running until it is no longer needed <em>and</em>
+the system needs to reclaim its memory for use by other applications.</p>
+
+<p>An unusual and fundamental feature of Android is that an application process's
+lifetime is <em>not</em> directly controlled by the application itself.
+Instead, it is determined by the system through a combination of the parts of the application
+that the system knows are running, how important these things are to the user,
+and how much overall memory is available in the system.</p>
+
+<p>It is important that
+application developers understand how different application components
+(in particular {@link android.app.Activity}, {@link android.app.Service},
+and {@link android.content.BroadcastReceiver}) impact the lifetime
+of the application's process. <strong>Not using these components correctly can
+result in the system killing the application's process while it is doing
+important work.</strong></p>
+
+<p>A common example of a process life-cycle bug is a
+{@link android.content.BroadcastReceiver} that starts a thread when it
+receives an Intent in its {@link android.content.BroadcastReceiver#onReceive
+BroadcastReceiver.onReceive()}
+method, and then returns from the function. Once it returns, the system
+considers the BroadcastReceiver to be no longer active, and thus, its hosting
+process no longer needed (unless other application components are active in
+it). So, the system may kill the process at any time to reclaim memory, and in doing so,
+it terminates the spawned thread running in the process. The solution to this problem
+is to start a {@link android.app.Service} from the BroadcastReceiver, so the
+system knows that there is still active work being done in the process.</p>
+
+<p>To determine which processes should be killed when low on memory, Android
+places each process into an "importance hierarchy" based on the components running in
+them and the state of those components. These process types are (in order of importance):</p>
+
+<ol>
+
+<li>A <strong>foreground process</strong> is one that is required for
+what the user is currently doing. Various application components can
+cause its containing process to be considered foreground in different
+ways. A process is considered to be in the foreground if any of the
+following conditions hold:
+ <ul>
+ <li> It is running an {@link android.app.Activity}
+ at the top of the screen that the user is interacting with (its
+ {@link android.app.Activity#onResume} method has been called).</li>
+ <li> It has a {@link android.content.BroadcastReceiver} that is currently running
+ (its {@link android.content.BroadcastReceiver#onReceive
+ BroadcastReceiver.onReceive()} method is executing).</li>
+ <li>It has a {@link android.app.Service} that is currently executing code
+ in one of its callbacks ({@link android.app.Service#onCreate Service.onCreate()},
+ {@link android.app.Service#onStart Service.onStart()}, or
+ {@link android.app.Service#onDestroy Service.onDestroy()}).</li>
+ </ul>
+</li>
+<p>There will only ever be a few such processes in the system, and these will only
+be killed as a last resort if memory is so low that not even these processes
+can continue to run. Generally, at this point, the device has
+reached a memory paging state, so this action is required in order to keep the user
+interface responsive.</p>
+</li>
+
+<li>A <strong>visible process</strong> is one holding an {@link android.app.Activity}
+that is visible to the user on-screen but not in the foreground (its
+{@link android.app.Activity#onPause} method has been called). This may
+occur, for example, if the foreground Activity is displayed as a dialog
+that allows the previous Activity to be seen behind it. Such a
+process is considered extremely important and will not be killed unless doing so is
+required to keep all foreground processes running.
+</li>
+
+<li>A <strong>service process</strong> is one holding a {@link android.app.Service}
+that has been started with the
+{@link android.content.Context#startService startService()} method. Though these
+processes are not directly visible to the user, they are generally doing things
+that the user cares about (such as background mp3 playback or background
+network data upload or download), so the system will always keep such processes
+running unless there is not enough memory to retain all foreground and visible process.
+</li>
+
+<li>A <strong>background process</strong> is one holding an {@link android.app.Activity}
+that is not currently visible to the user (its
+{@link android.app.Activity#onStop} method has been called). These processes
+have no direct impact on the user experience. Provided they implement
+their Activity life-cycle correctly
+(see {@link android.app.Activity} for more details), the system
+can kill such processes at any time to reclaim memory for one of the three
+previous processes types. Usually there are many of these processes running,
+so they are kept in an LRU list to ensure the process that was most recently seen
+by the user is the last to be killed when running low on memory.
+</li>
+
+<li>An <strong>empty process</strong> is one that doesn't hold any active application
+components. The only reason to keep such a process around is as a cache to
+improve startup time the next time a component of its application needs to
+run. As such, the system will often kill these processes in order to
+balance overall system resources between these empty cached processes and the
+underlying kernel caches.
+</li>
+
+</ol>
+
+<p>When deciding how to classify a process, the system will base its decision on the most
+important level found among all the components currently active in the process.
+See the {@link android.app.Activity}, {@link android.app.Service}, and
+{@link android.content.BroadcastReceiver} documentation for more detail on how
+each of these components contribute to the overall life-cycle of a process.
+The documentation for each of these classes describes in more detail how
+they impact the overall life-cycle of their application.</p>
+
+<p>A process's priority may also be increased based on other dependencies
+a process has to it. For example, if process A has bound to a
+{@link android.app.Service} with
+the {@link android.content.Context#BIND_AUTO_CREATE Context.BIND_AUTO_CREATE}
+flag or is using a
+{@link android.content.ContentProvider} in process B, then process B's
+classification will always be at least as important as process A's.</p>
diff --git a/docs/html/guide/topics/providers/content-providers.jd b/docs/html/guide/topics/providers/content-providers.jd
new file mode 100644
index 0000000..93b379e
--- /dev/null
+++ b/docs/html/guide/topics/providers/content-providers.jd
@@ -0,0 +1,847 @@
+page.title=Content Providers
+@jd:body
+
+<h1>Content Providers</h1>
+
+<p>
+Content providers store and retrieve data and make it accessible to all
+applications. They're the only way to share data across applications; there's
+no common storage area that all Android packages can access.
+
+<p>
+Android ships with a number of content providers for common data types
+(audio, video, images, personal contact information, and so on). You can
+see some of them listed in the {@link android.provider android.provider}
+package. You can query these providers for the data they contain (although,
+for some, you must acquire the proper permission to read the data).
+
+<p>
+If you want to make your own data public, you have two options: You can
+create your own content provider (a {@link android.content.ContentProvider}
+subclass) or you can add the data to an existing provider &mdash; if there's
+one that controls the same type of data and you have permission to write to it.
+
+<p>
+This document is an introduction to using content providers. It explores
+the following topics:
+
+<dl><dd><a href="#basics">Content provider basics</a>
+<br/><a href="#querying">Querying a content provider</a>
+<br/><a href="#modifying">Modifying data in a provider</a>
+<br/><a href="#creating">Creating a content provider</a></dd></dl>
+
+
+<h2>Content Provider Basics<a href="#basics"></a></h2>
+
+<p>
+How a content provider actually stores its data under the covers is
+up to its designer. But all content providers implement a common interface
+for querying the provider and returning results &mdash; as well as for
+adding, altering, and deleting data.
+
+<p>
+It's an interface that clients use indirectly, most generally through
+{@link android.content.ContentResolver} objects. You get a ContentResolver
+by calling <code>{@link android.content.Context#getContentResolver
+getContentResolver()}</code> from within the implementation of an Activity
+or other application component:
+
+<pre>ContentResolver cr = getContentResolver();</pre>
+
+<p>
+You can then use the ContentResolver's methods to interact with whatever
+content providers you're interested in.
+
+<p>
+When a query is initiated, the Android system identifies the content provider
+that's the target of the query and makes sure that it is up and running.
+The system instantiates all ContentProvider objects; you never need to do it
+on your own. In fact, you never deal directly with ContentProvider objects
+at all. Typically, there's just a single instance of each type of
+ContentProvider. But it can communicate with multiple ContentResolver objects
+in different applications and processes. The interaction between processes is
+handled by the ContentResolver and ContentProvider classes.
+
+
+<h3>The data model</h3>
+
+<p>
+Content providers expose their data as a simple table on a database model,
+where each row is a record and each column is data of a particular type
+and meaning. For example, information about people and their phone numbers
+might be exposed as follows:
+
+<table>
+ <tr>
+ <th scope="col">_ID</th>
+ <th scope="col">NUMBER</th>
+ <th scope="col">NUMBER_KEY</th>
+ <th scope="col">LABEL</th>
+ <th scope="col">NAME</th>
+ <th scope="col">TYPE</th>
+ </tr>
+ <tr>
+ <td>13</td>
+ <td>(425) 555 6677</td>
+ <td>425 555 6677</td>
+ <td>Kirkland office</td>
+ <td>Bully Pulpit</td>
+ <td>{@code TYPE_WORK}</td>
+ </tr>
+ <tr>
+ <td>44</td>
+ <td>(212) 555-1234</td>
+ <td>212 555 1234</td>
+ <td>NY apartment</td>
+ <td>Alan Vain</td>
+ <td>{@code TYPE_HOME}</td>
+ </tr>
+ <tr>
+ <td>45</td>
+ <td>(212) 555-6657</td>
+ <td>212 555 6657</td>
+ <td>Downtown office</td>
+ <td>Alan Vain</td>
+ <td>{@code TYPE_MOBILE}</td>
+ </tr>
+ <tr>
+ <td>53</td>
+ <td>201.555.4433</td>
+ <td>201 555 4433</td>
+ <td>Love Nest</td>
+ <td>Rex Cars</td>
+ <td>{@code TYPE_HOME}</td>
+ </tr>
+</table>
+
+<p>
+Every record includes a numeric {@code _ID} field that uniquely identifies
+the record within the table. IDs can be used to match records in related
+tables &mdash; for example, to find a person's phone number in one table
+and pictures of that person in another.
+
+<p>
+A query returns a {@link android.database.Cursor} object that can move from
+record to record and column to column to read the contents of each field.
+It has specialized methods for reading each type of data. So, to read a field,
+you must know what type of data the field contains. (There's more on query
+results and Cursor objects later.)
+
+
+<h3>URIs</h3><a name="uri"></a>
+
+<p>
+Each content provider exposes a public URI (wrapped as a {@link android.net.Uri}
+object) that uniquely identifies its data set. A content provider that controls
+multiple data sets (multiple tables) exposes a separate URI for each one. All
+URIs for providers begin with the string "{@code content://}". The {@code content:}
+scheme identifies the data as being controlled by a content provider.
+
+<p>
+If you're defining a content provider, it's a good idea to also define a
+constant for its URI, to simplify client code and make future updates cleaner.
+Android defines {@code CONTENT_URI} constants for all the providers that come
+with the platform. For example, the URI for the table that matches
+phone numbers to people and the URI for the table that holds pictures of
+people (both controlled by the Contacts content provider) are:
+
+<p>
+<dl><dd>{@code android.provider.Contacts.Phones.CONTENT_URI}
+<br/>{@code android.provider.Contacts.Photos.CONTENT_URI}</dd></dl>
+
+<p>
+Similarly, the URIs for the table of recent phone calls and the table
+of calendar entries are:
+
+<p>
+<dl><dd>{@code android.provider.CallLog.Calls.CONTENT_URI}
+<br/>{@code android.provider.Calendar.CONTENT_URI}</dd></dl>
+
+<p>
+The URI constant is used in all interactions with the content provider.
+Every {@link android.content.ContentResolver} method takes the URI
+as its first argument. It's what identifies which provider the ContentResolver
+should talk to and which table of the provider is being targeted.
+
+
+<h2>Querying a Content Provider<a name="querying"></a></h2>
+
+<p>
+You need three pieces of information to query a content provider:
+<ul>
+<li>The URI that identifies the provider
+<li>The names of the data fields you want to receive
+<li>The data types for those fields
+</ul>
+
+<p>
+If you're querying a particular record, you also need the ID for that record.
+
+
+<h3>Making the query</h3>
+
+<p>
+To query a content provider, you can use either the
+<code>{@link android.content.ContentResolver#query ContentResolver.query()}</code>
+method or the <code>{@link android.app.Activity#managedQuery
+Activity.managedQuery()}</code> method.
+Both methods take the same set of arguments, and both return a
+Cursor object. However, {@code managedQuery()}
+causes the activity to manage the life cycle of the Cursor. A managed Cursor
+handles all of the niceties, such as unloading itself when the activity pauses,
+and requerying itself when the activity restarts. You can ask an Activity to
+begin managing an unmanaged Cursor object for you by calling
+<code>{@link android.app.Activity#startManagingCursor
+Activity.startManagingCursor()}</code>.
+
+<p>
+The first argument to either <code>{@link android.content.ContentResolver#query query()}</code>
+or <code>{@link android.app.Activity#managedQuery managedQuery()}</code> is the provider URI
+&mdash; the {@code CONTENT_URI} constant that identifies a particular
+ContentProvider and data set (see <a href="#uri">URIs</a> earlier).
+
+<p>
+To restrict a query to just one record, you can append the {@code _ID} value for
+that record to the URI &mdash; that is, place a string matching the ID as the
+last segment of the path part of the URI. For example, if the ID is 23,
+the URI would be:
+
+<dl><dd>{@code content://. . . ./23}</dd></dl>
+
+<p>
+There are some helper methods, particularly
+<code>{@link android.content.ContentUris#withAppendedId
+ContentUris.withAppendedId()}</code> and <code>{@link
+android.net.Uri#withAppendedPath Uri.withAppendedPath()}</code>,
+that make it easy to append an ID to a URI. Both are static methods that return
+a Uri object with the ID added. So, for example, if you were looking for record
+23 in the database of people contacts, you might construct a query as follows:
+
+<pre>
+import android.provider.Contacts.People;
+import android.content.ContentUris;
+import android.net.Uri;
+import android.database.Cursor;
+
+// Use the ContentUris method to produce the base URI for the contact with _ID == 23.
+Uri myPerson = ContentUris.withAppendedId(People.CONTENT_URI, 23);
+
+// Alternatively, use the Uri method to produce the base URI.
+// It takes a string rather than an integer.
+Uri myPerson = Uri.withAppendedPath(People.CONTENT_URI, "23");
+
+// Then query for this specific record:
+Cursor cur = managedQuery(myPerson, null, null, null, null);
+</pre>
+
+<p>
+The other arguments to the <code>{@link android.content.ContentResolver#query query()}</code>
+and <code>{@link android.app.Activity#managedQuery managedQuery()}</code> methods delimit
+the query in more detail. They are:
+
+<ul>
+<p><li>The names of the data columns that should be returned. A {@code null}
+value returns all columns. Otherwise, only columns that are listed by name
+are returned. All the content providers that come with the platform define
+constants for their columns. For example, the
+{@link android.provider.Contacts.Phones android.provider.Contacts.Phones} class
+defines constants for the names of the columns in the phone table illustrated
+earlier &mdash {@code _ID}, {@code NUMBER}, {@code NUMBER_KEY}, {@code NAME},
+and so on.
+
+<p><li>A filter detailing which rows to return, formatted as an SQL {@code WHERE}
+clause (excluding the {@code WHERE} itself). A {@code null} value returns
+all rows (unless the URI limits the query to a single record).
+
+<p><li>Selection arguments.
+
+<p><li>A sorting order for the rows that are returned, formatted as an SQL
+{@code ORDER BY} clause (excluding the {@code ORDER BY} itself). A {@code null} value
+returns the records in the default order for the table, which may be
+unordered.
+</ul>
+
+<p>
+Let's look at an example query to retrieve a list of contact names and their
+primary phone numbers:
+
+<pre>
+import android.provider.Contacts.People;
+import android.database.Cursor;
+
+// Form an array specifying which columns to return.
+String[] projection = new String[] {
+ People._ID,
+ People._COUNT,
+ People.NAME,
+ People.NUMBER
+ };
+
+// Get the base URI for the People table in the Contacts content provider.
+Uri contacts = People.CONTENT_URI;
+
+// Make the query.
+Cursor managedCursor = managedQuery(contacts,
+ projection, // Which columns to return
+ null, // Which rows to return (all rows)
+ null, // Selection arguments (none)
+ // Put the results in ascending order by name
+ People.NAME + " ASC");
+</pre>
+
+<p>
+This query retrieves data from the People table of the Contacts content
+provider. It gets the name, primary phone number, and unique record ID for
+each contact. It also reports the number of records that are returned as
+the {@code _COUNT} field of each record.
+
+<p>
+The constants for the names of the columns are defined in various interfaces
+&mdash; {@code _ID} and {@code _COUNT} in
+{@link android.provider.BaseColumns BaseColumns}, {@code NAME} in {@link android.provider.Contacts.PeopleColumns PeopleColumns}, and {@code NUMBER}
+in {@link android.provider.Contacts.PhonesColumns PhoneColumns}. The
+{@link android.provider.Contacts.People Contacts.People} class implements
+each of these interfaces, which is why the code example above could refer
+to them using just the class name.
+
+
+<h3>What a query returns</h3>
+
+<p>
+A query returns a set of zero or more database records. The names of the
+columns, their default order, and their data types are specific to each
+content provider.
+But every provider has an {@code _ID} column, which holds a unique numeric
+ID for each record. Every provider can also report the number
+of records returned as the {@code _COUNT} column; its value
+is the same for all rows.
+
+<p>
+Here is an example result set for the query in the previous section:
+
+<table border="1">
+ <tbody>
+ <tr>
+ <th scope="col">_ID</th>
+ <th scope="col">_COUNT</th>
+ <th scope="col">NAME</th>
+ <th scope="col">NUMBER</th>
+ </tr>
+ <tr>
+ <td>44</td>
+ <td>3</td>
+ <td>Alan Vain</td>
+ <td>212 555 1234</td>
+ </tr>
+ <tr>
+ <td>13</td>
+ <td>3</td>
+ <td>Bully Pulpit</td>
+ <td>425 555 6677</td>
+ </tr>
+ <tr>
+ <td>53</td>
+ <td>3</td>
+ <td>Rex Cars</td>
+ <td>201 555 4433</td>
+ </tr>
+ </tbody>
+</table>
+
+<p>
+The retrieved data is exposed by a {@link android.database.Cursor Cursor}
+object that can be used to iterate backward or forward through the result
+set. You can use this object only to read the data. To add, modify, or
+delete data, you must use a ContentResolver object.
+
+
+<h3>Reading retrieved data</h3>
+
+<p>
+The Cursor object returned by a query provides access to a recordset of
+results. If you have queried for a specific record by ID, this set will
+contain only one value. Otherwise, it can contain multiple values.
+(If there are no matches, it can also be empty.) You
+can read data from specific fields in the record, but you must know the
+data type of the field, because the Cursor object has a separate method
+for reading each type of data &mdash; such as <code>{@link
+android.database.Cursor#getString getString()}</code>, <code>{@link
+android.database.Cursor#getInt getInt()}</code>, and <code>{@link
+android.database.Cursor#getFloat getFloat()}</code>.
+(However, for most types, if you call the method for reading strings,
+the Cursor object will give you the String representation of the data.)
+The Cursor lets you request the column name from the index of the column,
+or the index number from the column name.
+
+<p>
+The following snippet demonstrates reading names and phone numbers from
+the query illustrated earlier:
+
+<pre>
+import android.provider.Contacts.People;
+
+private void getColumnData(Cursor cur){
+ if (cur.moveToFirst()) {
+
+ String name;
+ String phoneNumber;
+ int nameColumn = cur.getColumnIndex(People.NAME);
+ int phoneColumn = cur.getColumnIndex(People.NUMBER);
+ String imagePath;
+
+ do {
+ // Get the field values
+ name = cur.getString(nameColumn);
+ phoneNumber = cur.getString(phoneColumn);
+
+ // Do something with the values.
+ ...
+
+ } while (cur.moveToNext());
+
+ }
+}
+</pre>
+
+<p>
+If a query can return binary data, such as an image or sound, the data
+may be directly entered in the table or the table entry for that data may be
+a string specifying a {@code content:} URI that you can use to get the data.
+In general, smaller amounts of data (say, from 20 to 50K or less) are most often
+directly entered in the table and can be read by calling
+<code>{@link android.database.Cursor#getBlob Cursor.getBlob()}</code>.
+It returns a byte array.
+
+<p>
+If the table entry is a {@code content:} URI, you should never try to open
+and read the file directly (for one thing, permissions problems can make this
+fail). Instead, you should call
+<code>{@link android.content.ContentResolver#openInputStream
+ContentResolver.openInputStream()}</code> to get an
+{@link java.io.InputStream} object that you can use to read the data.
+
+
+<h2>Modifying Data<a name="modifying"></a></h2>
+
+<p>
+Data kept by a content provider can be modified by:
+
+<ul>
+<p><li>Adding new records
+<li>Adding new values to existing records
+<li>Batch updating existing records
+<li>Deleting records
+</ul>
+
+<p>
+All data modification is accomplished using {@link android.content.ContentResolver}
+methods. Some content providers require a more restrictive permission for writing
+data than they do for reading it. If you don't have permission to write to a
+content provider, the ContentResolver methods will fail.
+
+
+<h3>Adding records</h3>
+
+<p>
+To add a new record to a content provider, first set up a map of key-value pairs
+in a {@link android.content.ContentValues} object, where each key matches
+the name of a column in the content provider and the value is the desired
+value for the new record in that column. Then call <code>{@link
+android.content.ContentResolver#insert ContentResolver.insert()}</code> and pass
+it the URI of the provider and the ContentValues map. This method returns
+the full URI of the new record &mdash; that is, the provider's URI with
+the appended ID for the new record. You can then use this URI to query and
+get a Cursor over the new record, and to further modify the record.
+Here's an example:
+
+<pre>
+import android.provider.Contacts.People;
+import android.content.ContentResolver;
+import android.content.ContentValues;
+
+ContentValues values = new ContentValues();
+
+// Add Abraham Lincoln to contacts and make him a favorite.
+values.put(People.NAME, "Abraham Lincoln");
+// 1 = the new contact is added to favorites
+// 0 = the new contact is not added to favorites
+values.put(People.STARRED, 1);
+
+Uri uri = getContentResolver().insert(People.CONTENT_URI, values);
+</pre>
+
+
+<h3>Adding new values</h3>
+
+<p>
+Once a record exists, you can add new information to it or modify
+existing information. For example, the next step in the example above would
+be to add contact information &mdash; like a phone number or an IM or e-mail
+address &mdash; to the new entry.
+
+<p>
+The best way to add to a record in the Contacts database is to append
+the name of the table where the new data goes to the URI for the
+record, then use the amended URI to add the new data values. Each
+Contacts table exposes a name for this purpose as a {@code
+CONTENT_DIRECTORY} constant. The following code continues the previous
+example by adding a phone number and e-mail address for the record
+just created:
+
+<pre>
+Uri phoneUri = null;
+Uri emailUri = null;
+
+// Add a phone number for Abraham Lincoln. Begin with the URI for
+// the new record just returned by insert(); it ends with the _ID
+// of the new record, so we don't have to add the ID ourselves.
+// Then append the designation for the phone table to this URI,
+// and use the resulting URI to insert the phone number.
+phoneUri = Uri.withAppendedPath(uri, People.Phones.CONTENT_DIRECTORY);
+
+values.clear();
+values.put(People.Phones.TYPE, People.Phones.TYPE_MOBILE);
+values.put(People.Phones.NUMBER, "1233214567");
+getContentResolver().insert(phoneUri, values);
+
+// Now add an email address in the same way.
+emailUri = Uri.withAppendedPath(uri, People.ContactMethods.CONTENT_DIRECTORY);
+
+values.clear();
+// ContactMethods.KIND is used to distinguish different kinds of
+// contact methods, such as email, IM, etc.
+values.put(People.ContactMethods.KIND, Contacts.KIND_EMAIL);
+values.put(People.ContactMethods.DATA, "test@example.com");
+values.put(People.ContactMethods.TYPE, People.ContactMethods.TYPE_HOME);
+getContentResolver().insert(emailUri, values);
+</pre>
+
+<p>
+You can place small amounts of binary data into a table by calling
+the version of <code>{@link android.content.ContentValues#put
+ContentValues.put()}</code> that takes a byte array.
+That would work for a small icon-like image or a short audio clip, for example.
+However, if you have a large amount of binary data to add, such as a photograph
+or a complete song, put a {@code content:} URI for the data in the table and call
+<code>{@link android.content.ContentResolver#openOutputStream
+ContentResolver.openOutputStream()}</code>
+with the file's URI. (That causes the content provider to store the data
+in a file and record the file path in a hidden field of the record.)
+
+<p>
+In this regard, the {@link android.provider.MediaStore} content
+provider, the main provider that dispenses image, audio, and video
+data, employs a special convention: The same URI that is used with
+{@code query()} or {@code managedQuery()} to get meta-information
+about the binary data (such as, the caption of a photograph or the
+date it was taken) is used with {@code openInputStream()}
+to get the data itself. Similarly, the same URI that is used with
+{@code insert()} to put meta-information into a MediaStore record
+is used with {@code openOutputStream()} to place the binary data there.
+The following code snippet illustrates this convention:
+
+<pre>
+import android.provider.MediaStore.Images.Media;
+import android.content.ContentValues;
+import java.io.OutputStream;
+
+// Save the name and description of an image in a ContentValues map.
+ContentValues values = new ContentValues(3);
+values.put(Media.DISPLAY_NAME, "road_trip_1");
+values.put(Media.DESCRIPTION, "Day 1, trip to Los Angeles");
+values.put(Media.MIME_TYPE, "image/jpeg");
+
+// Add a new record without the bitmap, but with the values just set.
+// insert() returns the URI of the new record.
+Uri uri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI, values);
+
+// Now get a handle to the file for that record, and save the data into it.
+// Here, sourceBitmap is a Bitmap object representing the file to save to the database.
+try {
+ OutputStream outStream = getContentResolver().openOutputStream(uri);
+ sourceBitmap.compress(Bitmap.CompressFormat.JPEG, 50, outStream);
+ outStream.close();
+} catch (Exception e) {
+ Log.e(TAG, "exception while writing image", e);
+}
+</pre>
+
+
+<h3>Batch updating records</h3>
+
+<p>
+To batch update a group of records (for example, to change "NY" to "New York"
+in all fields), call the <code>{@link
+android.content.ContentResolver#update ContentResolver.update()}</code>
+method with the columns and values to change.
+
+
+<h3>Deleting a record <a name="deletingrecord"></a></h3>
+
+<p>
+To delete a single record, call {<code>{@link
+android.content.ContentResolver#delete ContentResolver.delete()}</code>
+with the URI of a specific row.
+
+<p>
+To delete multiple rows, call <code>{@link
+android.content.ContentResolver#delete ContentResolver.delete()}</code>
+with the URI of the type of record to delete (for example, {@code android.provider.Contacts.People.CONTENT_URI}) and an SQL {@code WHERE}
+clause defining which rows to delete. (<i><b>Caution</b>:
+Be sure to include a valid {@code WHERE} clause if you're deleting a general
+type, or you risk deleting more records than you intended!</i>).
+
+
+<h2>Creating a Content Provider<a name="creating"></a></h2>
+
+<p>
+To create a content provider, you must:
+
+<ul>
+<p><li>Set up a system for storing the data. Most content providers
+store their data using Android's file storage methods or SQLite databases,
+but you can store your data any way you want. Android provides the
+{@link android.database.sqlite.SQLiteOpenHelper SQLiteOpenHelper}
+class to help you create a database and {@link
+android.database.sqlite.SQLiteDatabase SQLiteDatabase} to manage it.
+
+<p><li>Extend the {@link android.content.ContentProvider} class to provide
+access to the data.
+
+<p><li>Declare the content provider in the manifest file for your
+application (AndroidManifest.xml).
+</ul>
+
+<p>
+The following sections have notes on the last two of these tasks.
+
+
+<h3>Extending the ContentProvider class</h3>
+
+<p>
+You define a {@link android.content.ContentProvider} subclass to
+expose your data to others using the conventions expected by
+ContentResolver and Cursor objects. Principally, this means
+implementing six abstract methods declared in the ContentProvider class:
+
+<dl><dd>{@code query()}
+<br/>{@code insert()}
+<br/>{@code update()}
+<br/>{@code delete()}
+<br/>{@code getType()}
+<br/>{@code onCreate()}</dd></dl>
+
+<p>
+The {@code query()} method must return a {@link android.database.Cursor} object
+that can iterate over the requested data. Cursor itself is an interface, but
+Android provides some ready-made Cursor objects that you can use. For example,
+{@link android.database.sqlite.SQLiteCursor} can iterate over data stored in
+an SQLite database. You get the Cursor object by calling any of the {@link
+android.database.sqlite.SQLiteDatabase SQLiteDatabase} class's {@code query()}
+methods. There are other Cursor implementations &mdash; such as {@link
+android.database.MatrixCursor} &mdash; for data not stored in a database.
+
+<p>
+As a courtesy, you might also want to call <code>{@link android.content.ContentResolver#notifyChange(android.net.Uri,android.database.ContentObserver)
+ContentResolver.notifyChange()}</code> to notify listeners when there are
+modifications to the data.
+
+<p>
+Beyond defining the subclass itself, there are other steps you should take
+to simplify the work of clients and make the class more accessible:
+
+<ul>
+<p>
+<li>Define a {@code public static final} {@link android.net.Uri}
+named {@code CONTENT_URI}. This is the string that represents the full
+{@code content:} URI that your content provider handles. You must define a
+unique string for this value. The best solution is to use the fully-qualified
+class name of the content provider (made lowercase). So, for example, the
+URI for a TransportationProvider class could be defined as follows:
+
+<pre>public static final Uri CONTENT_URI =
+ Uri.parse("content://com.example.codelab.transporationprovider");</pre>
+
+<p>
+If the provider has subtables, also define {@code CONTENT_URI} constants for
+each of the subtables. These URIs should all have the same authority (since
+that identifies the content provider), and be distinguished only by their paths.
+For example:
+
+<dl><dd>{@code content://com.example.codelab.transporationprovider/train}
+<br/>{@code content://com.example.codelab.transporationprovider/air/domestic}
+<br/>{@code content://com.example.codelab.transporationprovider/air/international}</dd></dl>
+
+<p>
+For an overview of {@code content:} URIs, see the <a href="#urisum">Content URI
+Summary</a> at the end of this document.
+
+<p>
+<li>Define the column names that the content provider will return to clients.
+If you are using an underlying database, these column names are typically
+identical to the SQL database column names they represent. Also define
+{@code public static} String constants that clients can use to specify
+the columns in queries and other instructions.
+
+<p>
+Be sure to include an integer column named "{@code _id}"
+(with the constant {@code _ID}) for
+the IDs of the records. You should have this field whether or not you have
+another field (such as a URL) that is also unique among all records. If
+you're using the SQLite database, the {@code _ID} field should be the
+following type:
+
+<dl><dd>{@code INTEGER PRIMARY KEY AUTOINCREMENT}</dd></dl>
+
+<p>
+The {@code AUTOINCREMENT} descriptor is optional. But without it, SQLite
+increments an ID counter field to the next number above the largest
+existing number in the column. If you delete the last row, the next row added
+will have the same ID as the deleted row. {@code AUTOINCREMENT} avoids this
+by having SQLite increment to the next largest value whether deleted or not.
+
+<p>
+<li>Carefully document the data type of each column. Clients need this
+information to read the data.
+
+<p>
+<li>If you are handling a new data type, you must define a new MIME type
+to return in your implementation of <code>{@link
+android.content.ContentProvider#getType ContentProvider.getType()}</code>.
+The type depends in part on whether or not the {@code content:} URI submitted
+to {@code getType()} limits the request to a specific record. There's one
+form of the MIME type for a single record and another for multiple records.
+Use the {@link android.net.Uri Uri} methods to help determine what is being
+requested. Here is the general format for each type:
+
+<ul>
+<p><li>For a single record:
+
+<dl><dd>{@code vnd.android.cursor.item/vnd.<em>yourcompanyname.contenttype</em}</dd></dl>
+
+<p>For example, a request for train record 122 such as the following URI,
+
+<dl><dd>{@code content://com.example.transportationprovider/trains/122}</dd></dl>
+
+<p>might return this MIME type:
+
+<dl><dd>{@code vnd.android.cursor.item/vnd.example.rail}</dd></dl>.
+
+<p>
+<li>For multiple records:
+
+<dl><dd>{@code vnd.android.cursor.dir/vnd.<em>yourcompanyname.contenttype</em>}</dd></dl>
+
+<p>For example, a request for all train records like the following URI,
+
+<dl><dd>{@code content://com.example.transportationprovider/trains}</dd></dl>
+
+<p>might return this MIME type
+
+<dl><dd>{@code vnd.android.cursor.dir/vnd.example.rail}</dd></dl>
+</ul>
+
+<p>
+<li>If you are exposing byte data that's too big to put in the table itself
+&mdash; such as a large bitmap file &mdash; the field that exposes the
+data to clients should actually contain a {@code content:} URI string.
+This is the field that gives clients access to the data file. The record
+should also have another field, named "{@code _data}" that lists the exact file
+path on the device for that file. This field is not intended to be read by
+the client, but by the ContentResolver. The client will call <code>{@link
+android.content.ContentResolver#openInputStream ContentResolver.openInputStream()}</code>
+on the user-facing field holding the URI for the item. The ContentResolver
+will request the "{@code _data}" field for that record, and because
+it has higher permissions than a client, it should be able to access
+that file directly and return a read wrapper for the file to the client.
+
+</ul>
+
+<p>
+For an example of a private content provider implementation, see the
+NodePadProvider class in the notepad sample application that ships with the SDK.
+
+
+<h3>Declaring the content provider</h3>
+
+<p>
+To let the Android system know about the content provider you've developed,
+declare it with a {@code &lt;provider&gt;} element in the application's
+AndroidManifest.xml file. Content providers that are not declared in the
+manifest are not visible to the Android system
+
+<p>
+The {@code name} attribute is the fully qualified name of the ContentProvider
+subclass. The {@code authorities} attribute is the authority part of the
+{@code content:} URI that identifies the provider.
+For example if the ContentProvider subclass is AutoInfoProvider, the
+{@code &lt;provider&gt;} element might look like this:
+
+<pre>
+&lt;provider name="com.example.autos.AutoInfoProvider"
+ authorities="com.example.autos.autoinfoprovider"
+ . . . /&gt
+&lt;/provider&gt;
+</pre>
+
+<p>
+Note that the {@code authorities} attribute omits the path part of a
+{@code content:} URI. For example, if AutoInfoProvider controlled subtables
+for different types of autos or different manufacturers,
+
+<dl><dd>{@code content://com.example.autos.autoinfoprovider/honda}
+<br/>{@code content://com.example.autos.autoinfoprovider/gm/compact}
+<br/>{@code content://com.example.autos.autoinfoprovider/gm/suv}</dd></dl>
+
+<p>
+those paths would not be declared in the manifest. The authority
+identifies the provider; your provider can interpret the path part of the
+URI in any way you choose.
+
+<p>
+Other {@code &lt;provider&gt;} attributes can set permissions to read and
+write data, provide for an icon and text that can be displayed to users,
+enable and disable the provider, and so on. Set the {@code multiprocess}
+attribute to "{@code true}" if data does not need to be synchronized between
+multiple running versions of the content provider. This permits an instance
+of the provider to be created in each client process, eliminating the need
+to perform IPC.
+
+
+<h2>Content URI Summary</h2><a name="urisum"></a>
+
+<p>
+Here is a recap of the important parts of a content URI:
+
+<p>
+<img src="../../images/content_uri.png" alt="Elements of a content URI"
+height="80" width="528">
+
+<ol type="A">
+<p><li>Standard prefix indicating that the data is controlled by a
+content provider. It's never modified. </li>
+
+<p><li>The authority part of the URI; it identifies the content provider.
+For third-party applications, this should be a fully-qualified class name
+(reduced to lowercase) to ensure uniqueness. The authority is declared in
+the {@code &lt;provider&gt;} element's {@code authorities} attribute:
+
+<pre>&lt;provider name=".TransportationProvider"
+ authorities="com.example.transportationprovider"
+ . . . &gt;</pre>
+
+<p><li>The path that the content provider uses to determine what kind of data is
+being requested. This can be zero or more segments long. If the content provider
+exposes only one type of data (only trains, for example), it can be absent.
+If the provider exposes several types, including subtypes, it can be several
+segments long &mdash; for example, "{@code land/bus}", "{@code land/train}",
+"{@code sea/ship}", and "{@code sea/submarine}" to give four possibilities.
+
+<p><li>The ID of the specific record being requested, if any. This is the
+{@code _ID} value of the requested record. If the request is not limited to
+a single record, this segment and the trailing slash are omitted:
+
+<dl><dd>{@code content://com.example.transportationprovider/trains}</dd></dl>
+</ol>
+
+
diff --git a/docs/html/guide/topics/resources/available-resources.jd b/docs/html/guide/topics/resources/available-resources.jd
new file mode 100644
index 0000000..bfe360e
--- /dev/null
+++ b/docs/html/guide/topics/resources/available-resources.jd
@@ -0,0 +1,1211 @@
+page.title=Available Resource Types
+@jd:body
+
+<p>This page describes the different types of resources that you can
+externalize from your code and package with your application. They fall into
+the following groups:</p>
+<ul>
+ <li><a href="#simplevalues">Simple Values</a></li>
+ <li><a href="#drawables">Drawables</a></li>
+ <li><a href="#animation">Animation</a></li>
+ <li><a href="#layoutresources">Layout</a></li>
+ <li><a href="#stylesandthemes">Styles and Themes</a></li>
+</ul>
+
+<p>For more details on how to use resources in your application, please see the
+ <a href="{@docRoot}devel/resources-i18n.html">Resources and i18n</a>
+ documentation.</p>
+
+<a name="simplevalues" id="simplevalues"></a>
+<h2>Simple Values</h2>
+
+<p>All simple resource values can be expressed as a string, using various
+formats to unambiguously indicate the type of resource being created. For
+this reason, these values can be defined both as standard resources
+(under res/values), as well as direct values supplied for
+mappings in <a href="#stylesandthemes">styles and themes</a>, and attributes in
+XML files such as <a href="#layoutresources">layouts</a>.</p>
+
+<ul>
+ <li><a href="#colorvals">Colors</a></li>
+ <li><a href="#stringresources">Strings and Styled Text</a></li>
+ <li><a href="#dimension">Dimensions</a></li>
+</ul>
+
+
+<a name="colorvals" id="colorvals"></a>
+<h3>Color Values</h3>
+<p>
+ A color value specifies an RGB value with an alpha channel, which can
+ be used in various places such as specifying a solid color for a Drawable
+ or the color to use for text. A color value always begins with
+ a '#' character and then is followed by the alpha-red-green-blue information
+ in one of the following formats:
+</p>
+<ul>
+<li> #RGB
+<li> #ARGB
+<li> #RRGGBB
+<li> #AARRGGBB
+</ul>
+<p>
+ If you want to retrieve the color represented by a resource ID, you can call
+ the {@link android.content.res.Resources#getColor(int) Resources.getColor()} method.
+</p>
+<p>
+ <strong>Source file format:</strong> XML file requiring a
+ <code>&lt;?xml version="1.0" encoding="utf-8"?&gt;</code> declaration, and
+ a root <code>&lt;resources&gt;</code> element containing one or more
+ <code>&lt;color&gt;</code> tags.
+</p>
+<p>
+ <strong>Resource source file location</strong>: res/values/<em>colors</em>.xml (file name is arbitrary)
+</p>
+<p>
+ <strong>Compiled resource datatype:</strong> Resource pointer to a Java int.
+</p>
+<p>
+ <strong>Resource reference name:</strong>
+</p>
+<ul>
+ <li>
+ <strong>Java</strong> <code>R.color.<em>some_name</em></code>
+ </li>
+ <li>
+ <strong>XML</strong> <code>@[<em>package</em>:]color/some_name</code> (where <em>some_name</em> is the <em>name</em> of a specific color)
+ </li>
+</ul>
+<p>
+ <strong>Syntax</strong>
+</p>
+<pre>
+&lt;color name=<em>color_name</em>&gt;<em>#color_value</em>&lt;/color&gt;
+</pre>
+<dl>
+ <dt>
+ &lt;color&gt;
+ </dt>
+ <dd>
+ Value is a color, using web-style syntax, as describe above. Has only one attribute:
+ <ul>
+ <li>
+ <em>name</em> - The name used in referring to this color.
+ </li>
+ </ul>
+ </dd>
+</dl>
+<p>
+ <strong>Example XML Declaration</strong>
+</p>
+<p>
+ The following code declares two colors, the first fully opaque, and the
+ second translucent.
+</p>
+<pre>
+&lt;resources&gt;
+ &lt;color name="opaque_red"&gt;#f00&lt;/color&gt;
+ &lt;color name="translucent_red"&gt;#80ff0000&lt;/color&gt;
+&lt;/resources&gt;
+</pre>
+<p>
+ <strong>Example Code Use</strong>
+</p>
+<p>
+ Example Java code
+</p>
+<pre>
+// Retrieve a color value.
+int color = getResources.getColor(R.color.opaque_red);
+</pre>
+<p>
+ Example XML code
+</p>
+<pre>
+&lt;TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textAlign="center"
+ android:textColor="@color/translucent_red"
+ android:text="Some Text"/&gt;
+</pre>
+
+<a name="stringresources" id="stringresources"></a>
+<h3>Strings and Styled Text</h3>
+<p>
+ Strings, with optional <a href="#styledtext">simple formatting</a>, can be
+stored and retrieved as resources. You can add formatting to your string by
+using three standard HTML tags: &lt;b&gt;, &lt;i&gt;, and &lt;u&gt;. To
+guarantee getting an unstyled string only (the raw text) call the
+<code>toString()</code> method of the retrieved CharSequence object.
+Methods that accept string resources should be able to process these styling
+tags.
+</p>
+<p>
+ If you want to retrieve the String represented by a resource ID, you can call the {@link android.content.Context#getString(int) Context.getString()} method.
+</p>
+<p>
+ <strong>Note:</strong> If you use an apostrophe or a quote in your string, you must either escape it or enclose the whole string in the other kind of enclosing quotes:
+</p>
+<pre>
+&lt;string name="good_example"&gt;"This'll work"&lt;/string&gt;
+&lt;string name="good_example_2"&gt;This\'ll also work&lt;/string&gt;
+&lt;string name="bad_example"&gt;This won't work!&lt;/string&gt;
+&lt;string name="bad_example_2"&gt;XML encodings won&amp;apos;t work either!&lt;/string&gt;
+</pre>
+<p>
+ <strong>Source file format:</strong> XML file requiring a <code>&lt;?xml version="1.0" encoding="utf-8"?&gt;</code> declaration, and a root <code>&lt;resources&gt;</code> element containing one or more <code>&lt;string&gt;</code> tags.
+</p>
+<p>
+ <strong>Resource source file location</strong>: res/values/<em>strings</em>.xml (file name is arbitrary)
+</p>
+<p>
+ <strong>Compiled resource datatype:</strong> Resource pointer to a Java CharSequence.
+</p>
+<p>
+ <strong>Resource reference name:</strong>
+</p>
+<ul>
+ <li>
+ <strong>Java</strong> <code>R.string.<em>some_name</em></code>
+ </li>
+ <li>
+ <strong>XML</strong> <code>@[<em>package</em>:]string/some_name</code> (where <em>some_name</em> is the <em>name</em> of a specific string)
+ </li>
+</ul>
+<p>
+ <strong>Syntax</strong>
+</p>
+<pre>
+&lt;string name=<em>string_name</em>&gt;<em>string_value</em>&lt;/string&gt;
+</pre>
+<dl>
+ <dt>
+ &lt;string&gt;
+ </dt>
+ <dd>
+ Value is a string, with optional styling tags. Has only one attribute:
+ <ul>
+ <li>
+ <em>name</em> - The name used in referring to this string.
+ </li>
+ </ul>
+ </dd>
+</dl>
+<p>
+ <strong>Example XML Declaration</strong>
+</p>
+<p>
+ The following declares two strings: the first &mdash; simple text with no
+ formatting (resulting in a CharSequence that is simply a String object) &mdash; the second includes formatting information in the string (resulting
+ in a CharSequence that is a complex data structure). If you are using the custom editor for string files in Eclipse, the HTML formatting tags will automatically be escaped and you will need to use {@link android.content.Context#getString(int) Context.getString()} and {@link android.text.Html#fromHtml} to retreive the resource and then convert it to formatted text.
+</p>
+<pre>
+&lt;resources&gt;
+ &lt;string name="simple_welcome_message"&gt;Welcome!&lt;/string&gt;
+ &lt;string name="styled_welcome_message"&gt;We are &lt;b&gt;&lt;i&gt;so&lt;/i&gt;&lt;/b&gt; glad to see you.&lt;/string&gt;
+&lt;/resources&gt;
+</pre>
+<p>
+ <strong>Example Code Use</strong>
+</p>
+<p>
+ Example Java code
+</p>
+<pre>
+// Assign a styled string resource to a TextView
+// on the current screen.
+CharSequence str = getString(R.string.styled_welcome_message);
+TextView tv = (TextView)findViewByID(R.id.text);
+tv.setText(str);
+</pre>
+<p>
+ Example XML code
+</p>
+<pre>
+&lt;TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textAlign="center"
+ android:text="@string/simple_welcome_message"/&gt;
+</pre>
+
+<a name="styledtext" id="styledtext"></a>
+<h4>Using Styled Text as a Format String</h4>
+<p>
+Sometimes you may want to create a styled text resource that is also used as a
+format string. This cannot be done directly because there is no way of passing
+the styled text as the format string argument of String.format()
+without stripping out the style information. The workaround is to store the
+style tags as escaped HTML tags, and then convert the escaped HTML string into
+a styled text after formatting has taken place.
+</p>
+<p>
+To use styled text as a format string, do the following.
+</p>
+<ol>
+ <li>Store your styled text resource as an escaped string, so that the HTML tags in your text resource are not interpreted as if they were XML tags:
+<pre>
+&lt;resources&gt;
+ &lt;string name="search_results_resultsTextFormat"&gt;%1$d results for &amp;lt;b>&amp;amp;quot;%2$s&amp;amp;quot;&amp;lt;/b>&lt;/string&gt;
+&lt;/resources&gt;
+</pre>
+<p>
+In this example the format string has two arguments: <code>%1$d</code> is a decimal number, <code>%2$s</code> is a string.
+</p>
+</li>
+<li>
+ Make sure any String arguments are properly escaped if they might contain '&lt;' or '&amp;' characters.
+The {@link android.text.TextUtils#htmlEncode} method will do this:
+<pre>
+String escapedTitle = TextUtil.htmlEncode(title);
+</pre>
+</li>
+<li>
+ Use String.format() to format the HTML text, then use {@link android.text.Html#fromHtml} to convert the HTML text into styled text:
+<pre>
+String resultsTextFormat = getContext().getResources().getString(R.string.search_results_resultsTextFormat);
+String resultsText = String.format(resultsTextFormat, count, escapedTitle);
+CharSequence styledResults = Html.fromHtml(resultsText);
+</pre>
+</li>
+</ol>
+
+<a name="dimension" id="dimension"></a>
+<h3>Dimension Values</h3>
+<p>You can create common dimensions to use for various screen elements by
+defining dimension values in XML. A dimension resource is a number followed by
+a unit of measurement. For example: 10px, 2in, 5sp. Here are the units of
+measurement supported by Android:</p>
+<dl>
+ <dt>px</dt>
+ <dd>Pixels - corresponds to actual pixels on the screen.</dd>
+
+ <dt>in</dt>
+ <dd>Inches - based on the physical size of the screen.</dd>
+
+ <dt>mm</dt>
+ <dd>Millimeters - based on the physical size of the screen.</dd>
+
+ <dt>pt</dt>
+ <dd>Points - 1/72 of an inch based on the physical size of the screen.</dd>
+
+ <dt>dp</dt>
+ <dd>Density-independent Pixels - an abstract unit that is based on the
+ physical density of the screen. These units are relative to a 160 dpi
+ screen, so one dp is one pixel on a 160 dpi screen. The ratio of
+ dp-to-pixel will change with the screen density, but not necessarily
+ in direct proportion. <strong>Note:</strong> The compiler accepts both "dip" and "dp", though "dp" is more consistent with "sp".</dd>
+
+ <dt>sp</dt>
+ <dd>Scale-independent Pixels - this is like the dp unit, but it is also
+ scaled by the user's font size preference. It is recommend you use this
+ unit when specifying font sizes, so they will be adjusted for both the
+ screen density and user's preference.</dd>
+</dl>
+
+<p>Dimension values are not normally used as raw resources, but rather as
+attribute values in XML files. You can, however, create plain resources
+containing this data type.</p>
+
+<p><strong>Source file format:</strong> XML file requiring a <code>&lt;?xml
+version="1.0" encoding="utf-8"?&gt;</code> declaration, and a root
+<code>&lt;resources&gt;</code> element containing one or more
+<code>&lt;dimen&gt;</code> tags.</p>
+
+<p><strong>Resource source file location</strong>: res/values/dimens.xml (File
+name is arbitrary; standard practice is to put all dimensions in one file
+devoted to dimensions.)</p>
+<p><strong>Compiled resource datatype:</strong> Resource pointer to a
+dimension.</p>
+<p>
+ <strong>Resource reference name:</strong>
+</p>
+<ul>
+ <li>
+ <strong>Java</strong> <code>R.dimen.<em>some_name</em></code>
+ </li>
+ <li>
+ <strong>XML</strong> <code>@[<em>package</em>:]dimen/<em>some_name</em></code> (where <em>some_name</em> is the <em>name</em> of a specific <code>&lt;dimen&gt;</code> element)
+ </li>
+</ul>
+<p>
+ <strong>Syntax</strong>
+</p>
+<pre>
+&lt;dimen name=<em>dimen_name</em>&gt;<em>dimen_value</em>&lt;/dimen&gt;
+</pre>
+<dl>
+ <dt>
+ &lt;dimen&gt;
+ </dt>
+ <dd>
+ A valid dimension value.
+ <ul>
+ <li>
+ <em>name</em> - The name used in referring to this dimension.
+ </li>
+ </ul>
+ </dd>
+</dl>
+<p>
+ <strong>Example XML Declaration</strong>
+</p>
+<p>
+ The following code declares several dimension values.
+</p>
+<pre>
+&lt;resources&gt;
+ &lt;dimen name="one_pixel"&gt;1px&lt;/dimen&gt;
+ &lt;dimen name="double_density"&gt;2dp&lt;/dimen&gt;
+ &lt;dimen name="sixteen_sp"&gt;16sp&lt;/dimen&gt;
+&lt;/resources&gt;
+</pre>
+<p>
+ <strong>Example Code Use</strong>
+</p>
+<p>
+ Example Java code:
+</p>
+<pre>
+float dimen = Resources.getDimen(R.dimen.one_pixel);
+</pre>
+<p>
+ Example XML code:
+</p>
+<pre>
+&lt;TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textSize="@dimen/sixteen_sp"/&gt;
+</pre>
+
+<a name="drawables" id="drawables"></a>
+<h2>Drawables</h2>
+
+<p>A {@link android.graphics.drawable.Drawable} is a type of resource that
+you retrieve with {@link android.content.res.Resources#getDrawable
+Resources.getDrawable()} and use to draw to the screen. There are a
+number of drawable resources that can be created.</p>
+
+<ul>
+ <li><a href="#imagefileresources">Bitmap Drawables</a></li>
+ <li><a href="#colordrawableresources">Color Drawables</a></li>
+ <li><a href="#ninepatch">Nine Patch (Stretchable) Drawables</a></li>
+</ul>
+
+<a name="imagefileresources" id="imagefileresources"></a>
+<h3>Bitmap files</h3>
+<p>Android supports bitmap resource files in a few different formats: png
+(preferred), jpg (acceptable), gif (discouraged). The bitmap file itself is
+compiled and referenced by the file name without the extension (so
+res/drawable/my_picture.png would be referenced as R.drawable.my_picture).</p>
+
+<p>
+ <strong>Source file formats:</strong> png (preferred), jpg (acceptable), gif (discouraged). One resource per file.
+</p>
+<p>
+ <strong>Resource file location</strong>: res/drawable/<em>some_file</em>.png or <em>some_file</em>.jpg or <em>some_file</em>.gif.
+</p>
+<p>
+ <strong>Compiled resource datatype:</strong> Resource pointer to a {@link android.graphics.drawable.BitmapDrawable BitmapDrawable}.
+</p>
+<p>
+ <strong>Resource reference name:</strong>
+</p>
+<ul>
+ <li>
+ <strong>Java</strong> <code>R.drawable.<em>some_file</em></code>
+ </li>
+ <li>
+ <strong>XML</strong> <code>@[<em>package</em>:]drawable/<em>some_file</em></code>
+ </li>
+</ul>
+<p>
+ <strong>Example Code Use</strong>
+</p>
+<p>
+ The following Java snippet demonstrates loading an {@link android.widget.ImageView ImageView} object with a single bitmap from a list of bitmap resources. ImageView is a basic display rectangle for graphics (animations or still images).
+</p>
+<pre>
+// Load an array with BitmapDrawable resources.
+private Integer[] mThumbIds = {
+ R.drawable.sample_thumb_0,
+ R.drawable.sample_thumb_1,
+ R.drawable.sample_thumb_2,
+ R.drawable.sample_thumb_3,
+ R.drawable.sample_thumb_4
+};
+
+// Load and return a view with an image.
+public View getView(int position, ViewGroup parent)
+{
+ ImageView i = new ImageView(mContext);
+ i.setImageResource(mThumbIds[position]);
+ i.setAdjustViewBounds(true);
+ i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
+ i.setBackground(android.R.drawable.picture_frame);
+ return i;
+}
+</pre>
+<p>
+ This XML example demonstrates loading a bitmap file (chat_icon.png) in an ImageView.
+</p>
+<pre>
+&lt;ImageView id="@+id/icon"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:tint="#FF000000"
+ android:src="@drawable/chat_icon"/&gt;
+</pre>
+
+<a name="colordrawableresources" id="colordrawableresources"></a>
+<h3>Color Drawables</h3>
+<p>You can create a {@link android.graphics.drawable.PaintDrawable} object that is a rectangle of color,
+with optionally rounded corners. This element can be defined in any of the
+files inside res/values/.</p>
+<p><strong>Source file format:</strong> XML file requiring a <code>&lt;?xml
+version="1.0" encoding="utf-8"?&gt;</code> declaration, and a root
+<code>&lt;resources&gt;</code> element containing one or more
+<code>&lt;drawable&gt;</code> tags.</p>
+<p>
+ <strong>Resource source file location</strong>: res/values/colors.xml (File name is arbitrary; standard practice is to put the PaintDrawable items in the file along with the <a href="{@docRoot}devel/resources-i18n.html#numericcolorresources">numeric color values</a>.)
+</p>
+<p>
+ <strong>Compiled resource datatype:</strong> Resource pointer to a {@link android.graphics.drawable.PaintDrawable}.
+</p>
+<p>
+ <strong>Resource reference name:</strong>
+</p>
+<ul>
+ <li>
+ <strong>Java</strong> <code>R.drawable.<em>some_name</em></code>
+ </li>
+ <li>
+ <strong>XML</strong> <code>@[<em>package</em>:]drawable/<em>some_name</em></code> (where <em>some_name</em> is the name of a specific resource)
+ </li>
+</ul>
+<p>
+ <strong>Syntax</strong>
+</p>
+<pre>
+&lt;drawable name=<em>color_name</em>&gt;<em>color_value</em>&lt;/drawable&gt;
+</pre>
+<dl>
+ <dt>
+ &lt;drawable&gt;
+ </dt>
+ <dd>
+ A valid <a href="#colorvals">color value</a>.
+ <ul>
+ <li>
+ <em>name</em> - The name used in referring to this drawable.
+ </li>
+ </ul>
+ </dd>
+</dl>
+<p>
+ <strong>Example XML Declaration</strong>
+</p>
+<p>
+ The following code declares several color drawables.
+</p>
+<pre>
+&lt;resources&gt;
+ &lt;drawable name="solid_red"&gt;#f00&lt;/drawable&gt;
+ &lt;drawable name="solid_blue"&gt;#0000ff&lt;/drawable&gt;
+ &lt;drawable name="solid_green"&gt;#f0f0&lt;/drawable&gt;
+&lt;/resources&gt;
+</pre>
+<p>
+ <strong>Example Code Use</strong>
+</p>
+<p>
+ Example Java code
+</p>
+<pre>
+// Assign a PaintDrawable as the background to
+// a TextView on the current screen.
+Drawable redDrawable = Resources.getDrawable(R.drawable.solid_red);
+TextView tv = (TextView)findViewByID(R.id.text);
+tv.setBackground(redDrawable);
+</pre>
+<p>
+ Example XML code
+</p>
+<pre>
+&lt;TextView android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:textAlign="center"
+ android:background="@drawable/solid_red"/&gt;
+</pre>
+
+<a name="ninepatch" id="ninepatch"></a>
+<h3>Nine-Patch Stretchable Image</h3>
+<p>
+ Android supports a stretchable bitmap image, called a
+ {@link android.graphics.NinePatch} graphic. This is a PNG image in which
+ you define stretchable sections that Android will resize to fit the object
+ at display time to accommodate variable sized sections, such as text strings.
+ You typically assign this resource to the View's background. An example use
+ of a stretchable image is the button backgrounds that Android uses; buttons
+ must stretch to accommodate strings of various lengths.
+</p>
+<p>
+ A NinePatch drawing is a standard PNG image that includes a 1 pixel wide
+ border. This border is used to define the stretchable and static areas of
+ the screen. You indicate a stretchable section by drawing one or more 1 pixel
+ wide black lines in the left or top part of this border. You can have as
+ many stretchable sections as you want. The relative size of the stretchable
+ sections stays the same, so the largest sections always remain the largest.
+</p>
+<p>
+ You can also define an optional drawable section of the image (effectively,
+ the padding lines) by drawing a line on the right and bottom lines. If you
+ do not draw these lines, the first top and left lines will be used.
+</p>
+<p>
+ If a View object sets this graphic as a background and then specifies the
+ View object's text, it will stretch itself so that all the text fits inside
+ the area designated by the right and bottom lines (if included). If the
+ padding lines are not included, Android uses the left and top lines to
+ define the writeable area.
+</p>
+<p>The <a href="{@docRoot}reference/draw9patch.html">Draw 9-patch</a> tool offers
+ an extremely handy way to create your NinePatch images, using a
+ WYSIWYG graphics editor.
+</p>
+<p>
+ Here is a sample NinePatch file used to define a button.
+</p>
+<p>
+ <img src="{@docRoot}images/ninepatch_raw.png" alt="Raw ninepatch file
+ showing the definition lines">
+</p>
+<p>
+ This ninepatch uses one single stretchable area, and it also defines a drawable area.
+</p>
+<p>
+ <strong>Source file format:</strong> PNG &mdash; one resource per file
+</p>
+<p>
+ <strong>Resource source file location</strong>: res/drawable/<em>some_name</em>.9.png (must end in .9.png)
+</p>
+<p>
+ <strong>Compiled resource datatype:</strong> Resource pointer to a {@link android.graphics.drawable.NinePatchDrawable NinePatchDrawable}.
+</p>
+<p>
+ <strong>Resource reference name:</strong>
+</p>
+<ul>
+ <li>
+ <strong>Java</strong> <code>R.drawable.<em>some_file</em></code>
+ </li>
+ <li>
+ <strong>XML</strong> <code>@[<em>package</em>:]drawable.<em>some_file</em></code>
+ </li>
+</ul>
+<p>
+ <strong>Example XML Code</strong>
+</p>
+<p>
+ Note that the width and height are set to "wrap_content" to make the button fit neatly around the text.
+</p>
+<pre>
+&lt;Button id="@+id/tiny"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentTop="true"
+ android:layout_centerInParent="true"
+ android:text="Tiny"
+ android:textSize="8sp"
+ android:background="@drawable/my_button_background"/&gt;
+
+&lt;Button id="@+id/big"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentBottom="true"
+ android:layout_centerInParent="true"
+ android:text="Biiiiiiig text!"
+ android:textSize="30sp"
+ android:background="@drawable/my_button_background"/&gt;
+</pre>
+<p>
+ Here are the two buttons based on this XML and the NinePatch graphic shown above. Notice how the width and height of the button varies with the text, and the background image stretches to accommodate it.
+</p>
+<p>
+ <img src="{@docRoot}images/ninepatch_examples.png" alt="Two buttons based on the NinePatch button background">
+</p>
+
+<a name="animation" id="animation"></a>
+<h2>Animation</h2>
+<a name="tweenedanimation" id="tweenedanimation"></a>
+<h3>
+ Tweened Animation
+</h3>
+<p>
+ Android can perform simple animation on a graphic, or a series of graphics. These include rotations, fading, moving, and stretching.
+</p>
+<p>
+ <strong>Source file format:</strong> XML file, one resource per file, one root tag with no <code>&lt;?xml&gt;</code> declaration
+</p>
+<p>
+ <strong>Resource file location</strong>: res/anim/<em>some_file</em>.xml
+</p>
+<p>
+ <strong>Compiled resource datatype:</strong> Resource pointer to an {@link android.view.animation.Animation}.
+</p>
+<p>
+ <strong>Resource reference name:</strong>
+</p>
+<ul>
+ <li>
+ <strong>Java</strong> <code>R.anim.<em>some_file</em></code>
+ </li>
+ <li>
+ <strong>XML</strong> <code>@[<em>package</em>:]anim/<em>some_file</em></code>
+ </li>
+</ul>
+<p>
+ <strong>Syntax</strong>
+</p>
+<p>
+ The file must have a single root element: this will be either a single <code>&lt;alpha&gt;</code>, <code>&lt;scale&gt;</code>, <code>&lt;translate&gt;</code>, <code>&lt;rotate&gt;</code>, interpolator element, or <code>&lt;set&gt;</code> element that holds groups of these elements (which may include another <code>&lt;set&gt;</code>). By default, all elements are applied simultaneously. To have them occur sequentially, you must specify the <code>startOffset</code> attribute, as shown in the example code.
+</p>
+<pre>
+&lt;set android:shareInterpolator=boolean&gt; // Only required if multiple tags are used.
+ &lt;alpha android:fromAlpha=float
+ android:toAlpha=float &gt; |
+ &lt;scale android:fromXScale=float
+ android:toXScale=float
+ android:fromYScale=float
+ android:toYScale=float
+ android:pivotX=string
+ android:pivotY=string&gt; |
+ &lt;translate android:fromX=string
+ android:toX=string
+ android:fromY=string
+ android:toY=string&gt; |
+ &lt;rotate android:fromDegrees=float
+ android:toDegrees=float
+ android:pivotX=string
+ android:pivotY=string /&gt; |
+ &lt;<em>interpolator tag</em>&gt;
+ &lt;set&gt;
+&lt;/set&gt;
+</pre>
+<p>
+ <strong>Elements and Attributes</strong>
+</p>
+<dl>
+ <dt>
+ &lt;set&gt;
+ </dt>
+ <dd>
+ The outermost tag, which can recursively hold itself or other animations. You can include as many child elements of the same or different types as you like. Supports the following attribute:
+ <ul>
+ <li>
+ <em>shareInterpolator</em> - Whether to share the same Interpolator among all immediate child elements.
+ </li>
+ </ul>
+ </dd>
+ <dt>
+ &lt;alpha&gt;
+ </dt>
+ <dd>
+ A fading animation, compiled to {@link android.view.animation.AlphaAnimation}. Supports the following attributes:
+ <ul>
+ <li>
+ <em>fromAlpha</em> - 0.0 to 1.0, where 0.0 is transparent.
+ </li>
+ <li>
+ <em>toAlpha</em> - 0.0 to 1.0, where 0.0 is transparent.
+ </li>
+ </ul>
+ </dd>
+ <dt>
+ &lt;scale&gt;
+ </dt>
+ <dd>
+ A resizing animation, compiled to {@link android.view.animation.ScaleAnimation}. You can specify what is the center point of the image (the pinned center), from which it grows outward (or inward), by specifying pivotX and pivotY. So, for example, if these were 0, 0 (top left corner), all growth would be down and to the right. <code>scale</code> supports the following attributes:
+ <ul>
+ <li>
+ <em>fromXScale</em> - Starting X size, where 1.0 is no change.
+ </li>
+ <li>
+ <em>toXScale</em> - Ending X size, where 1.0 is no change.
+ </li>
+ <li>
+ <em>fromYScale</em> - Starting Y size, where 1.0 is no change.
+ </li>
+ <li>
+ <em>toYScale</em> - Ending Y size, where 1.0 is no change.
+ </li>
+ <li>
+ <em>pivotX</em> - The X coordinate of the pinned center.
+ </li>
+ <li>
+ <em>pivotY</em> - The Y coordinate of the pinned center.
+ </li>
+ </ul>
+ </dd>
+ <dt>
+ &lt;translate&gt;
+ </dt>
+ <dd>
+ A motion animation that moves a visual element within its parent element. It is equivalent to {@link android.view.animation.TranslateAnimation}.
+Supports the following attributes in any of the following three formats: values from -100 to 100, ending with "%", indicating a percentage relative to itself; values from -100 to 100, ending in "%p", indicating a percentage relative to its parent; a float with no suffix, indicating an absolute value.
+ <ul>
+ <li>
+ <em>fromXDelta</em> - Starting X location.
+ </li>
+ <li>
+ <em>toXDelta</em> - Ending X location.
+ </li>
+ <li>
+ <em>fromYDelta</em> - Starting Y location.
+ </li>
+ <li>
+ <em>toYDelta</em> - Ending Y location.
+ </li>
+ </ul>
+ </dd>
+ <dt>
+ &lt;rotate&gt;
+ </dt>
+ <dd>
+ A rotation animation, compiled to {@link android.view.animation.RotateAnimation}. Supports the following attributes:
+ <ul>
+ <li>
+ <em>fromDegrees</em> - Starting rotation, in degrees.
+ </li>
+ <li>
+ <em>toDegrees</em> - Ending rotation, in degrees.
+ </li>
+ <li>
+ <em>pivotX</em> - The X coordinate of the center of rotation, in pixels, where (0,0) is the top left corner.
+ </li>
+ <li>
+ <em>pivotY</em> - The Y coordinate of the center of rotation, in pixels, where (0,0) is the top left corner.
+ </li>
+ </ul>
+ </dd>
+ <dt>
+ <em>&lt;interpolator tag&gt;</em>
+ </dt>
+ <dd>
+ You can also use any of the interpolator subclass elements defined in {@link android.R.styleable}. Examples include &lt;CycleInterpolator&gt;, &lt;EaseInInterpolator&gt;, and &lt;EaseOutInterpolator&gt;. These objects define a velocity curve that describes how quickly a visual action takes place on a timeline (fast at first and slow later, slow at first and gradually faster, and so on).
+ </dd>
+</dl>
+<p>
+ Note that alpha, scale, rotate, translate all support the following attributes from the base animation class, BaseAnimation:
+</p>
+<dl>
+ <dt>
+ <em>duration</em>
+ </dt>
+ <dd>
+ Duration, in milliseconds, for this effect.
+ </dd>
+ <dt>
+ <em>startOffset</em>
+ </dt>
+ <dd>
+ Offset start time for this effect, in milliseconds.
+ </dd>
+ <dt>
+ <em>fillBefore</em>
+ </dt>
+ <dd>
+ Equivalent to {@link android.view.animation.Animation#setFillBefore animation.Animation.setFillBefore()}.
+ </dd>
+ <dt>
+ <em>fillAfter</em>
+ </dt>
+ <dd>
+ Equivalent to {@link android.view.animation.Animation#setFillAfter animation.Animation.setFillAfter()}.
+ </dd>
+ <dt>
+ <em>interpolator</em>
+ </dt>
+ <dd>
+ You can optionally set an interpolator for each element to determine how quickly or slowly it performs its effect over time. For example, slow at the beginning and faster at the end for EaseInInterpolator, and the reverse for EaseOutInterpolator. A list of interpolators is given in {@link android.R.anim}. To specify these, use the syntax @android:anim/<em>interpolatorName</em>.
+ </dd>
+</dl>
+<p>
+ <strong>Example XML Declaration</strong>
+</p>
+<p>
+ The following XML from the ApiDemos application is used to stretch, then simultaneously spin and rotate a block of text.
+</p>
+<pre>
+&lt;set android:shareInterpolator="false"&gt;
+ &lt;scale
+ android:interpolator="&#64;android:anim/ease_in_out_interpolator"
+ android:fromXScale="1.0"
+ android:toXScale="1.4"
+ android:fromYScale="1.0"
+ android:toYScale="0.6"
+ android:pivotX="50%"
+ android:pivotY="50%"
+ android:fillAfter="false"
+ android:duration="700" /&gt;
+ &lt;set android:interpolator="&#64;android:anim/ease_in_interpolator"&gt;
+ &lt;scale
+ android:fromXScale="1.4"
+ android:toXScale="0.0"
+ android:fromYScale="0.6"
+ android:toYScale="0.0"
+ android:pivotX="50%"
+ android:pivotY="50%"
+ android:startOffset="700"
+ android:duration="400"
+ android:fillBefore="false" /&gt;
+ &lt;rotate
+ android:fromDegrees="0"
+ android:toDegrees="-45"
+ android:toYScale="0.0"
+ android:pivotX="50%"
+ android:pivotY="50%"
+ android:startOffset="700"
+ android:duration="400" /&gt;
+ &lt;/set&gt;
+&lt;/set&gt;
+</pre>
+<p>
+ The following Java code loads animations called res/anim/hyperspace_in.xml and res/anim/hyperspace_out.xml into a {@link android.widget.ViewFlipper}.
+</p>
+<pre>
+mFlipper.setInAnimation(AnimationUtils.loadAnimation(this, R.anim.hyperspace_in));
+mFlipper.setOutAnimation(AnimationUtils.loadAnimation(this, R.anim.hyperspace_out));
+</pre>
+
+<a name="layoutresources" id="layoutresources"></a>
+<h2>Layout</h2>
+<p>
+ Android lets you specify screen layouts using XML elements inside an XML file, similar to designing screen layout for a webpage in an HTML file. Each file contains a whole screen or a part of a screen, and is compiled into a View resource that can be passed in to {@link android.app.Activity#setContentView(int) Activity.setContentView} or used as a reference by other layout resource elements. Files are saved in the res/layout/ folder of your project, and compiled by the Android resource compiler aapt.
+</p>
+<p>
+ Every layout XML file must evaluate to a single root element. First we'll describe how to use the standard XML tags understood by Android as it is shipped, and then we'll give a little information on how you can define your own custom XML elements for custom View objects. See <a href="{@docRoot}devel/implementing-ui.html">Implementing a User Interface</a> for details about the visual elements that make up a screen.
+</p>
+<p>
+ The root element must have the Android namespace "http://schemas.android.com/apk/res/android" defined in the root element
+</p>
+<p>
+ <strong>Source file format:</strong> XML file requiring a <code>&lt;?xml version="1.0" encoding="utf-8"?&gt;</code> declaration, and a root element of one of the supported XML layout elements.
+</p>
+<p>
+ <strong>Resource file location</strong>: res/layout/<em>some_file</em>.xml.
+</p>
+<p>
+ <strong>Compiled resource datatype:</strong> Resource pointer to a {@link android.view.View} (or subclass) resource.
+</p>
+<p>
+ <strong>Resource reference name:</strong>
+</p>
+<ul>
+ <li>
+ <strong>Java</strong> <code>R.drawable.<em>some_file</em></code>
+ </li>
+ <li>
+ <strong>XML</strong> <code>@[<em>package</em>:]layout/<em>some_file</em></code>
+ </li>
+</ul>
+<p>
+ <strong>Syntax</strong>
+</p>
+<pre>
+&lt;<em>ViewGroupClass</em> xmlns:android="http://schemas.android.com/apk/res/android"
+ id="@+id/<em>string_name</em>" (attributes)&gt;
+ &lt;<em>widget</em> or other nested <em>ViewGroupClass</em>&gt;+
+ &lt;requestFocus/&gt;(0 or 1 per layout file, assigned to any element)
+&lt;/<em>ViewGroupClass</em>&gt;
+</pre>
+<dl>
+ <dt>
+ &lt;<em>ViewGroupClass</em>&gt;
+ </dt>
+ <dd>
+ <p>The file must have a single root element. This can be a ViewGroup class that contains other elements, or a widget (or custom item) if it's only one object. By default, you can use any (case-sensitive) Android {@link android.widget widget} or {@link android.view.ViewGroup ViewGroup} class name as an element. These elements support attributes that apply to the underlying class, but the naming is not as clear. How to discover what attributes are supported for what tags is discussed below. You should not assume that any nesting is valid (for example you cannot enclose <code>&lt;TextView&gt;</code> elements inside a <code>&lt;ListLayout&gt;</code>).</p>
+ <p>If a class derives from another class, the XML element inherits all the attributes from the element that it "derives" from. So, for example, <code>&lt;EditText&gt;</code> is the corresponding XML element for the EditText class. It exposes its own unique attributes (<code>EditText_numeric</code>), as well as all attributes supported by <code>&lt;TextView&gt;</code> and <code>&lt;View&gt;</code>. For the <em>id</em> attribute of a tag in XML, you should use a special syntax: "@+id/<em>somestringvalue</em>". The "@+" syntax creates a resource number in the R.id class, if one doesn't exist, or uses it, if it does exist. When declaring an ID value for an XML tag, use this syntax. Example: <code>&lt;TextView id="@+id/nameTextbox"/&gt;</code>, and refer to it this way in Java: <code>findViewById(R.id.nameTextbox)</code>. All elements support the following values:</p>
+ <ul>
+ <li>
+ <em>id</em> - An ID value used to access this element in Java. Typically you will use the syntax @+id/<em>string_name</em> to generate an ID for you in the id.xml file if you haven't created one yourself.
+ </li>
+ <li>
+ <code>xmlns:android="http://schemas.android.com/apk/res/android"</code> - <em><strong>Required for the root element only.</strong></em>
+ </li>
+ </ul>
+ </dd>
+ <dt>
+ &lt;requestFocus&gt;
+ </dt>
+ <dd>
+ Any element representing a View object can include this empty element, which gives it's parent tag initial focus on the screen. You can have only one of these elements per file.
+ </dd>
+</dl>
+<p>
+ <strong>What Attributes Are Supported for What Elements?</strong>
+</p>
+<p>
+ Android uses the {@link android.view.LayoutInflater} class at run time to load an XML layout resource and translate it into visual elements. By default, all widget class names are supported directly as tags, but a full list of supported tags and attributes is listed in the {@link android.R.styleable} reference page. However, the attribute names are somewhat obscure. If an underscore appears in the name, this indicates that it is an attribute &mdash; typically of the element before the underscore. So, for example, <code>EditText_autoText</code> means that the <code>&lt;EditText&gt;</code> tag supports an attribute <em>autoText</em>. When you actually use the attribute in that element, use only the portion after the last underscore, and prefix the attribute with the prefix "<code>android:</code>". So, for example, if {@link android.R.styleable} lists the following values:
+</p>
+<ul>
+ <li>
+ <code>TextView</code>
+ </li>
+ <li>
+ <code>TextView_lines</code>
+ </li>
+ <li>
+ <code>TextView_maxlines</code>
+ </li>
+</ul>
+<p>
+ You could create an element like this:
+</p>
+<pre>
+&lt;TextView android:lines="10" android:maxlines="20"/&gt;
+</pre>
+<p>
+ This would create a {@link android.widget.TextView} object and set its lines and maxlines properties.
+</p>
+<p>
+ Attributes come from three sources:
+</p>
+<ul>
+ <li>
+ <strong>Attributes exposed directly by the element.</strong> For example, <code>TextView</code> supports <code>TextView_text</code>, as discussed above.
+ </li>
+ <li>
+ <strong>Attributes exposed by all the superclasses of that element.</strong> For example, the TextView class extends the View class, so the <code>&lt;TextView&gt;</code> element supports all the attributes that the <code>&lt;View&gt;</code> element exposes &mdash; a long list, including <code>View_paddingBottom</code> and <code>View_scrollbars</code>. These too are used without the class name: <code>&lt;TextView android:paddingBottom="20" android:scrollbars="horizontal" /&gt;</code>.
+ </li>
+ <li>
+ <strong>Attributes of the object's {@link android.view.ViewGroup.LayoutParams} subclass.</strong> All View objects support a LayoutParams member (see <a href="{@docRoot}devel/ui/layout.html">LayoutParams in Implementing a UI</a>). To set properties on an element's LayoutParams member, the attribute to use is "android:layout_<em>layoutParamsProperty</em>". For example: <code>android:layout_gravity</code> for an object wrapped by a <code>&lt;LinearLayout&gt;</code> element. Remember that each LayoutParams subclass also supports inherited attributes. Attributes exposed by each subclass are given in the format <em>someLayoutParamsSubclass</em>_Layout_layout_<em>someproperty</em>. This defines an attribute "android:layout_<em>someproperty</em>". Here is an example of how Android documentation lists the properties of the {@link android.widget.LinearLayout.LayoutParams LinearLayout.LayoutParams} class:
+ </li>
+</ul>
+<ul>
+ <li>LinearLayout_Layout // The actual object &mdash; not used.
+ </li>
+ <li>LinearLayout_Layout_layout_gravity // Exposes a <code>gravity</code> attribute
+ </li>
+ <li>LinearLayout_Layout_layout_height // Exposes a <code>height</code> attribute
+ </li>
+ <li>LinearLayout_Layout_layout_weight // Exposes a <code>weight</code> attribute
+ </li>
+ <li>LinearLayout_Layout_layout_width // Exposes a <code>width</code> attribute
+ </li>
+</ul>
+<p>
+ Here is an example that sets some of these values on a few objects, including direct attributes, inherited attributes, and LayoutParams attributes:
+</p>
+<pre>
+&lt;?xml version="1.0" encoding="utf-8"?&gt;
+&lt;!-- res/main_screen.xml --&gt;
+&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" // The object's own orientation property
+ android:padding="4" // Inherited View property
+ android:gravity="center" // The object's own property
+ android:layout_width="fill_parent" // Parent object's LinearLayout.LayoutParams.width
+ android:layout_height="fill_parent"&gt; // Parent object's LinearLayout.LayoutParams.height
+
+ &lt;TextView android:layout_width="fill_parent" // TextView.LayoutParams.width
+ android:layout_height="wrap_content" // TextView.LayoutParams.height
+ android:layout_weight="0" // TextView.LayoutParams.weight
+ android:paddingBottom="4" // TextView.paddingBottom
+ android:text="@string/redirect_getter"/&gt; // TextView.text
+
+ &lt;EditText id="@+id/text"
+ android:layout_width="fill_parent" // EditText.LayoutParams.width
+ android:layout_height="wrap_content" // EditText.LayoutParams.height
+ android:layout_weight="0" // EditText.LinearLayoutParams.weight
+ android:paddingBottom="4"&gt; // EditText.paddingBottom
+ &lt;requestFocus /&gt;
+ &lt;/EditText&gt;
+
+ &lt;Button id="@+id/apply"
+ android:layout_width="wrap_content" // Button.LayoutParams.width
+ android:layout_height="wrap_content" // Button.LayoutParams.height
+ android:text="@string/apply" /&gt; // TextView.text
+&lt;/LinearLayout&gt;
+</pre>
+<p>
+ <strong>Example Code Use</strong>
+</p>
+<p>
+ The most common use is to load the XML file (located at <em>res/main_screen.xml</em>) and use it as the current screen, as shown here with the preceding file:
+</p>
+<pre>
+setContentView(R.layout.main_screen);
+</pre>
+<p>
+ However, layout elements can also represent repeating elements used as templates.
+</p>
+<a name="customresources" id="customresources"></a>
+<h3>Custom Layout Resources</h3>
+<p>
+ You can define custom elements to use in layout resources. These custom elements can then be used the same as any Android layout elements: that is, you can use them and specify their attributes in other resources. The ApiDemos sample application has an example of creating a custom layout XML tag, LabelView. To create a custom element, you will need the following files:
+</p>
+<ul>
+ <li>
+ <strong>Java implementation file</strong> - The implementation file. The class must extend {@link android.view.View View} or a subclass. See LabelView.java in ApiDemos.
+ </li>
+ <li>
+ <strong>res/values/attrs.xml</strong> - Defines the XML element, and the attributes that it supports, for clients to use to instantiate your object in their layout XML file. Define your element in a <code>&lt;declare-styleable id=<em>your_java_class_name</em>&gt;</code>. See res/layout/attrs.xml in ApiDemos.
+ </li>
+ <li>
+ <strong>res/layout/<em>your_class</em>.xml</strong> [<em>optional</em>] - An optional XML file to describe the layout of your object. This could also be done in Java. See custom_view_1.xml in ApiDemos.
+ </li>
+</ul>
+<p>
+ <strong>Source file format:</strong> XML file without an <code>&lt;?xml&gt;</code> declaration, and a <code>&lt;resources&gt;</code> root element containing one or more custom element tags.
+</p>
+<p>
+ <strong>Resource file location</strong>: res/values/<em>attrs</em>.xml (file name is arbitrary).
+</p>
+<p>
+ <strong>Compiled resource datatype:</strong> Resource pointer to a {@link android.view.View} (or subclass) resource.
+</p>
+<p>
+ <strong>Resource reference name:</strong> R.styleable.<em>some_file</em> (Java).
+</p>
+
+<a name="stylesandthemes" id="stylesandthemes"></a>
+<h2>Styles and Themes</h2>
+<p>
+ A <em>style</em> is one or more attributes applied to a single element (for example, 10 point red Arial font, applied to a TextView). A style is applied as an attribute to an element in a layout XML file.
+</p>
+<p>
+ A <em>theme</em> is one or more attributes applied to a whole screen &mdash; for example, you might apply the stock Android Theme.dialog theme to an activity designed to be a floating dialog box. A theme is assigned as an attribute to an Activity in the manifest file.
+</p>
+<p>
+ Both styles and themes are defined in a &lt;style&gt; block containing one or more string or numerical values (typically color values), or references to other resources (drawables and so on). These elements support inheritance, so you could have MyBaseTheme, MyBaseTheme.Fancy, MyBaseTheme.Small, and so on.
+</p>
+<p>
+ <strong>Source file format:</strong> XML file requiring a <code>&lt;?xml version="1.0" encoding="utf-8"?&gt;</code> declaration, and a root <code>&lt;resources&gt;</code> element containing one or more <code>&lt;style&gt;</code> tags.
+</p>
+<p>
+ <strong>Resource source file location</strong>: res/values/styles.xml (file name is arbitrary). The file name is arbitrary, but standard practice is to put all styles into a file named styles.xml.
+</p>
+<p>
+ <strong>Compiled resource datatype:</strong> Resource pointer to a Java CharSequence.
+</p>
+<p>
+ <strong>Resource reference name:</strong>
+</p>
+<ul>
+ <li>
+ <strong>Java</strong> <code>R.style.<em>styleID</em></code> for the whole style, <code>R.style.<em>styleID</em>.<em>itemID</em></code> for an individual setting
+ </li>
+ <li>
+ <strong>XML</strong> <code>@[<em>package</em>:]style/<em>styleID</em></code> for a whole style, <code>@[<em>package</em>:]style/<em>styleID</em>/<em>itemID</em></code> for an individual item. <strong>Note</strong>: to refer to a value in the <em>currently</em> applied theme, use "?" instead of "@" as described below (XML).
+ </li>
+</ul>
+<p>
+ <strong>Syntax</strong>
+</p>
+<pre>
+&lt;style name=<em>string</em> [parent=<em>string</em>] &gt;
+ &lt;item name=<em>string</em>&gt;<em>Hex value | string value | reference</em>&lt;/item&gt;+<em>
+</em>&lt;/style&gt;
+</pre>
+<dl>
+ <dt>
+ &lt;style&gt;
+ </dt>
+ <dd>
+ Holds one or more &lt;item&gt; elements, each describing one value. This style, which is a bundle of values, can be referred to as a <em>theme</em>.
+ <ul>
+ <li>
+ <em>name</em> - The name used in referring to this theme.
+ </li>
+ <li>
+ <em>parent</em> - An optional parent theme. All values from the specified theme will be inherited into this theme. Any values with identical names that you specify will override inherited values. The name must be qualified by the package, but you don't need the /style directive (for example, <code>android:Theme</code> for the base Android theme, or <code>MyTheme</code> for a theme defined in your package).
+ </li>
+ </ul>
+ </dd>
+ <dt>
+ &lt;item&gt;
+ </dt>
+ <dd>
+ A value to use in this theme. It can be a standard string, a hex color value, or a reference to any other resource type.
+ </dd>
+</dl>
+<p>
+ <strong>Example: Declaring a Style in XML</strong>
+</p>
+<pre>
+&lt;?xml version="1.0" encoding="utf-8"?&gt;
+&lt;resources&gt;
+ &lt;style name="SpecialText"&gt;
+ &lt;item name="android:textSize"&gt;18sp&lt;/item&gt;
+ &lt;item name="android:textColor"&gt;#008&lt;/item&gt;
+ &lt;/style&gt;
+&lt;/resources&gt;
+</pre>
+<p>
+ <strong>Example: Referencing a Declared Style from an XML Resource</strong>
+</p>
+<p>
+ The following layout XML file applies the previously defined style to a single text box.
+</p>
+<pre>
+&lt;!-- MainPageLayout.xml --&gt;
+&lt;?xml version="1.0" encoding="utf-8"?&gt;
+&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="fill_parent"
+ android:layout_width="fill_parent"
+ android:orientation="vertical"
+ android:scrollbars="vertical"
+ id="main_frame"&gt;
+ &lt;EditText id="@+id/text1"
+ style="@style/SpecialText"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Hello, World!" /&gt;
+&lt;/LinearLayout&gt;
+</pre>
+
+
+<p>
+ <strong>Example XML Declaration of a Theme</strong>
+</p>
+<p>
+ The following example defines a theme, "ThemeNew," which creates new theme items,
+ refers to some previously defined theme items (values beginning with '@'),
+ and refers to package resources (values beginning with '?').
+</p>
+<pre>
+&lt;style name="ThemeNew"&gt;
+ &lt;item name="windowFrame"&gt;@drawable/screen_frame&lt;/item&gt;
+ &lt;item name="windowBackground"&gt;@drawable/screen_background_white&lt;/item&gt;
+ &lt;item name="panelForegroundColor"&gt;#FF000000&lt;/item&gt;
+ &lt;item name="panelBackgroundColor"&gt;#FFFFFFFF&lt;/item&gt;
+ &lt;item name="panelTextColor"&gt;?panelForegroundColor&lt;/item&gt;
+ &lt;item name="panelTextSize"&gt;14&lt;/item&gt;
+ &lt;item name="menuItemTextColor"&gt;?panelTextColor&lt;/item&gt;
+ &lt;item name="menuItemTextSize"&gt;?panelTextSize&lt;/item&gt;
+&lt;/style&gt;
+</pre>
+<p>
+ Notice that, to reference a value from the currently loaded theme, we use
+ a question-mark (?) instead of the at-symbol (@), in the reference string.
+ You must refer to such a specific <code>&lt;item&gt;</code> by its name in
+ the currently loaded theme. This can be used in XML resources only.
+</p>
+
+<p>
+ <strong>Example Code Use of a Theme</strong>
+</p>
+<p>
+ The following Java snippet demonstrates loading a style set (i.e., a theme).
+</p>
+<pre>
+setTheme(R.style.ThemeNew);
+</pre>
+<p>
+ The following XML applies an Android theme to a whole file (in this case, the Android dialog theme, to make the screen a floating dialog screen).
+</p>
+<pre>
+&lt;!-- AndroidManifest.xml --&gt;
+&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.codelab.rssexample"&gt;
+ &lt;activity class="AddRssItem" android:label="@string/add_item_label" android:theme="@android:style/Theme.Dialog"/&gt;
+&lt;/manifest&gt;
+</pre>
diff --git a/docs/html/guide/topics/resources/resources-i18n.jd b/docs/html/guide/topics/resources/resources-i18n.jd
new file mode 100755
index 0000000..d3ddd23
--- /dev/null
+++ b/docs/html/guide/topics/resources/resources-i18n.jd
@@ -0,0 +1,699 @@
+page.title=Resources and i18n
+@jd:body
+<h1>Resources and Internationalization</h1>
+
+<p>Resources are external files (that is, non-code files) that are used by
+your code and compiled into your application at build time. Android
+supports a number of different kinds of resource files, including XML,
+PNG, and JPEG files. The XML files have very different formats depending
+on what they describe. This document describes what kinds of files are
+supported, and the syntax or format of each.</p>
+<p>Resources are externalized from source code, and XML files are compiled into
+a binary, fast loading format for efficiency reasons. Strings, likewise are compressed
+into a more efficient storage form. It is for these reasons that we have these
+different resource types in the Android platform.</p>
+
+<p>This document contains the following sections:</p>
+
+<ul>
+ <li> <a href="#Resources">Resources</a>
+ <ul>
+ <li> <a href="#CreatingResources">Creating Resources</a></li>
+ <li> <a href="#UsingResources">Using Resources</a>
+ <ul>
+ <li><a href="#ResourcesInCode">Using Resources in Code</a></li>
+ <li> <a href="#ReferencesToResources">References to Resources</a></li>
+ <li> <a href="#ReferencesToThemeAttributes">References to Theme Attributes</a></li>
+ <li> <a href="#UsingSystemResources">Using System Resources</a></li>
+ </ul>
+ </li>
+ <li><a href="#AlternateResources">Alternate Resources</a></li>
+ <li><a href="{@docRoot}reference/available-resources.html">
+ Resource Reference</a></li>
+ <li> <a href="#ResourcesTerminology">Terminology</a></li>
+ </ul>
+ </li>
+ <li><a href="#i18n">Internationalization (I18N)</a></li>
+</ul>
+<p>This is a fairly technically dense document, and together with the
+<a href="{@docRoot}reference/available-resources.html">Resource Reference</a>
+document, they cover a lot of information about resources. It is not necessary
+to know this document by heart to use Android, but rather to know that the
+information is here when you need it.</p>
+
+<a name="Resources"></a>
+<h2>Resources</h2>
+
+<p>This topic includes a terminology list associated with resources, and a series
+ of examples of using resources in code. For a complete guide to the supported
+ Android resource types, see
+ <a href="{@docRoot}reference/available-resources.html">Resources</a>.
+ </p>
+<p>The Android resource system keeps track of all non-code
+ assets associated with an application. You use the
+ {@link android.content.res.Resources Resources} class to access your
+ application's resources; the Resources instance associated with your
+ application can generally be found through
+ {@link android.content.Context#getResources Context.getResources()}.</p>
+<p>An application's resources are compiled into the application
+binary at build time for you by the build system. To use a resource,
+you must install it correctly in the source tree and build your
+application. As part of the build process, symbols for each
+of the resources are generated that you can use in your source
+code -- this allows the compiler to verify that your application code matches
+up with the resources you defined.</p>
+
+<p>The rest of this section is organized as a tutorial on how to
+use resources in an application.</p>
+
+<a name="CreatingResources" id="CreatingResources"></a>
+<h2>Creating Resources</h2>
+
+<p>Android supports string, bitmap, and many other types of resource. The syntax and format
+of each, and where they're stored, depends upon the type of object. In
+general, though, you create resources from three types of files: XML files
+(everything but bitmaps and raw), bitmap files(for images) and Raw files (anything
+else, for example sound files, etc.). In fact, there are two different types of
+XML file as well, those that get compiled as-is into the package, and those that
+are used to generate resources by aapt. Here is a list of each
+resource type, the format of the file, a description of the file, and details
+of any XML files. </p>
+
+<p>You will create and store your resource files under the appropriate
+subdirectory under the <code>res/</code> directory in your project. Android
+has a resource compiler (aapt) that compiles resources according to which
+subfolder they are in, and the format of the file. Here is a list of the file
+types for each resource. See the
+<a href="{@docRoot}reference/available-resources.html">resource reference</a> for
+descriptions of each type of object, the syntax, and the format or syntax of
+the containing file.</p>
+
+<table width="100%" border="1">
+ <tr>
+ <th scope="col">Directory</th>
+ <th scope="col">Resource Types </th>
+ </tr>
+ <tr>
+ <td><code>res/anim/</code></td>
+ <td>XML files that are compiled into
+ <a href="{@docRoot}reference/available-resources.html#animationdrawable">frame by
+ frame animation</a> or
+ <a href="{@docRoot}reference/available-resources.html#tweenedanimation">tweened
+ animation</a> objects </td>
+ </tr>
+ <tr>
+ <td><code>res/drawable/</code></td>
+ <td><p>.png, .9.png, .jpg files that are compiled into the following
+ Drawable resource subtypes:</p>
+ <p>To get a resource of this type, use <code>Resource.getDrawable(<em>id</em>)</code>
+ <ul>
+ <li><a href="{@docRoot}reference/available-resources.html#imagefileresources">bitmap files</a></li>
+ <li><a href="{@docRoot}reference/available-resources.html#ninepatch">9-patches (resizable bitmaps)</a></li>
+ </ul></td>
+ </tr>
+ <tr>
+ <td><code>res/layout/</code></td>
+ <td>XML files that are compiled into screen layouts (or part of a screen).
+ See <a href="{@docRoot}devel/ui/xml.html">layouts</a></td>
+ </tr>
+ <tr>
+ <td><code>res/values/</code></td>
+ <td><p>XML files that can be compiled into many kinds of resource.</p>
+ <p class="note"><strong>Note:</strong> unlike the other res/ folders, this one
+ can hold any number of files that hold descriptions of resources to create
+ rather than the resources themselves. The XML element types control
+ where these resources are placed under the R class.</p>
+ <p>While the files can be named anything, these are
+ the typical files in this folder (the convention is to name
+ the file after the type of elements defined within):</p>
+ <ul>
+ <li><strong>arrays.xml</strong> to define arrays </li>
+ <!-- TODO: add section on arrays -->
+ <li><strong>colors.xml</strong> to define <a href="{@docRoot}reference/available-resources.html#colordrawableresources">color
+ drawables</a> and <a href="#colorvals">color string values</a>.
+ Use <code>Resources.getDrawable()</code> and
+ <code>Resources.getColor(), respectively,</code>
+ to get these resources.</li>
+ <li><strong>dimens.xml</strong> to define <a href="{@docRoot}reference/available-resources.html#dimension">dimension value</a>. Use <code>Resources.getDimension()</code> to get
+ these resources.</li>
+ <li><strong>strings.xml</strong> to define <a href="{@docRoot}reference/available-resources.html#stringresources">string</a> values (use either
+ <code>Resources.getString</code> or preferably <code>Resources.getText()</code>
+ to get
+ these resources. <code>getText()</code> will retain any rich text styling
+ which is usually desirable for UI strings.</li>
+ <li><strong>styles.xml</strong> to define <a href="{@docRoot}reference/available-resources.html#stylesandthemes">style</a> objects.</li>
+ </ul></td>
+ </tr>
+ <tr>
+ <td><code>res/xml/</code></td>
+ <td>Arbitrary XML files that are compiled and can be read at run time by
+ calling {@link android.content.res.Resources#getXml(int) Resources.getXML()}.</td>
+ </tr>
+ <tr>
+ <td><code>res/raw/</code></td>
+ <td>Arbitrary files to copy directly to the device. They are added uncompiled
+ to the compressed file that your application build produces. To use these
+ resources in your application, call {@link android.content.res.Resources#openRawResource(int)
+ Resources.openRawResource()} with the resource ID, which is R.raw.<em>somefilename</em>.</td>
+ </tr>
+</table>
+<p>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</p>
+<a name="colorvals" id="colorvals"></a>
+<h3>Global Resource Notes</h3>
+<ul>
+ <li>Several resources allow you to define colors. Android accepts color values
+ written in various web-style formats -- a hexadecimal constant in any of the
+ following forms: #RGB, #ARGB, #RRGGBB, #AARRGGBB. </li>
+ <li>All color values support setting an alpha channel value, where the first
+ two hexadecimal numbers specify the transparency. Zero in the alpha channel
+ means transparent. The default value is opaque. </li>
+</ul>
+<a name="UsingResources" id="UsingResources"></a>
+<h2>Using Resources </h2>
+<p>This section describes how to use the resources you've created. It includes the
+ following topics:</p>
+<ul>
+ <li><a href="#ResourcesInCode">Using resources in code</a>&nbsp;- How to call
+ resources in your code to instantiate them. </li>
+ <li><a href="#ReferencesToResources">Referring to resources from other resources</a> &nbsp;-
+ You can reference resources from other resources. This lets you reuse common
+ resource values inside resources. </li>
+ <li><a href="#AlternateResources">Supporting Alternate Resources for Alternate
+ Configurations</a> - You can specify different resources
+ to load, depending on the language or display configuration of the host
+ hardware. </li>
+</ul>
+<p>At compile time, Android generates a class named R that contains resource identifiers
+ to all the resources in your program. This class contains several subclasses,
+ one for each type of resource supported by Android, and for which you provided
+ a resource file. Each class contains one or more identifiers for the compiled resources,
+ that you use in your code to load the resource. Here is a small resource file
+ that contains string, layout (screens or parts of screens), and image resources.</p>
+<p class="note"><strong>Note:</strong> the R class is an auto-generated file and is not
+designed to be edited by hand. It will be automatically re-created as needed when
+the resources are updated.</p>
+<pre class="prettyprint">package com.android.samples;
+public final class R {
+ public static final class string {
+ public static final int greeting=0x0204000e;
+ public static final int start_button_text=0x02040001;
+ public static final int submit_button_text=0x02040008;
+ public static final int main_screen_title=0x0204000a;
+ };
+ public static final class layout {
+ public static final int start_screen=0x02070000;
+ public static final int new_user_pane=0x02070001;
+ public static final int select_user_list=0x02070002;
+
+ };
+ public static final class drawable {
+ public static final int company_logo=0x02020005;
+ public static final int smiling_cat=0x02020006;
+ public static final int yellow_fade_background=0x02020007;
+ public static final int stretch_button_1=0x02020008;
+
+ };
+};
+</pre>
+<a name="ResourcesInCode" id="ResourcesInCode"></a>
+<h3>Using Resources in Code </h3>
+
+<p>Using resources in code is just a matter of knowing the full resource ID
+and what type of object your resource has been compiled into. Here is the
+syntax for referring to a resource:</p>
+<p><code>R.<em>resource_type</em>.<em>resource_name</em></code></p>
+<p>or</p>
+<p><code>android.R.<em>resource_type</em>.<em>resource_name</em></code></p>
+
+<p>Where <code>resource_type</code> is the R subclass that holds a specific type
+of resource. <code>resource_name</code> is the <em>name</em> attribute for resources
+defined in XML files, or the file name (without the extension) for resources
+defined by other file types. Each type of resource will be added to a specific
+R subclass, depending on the type of resource it is; to learn which R subclass
+hosts your compiled resource type, consult the
+<a href="{@docRoot}reference/available-resources.html">resource
+reference</a> document. Resources compiled by your own application can
+be referred to without a package name (simply as
+<code>R.<em>resource_type</em>.<em>resource_name</em></code>). Android contains
+a number of standard resources, such as screen styles and button backgrounds. To
+refer to these in code, you must qualify them with <code>android</code>, as in
+<code>android.R.drawable.button_background</code>.</p>
+
+<p>Here are some good and bad examples of using compiled resources in code:</p>
+
+<pre class="prettyprint">// Load a background for the current screen from a drawable resource.
+this.getWindow().setBackgroundDrawableResource(R.drawable.my_background_image);
+
+// WRONG Sending a string resource reference into a
+// method that expects a string.
+this.getWindow().setTitle(R.string.main_title);
+
+// RIGHT Need to get the title from the Resources wrapper.
+this.getWindow().setTitle(Resources.getText(R.string.main_title));
+
+// Load a custom layout for the current screen.
+setContentView(R.layout.main_screen);
+
+// Set a slide in animation for a ViewFlipper object.
+mFlipper.setInAnimation(AnimationUtils.loadAnimation(this,
+ R.anim.hyperspace_in));
+
+// Set the text on a TextView object.
+TextView msgTextView = (TextView)findViewByID(R.id.msg);
+msgTextView.setText(R.string.hello_message); </pre>
+
+<a name="ReferencesToResources" id="ReferencesToResources"></a>
+<h3>References to Resources</h3>
+
+<p>A value supplied in an attribute (or resource) can also be a reference to
+a resource. This is often used in layout files to supply strings (so they
+can be localized) and images (which exist in another file), though a reference
+can be any resource type including colors and integers.</p>
+
+<p>For example, if we have
+<a href="{@docRoot}reference/available-resources.html#colordrawableresources">color
+resources</a>, we can write a layout file that sets the text color size to be
+the value contained in one of those resources:</p>
+
+<pre>
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;EditText id=&quot;text&quot;
+ xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
+ android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;
+ <strong>android:textColor=&quot;&#64;color/opaque_red&quot;</strong>
+ android:text=&quot;Hello, World!&quot; /&gt;
+</pre>
+
+<p>Note here the use of the '@' prefix to introduce a resource reference -- the
+text following that is the name of a resource in the form
+of <code>@[package:]type/name</code>. In this case we didn't need to specify
+the package because we are referencing a resource in our own package. To
+reference a system resource, you would need to write:</p>
+
+<pre>
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;EditText id=&quot;text&quot;
+ xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
+ android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;
+ android:textColor=&quot;&#64;<strong>android:</strong>color/opaque_red&quot;
+ android:text=&quot;Hello, World!&quot; /&gt;
+</pre>
+
+<p>As another example, you should always use resource references when supplying
+strings in a layout file so that they can be localized:</p>
+
+<pre>
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;EditText id=&quot;text&quot;
+ xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
+ android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;
+ android:textColor=&quot;&#64;android:color/opaque_red&quot;
+ android:text=&quot;&#64;string/hello_world&quot; /&gt;
+</pre>
+
+<p>This facility can also be used to create references between resources.
+For example, we can create new drawable resources that are aliases for
+existing images:</p>
+
+<pre>
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;resources&gt;
+ &lt;drawable id=&quot;my_background&quot;&gt;&#64;android:drawable/theme2_background&lt;/drawable&gt;
+&lt;/resources&gt;
+</pre>
+
+<a name="ReferencesToThemeAttributes"></a>
+<h3>References to Theme Attributes</h3>
+
+<p>Another kind of resource value allows you to reference the value of an
+attribute in the current theme. This attribute reference can <em>only</em>
+be used in style resources and XML attributes; it allows you to customize the
+look of UI elements by changing them to standard variations supplied by the
+current theme, instead of supplying more concrete values.</p>
+
+<p>As an example, we can use this in our layout to set the text color to
+one of the standard colors defined in the base system theme:</p>
+
+<pre>
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;EditText id=&quot;text&quot;
+ xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
+ android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;fill_parent&quot;
+ <strong>android:textColor=&quot;?android:textDisabledColor&quot;</strong>
+ android:text=&quot;&#64;string/hello_world&quot; /&gt;
+</pre>
+
+<p>Note that this is very similar to a resource reference, except we are using
+an '?' prefix instead of '@'. When you use this markup, you are supplying
+the name of an attribute resource that will be looked up in the theme --
+because the resource tool knows that an attribute resource is expected,
+you do not need to explicitly state the type (which would be
+<code>?android:attr/android:textDisabledColor</code>).</p>
+
+<p>Other than using this resource identifier to find the value in the
+theme instead of raw resources, the name syntax is identical to the '@' format:
+<code>?[namespace:]type/name</code> with the type here being optional.</p>
+
+<a name="UsingSystemResources"></a>
+<h3>Using System Resources</h3>
+
+<p>Many resources included with the system are available to applications.
+All such resources are defined under the class "android.R". For example,
+you can display the standard application icon in a screen with the following
+code:</p>
+
+<pre class="prettyprint">
+public class MyActivity extends Activity
+{
+ public void onStart()
+ {
+ requestScreenFeatures(FEATURE_BADGE_IMAGE);
+
+ super.onStart();
+
+ setBadgeResource(android.R.drawable.sym_def_app_icon);
+ }
+}
+</pre>
+
+<p>In a similar way, this code will apply to your screen the standard
+"green background" visual treatment defined by the system:</p>
+
+<pre class="prettyprint">
+public class MyActivity extends Activity
+{
+ public void onStart()
+ {
+ super.onStart();
+
+ setTheme(android.R.style.Theme_Black);
+ }
+}
+</pre>
+
+<a name="AlternateResources" id="AlternateResources"></a>
+<h2>Supporting Alternate Resources for Alternate Languages and Configurations</h2>
+
+<p>You can supply different resources for your product according to the UI
+language or hardware configuration on the device. Note that although you can
+include different string, layout, and other resources, the SDK does not expose
+methods to let you specify which alternate resource set to load. Android
+detects the proper set for the hardware and location, and loads them as
+appropriate. Users can select alternate language settings using the settings
+panel on the device. </p>
+<p>To include alternate resources, create parallel resource folders with
+qualifiers appended to the folder names, indicating the configuration it
+applies to (language, screen orientation, and so on). For example, here is a
+project that holds one string resource file for English, and another for
+French:</p>
+
+<pre>
+MyApp/
+ res/
+ values-en/
+ strings.xml
+ values-fr/
+ strings.xml
+</pre>
+
+<p>Android supports several types of qualifiers, with various values for each.
+Append these to the end of the resource folder name, separated by dashes. You
+can add multiple qualifiers to each folder name, but they must appear in the
+order they are listed here. For example, a folder containing drawable
+resources for a fully specified configuration would look like:</p>
+
+<pre>
+MyApp/
+ res/
+ drawable-en-rUS-port-160dpi-finger-keysexposed-qwerty-dpad-480x320/
+</pre>
+
+<p>More typically, you will only specify a few specific configuration options
+that a resource is defined for. You may drop any of the values from the
+complete list, as long as the remaining values are still in the same
+order:</p>
+
+<pre>
+MyApp/
+ res/
+ drawable-en-rUS-finger/
+ drawable-port/
+ drawable-port-160dpi/
+ drawable-qwerty/
+</pre>
+
+<table border="1">
+ <tr>
+ <th> Qualifier </th>
+ <th> Values </th>
+ </tr>
+ <tr>
+ <td>Language</td>
+ <td>The two letter <a href="http://www.loc.gov/standards/iso639-2/php/code_list.php">ISO
+ 639-1</a> language code in lowercase. For example:
+ <code>en</code>, <code>fr</code>, <code>es</code> </td>
+ </tr>
+ <tr>
+ <td>Region</td>
+ <td>The two letter
+ <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO
+ 3166-1-alpha-2</a> language code in uppercase preceded by a lowercase
+ &quot;r&quot;. For example: <code>rUS</code>, <code>rFR</code>, <code>rES</code></td>
+ </tr>
+ <tr>
+ <td>Screen orientation</td>
+ <td><code>port</code>, <code>land</code>, <code>square</code> </td>
+ </tr>
+ <tr>
+ <td>Screen pixel density</td>
+ <td><code>92dpi</code>, <code>108dpi</code>, etc. </td>
+ </tr>
+ <tr>
+ <td>Touchscreen type</td>
+ <td><code>notouch</code>, <code>stylus</code>, <code>finger</code></td>
+ </tr>
+ <tr>
+ <td>Whether the keyboard is available to the user</td>
+ <td><code>keysexposed</code>, <code>keyshidden</code> </td>
+ </tr>
+ <tr>
+ <td>Primary text input method</td>
+ <td><code>nokeys</code>, <code>qwerty</code>, <code>12key</code> </td>
+ </tr>
+ <tr>
+ <td>Primary non-touchscreen<br />
+ navigation method</td>
+ <td><code>notouch</code>, <code>dpad</code>, <code>trackball</code>, <code>wheel</code> </td>
+ </tr>
+ <tr>
+ <td>Screen dimensions</td>
+ <td><code>320x240</code>, <code>640x480</code>, etc. The larger dimension
+ must be specified first. </td>
+ </tr>
+</table>
+
+<p>This list does not include device-specific parameters such as carrier,
+branding, device/hardware, or manufacturer. Everything that an application
+needs to know about the device that it is running on is encoded via the
+resource qualifiers in the table above.</p>
+
+<p>Here are some general guidelines on qualified resource directory names:</p>
+
+<ul>
+ <li>Values are separated by a dash (as well as a dash after the base directory
+ name) </li>
+ <li>Values are case-sensitive (even though they must be unique across all folder
+ names in a case-insensitive way)<br />For example,</li>
+ <ul>
+ <li>A portrait-specific <code>drawable</code> directory must be named
+ <code>drawable-port</code>, not <code>drawable-PORT</code>.</li>
+ <li>You may not have two directories named <code>drawable-port</code>
+ and <code>drawable-PORT</code>, even if you had intended "port" and
+ "PORT" to refer to different parameter values.</li>
+ </ul>
+ <li>Only one value for each qualifier type is supported (that is, you cannot
+ specify <code>drawable-rEN-rFR/</code>)</li>
+ <li>You can specify multiple parameters to define specific configurations,
+ but they must always be in the order listed above.
+ For example, <code>drawable-en-rUS-land</code> will apply to landscape view,
+ US-English devices. </li>
+ <li>Android will try to find the most specific matching directory for the current
+ configuration, as described below</li>
+ <li>The order of parameters listed in this table is used to break a tie in case
+ of multiple qualified directories (see the example given below) </li>
+ <li>All directories, both qualified and unqualified, live under the <code>res/</code> folder.
+ Qualified directories cannot be nested (you cannot have <code>res/drawable/drawable-en</code>) </li>
+ <li>All resources will be referenced in code or resource reference syntax by
+ their simple, undecorated name. So if a resource is named this:<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>MyApp/res/drawable-port-92dp/myimage.png</code><br />
+ It would be referenced as this:<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>R.drawable.myimage</code> (code)<br />
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<code>&#064;drawable/myimage</code> (XML)</li>
+</ul>
+
+<h3>How Android finds the best matching directory </h3>
+
+<p>Android will pick which of the various underlying resource files should be
+used at runtime, depending on the current configuration. The selection process
+is as follows:</p>
+
+<ol>
+ <li>
+ Eliminate any resources whose configuration does not match the current
+ device configuration. For example, if the screen pixel density is 108dpi,
+ this would eliminate only <code>MyApp/res/drawable-port-92dpi/</code>.
+ <blockquote>
+ <pre>
+MyApp/res/drawable/myimage.png
+MyApp/res/drawable-en/myimage.png
+MyApp/res/drawable-port/myimage.png
+<strike>MyApp/res/drawable-port-92dpi/myimage.png</strike>
+</pre>
+ </blockquote>
+ </li>
+ <li>
+ Pick the resources with the highest number of matching configurations.
+ For example, if our locale is en-GB and orientation is port, then we
+ have two candidates with one matching configuration each:
+ <code>MyApp/res/drawable-en/</code> and <code>MyApp/res/drawable-port/</code>.
+ The directory <code>MyApp/res/drawable/</code> is eliminated because
+ it has zero matching configurations, while the others have one matching
+ configuration.
+ <blockquote>
+ <pre>
+<strike>MyApp/res/drawable/myimage.png</strike>
+MyApp/res/drawable-en/myimage.png
+MyApp/res/drawable-port/myimage.png
+</pre>
+ </blockquote>
+ </li>
+ <li>
+ Pick the final matching file based on configuration precedence, which
+ is the order of parameters listed in the table above. That is, it is
+ more important to match the language than the orientation, so we break
+ the tie by picking the language-specific file, <code>MyApp/res/drawable-en/</code>.
+ <blockquote>
+ <pre>MyApp/res/drawable-en/myimage.png
+<strike>MyApp/res/drawable-port/myimage.png</strike>
+</pre>
+ </blockquote>
+ </li>
+</ol>
+
+<a name="ResourcesTerminology"></a>
+<h2>Terminology</h2>
+
+<p>The resource system brings a number of different pieces together to
+form the final complete resource functionality. To help understand the
+overall system, here are some brief definitions of the core concepts and
+components you will encounter in using it:</p>
+
+<p><strong>Asset</strong>: A single blob of data associated with an application. This
+includes object files compiled from the Java source code, graphics (such as PNG
+images), XML files, etc. These files are organized in a directory hierarchy
+that, during final packaging of the application, is bundled together into a
+single ZIP file.</p>
+
+<p><strong>aapt</strong>: Android Asset Packaging Tool. The tool that generates the
+final ZIP file of application assets. In addition to collecting raw assets
+together, it also parses resource definitions into binary asset data.</p>
+
+<p><strong>Resource Table</strong>: A special asset that aapt generates for you,
+describing all of the resources contained in an application/package.
+This file is accessed for you by the Resources class; it is not touched
+directly by applications.</p>
+
+<p><strong>Resource</strong>: An entry in the Resource Table describing a single
+named value. Broadly, there are two types of resources: primitives and
+bags.</p>
+
+<p><strong>Resource Identifier</strong>: In the Resource Table all resources are
+identified by a unique integer number. In source code (resource descriptions,
+XML files, Java source code) you can use symbolic names that stand as constants for
+the actual resource identifier integer.</p>
+
+<p><strong>Primitive Resource</strong>: All primitive resources can be written as a
+simple string, using formatting to describe a variety of primitive types
+included in the resource system: integers, colors, strings, references to
+other resources, etc. Complex resources, such as bitmaps and XML
+describes, are stored as a primitive string resource whose value is the path
+of the underlying Asset holding its actual data.</p>
+
+<p><strong>Bag Resource</strong>: A special kind of resource entry that, instead of a
+simple string, holds an arbitrary list of name/value pairs. Each name is
+itself a resource identifier, and each value can hold
+the same kinds of string formatted data as a normal resource. Bags also
+support inheritance: a bag can inherit the values from another bag, selectively
+replacing or extending them to generate its own contents.</p>
+
+<p><strong>Kind</strong>: The resource kind is a way to organize resource identifiers
+for various purposes. For example, drawable resources are used to
+instantiate Drawable objects, so their data is a primitive resource containing
+either a color constant or string path to a bitmap or XML asset. Other
+common resource kinds are string (localized string primitives), color
+(color primitives), layout (a string path to an XML asset describing a view
+layout), and style (a bag resource describing user interface attributes).
+There is also a standard "attr" resource kind, which defines the resource
+identifiers to be used for naming bag items and XML attributes</p>
+
+<p><strong>Style</strong>: The name of the resource kind containing bags that are used
+to supply a set of user interface attributes. For example, a TextView class may
+be given a style resource that defines its text size, color, and alignment.
+In a layout XML file, you associate a style with a bag using the "style"
+attribute, whose value is the name of the style resource.</p>
+
+<p><strong>Style Class</strong>: Specifies a related set of attribute resources.
+This data is not placed in the resource table itself, but used to generate
+constants in the source code that make it easier for you to retrieve values out of
+a style resource and/or XML tag's attributes. For example, the
+Android platform defines a "View" style class that
+contains all of the standard view attributes: padding, visibility,
+background, etc.; when View is inflated it uses this style class to
+retrieve those values from the XML file (at which point style and theme
+information is applied as approriate) and load them into its instance.</p>
+
+<p><strong>Configuration</strong>: For any particular resource identifier, there may be
+multiple different available values depending on the current configuration.
+The configuration includes the locale (language and country), screen
+orientation, screen density, etc. The current configuration is used to
+select which resource values are in effect when the resource table is
+loaded.</p>
+
+<p><strong>Theme</strong>: A standard style resource that supplies global
+attribute values for a particular context. For example, when writing an
+Activity the application developer can select a standard theme to use, such
+as the Theme.White or Theme.Black styles; this style supplies information
+such as the screen background image/color, default text color, button style,
+text editor style, text size, etc. When inflating a layout resource, most
+values for widgets (the text color, selector, background) if not explicitly
+set will come from the current theme; style and attribute
+values supplied in the layout can also assign their value from explicitly
+named values in the theme attributes if desired.</p>
+
+<p><strong>Overlay</strong>: A resource table that does not define a new set of resources,
+but instead replaces the values of resources that are in another resource table.
+Like a configuration, this is applied at load time
+to the resource data; it can add new configuration values (for example
+strings in a new locale), replace existing values (for example change
+the standard white background image to a "Hello Kitty" background image),
+and modify resource bags (for example change the font size of the Theme.White
+style to have an 18 pt font size). This is the facility that allows the
+user to select between different global appearances of their device, or
+download files with new appearances.</p>
+
+<h2>Resource Reference</h2>
+<p>The <a href="{@docRoot}reference/available-resources.html">Resource Reference</a>
+document provides a detailed list of the various types of resource and how to use them
+from within the Java source code, or from other references.</p>
+
+<a name="i18n" id="i18n"></a>
+<h2>Internationalization and Localization</h2>
+<p class="note"><strong>Coming Soon:</strong> Internationalization and Localization are
+critical, but are also not quite ready yet in the current SDK. As the
+SDK matures, this section will contain information on the Internationalization
+and Localization features of the Android platform. In the meantime, it is a good
+idea to start by externalizing all strings, and practicing good structure in
+creating and using resources.</p>
+
diff --git a/docs/html/guide/topics/security/security.jd b/docs/html/guide/topics/security/security.jd
new file mode 100644
index 0000000..4b258e0
--- /dev/null
+++ b/docs/html/guide/topics/security/security.jd
@@ -0,0 +1,394 @@
+page.title=Security and Permissions
+@jd:body
+
+<p>Android is a multi-process system, where each application (and parts of the
+system) runs in its own process. Most security between applications and
+the system is enforced at the process level through standard Linux facilities,
+such as user and group IDs that are assigned to applications.
+Additional finer-grained security features are provided
+through a "permission" mechanism that enforces restrictions on the specific
+operations that a particular process can perform, and per-URI permissions
+for granting ad-hoc access to specific pieces of data.</p>
+
+<p>This document covers these topics: </p>
+
+<ul>
+<li><a href="#arch">Security Architecture</a></li>
+<li><a href="#signing">Application Signing</a></li>
+<li><a href="#userid">User IDs and File Access</a></li>
+<li><a href="#permissions">Using Permissions</a></li>
+<li><a href="#declaring">Declaring and Enforcing Permissions</a>
+ <ul>
+ <li><a href="#manifest">Enforcing Permissions in AndroidManifest.xml</a></li>
+ <li><a href="#broadcasts">Enforcing Permissions when Sending Broadcasts</a></li>
+ <li><a href="#enforcement">Other Permission Enforcement</a></li>
+ </ul></li>
+<li>><a href="#uri">URI Permissions</a></li>
+</ul>
+
+
+<a name="arch"></a>
+<h2>Security Architecture</h2>
+
+<p>A central design point of the Android security architecture is that no
+application, by default, has permission to perform any operations that would
+adversely impact other applications, the operating system, or the user. This
+includes reading or writing the user's private data (such as contacts or
+e-mails), reading or writing another application's files, performing
+network access, keeping the device awake, etc.<p>
+
+<p>An application's process is a secure sandbox. It can't disrupt other
+applications, except by explicitly declaring the <em>permissions</em> it needs
+for additional capabilities not provided by the basic sandbox. These
+permissions it requests can be handled by the operating in various ways,
+typically by automatically allowing or disallowing based on certificates or
+by prompting the user. The permissions required by an application are declared
+statically in that application, so they can be known up-front at install time
+and will not change after that.</p>
+
+
+<a name="signing"></a>
+<h2>Application Signing</h2>
+
+<p>All Android applications (.apk files) must be signed with a certificate whose
+private key is held by their developer. This certificate identifies the author
+of the application. The certificate does <em>not</em> need to be signed by
+a certificate authority: it is perfectly allowable, and typical, for Android
+applications to use self-signed certificates. The certificate is used only
+to establish trust relationships between applications, not for wholesale
+control over whether an application can be installed. The most significant
+ways that signatures impact security is by determining who can access
+signature-based permissions and who can share user IDs.</p>
+
+
+<a name="userid"></a>
+<h2>User IDs and File Access</h2>
+
+<p>Each Android package (.apk) file installed on the device is given its
+own unique Linux user ID, creating a sandbox for it and preventing it from touching
+other applications (or other applications from touching it). This user ID is
+assigned to it when the application is installed on the device, and
+remains constant for the duration of its life on that device.</p>
+
+<p>Because security enforcement happens at the
+process level, the code of any two packages can not normally
+run in the same process, since they need to run as different Linux users.
+You can use the {@link android.R.attr#sharedUserId} attribute in the
+<code>AndroidManifest.xml</code>'s
+{@link android.R.styleable#AndroidManifest manifest} tag of each package to
+have them assigned the same user ID. By doing this, for purposes of security
+the two packages are then treated as being the same application, with the same
+user ID and file permissions. Note that in order to retain security, only two applications
+signed with the same signature (and requesting the same sharedUserId) will
+be given the same user ID.</p>
+
+<p>Any data stored by an application will be assigned that application's user
+ID, and not normally accessible to other packages. When creating a new file
+with {@link android.content.Context#getSharedPreferences},
+{@link android.content.Context#openFileOutput}, or
+{@link android.content.Context#openOrCreateDatabase},
+you can use the
+{@link android.content.Context#MODE_WORLD_READABLE} and/or
+{@link android.content.Context#MODE_WORLD_WRITEABLE} flags to allow any other
+package to read/write the file. When setting these flags, the file is still
+owned by your application, but its global read and/or write permissions have
+been set appropriately so any other application can see it.</p>
+
+
+<a name="permissions"></a>
+<h2>Using Permissions</h2>
+
+<p>A basic Android application has no permissions associated with it,
+meaning it can not do anything that would adversely impact the user experience
+or any data on the device. To make use of protected features of the device,
+you must include in your <code>AndroidManifest.xml</code> one or more
+<code>{@link android.R.styleable#AndroidManifestUsesPermission &lt;uses-permission&gt;}</code>
+tags declaring the permissions that your application needs.</p>
+
+<p>For example, an application that needs to monitor incoming SMS messages would
+specify:</p>
+
+<pre>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
+ package=&quot;com.android.app.myapp&quot; &gt;
+
+ &lt;uses-permission android:name=&quot;android.permission.RECEIVE_SMS&quot; /&gt;
+
+&lt;/manifest&gt;</pre>
+
+<p>At application install time, permissions requested by the application are
+granted to it by the package installer, based on checks against the
+signatures of the applications declaring those permissions and/or interaction
+with the user. <em>No</em> checks with the user
+are done while an application is running: it either was granted a particular
+permission when installed, and can use that feature as desired, or the
+permission was not granted and any attempt to use the feature will fail
+without prompting the user.</p>
+
+<p>Often times a permission failure will result in a {@link
+java.lang.SecurityException} being thrown back to the application. However,
+this is not guaranteed to occur everywhere. For example, the {@link
+android.content.Context#sendBroadcast} method checks permissions as data is
+being delivered to each receiver, after the method call has returned, so you
+will not receive an exception if there are permission failures. In almost all
+cases, however, a permission failure will be printed to the system log.</p>
+
+<p>The permissions provided by the Android system can be found at {@link
+android.Manifest.permission}. Any application may also define and enforce its
+own permissions, so this is not a comprehensive list of all possible
+permissions.</p>
+
+<p>A particular permission may be enforced at a number of places during your
+program's operation:</p>
+
+<ul>
+<li>At the time of a call into the system, to prevent an application from
+executing certain functions.</li>
+<li>When starting an activity, to prevent applications from launching
+activities of other applications.</li>
+<li>Both sending and receiving broadcasts, to control who can receive
+your broadcast or who can send a broadcast to you.</li>
+<li>When accessing and operating on a content provider.</li>
+<li>Binding or starting a service.</li>
+</ul>
+
+
+<a name="declaring"></a>
+<h2>Declaring and Enforcing Permissions</h2>
+
+<p>To enforce your own permissions, you must first declare them in your
+<code>AndroidManifest.xml</code> using one or more
+<code>{@link android.R.styleable#AndroidManifestPermission &lt;permission&gt;}</code>
+tags.</p>
+
+<p>For example, an application that wants to control who can start one
+of its activities could declare a permission for this operation as follows:</p>
+
+<pre>&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
+ package=&quot;com.me.app.myapp&quot; &gt;
+
+ &lt;permission android:name=&quot;com.me.app.myapp.permission.DEADLY_ACTIVITY&quot;
+ android:label=&quot;&#64;string/permlab_deadlyActivity&quot;
+ android:description=&quot;&#64;string/permdesc_deadlyActivity&quot;
+ android:permissionGroup=&quot;android.permission-group.COST_MONEY&quot;
+ android:protectionLevel=&quot;dangerous&quot; /&gt;
+
+&lt;/manifest&gt;</pre>
+
+<p>The {@link android.R.styleable#AndroidManifestPermission_protectionLevel
+&lt;protectionLevel&gt;} attribute is required, telling the system how the
+user is to be informed of applications requiring the permission, or who is
+allowed to hold that permission, as described in the linked documentation.</p>
+
+<p>The {@link android.R.styleable#AndroidManifestPermission_permissionGroup
+&lt;permissionGroup&gt;} attribute is optional, and only used to help the system display
+permissions to the user. You will usually want to set this to either a standard
+system group (listed in {@link android.Manifest.permission_group
+android.Manifest.permission_group}) or in more rare cases to one defined by
+yourself. It is preferred to use an existing group, as this simplifies the
+permission UI shown to the user.</p>
+
+<p>Note that both a label and description should be supplied for the
+permission. These are string resources that can be displayed to the user when
+they are viewing a list of permissions
+(<code>{@link android.R.styleable#AndroidManifestPermission_label android:label}</code>)
+or details on a single permission (
+<code>{@link android.R.styleable#AndroidManifestPermission_description android:description}</code>).
+The label should be short, a few words
+describing the key piece of functionality the permission is protecting. The
+description should be a couple sentences describing what the permission allows
+a holder to do. Our convention for the description is two sentences, the first
+describing the permission, the second warning the user of what bad things
+can happen if an application is granted the permission.</p>
+
+<p>Here is an example of a label and description for the CALL_PHONE
+permission:</p>
+
+<pre>
+ &lt;string name=&quot;permlab_callPhone&quot;&gt;directly call phone numbers&lt;/string&gt;
+ &lt;string name=&quot;permdesc_callPhone&quot;&gt;Allows the application to call
+ phone numbers without your intervention. Malicious applications may
+ cause unexpected calls on your phone bill. Note that this does not
+ allow the application to call emergency numbers.&lt;/string&gt;
+</pre>
+
+<p>You can look at the permissions currently defined in the system with the
+shell command <code>adb shell pm list permissions</code>. In particular,
+the '-s' option displays the permissions in a form roughly similar to how the
+user will see them:</p>
+
+<pre>
+$ adb shell pm list permissions -s
+All Permissions:
+
+Network communication: view Wi-Fi state, create Bluetooth connections, full
+Internet access, view network state
+
+Your location: access extra location provider commands, fine (GPS) location,
+mock location sources for testing, coarse (network-based) location
+
+Services that cost you money: send SMS messages, directly call phone numbers
+
+...</pre>
+
+<a name="manifest"></a>
+<h3>Enforcing Permissions in AndroidManifest.xml</h3>
+
+<p>High-level permissions restricting access to entire components of the
+system or application can be applied through your
+<code>AndroidManifest.xml</code>. All that this requires is including an {@link
+android.R.attr#permission android:permission} attribute on the desired
+component, naming the permission that will be used to control access to
+it.</p>
+
+<p><strong>{@link android.app.Activity}</strong> permissions
+(applied to the
+{@link android.R.styleable#AndroidManifestActivity &lt;activity&gt;} tag)
+restrict who can start the associated
+activity. The permission is checked during
+{@link android.content.Context#startActivity Context.startActivity()} and
+{@link android.app.Activity#startActivityForResult Activity.startActivityForResult()};
+if the caller does not have
+the required permission then {@link java.lang.SecurityException} is thrown
+from the call.</p>
+
+<p><strong>{@link android.app.Service}</strong> permissions
+(applied to the
+{@link android.R.styleable#AndroidManifestService &lt;service&gt;} tag)
+restrict who can start or bind to the
+associated service. The permission is checked during
+{@link android.content.Context#startService Context.startService()},
+{@link android.content.Context#stopService Context.stopService()} and
+{@link android.content.Context#bindService Context.bindService()};
+if the caller does not have
+the required permission then {@link java.lang.SecurityException} is thrown
+from the call.</p>
+
+<p><strong>{@link android.content.BroadcastReceiver}</strong> permissions
+(applied to the
+{@link android.R.styleable#AndroidManifestReceiver &lt;receiver&gt;} tag)
+restrict who can send broadcasts to the associated receiver.
+The permission is checked <em>after</em>
+{@link android.content.Context#sendBroadcast Context.sendBroadcast()} returns,
+as the system tries
+to deliver the submitted broadcast to the given receiver. As a result, a
+permission failure will not result in an exception being thrown back to the
+caller; it will just not deliver the intent. In the same way, a permission
+can be supplied to
+{@link android.content.Context#registerReceiver(android.content.BroadcastReceiver, android.content.IntentFilter, String, android.os.Handler)
+Context.registerReceiver()}
+to control who can broadcast to a programmatically registered receiver.
+Going the other way, a permission can be supplied when calling
+{@link android.content.Context#sendBroadcast(Intent, String) Context.sendBroadcast()}
+to restrict which BroadcastReceiver objects are allowed to receive the broadcast (see
+below).</p>
+
+<p><strong>{@link android.content.ContentProvider}</strong> permissions
+(applied to the
+{@link android.R.styleable#AndroidManifestProvider &lt;provider&gt;} tag)
+restrict who can access the data in
+a {@link android.content.ContentProvider}. (Content providers have an important
+additional security facility available to them called
+<a href="#uri">URI permissions</a> which is described later.)
+Unlike the other components,
+there are two separate permission attributes you can set:
+{@link android.R.attr#readPermission android:readPermission} restricts who
+can read from the provider, and
+{@link android.R.attr#writePermission android:writePermission} restricts
+who can write to it. Note that if a provider is protected with both a read
+and write permission, holding only the write permission does not mean
+you can read from a provider. The permissions are checked when you first
+retrieve a provider (if you don't have either permission, a SecurityException
+will be thrown), and as you perform operations on the provider. Using
+{@link android.content.ContentResolver#query ContentResolver.query()} requires
+holding the read permission; using
+{@link android.content.ContentResolver#insert ContentResolver.insert()},
+{@link android.content.ContentResolver#update ContentResolver.update()},
+{@link android.content.ContentResolver#delete ContentResolver.delete()}
+requires the write permission.
+In all of these cases, not holding the required permission results in a
+{@link java.lang.SecurityException} being thrown from the call.</p>
+
+
+<a name="broadcasts"></a>
+<h3>Enforcing Permissions when Sending Broadcasts</h3>
+
+<p>In addition to the permission enforcing who can send Intents to a
+registered {@link android.content.BroadcastReceiver} (as described above), you
+can also specify a required permission when sending a broadcast. By calling {@link
+android.content.Context#sendBroadcast(android.content.Intent,String)
+Context.sendBroadcast()} with a
+permission string, you require that a receiver's application must hold that
+permission in order to receive your broadcast.</p>
+
+<p>Note that both a receiver and a broadcaster can require a permission. When
+this happens, both permission checks must pass for the Intent to be delivered
+to the associated target.</p>
+
+
+<a name="enforcement"></a>
+<h3>Other Permission Enforcement</h3>
+
+<p>Arbitrarily fine-grained permissions can be enforced at any call into a
+service. This is accomplished with the {@link
+android.content.Context#checkCallingPermission Context.checkCallingPermission()}
+method. Call with a desired
+permission string and it will return an integer indicating whether that
+permission has been granted to the current calling process. Note that this can
+only be used when you are executing a call coming in from another process,
+usually through an IDL interface published from a service or in some other way
+given to another process.</p>
+
+<p>There are a number of other useful ways to check permissions. If you have
+the pid of another process, you can use the Context method {@link
+android.content.Context#checkPermission(String, int, int) Context.checkPermission(String, int, int)}
+to check a permission against that pid. If you have the package name of another
+application, you can use the direct PackageManager method {@link
+android.content.pm.PackageManager#checkPermission(String, String)
+PackageManager.checkPermission(String, String)}
+to find out whether that particular package has been granted a specific permission.</p>
+
+
+<a name="uri"></a>
+<h2>URI Permissions</h2>
+
+<p>The standard permission system described so far is often not sufficient
+when used with content providers. A content provider may want to
+protect itself with read and write permissions, while its direct clients
+also need to hand specific URIs to other applications for them to operate on.
+A typical example is attachments in a mail application. Access to the mail
+should be protected by permissions, since this is sensitive user data. However,
+if a URI to an image attachment is given to an image viewer, that image viewer
+will not have permission to open the attachment since it has no reason to hold
+a permission to access all e-mail.</p>
+
+<p>The solution to this problem is per-URI permissions: when starting an
+activity or returning a result to an activity, the caller can set
+{@link android.content.Intent#FLAG_GRANT_READ_URI_PERMISSION
+Intent.FLAG_GRANT_READ_URI_PERMISSION} and/or
+{@link android.content.Intent#FLAG_GRANT_WRITE_URI_PERMISSION
+Intent.FLAG_GRANT_WRITE_URI_PERMISSION}. This grants the receiving activity
+permission access the specific data URI in the Intent, regardless of whether
+it has any permission to access data in the content provider corresponding
+to the Intent.</p>
+
+<p>This mechanism allows a common capability-style model where user interaction
+(opening an attachment, selecting a contact from a list, etc) drives ad-hoc
+granting of fine-grained permission. This can be a key facility for reducing
+the permissions needed by applications to only those directly related to their
+behavior.</p>
+
+<p>The granting of fine-grained URI permissions does, however, require some
+cooperation with the content provider holding those URIs. It is strongly
+recommended that content providers implement this facility, and declare that
+they support it through the
+{@link android.R.styleable#AndroidManifestProvider_grantUriPermissions
+android:grantUriPermissions} attribute or
+{@link android.R.styleable#AndroidManifestGrantUriPermission
+&lt;grant-uri-permissions&gt;} tag.</p>
+
+<p>More information can be found in the
+{@link android.content.Context#grantUriPermission Context.grantUriPermission()},
+{@link android.content.Context#revokeUriPermission Context.revokeUriPermission()}, and
+{@link android.content.Context#checkUriPermission Context.checkUriPermission()}
+methods.</p>
+
diff --git a/docs/html/guide/topics/views/binding.jd b/docs/html/guide/topics/views/binding.jd
new file mode 100644
index 0000000..e6fa3ea
--- /dev/null
+++ b/docs/html/guide/topics/views/binding.jd
@@ -0,0 +1,80 @@
+page.title=Binding to Data with AdapterView
+@jd:body
+
+<p>Some types of ViewGroup objects have a UI that is visible on the screen &mdash; {@link android.widget.AdapterView AdapterView} is one such object. AdapterView is a ViewGroup subclass whose child Views are determined by an {@link android.widget.Adapter Adapter} that binds to data of some type. AdapterView is useful whenever you need to display stored data (versus resource strings or drawables) in your layout.</p>
+
+<p>{@link android.widget.Gallery Gallery}, {@link android.widget.ListView ListView}, and {@link android.widget.Spinner Spinner} are examples of AdapterView subclasses that you can use to bind to a specific type of data and display it in a certain way. </p>
+
+
+<p>AdapterView objects have two main responsibilities: </p>
+<ul>
+ <li>Filling the layout with data
+ </li>
+ <li>Handling user selections
+ </li>
+</ul>
+
+<p>The sections below describe how the AdapterView fulfills those responsibilities.</p>
+
+<h3>
+ Filling the layout with data
+</h3>
+
+<p>This is typically done by binding the class to an {@link
+android.widget.Adapter} that gets its data from somewhere &mdash; either a list that
+the code supplies, or query results from the device's database. </p>
+
+<pre>
+// Get a Spinner and bind it to an ArrayAdapter that
+// references a String array.
+Spinner s1 = (Spinner) findViewById(R.id.spinner1);
+ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
+ this, R.array.colors, android.R.layout.simple_spinner_item);
+adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+s1.setAdapter(adapter);
+
+// Load a Spinner and bind it to a data query.
+private static String[] PROJECTION = new String[] {
+ People._ID, People.NAME
+ };
+
+Spinner s2 = (Spinner) findViewById(R.id.spinner2);
+Cursor cur = managedQuery(People.CONTENT_URI, PROJECTION, null, null);
+
+SimpleCursorAdapter adapter2 = new SimpleCursorAdapter(this,
+ android.R.layout.simple_spinner_item, // Use a template
+ // that displays a
+ // text view
+ cur, // Give the cursor to the list adatper
+ new String[] {People.NAME}, // Map the NAME column in the
+ // people database to...
+ new int[] {android.R.id.text1}); // The "text1" view defined in
+ // the XML template
+
+adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+s2.setAdapter(adapter2);
+</pre>
+
+<p>Note that it is necessary to have the People._ID column in projection used with CursorAdapter
+or else you will get an exception.</p>
+<h3>
+ Handling user selections
+</h3>
+<p> This is done by setting the class's {@link
+android.widget.AdapterView.OnItemClickListener} member to a listener and
+catching the selection changes. </p>
+<pre>
+// Create a message handling object as an anonymous class.
+private OnItemClickListener mMessageClickedHandler = new OnItemClickListener() {
+ public void onItemClick(AdapterView parent, View v, int position, long id)
+ {
+ // Display a messagebox.
+ Toast.makeText(mContext,"You've got an event",Toast.LENGTH_SHORT).show();
+ }
+};
+
+// Now hook into our object and set its onItemClickListener member
+// to our class handler object.
+mHistoryView = (ListView)findViewById(R.id.history);
+mHistoryView.setOnItemClickListener(mMessageClickedHandler);
+</pre>
diff --git a/docs/html/guide/topics/views/custom-views.jd b/docs/html/guide/topics/views/custom-views.jd
new file mode 100644
index 0000000..9850e17
--- /dev/null
+++ b/docs/html/guide/topics/views/custom-views.jd
@@ -0,0 +1,440 @@
+page.title=Building Custom Views
+@jd:body
+
+<p>Android comes with a solid collection of Views that you can use
+to construct your applications, for example:</p>
+
+
+<p>Android offers a sophisticated and powerful componentized model for building your UI, based on the fundamental building block classes {@link android.view.View} and {@link android.view.ViewGroup}. To start with, the platform includes a variety of prebuilt View and ViewGroup subclasses &mdash; called widgets and layouts, respectively &mdash; that you can use to construct your UI. The widgets and layouts are fully implemented and handle all of their own measuring and drawing, so you can use them right away. You can make new types of UI elements simply by nesting and grouping the widgets and layouts. Using widgets and layouts is the recommended approach to building a UI for your applications.</p>
+
+<p>A partial list of available widgets includes {@link android.widget.Button Button},
+{@link android.widget.TextView TextView},
+{@link android.widget.EditText EditText},
+{@link android.widget.ListView ListView},
+{@link android.widget.CheckBox CheckBox},
+{@link android.widget.RadioButton RadioButton},
+{@link android.widget.Gallery Gallery},
+{@link android.widget.Spinner Spinner}, and the more special-purpose
+{@link android.widget.AutoCompleteTextView AutoCompleteTextView},
+{@link android.widget.ImageSwitcher ImageSwitcher}, and
+{@link android.widget.TextSwitcher TextSwitcher}. </p>
+
+<p>Among the layouts available are {@link android.widget.LinearLayout LinearLayout},
+{@link android.widget.FrameLayout FrameLayout}, {@link android.widget.AbsoluteLayout AbsoluteLayout},and others. For more examples, see <a href="layout">Common Layout Objects</a>.</p>
+
+<p>If none of the prebuilt widgets or layouts meets your needs, you can also create your own View subclass, such as a layout group or compound control. If you only need to make small adjustments to an existing widget or layout, you can simply subclass the widget or layout and override
+</p>
+
+<p>Creating your own View subclasses gives you precise control over the appearance and function of a screen element. To give an idea of the control you get with custom views, here are some examples of what you could do with them:</p>
+
+<ul>
+ <li>
+ You could create a completely custom-rendered View type, for example a "volume
+ control" knob rendered using 2D graphics, and which resembles an
+ analog electronic control.
+ </li>
+ <li>
+ You could combine a group of View components into a new single component, perhaps
+ to make something like a ComboBox (a combination of popup list and free
+ entry text field), a dual-pane selector control (a left and right pane
+ with a list in each where you can re-assign which item is in which
+ list), and so on.
+ </li>
+ <li>
+ You could override the way that an EditText component is rendered on the screen
+ (the Notepad tutorial uses this to good effect, to create a lined-notepad
+ page).
+ </li>
+ <li>
+ You could capture other events like key presses and handle them in some custom
+ way (such as for a game).
+ </li>
+</ul>
+<p>
+The sections below explain how to create custom Views and use them in your application.
+</p>
+
+<p>For detailed information, see {android.view.View}. </p>
+
+
+<h2 style="clear:right;">Contents</h2>
+<dl>
+<dt><a href="#basic">The Basic Approach</a></dt>
+<dt><a href="#custom">Fully Customized Views</a></dt>
+<dt><a href="#customexample">Customized View Example</a></dt>
+<dt><a href="#compound">Compound Controls</a></dt>
+<dt><a href="#tweaking">Modifying an Existing Component Type</a></dt>
+</dl>
+
+<a name="basic"></a>
+<h2>The Basic Approach
+</h2>
+<p>
+These steps provide a high level overview of
+what you need to know to get started in creating your own
+View components:</p>
+
+<ol>
+ <li>
+ Extend an existing {@link android.view.View View} class or subclass
+ with your own class.
+ </li>
+ <li>
+ Override some of the methods from the superclass: the superclass methods
+ to override start with '<code>on</code>', for
+ example, {@link android.view.View#onDraw onDraw()},
+ {@link android.view.View#onMeasure onMeasure()}, and
+ {@link android.view.View#onKeyDown onKeyDown()}.
+ <ul>
+ <li>
+ This is similar to the <code>on...</code> events in {@link android.app.Activity
+ Activity} or {@link android.app.ListActivity ListActivity}
+ that you override for life cycle and other functionality hooks.
+ </li>
+ </ul>
+ <li>
+ Use your new extension class: once completed, your new extension class
+ can be used in place of the view upon which it was based, but now with the new
+ functionality.
+ </li>
+</ol>
+<p class="note">
+ Extension classes can be defined as inner classes inside the activities
+ that use them. This is useful because it controls access to them but
+ isn't necessary (perhaps you want to create a new public View for
+ wider use in your application).
+</p>
+
+<a name="custom"></a>
+<h2>Fully Customized Components</h2>
+<p>
+Fully customized components can be used to create graphical components that
+appear however you wish. Perhaps a graphical VU
+meter that looks like an old analog gauge, or a sing-a-long text view where
+a bouncing ball moves along the words so you can sing along with a karaoke
+machine. Either way, you want something that the built-in components just
+won't do, no matter how you combine them.</p>
+<p>Fortunately, you can easily create components that look and behave in any
+way you like, limited perhaps only by your imagination, the size of the
+screen, and the available processing power (remember that ultimately your
+application might have to run on something with significantly less power
+than your desktop workstation).</p>
+<p>To create a fully customized component:</p>
+<ol>
+ <li>
+ The most generic view you can extend is, unsurprisingly, {@link
+ android.view.View View}, so you will usually start by extending this to
+ create your new super component.
+ </li>
+ <li>
+ You can supply a constructor which can
+ take attributes and parameters from the XML, and you can also consume
+ your own such attributes and parameters (perhaps the color and range of
+ the VU meter, or the width and damping of the needle, etc.)
+ </li>
+ <li>
+ You will probably want to create your own event listeners,
+ property accessors and modifiers, and possibly more sophisticated
+ behavior in your component class as well.
+ </li>
+ <li>
+ You will almost certainly want to override <code>onMeasure()</code> and
+ are also likely to need to override <code>onDraw()</code> if you want
+ the component to show something. While both have default behavior,
+ the default <code>onDraw()</code> will do nothing, and the default
+ <code>onMeasure()</code> will always set a size of 100x100 &mdash; which is
+ probably not what you want.
+ </li>
+ <li>
+ Other <code>on...</code> methods may also be overridden as required.
+ </li>
+</ol>
+<h4><code>onDraw()</code> and <code>onMeasure()</code></h4>
+<p><code>onDraw()</code> delivers you a {@link android.graphics.Canvas Canvas}
+upon which you can implement anything you want: 2D graphics, other standard or
+custom components, styled text, or anything else you can think of.</p>
+<p><em>Note:</em>
+Except for 3D graphics. If you want to
+use 3D graphics, you must extend {@link android.view.SurfaceView SurfaceView}
+instead of View, and draw from a seperate thread. See the
+GLSurfaceViewActivity sample
+for details.</p>
+<p><code>onMeasure()</code> is a little more involved. <code>onMeasure()</code>
+is a critical piece of the rendering contract between your component and its
+container. <code>onMeasure()</code> should be overridden to efficiently and
+accurately report the measurements of its contained parts. This is made
+slightly more complex by the requirements of limits from the parent
+(which are passed in to the <code>onMeasure()</code> method) and by the
+requirement to call the <code>setMeasuredDimension()</code> method with the
+measured width and height once they have been calculated. If you fail to
+call this method from an overridden <code>onMeasure()</code> method, the
+result will be an exception at measurement time.</p>
+<p>At a high level, implementing <code>onMeasure()</code> looks something
+ like this:</p>
+
+<ol>
+ <li>
+ The overridden <code>onMeasure()</code> method is called with width and
+ height measure specifications (<code>widthMeasureSpec</code> and
+ <code>heighMeasureSpec</code> parameters, both are integer codes
+ representing dimensions) which should be treated as requirements for
+ the restrictions on the width and height measurements you should produce. A
+ full reference to the kind of restrictions these specifications can require
+ can be found in the reference documentation under {@link
+ android.view.View#onMeasure View.onMeasure(int, int)} (this reference
+ documentation does a pretty good job of explaining the whole measurement
+ operation as well).
+ </li>
+ <li>
+ Your component's <code>onMeasure()</code> method should calculate a
+ measurement width and height which will be required to render the
+ component. It should try to stay within the specifications passed in,
+ although it can choose to exceed them (in this case, the parent can
+ choose what to do, including clipping, scrolling, throwing an exception,
+ or asking the <code>onMeasure()</code> to try again, perhaps with
+ different measurement specifications).
+ </li>
+ <li>
+ Once the width and height are calculated, the <code>setMeasuredDimension(int
+ width, int height)</code> method must be called with the calculated
+ measurements. Failure to do this will result in an exception being
+ thrown.
+ </li>
+</ol>
+
+<a name="customexample"></a>
+<h3>A Custom View Example</h3>
+<p>The CustomView sample in the
+<a href="{@docRoot}samples/ApiDemos/index.html">API Demos</a> provides an example
+of a customized View. The custom View is defined in the
+<a href="{@docRoot}samples/ApiDemos/src/com/example/android/apis/view/LabelView.html">LabelView</a>
+class.</p>
+<p>The LabelView sample demonstrates a number of different aspects of custom components:</p>
+<ul>
+ <li>Extending the View class for a completely custom component.</li>
+ <li>Parameterized constructor that takes the view inflation parameters
+ (parameters defined in the XML). Some of these are passed through to the
+ View superclass, but more importantly, there are some custom attributes defined
+ and used for LabelView.</li>
+ <li>Standard public methods of the type you would expect to see for a label
+ component, for example <code>setText()</code>, <code>setTextSize()</code>,
+ <code>setTextColor()</code> and so on.</li>
+ <li>An overridden <code>onMeasure</code> method to determine and set the
+ rendering size of the component. (Note that in LabelView, the real work is done
+ by a private <code>measureWidth()</code> method.)</li>
+ <li>An overridden <code>onDraw()</code> method to draw the label onto the
+ provided canvas.</li>
+</ul>
+<p>You can see some sample usages of the LabelView custom View in
+<a href="{@docRoot}samples/ApiDemos/res/layout/custom_view_1.html">custom_view_1.xml</a>
+from the samples. In particular, you can see a mix of both <code>android:</code>
+namespace parameters and custom <code>app:</code> namespace parameters. These
+<code>app:</code> parameters are the custom ones that the LabelView recognizes
+and works with, and are defined in a styleable inner class inside of the
+samples R resources definition class.</p>
+
+<a name="compound"></a>
+<h2>Compound Controls
+</h2>
+<p>If you don't want to create a completely customized component, but instead
+are looking to put together a reusable component that consists of a group of
+existing controls, then creating a Compound Component (or Compound Control) might
+fit the bill. In a nutshell, this brings together a number of more atomic
+controls (or views) into a logical group of items that can be treated as a
+single thing. For example, a Combo Box can be thought of as a
+combination of a single line EditText field and an adjacent button with an attached
+ PopupList. If you press the button and select
+something from the list, it populates the EditText field, but the user can
+also type something directly into the EditText if they prefer.</p>
+<p>In Android, there are actually two other Views readily available to do
+this: {@link android.widget.Spinner Spinner} and
+{@link android.widget.AutoCompleteTextView AutoCompleteTextView}, but
+regardless, the concept of a Combo Box makes an easy-to-understand
+example.</p>
+<p>To create a compound component:</p>
+<ol>
+ <li>
+ The usual starting point is a Layout of some kind, so create a class
+ that extends a Layout. Perhaps in the case of a Combo box we might use
+ a LinearLayout with horizontal orientation. Remember that other layouts
+ can be nested inside, so the compound component can be arbitrarily
+ complex and structured. Note that just like with an Activity, you can
+ use either the declarative (XML-based) approach to creating the
+ contained components, or you can nest them programmatically from your
+ code.
+ </li>
+ <li>
+ In the constructor for the new class, take whatever parameters the
+ superclass expects, and pass them through to the superclass constructor
+ first. Then you can set up the other views to use within your new
+ component; this is where you would create the EditText field and the
+ PopupList. Note that you also might introduce your own attributes and
+ parameters into the XML that can be pulled out and used by your
+ constructor.
+ </li>
+ <li>
+ You can also create listeners for events that your contained views might
+ generate, for example, a listener method for the List Item Click Listener
+ to update the contents of the EditText if a list selection is made.
+ </li>
+ <li>
+ You might also create your own properties with accessors and modifiers,
+ for example, allow the EditText value to be set initially in the
+ component and query for its contents when needed.
+ </li>
+ <li>
+ In the case of extending a Layout, you don't need to override the
+ <code>onDraw()</code> and <code>onMeasure()</code> methods since the
+ layout will have default behavior that will likely work just fine. However,
+ you can still override them if you need to.
+ </li>
+ <li>
+ You might override other <code>on...</code> methods, like
+ <code>onKeyDown()</code>, to perhaps choose certain default values from
+ the popup list of a combo box when a certain key is pressed.
+ </li>
+</ol>
+<p>
+ To summarize, the use of a Layout as the basis for a Custom Control has a
+number of advantages, including:</p>
+
+<ul>
+ <li>
+ You can specify the layout using the declarative XML files just like
+ with an activity screen, or you can create views programmatically and
+ nest them into the layout from your code.
+ </li>
+ <li>
+ The <code>onDraw()</code> and <code>onMeasure()</code> methods (plus
+ most of the other <code>on...</code> methods) will likely have suitable behavior so
+ you don't have to override them.
+ </li>
+ <li>
+ In the end, you can very quickly construct arbitrarily complex compound
+ views and re-use them as if they were a single component.
+ </li>
+</ul>
+<h4>Examples of Compound Controls</h4>
+<p>In the API Demos project
+ that comes with the SDK, there are two List
+ examples &mdash; Example 4 and Example 6 under Views/Lists demonstrate a
+ SpeechView which extends LinearLayout to make a component for displaying
+ Speech quotes. The corresponding classes in the sample code are
+ <code>List4.java</code> and <code>List6.java</code>.</p>
+
+<a name="tweaking"></a>
+<h2>Modifying an Existing View Type
+</h2>
+<p>There is an even easier option for creating a custom View which is
+useful in certain circumstances. If there is a component that is already very
+similar to what you want, you can simply extend that component and just
+override the behavior that you want to change. You can do all of the things
+you would do with a fully customized component, but by starting with a more
+specialized class in the View heirarchy, you can also get a lot of behavior for
+free that probably does exactly what you want.</p>
+<p>For example, the SDK includes a <a
+href="{@docRoot}samples/NotePad/index.html">NotePad application</a> in the
+samples. This demonstrates many aspects of using the Android platform, among
+them is extending an EditText View to make a lined notepad. This is not a
+perfect example, and the APIs for doing this might change from this early
+preview, but it does demonstrate the principles.</p>
+<p>If you haven't done so already, import the
+NotePad sample into Eclipse (or
+just look at the source using the link provided). In particular look at the definition of
+<code>MyEditText</code> in the <a
+href="{@docRoot}samples/NotePad/src/com/example/android/notepad/NoteEditor.html">NoteEditor.java</a>
+file.</p>
+<p>Some points to note here</p>
+<ol>
+ <li>
+ <strong>The Definition</strong>
+ <p>The class is defined with the following line:</p>
+ <code>public static class MyEditText extends EditText</code><br><br>
+
+ <ul>
+ <li>
+ It is defined as an inner class within the <code>NoteEditor</code>
+ activity, but it is public so that it could be accessed as
+ <code>NoteEditor.MyEditText</code> from outside of the <code>NoteEditor</code>
+ class if desired.
+ </li>
+ <li>
+ It is <code>static</code>, meaning it does not generate the so-called
+ "synthetic methods" that allow it to access data from the parent
+ class, which in turn means that it really behaves as a separate
+ class rather than something strongly related to <code>NoteEditor</code>.
+ This is a cleaner way to create inner classes if they do not need
+ access to state from the outer class, keeps the generated class
+ small, and allows it to be used easily from other classes.
+ </li>
+ <li>
+ It extends <code>EditText</code>, which is the View we have chosen to
+ customize in this case. When we are finished, the new class will be
+ able to substitute for a normal <code>EditText</code> view.<br>
+ <br>
+ </li>
+ </ul>
+ </li>
+ <li>
+ <strong>Class Initialization</strong>
+ <p>As always, the super is called first. Furthermore,
+ this is not a default constructor, but a parameterized one. The
+ EditText is created with these parameters when it is inflated from an
+ XML layout file, thus, our constructor needs to both take them and pass them
+ to the superclass constructor as well.</p>
+ </li>
+ <li>
+ <strong>Overridden Methods</strong>
+ <p>In this example, there is only one method to be overridden:
+ <code>onDraw()</code> &mdash; but there could easily be others needed when you
+ create your own custom components.</p>
+ <p>For the NotePad sample, overriding the <code>onDraw()</code> method allows
+ us to paint the blue lines on the <code>EditText</code> view canvas (the
+ canvas is passed into the overridden <code>onDraw()</code> method). The
+ super.onDraw() method is called before the method ends. The
+ superclass method should be invoked, but in this case, we do it at the
+ end after we have painted the lines we want to include.</p>
+ <li>
+ <strong>Use the Custom Component</strong>
+ <p>We now have our custom component, but how can we use it? In the
+ NotePad example, the custom component is used directly from the
+ declarative layout, so take a look at <code>note_editor.xml</code> in the
+ <code>res/layout</code> folder.</p>
+ <pre>
+&lt;view xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
+ class=&quot;com.android.notepad.NoteEditor$MyEditText&quot;
+ id=&quot;&#64;+id/note&quot;
+ android:layout_width=&quot;fill_parent&quot;
+ android:layout_height=&quot;fill_parent&quot;
+ android:background=&quot;&#64;android:drawable/empty&quot;
+ android:padding=&quot;10dip&quot;
+ android:scrollbars=&quot;vertical&quot;
+ android:fadingEdge=&quot;vertical&quot; /&gt; </pre>
+
+ <ul>
+ <li>
+ The custom component is created as a generic view in the XML, and
+ the class is specified using the full package. Note also that the
+ inner class we defined is referenced using the
+ <code>NoteEditor$MyEditText</code> notation which is a standard way to
+ refer to inner classes in the Java programming language.
+ </li>
+ <li>
+ The other attributes and parameters in the definition are the ones
+ passed into the custom component constructor, and then passed
+ through to the EditText constructor, so they are the same
+ parameters that you would use for an EditText view. Note that it is
+ possible to add your own parameters as well, and we will touch on
+ this again below.
+ </li>
+ </ul>
+ </li>
+</ol>
+<p>And that's all there is to it. Admittedly this is a simple case, but
+that's the point &mdash; creating custom components is only as complicated as you
+need it to be.</p>
+<p>A more sophisticated component may override even more <code>on...</code> methods and
+introduce some of its own helper methods, substantially customizing its properties and
+behavior. The only limit is your imagination and what you need the component to
+do.</p>
+
diff --git a/docs/html/guide/topics/views/hierarchy.jd b/docs/html/guide/topics/views/hierarchy.jd
new file mode 100644
index 0000000..17a13c1
--- /dev/null
+++ b/docs/html/guide/topics/views/hierarchy.jd
@@ -0,0 +1,47 @@
+page.title=Hierarchy of Screen Elements
+@jd:body
+
+<p>The basic functional unit of an Android application is the <em>activity</em> &mdash; an object of the class {@link android.app.Activity android.app.Activity}. An activity can do many things, but by itself it does not have a presence on the screen. To give your activity a screen presence and design its UI, you work with <em>views</em> and <em>viewgroups</em> -- basic units of user interface expression on the Android platform.</p>
+
+<h2>Views</h2>
+<p>A view is an object of base class {@link android.view.View android.view.View}. It's a data structure whose properties store the layout and content for a specific rectangular area of the screen. A View object handles measuring and layout, drawing, focus change, scrolling, and key/gestures for the screen area it represents. </p>
+<p>The View class serves as a base class for <em>widgets </em> &mdash; a set of fully implemented subclasses that draw interactive screen elements. Widgets handle their own measuring and drawing, so you can use them to build your UI more quickly. The list of widgets available includes Text, EditText, InputMethod, MovementMethod, Button, RadioButton, Checkbox, and ScrollView.</p>
+
+<h2>Viewgroups </h2>
+
+<p>A viewgroup is an object of class {@link android.view.ViewGroup android.view.Viewgroup}. As its name indicates, a viewgroup is a special type of view object whose function is to contain and manage a subordinate set of views and other viewgroups, Viewgroups let you add structure to your UI and build up complex screen elements that can be addressed as a single entity. </p>
+
+<p>The Viewgroup class serves as a base class for <em>layouts</em> &mdash; a set of fully implemented subclasses that provide common types of screen layout. The layouts give you a way to build a structure for a set of views. </p>
+
+<h2>A Tree-Structured UI</h2>
+
+<p>On the Android platform, you define an Activity's UI using a tree of view and viewgroup nodes, as shown in the diagram below. The tree can be as simple or complex as you need to make it, and you can build it up using Android's set of predefined widgets and layouts or custom view types that you create yourself. </p>
+
+<img src={@docRoot}images/viewgroup.png alt="An example of a tree of views and viewgroups" width="312" height="211" align="center"/>
+
+<p>To attach the tree to the screen for rendering, your Activity calls its setContentView() method and passes a reference to the root node object. Once the Android system has the reference to the root node object, it can work directly with the node to invalidate, measure, and draw the tree. When your Activity becomes active and receives focus, the system notifies your activity and requests the root node to measure and draw the tree. The root node then requests that its child nodes draw themselves &mdash; in turn, each viewgroup node in the tree is responsible for drawing its direct children. </p>
+
+<p>As mentioned previously, each view group has the responsibility of
+ measuring its available space, laying out its children, and calling Draw() on
+ each child to let it render itself. The children may request a size and location
+ in the parent, but the parent object has the final decision on where how big
+ each child can be.</p>
+
+<h2>LayoutParams: How a Child Specifies Its Position and Size</h2>
+
+<p>Every viewgroup class uses a nested class that extends {@link
+android.view.ViewGroup.LayoutParams ViewGroup.LayoutParams}. This subclass
+ contains property types that define a child's size and position, in properties
+ appropriate for that view group class. </p>
+
+<img src={@docRoot}images/layoutparams.png alt="An example of layoutparams" width="632" height="369" align="center"/>
+
+<p>Note that every LayoutParams subclass has its own syntax for setting
+values. Each child element must define LayoutParams that are appropriate for its parent, although it may define different LayoutParams for its children. </p>
+
+<p>All viewgroups include width and height. Many also include margins and
+borders. You can specify width and height exactly, though you probably won't want
+to do this often. More often you will tell your view to size itself either to
+the dimensions of its content, or to become as big as its containing object
+will allow.</p>
+
diff --git a/docs/html/guide/topics/views/index.jd b/docs/html/guide/topics/views/index.jd
new file mode 100644
index 0000000..9a15921d
--- /dev/null
+++ b/docs/html/guide/topics/views/index.jd
@@ -0,0 +1,45 @@
+page.title=Views and Layout
+@jd:body
+
+<p>To build a user interface fors your Android application, you work with <em>views</em> and <em>viewgroups</em> -- basic units of user interface expression on the Android platform. All views and viewgroups are descendants of the class {@link android.view.View}. To help you build your UI more quickly, Android provides a set of fully implemented views and viewgroups &mdash; called widgets and layouts &mdash; that you can use.
+
+The topics below describe the basics of how you use views to implement a user interface. including the types of screen elements available, the ways that you can declare them in your application, how you can bind a screen elements to local data, and how views can catch and handle screen or keypad events. </p>
+
+<p>For a quick start on how to create the Views you need for your UI, check out the <a href="{@docRoot}guide/tutorials/views/hello-views-index.html">Hello Views tutorials</a>. You can look at a variety of available layouts and screen elements as they would be rendered on a device, then look at the code for declaring and invoking each one. </p>
+
+<p>You can find additional sample code in the API Demos application, included in the SDK's samples directory. </p>
+
+<div class="sidebox">
+<p>Using Android resources is an important part of building your application's user interface. For information about what resources are available to you and how you use them, see the <a href="{@docRoot}guide/topics/resources/index.html">Resources</a> topics area.</p>
+</div>
+
+<ul>
+ <li>
+ <a href="hierarchy.html">Hierarchy of Screen Elements</a>
+ </li>
+ <li>
+ <a href="layout.html">Common Layout Objects</a>
+ </li>
+ <li>
+ <a href="ui-xml.html">Declaring a UI in XML</a>
+ </li>
+ <li>
+ <a href="binding.html">Binding to Data with AdapterView</a>
+ </li>
+ <li>
+ <a href="ui-events.html">Handling UI Events</a>
+ </li>
+ <li>
+ <a href="themes.html">Applying Styles and Themes to Your Application</a>
+ </li>
+ <li>
+ <a href="custom-views.html">Building Custom Views</a>
+ </li>
+ <li>
+ <a href="glossary.html">UI Elements and Concepts Glossary</a>
+ </li>
+ <li>
+ <a href="{@docRoot}guide/tutorials/views/hello-views-index.html">Hello Views</a>
+ </li>
+
+</ul>
diff --git a/docs/html/guide/topics/views/layout.jd b/docs/html/guide/topics/views/layout.jd
new file mode 100644
index 0000000..f6eedbb
--- /dev/null
+++ b/docs/html/guide/topics/views/layout.jd
@@ -0,0 +1,188 @@
+page.title=Common Layout Objects
+@jd:body
+
+<p>The sections below describe some of the more common types of layout objects you'll be likely to use in your applications. Like other layouts, they are subclasses of {@link android.view.ViewGroup ViewGroup}.</p>
+
+<h2>FrameLayout<a name="framelayout" id="framelayout"></a></h2>
+
+<p>{@link android.widget.FrameLayout FrameLayout} is the simplest layout
+object. It is intended as a blank reserved space on your screen that you can
+later fill with a single object &mdash; for example, a picture that you'll swap out.
+All child elements are pinned to the top left corner of the screen; you cannot
+specify a location for a child of a {@link android.widget.FrameLayout
+FrameLayout}. Later children will simply be drawn over earlier objects,
+partially or totally obscuring them (unless the newer object is transparent).
+</p>
+
+<h2>LinearLayout<a name="linearlayout" id="linearlayout"></a></h2>
+
+<p>A {@link android.widget.LinearLayout LinearLayout} aligns all children in a
+single direction &mdash; vertically or horizontally, depending on what property you
+set on the {@link android.widget.LinearLayout LinearLayout}. All children are
+stacked one after the other, so a vertical list will only have one child per
+row, no matter how wide they are, and a horizontal list will only be one row
+high (the height of the tallest child, plus padding). {@link
+android.widget.LinearLayout LinearLayout} respects margins between children,
+and also <em>gravity</em> (right, center, or left alignment of a child). </p>
+
+<p>{@link android.widget.LinearLayout LinearLayout} also supports assigning a
+<em>weight</em> to individual children. This value allows children to expand
+to fill any remaining space on a screen. This prevents a list of small objects
+from being bunched to one end of a large screen, allowing them to expand to
+fill the space. Children specify a weight value, and any remaining space is
+assigned to children in the proportion of their declared weight. Default
+weight is zero. So, for example, if there are three text boxes, and two of
+them declare a weight of 1, two of them will expand equally to fill the
+remaining space, and the third will not grow any additional amount.</p>
+
+<div class="sidebox">
+<p><strong>Tip</strong>: To create a proportionate size
+layout on the screen, create a container object that is fill_parent, assign
+the children heights or widths of zero, and then assign relative weight values
+to each child, depending on what proportion of the screen each should
+take.</p>
+</div>
+
+<p>The following two forms represent a {@link android.widget.LinearLayout LinearLayout} with a set of elements: a
+button, some labels, some text boxes. Both have padding values to adjust the
+padding nicely. The text boxes have their width set to <code>FILL_PARENT</code>; other
+elements are set to <code>WRAP_CONTENT</code>. The gravity, by default, is left. The form
+on the left has weight values unset (0 by default); the form on the right has
+the comments text box weight set to 1. If the Name textbox had also been set
+to 1, the Name and Comments text boxes would be the same height. </p>
+
+<p>
+ <img src="{@docRoot}images/linearlayout.png" alt="Linear layout with
+weight attribute." width="421" height="348" />
+</p>
+
+<p>Within a horizontal {@link android.widget.LinearLayout LinearLayout}, items are aligned by the position of
+their text base line (the first line of the first list element &mdash; topmost or
+leftmost &mdash; is considered the reference line). This is so that people scanning
+elements in a form shouldn't have to jump up and down to read element text in
+neighboring elements. This can be turned off by setting
+<code>android:baselineAligned=&quot;false&quot;</code> in the layout XML. </p>
+
+<h2>TableLayout<a name="tablelayout" id="tablelayout"></a></h2>
+
+<p>{@link android.widget.TableLayout TableLayout} positions its children into rows
+ and columns. A TableLayout consists of a number of TableRow objects,
+ each defining a row (actually, you can have other children, which will be explained
+ below). TableLayout containers do not display border lines for their rows, columns,
+ or cells. Each row has zero or more cells; each cell can hold one View object.
+ The table has as many columns as the row with the most cells. A table can leave
+cells empty. Cells cannot span columns, as they can in HTML. The following image
+ shows a table layout, with the invisible cell borders displayed as dotted lines. </p>
+<p><img src="{@docRoot}images/table_layout.png" alt="TableLayout example" width="499" height="348" /></p>
+<p>Columns can be hidden, can be marked to stretch to fill available screen space,
+ or can be marked as shrinkable to force the column to shrink until the table
+ fits the screen. See the reference documentation for this class for more details. </p>
+<h2>AbsoluteLayout<a name="absolutelayout" id="absolutelayout"></a></h2>
+<p>{@link android.widget.AbsoluteLayout AbsoluteLayout} enables children to specify
+ exact x/y coordinates to display on the screen, where (0,0) is the upper left
+ corner, and values increase as you move down or to the right. Margins are not
+ supported, and overlapping elements are allowed (although not recommended). We
+ generally recommend against using AbsoluteLayout unless you have good reasons
+ to use it, because it is fairly rigid and does not work well with different device
+ displays. </p>
+<h2>RelativeLayout<a name="relativelayout" id="relativelayout"></a></h2>
+<p>{@link android.widget.RelativeLayout RelativeLayout} lets children specify their
+ position relative to each other (specified by ID), or to the parent. So you can
+ align two elements by right border, or make one below another, or centered in
+ the screen. Elements are rendered in the order given, so if the first element
+ is centered in the screen, other elements aligning themselves to that element
+ will be aligned relative to screen center. If using XML to specify this layout
+ (as described later), a referenced element must be listed before you refer to
+ it. </p>
+<p>Here is an example relative layout with the visible and invisible elements outlined.
+ The root screen layout object is a RelativeLayout object. </p>
+<p><img src="{@docRoot}images/designing_ui_relative_layout.png" alt="RelativeLayout screen with elements highlighted." width="692" height="440" /></p>
+<p>This diagram shows the class names of the screen elements, followed by a list
+ of the properties of each. Some of these properties are supported directly by
+ the element, and some are supported by its LayoutParams member (subclass RelativeLayout
+ for all the elements in this screen, because all elements are children of a RelativeLayout
+ parent object). The RelativeLayout parameters are width, height, below, alignTop,
+ toLeft, padding, and marginLeft. Note that some of these parameters support values
+ relative to other children &mdash; hence the name RelativeLayout. These include the
+ toLeft, alignTop, and below properties, which indicate the object to the left,
+ top, and below respectively. </p>
+<h2>Summary of Important View Groups<a name="viewgroupsummary" id="viewgroupsummary"></a></h2>
+<p>These objects all hold child UI elements. Some provide visible UI, and others
+ only handle child layout. </p>
+<table width="100%" border="1">
+ <tr>
+ <th scope="col">Class</th>
+ <th scope="col">Description</th>
+ </tr>
+ <tr>
+ <td>{@link android.widget.AbsoluteLayout AbsoluteLayout}<br /></td>
+ <td>Enables you to specify the location of child objects relative to the
+ parent in exact measurements (for example, pixels). </td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.FrameLayout FrameLayout}</td>
+ <td>Layout that acts as a view frame to display
+ a single object. </td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.Gallery Gallery} </td>
+ <td>A horizontal scrolling display of images, from a bound list. </td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.GridView GridView} </td>
+ <td>Displays a scrolling grid of m columns and n rows.</td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.LinearLayout LinearLayout} </td>
+ <td>A layout that organizes its children into a single horizontal or vertical
+ row. It creates a scrollbar if the length of the window exceeds the length
+ of the screen. </td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.ListView ListView} </td>
+ <td>Displays a scrolling single column list. </td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.RelativeLayout RelativeLayout} </td>
+ <td>Enables you to specify the location of child objects relative to each
+ other (child A to the left of child B) or to the parent (aligned to the
+ top of the parent). </td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.ScrollView ScrollView} </td>
+ <td>A vertically scrolling column of elements. </td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.Spinner Spinner} </td>
+ <td>Displays a single item at a time from a bound list, inside a one-row
+ textbox. Rather like a one-row listbox that can scroll either horizontally
+ or vertically. </td>
+ </tr>
+ <tr>
+ <td>{@link android.view.SurfaceView SurfaceView} </td>
+ <td>Provides direct access to a dedicated drawing surface. It can hold child
+ views layered on top of the surface, but is intended for applications
+ that need to draw pixels, rather than using widgets. </td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.TabHost TabHost} </td>
+ <td>Provides a tab selection list that monitors clicks and enables the application
+ to change the screen whenever a tab is clicked. </td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.TableLayout TableLayout} </td>
+ <td>A tabular layout with an arbitrary number of rows and columns, each cell
+ holding the widget of your choice. The rows resize to fit the largest
+ column. The cell borders are not
+ visible. </td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.ViewFlipper ViewFlipper} </td>
+ <td>A list that displays one item at a time, inside a one-row textbox. It
+ can be set to swap items at timed intervals, like a slide show. </td>
+ </tr>
+ <tr>
+ <td>{@link android.widget.ViewSwitcher ViewSwitcher} </td>
+ <td>Same as ViewFlipper. </td>
+ </tr>
+</table>
diff --git a/docs/html/guide/topics/views/themes.jd b/docs/html/guide/topics/views/themes.jd
new file mode 100644
index 0000000..7c2e973
--- /dev/null
+++ b/docs/html/guide/topics/views/themes.jd
@@ -0,0 +1,88 @@
+page.title=Applying Styles and Themes to Your Application
+@jd:body
+
+<p>When designing your application, you can use <em>styles</em> and <em>themes</em> to apply uniform formatting to its various screens and UI elements.
+
+<ul>
+<li>A style is a set of one or more formatting attributes that you can apply as a unit to single elements in your layout XML file(s). For example, you could define a style that specifies a certain text size and color, then apply it to instances of a certain type of View element. </li>
+<li>A theme is a set of one or more formatting attributes that you can apply as a unit to all Activities in an application or to a single Activity. For example, you could define a theme that sets specific colors for the window frame and the panel foreground and background, and sets text sizes and colors for menus, then apply it to the Activities of your application.</li>
+</ul>
+
+<p>Styles and themes are resources &mdash; Android provides a variety default style and theme resources that you can use, or you can declare your own custom style and theme resources.
+
+<p>To create custom styles and themes, you declare new resources in an XML file, stored in the your application's <code>res/values</code> directory. You can then reference the custom resources from your other XML resources or manifest or from application code. When declaring styles and themes, in an XML file, you use the same container element &mdash; a <code>&lt;style&gt;</code> element. Inside, you declare format values in one or more <code>&lt;item&gt;</code> elements.</p>
+
+<p>Here's an example declaration of a style: </p>
+
+<pre>
+&lt;?xml version="1.0" encoding="utf-8"?&gt;
+&lt;resources&gt;
+ &lt;style name="SpecialText" parent="@style/Text"&gt;
+ &lt;item name="android:textSize"&gt;18sp&lt;/item&gt;
+ &lt;item name="android:textColor"&gt;#008&lt;/item&gt;
+ &lt;/style&gt;
+&lt;/resources&gt;
+</pre>
+
+<p>As shown, you can use <code>&lt;item&gt;</code> elements to set formatting values for the style. The <code>name</code> attribute can refer to a standard string, a hex color value, or a reference to any other resource type.</p>
+
+<p>Note the <code>parent</code> attribute in the <code>style</code> element. This attribute lets you specify a resource from which the current style will inherit values. The style can inherit from any type of resource that holds the style(s) you want. In general, your styles should always inherit (directly or indirectly) from a standard Android style resource, so that you only have to define the values that you want to change.</p>
+
+<p>Here's how you would reference the custom style from a resource delared in XML, in this case, an EditText element:</p>
+
+<pre>&lt;EditText id="@+id/text1"
+ style="@style/SpecialText"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="Hello, World!" /&gt;</pre>
+
+<p>Themes are declared in <code>&lt;style&gt;</code> elements also, and are referenced in the same manner, except that you can add a <code>style</code> attribute only to <code>&lt;application&gt;</code> and <code>&lt;activity&gt;</code> elements. If you do not explicitly specify a theme, the Android system applies default theme defined by {@link android.R.style#Theme}.</p>
+
+<p>Here's an example of how you would set a theme for all the activites of your application. The example applies a default system theme <code>Theme.Translucent</code>.</p>
+
+<pre>
+&lt;!-- AndroidManifest.xml--&gt;
+&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.home"&gt;
+ &lt;application android:theme="@android:style/Theme.Translucent" &gt;
+ &lt;activity class=".Home"
+ ...
+ &lt;/activity&gt;
+ &lt;/application&gt;
+&lt;/manifest&gt;
+</pre>
+
+<p>You can also load a theme for an Activity programmatically, if needed.
+To do so, use the {@link android.app.Activity#setTheme(int) setTheme()}
+method. Note that, when doing so, be sure to set the theme <em>before</em>
+instantiating any Views in the context, for example, before calling
+setContentView(View) or inflate(int, ViewGroup). This ensures that
+the system applies the same theme for all of your UI screens. Here's an example:</p>
+
+<pre>
+ protected void onCreate(Bundle icicle) {
+ super.onCreate(icicle);
+ ...
+ setTheme(android.R.style.Theme_Light);
+ setContentView(R.layout.linear_layout_3);
+}
+</pre>
+
+<p>If you are considering loading a theme programmatically for the main
+screen of your application, note that the theme would not be applied
+in any animations the system would use to show the activity, which
+would take place before your application starts. In most cases, if
+you want to apply a theme to your main screen, doing so in XML
+ is a better approach. </p>
+
+<p>For detailed information about custom styles and themes and referencing them from your application, see
+<a href="{@docRoot}reference/available-resources.html#stylesandthemes">Style
+and Theme Resources</a>.</p>
+
+<p>For information about default themes and styles available, see {@link android.R.style}.</p>
+
+
+
+
+
+
diff --git a/docs/html/guide/topics/views/ui-events.jd b/docs/html/guide/topics/views/ui-events.jd
new file mode 100644
index 0000000..4230314
--- /dev/null
+++ b/docs/html/guide/topics/views/ui-events.jd
@@ -0,0 +1,31 @@
+page.title=Handling UI Events
+@jd:body
+
+<p>Many Android classes declare callback methods for handling relevant UI events such as keypresses, touch events, focus changes, and so on. For example, {@link android.app.Activity Activity} provides the methods onKeyDown() and onKeyUp() and {@link android.widget.TextView TextView} provides onFocusChanged(). </p>
+
+<p>In most cases, you can handle events just by overriding the appropriate handler methods. When an event is received, the Android system calls your handler method with the event data.</p>
+
+<p>However, some classes do not declare handler methods for specific events. For example, {@link android.widget.Button Button} does not declare an onClick() handler method. To handle such events, you need to create an anonymous class to act as a listener for the event, then register the listener with the target class object. The example below shows how to set up a handler for click events in a Button object. </p>
+
+
+
+</p>
+<pre>public class ExampleSendResult extends Activity
+{
+ protected void onCreate(Bundle savedValues)
+ {
+ ...
+
+ // Listen for button clicks.
+ Button button = (Button)findViewById(R.id.corky);
+ button.setOnClickListener(mCorkyListener);
+ }
+
+ // Create an anonymous class to act as a button click listener.
+ private OnClickListener mCorkyListener = new OnClickListener()
+ {
+ public void onClick(View v)
+ {
+ //handle click event...
+ }
+ };</pre>
diff --git a/docs/html/guide/topics/views/ui-xml.jd b/docs/html/guide/topics/views/ui-xml.jd
new file mode 100644
index 0000000..f0a23c9
--- /dev/null
+++ b/docs/html/guide/topics/views/ui-xml.jd
@@ -0,0 +1,131 @@
+page.title=Declaring a UI in XML
+@jd:body
+
+<p>You can create your application's user interface in two ways:
+<ul>
+<li>You can declare UI elements statically, in XML. Android provides a straightforward XML vocabulary that corresponds to the View classes and subclasses, such as those for widgets and layouts. </li>
+<li>You can instantiate screen elements dynamically, at runtime, through code in your application. Your application can refer to or create View or other class objects and manipulate their properties programmatically. </li>
+</ul>
+
+<p>One advantage of declaring your UI in XML is that it enables you to better separate the presentation of your application from the code that controls it's behavior. Your UI description is external to your application code, which means that you can modify or adapt it without having to modify your source code and recompile. For example, you can create XML layouts for different screen orientations and for a variety of device screen sizes or languages. Additionally, declaring in XML makes it easier to see the elements and structure of your UI, so it's easier to debug problems. </p>
+
+<p>The Android framework gives you the flexibility to use either or both of these ways of declaring and managing your application's UI. For example, you could declare your application's default layouts in XML, including the screen elements that will appear in them and their properties. You could then add code in your application that would modify the state of the screen objects, including those declared in XML, at run time. </p>
+
+<p>You build your application's UI in approximately the same way, whether you are declaring it in XML or programmatically. In both cases, your UI will be a tree structure that may include multiple View or Viewgroup subclasses. <p>
+
+<p>In general, the XML vocabulary for declaring UI elements closely follows the structure and naming of the framework's UI-related classes and methods, where element names correspond to class names and attribute names correspond to methods. In fact, the correspondence is often so direct that you can guess what XML attribute corresponds to a class method, or guess what class corresponds to a given xml element. </p>
+
+<p>However, note that the XML vocabulary for defining UI is not entirely identical to the framework's classes and methods. In some cases, there are slight naming differences. For
+example, the EditText element has a <code>text</code> attribute that corresponds to
+EditText.setText. </p>
+
+<div class="sidebox"><p>For your convenience, the API reference documentation for UI related classes lists the available XML attributes that correspond to the class methods, including inherited attributes.</p>
+
+<p>To learn more about the available XML elements and attributes, as well as the format of the XML file, see <a
+href="{@docRoot}reference/available-resources.html#layoutresources">Layout Resources</a>.</p>
+ </div>
+
+<p>Using Android's XML vocabulary, you can quickly design UI layouts and the screen elements they contain, in the same way you create HTML files &mdash; as a series of nested tags. </p>
+
+<p>Each layout file must contain exactly one root element, and the root element must be a View or ViewGroup object. Once you've defined the root element, you can add additional layout objects or controls as child elements of the root element, if needed. In the example below, the tree of XML elements evaluates to the outermost LinearLayout object.
+
+<p>After you've declared your layout in XML, you must save the file, with the <code>.xml</code> extension, in the proper location, so that it will be compiled correctly. The proper location for storing layout files is in your application's <code>res/layout/</code> directory. </p>
+
+<p>When you compile your application, each XML layout file is compiled into an
+android.view.View resource. You can then load the layout resource from your application code, by calling <code>setContentView(R.layout.<em>layout_file_name</em>)</code> in your {@link android.app.Activity#onCreate(android.os.Bundle) Activity.onCreate()}
+implementation.</p>
+
+<p>When you load a layout resource, the Android system initializes run-time objects corresponding to the elements in your layout. It parses the elements of your layout in-order (depth-first), instantiating the Views and adding them to their parent(s). </p>
+
+<p>Attributes named <code>layout_<em>something</em></code> apply to that
+object's LayoutParams member. <a href="{@docRoot}reference/available-resources.html#layoutresources">Layout
+Resources</a> also describes how to learn the syntax for specifying
+LayoutParams properties. </p>
+
+<p>Also note that Android draws elements in the order in which they
+appear in the XML. Therefore, if elements overlap, the last one in the XML
+file will probably be drawn on top of any previously listed elements in that
+same space.</p>
+
+<p>The following values are supported for dimensions (described in {@link
+android.util.TypedValue TypedValue}):</p>
+
+<ul>
+ <li>px (pixels) </li>
+ <li>dip (device independent pixels) </li>
+ <li>sp (scaled pixels &mdash; best for text size) </li>
+ <li>pt (points) </li>
+ <li>in (inches) </li>
+ <li>mm (millimeters) </li>
+</ul>
+
+<p>Example: <code>android:layout_width=&quot;25px&quot;</code> </p>
+
+<p>For more information about these dimensions, see <a href="{@docRoot}reference/available-resources.html#dimension">Dimension Values</a>.</p>
+
+<p>The example below shows an XML file and the resulting screen in the UI. Note that the text on the
+top of the screen was set by calling {@link
+android.app.Activity#setTitle(java.lang.CharSequence) Activity.setTitle}. Note
+that the attributes that refer to relative elements (i.e., layout_toLeft)
+refer to the ID using the syntax of a relative resource
+(@id/<em>id_number</em>). </p>
+
+<table border="1">
+ <tr>
+ <td>
+ <pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
+&lt;!-- Demonstrates using a relative layout to create a form --&gt;
+&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android
+ android:layout_width=&quot;fill_parent&quot;
+ android:layout_height=&quot;wrap_content&quot;
+ android:background=&quot;@drawable/blue&quot;
+ android:padding=&quot;10px&quot;&gt;
+
+ &lt;TextView id=&quot;@+id/label&quot;
+ android:layout_width=&quot;fill_parent&quot;
+ android:layout_height=&quot;wrap_content&quot;
+ android:text=&quot;Type here:&quot;/&gt;
+
+ &lt;EditText id=&quot;@+id/entry&quot;
+ android:layout_width=&quot;fill_parent&quot;
+ android:layout_height=&quot;wrap_content&quot;
+ android:background=&quot;@android:drawable/editbox_background&quot;
+ android:layout_below=&quot;@id/label&quot;/&gt;
+
+ &lt;Button id=&quot;@+id/ok&quot;
+ android:layout_width=&quot;wrap_content&quot;
+ android:layout_height=&quot;wrap_content&quot;
+ android:layout_below=&quot;@id/entry&quot;
+ android:layout_alignParentRight=&quot;true&quot;
+ android:layout_marginLeft=&quot;10px&quot;
+ android:text=&quot;OK&quot; /&gt;
+
+ &lt;Button android:layout_width=&quot;wrap_content&quot;
+ android:layout_height=&quot;wrap_content&quot;
+ android:layout_toLeftOf=&quot;@id/ok&quot;
+ android:layout_alignTop=&quot;@id/ok&quot;
+ android:text=&quot;Cancel&quot; /&gt;
+&lt;/RelativeLayout&gt;</pre></td>
+ <td><img src="{@docRoot}images/designing_ui_layout_example.png" alt="Screen shot showing how this layout XML file is rendered." /></td>
+ </tr>
+</table>
+
+<h3>Loading the XML Resource </h3>
+
+<p>Loading the compiled layout resource is very easy, and done with a single
+call in the activity's onCreate() method, as shown here:</p>
+
+<pre>
+protected void onCreate(Bundle savedValues)
+{
+ // Be sure to call the super class.
+ super.onCreate(savedValues);
+
+ // Load the compiled layout resource into the window's
+ // default ViewGroup.
+ // The source file is res/layout/hello_activity.xml
+ setContentView(R.layout.hello_activity);
+
+ // Retrieve any important stored values.
+ restoreValues(savedValues);
+} </pre>