summaryrefslogtreecommitdiffstats
path: root/docs/html/guide
diff options
context:
space:
mode:
Diffstat (limited to 'docs/html/guide')
-rw-r--r--docs/html/guide/components/fundamentals.jd388
-rw-r--r--docs/html/guide/components/index.jd2
-rw-r--r--docs/html/guide/components/intents-common.jd1316
-rw-r--r--docs/html/guide/components/intents-filters.jd1640
-rw-r--r--docs/html/guide/components/services.jd54
-rw-r--r--docs/html/guide/guide_toc.cs263
-rw-r--r--docs/html/guide/index.jd75
-rw-r--r--docs/html/guide/practices/compatibility.jd485
-rw-r--r--docs/html/guide/practices/screens_support.jd3
-rw-r--r--docs/html/guide/topics/connectivity/bluetooth-le.jd9
-rw-r--r--docs/html/guide/topics/connectivity/nfc/hce.jd569
-rw-r--r--docs/html/guide/topics/data/data-storage.jd247
-rw-r--r--docs/html/guide/topics/manifest/action-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/activity-alias-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/activity-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/application-element.jd3
-rw-r--r--docs/html/guide/topics/manifest/category-element.jd10
-rw-r--r--docs/html/guide/topics/manifest/compatible-screens-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/data-element.jd147
-rw-r--r--docs/html/guide/topics/manifest/grant-uri-permission-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/instrumentation-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/intent-filter-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/manifest-element.jd12
-rw-r--r--docs/html/guide/topics/manifest/manifest-intro.jd12
-rw-r--r--docs/html/guide/topics/manifest/meta-data-element.jd6
-rw-r--r--docs/html/guide/topics/manifest/path-permission-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/permission-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/permission-group-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/permission-tree-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/provider-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/receiver-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/service-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/supports-gl-texture-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/supports-screens-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/uses-configuration-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/uses-feature-element.jd60
-rw-r--r--docs/html/guide/topics/manifest/uses-library-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/uses-permission-element.jd2
-rw-r--r--docs/html/guide/topics/manifest/uses-sdk-element.jd24
-rw-r--r--docs/html/guide/topics/media/mediaplayer.jd14
-rw-r--r--docs/html/guide/topics/media/mediarouter.jd670
-rw-r--r--docs/html/guide/topics/providers/document-provider.jd93
-rw-r--r--docs/html/guide/topics/resources/runtime-changes.jd116
-rw-r--r--docs/html/guide/topics/security/permissions.jd72
-rw-r--r--docs/html/guide/topics/ui/dialogs.jd2
45 files changed, 4253 insertions, 2077 deletions
diff --git a/docs/html/guide/components/fundamentals.jd b/docs/html/guide/components/fundamentals.jd
index ce50022..9ac063e 100644
--- a/docs/html/guide/components/fundamentals.jd
+++ b/docs/html/guide/components/fundamentals.jd
@@ -4,24 +4,9 @@ page.title=Application Fundamentals
<div id="qv-wrapper">
<div id="qv">
-<h2>Quickview</h2>
-<ul>
- <li>Android applications are composed of one or more application components (activities,
-services, content providers, and broadcast receivers)</li>
- <li>Each component performs a different role in the overall application behavior, and each
-one can be activated individually (even by other applications)</li>
- <li>The manifest file must declare all components in the application and should also declare
-all application requirements, such as the minimum version of Android required and any hardware
-configurations required</li>
- <li>Non-code application resources (images, strings, layout files, etc.) should include
-alternatives for different device configurations (such as different strings for different
-languages and different layouts for different screen sizes)</li>
-</ul>
-
-
<h2>In this document</h2>
<ol>
-<li><a href="#Components">Application Components</a>
+<li><a href="#Components">App Components</a>
<ol>
<li><a href="#ActivatingComponents">Activating components</a></li>
</ol>
@@ -29,98 +14,91 @@ languages and different layouts for different screen sizes)</li>
<li><a href="#Manifest">The Manifest File</a>
<ol>
<li><a href="#DeclaringComponents">Declaring components</a></li>
- <li><a href="#DeclaringRequirements">Declaring application requirements</a></li>
+ <li><a href="#DeclaringRequirements">Declaring app requirements</a></li>
</ol>
</li>
-<li><a href="#Resources">Application Resources</a></li>
+<li><a href="#Resources">App Resources</a></li>
</ol>
</div>
</div>
-<p>Android applications are written in the Java programming language. The Android SDK tools compile
-the code&mdash;along with any data and resource files&mdash;into an <i>Android package</i>, an
-archive file with an {@code .apk} suffix. All the code in a single {@code .apk} file is considered
-to be one application and is the file that Android-powered devices use to install the
-application.</p>
+<p>Android apps are written in the Java programming language. The Android SDK tools compile
+your code&mdash;along with any data and resource files&mdash;into an APK: an <i>Android package</i>,
+which is an archive file with an {@code .apk} suffix. One APK file contains all the contents
+of an Android app and is the file that Android-powered devices use to install the app.</p>
-<p>Once installed on a device, each Android application lives in its own security sandbox: </p>
+<p>Once installed on a device, each Android app lives in its own security sandbox: </p>
<ul>
- <li>The Android operating system is a multi-user Linux system in which each application is a
+ <li>The Android operating system is a multi-user Linux system in which each app is a
different user.</li>
-<li>By default, the system assigns each application a unique Linux user ID (the ID is used only by
-the system and is unknown to the application). The system sets permissions for all the files in an
-application so that only the user ID assigned to that application can access them. </li>
+<li>By default, the system assigns each app a unique Linux user ID (the ID is used only by
+the system and is unknown to the app). The system sets permissions for all the files in an
+app so that only the user ID assigned to that app can access them. </li>
-<li>Each process has its own virtual machine (VM), so an application's code runs in isolation from
-other applications.</li>
+<li>Each process has its own virtual machine (VM), so an app's code runs in isolation from
+other apps.</li>
-<li>By default, every application runs in its own Linux process. Android starts the process when any
-of the application's components need to be executed, then shuts down the process when it's no longer
-needed or when the system must recover memory for other applications.</li>
+<li>By default, every app runs in its own Linux process. Android starts the process when any
+of the app's components need to be executed, then shuts down the process when it's no longer
+needed or when the system must recover memory for other apps.</li>
</ul>
<p>In this way, the Android system implements the <em>principle of least privilege</em>. That is,
-each application, by default, has access only to the components that it requires to do its work and
-no more. This creates a very secure environment in which an application cannot access parts of
+each app, by default, has access only to the components that it requires to do its work and
+no more. This creates a very secure environment in which an app cannot access parts of
the system for which it is not given permission.</p>
-<p>However, there are ways for an application to share data with other applications and for an
-application to access system services:</p>
+<p>However, there are ways for an app to share data with other apps and for an
+app to access system services:</p>
<ul>
- <li>It's possible to arrange for two applications to share the same Linux user ID, in which case
-they are able to access each other's files. To conserve system resources, applications with the
+ <li>It's possible to arrange for two apps to share the same Linux user ID, in which case
+they are able to access each other's files. To conserve system resources, apps with the
same user ID can also arrange to run in the same Linux process and share the same VM (the
-applications must also be signed with the same certificate).</li>
- <li>An application can request permission to access device data such as the user's
+apps must also be signed with the same certificate).</li>
+ <li>An app can request permission to access device data such as the user's
contacts, SMS messages, the mountable storage (SD card), camera, Bluetooth, and more. All
-application permissions must be granted by the user at install time.</li>
+app permissions must be granted by the user at install time.</li>
</ul>
-<p>That covers the basics regarding how an Android application exists within the system. The rest of
+<p>That covers the basics regarding how an Android app exists within the system. The rest of
this document introduces you to:</p>
<ul>
- <li>The core framework components that define your application.</li>
+ <li>The core framework components that define your app.</li>
<li>The manifest file in which you declare components and required device features for your
-application.</li>
- <li>Resources that are separate from the application code and allow your application to
+app.</li>
+ <li>Resources that are separate from the app code and allow your app to
gracefully optimize its behavior for a variety of device configurations.</li>
</ul>
-<!--
-<p class="note"><strong>Tip:</strong> If you're new to Android development, we suggest that you
-follow the Beginner's Path link at the bottom of this page. For each document in the Application
-Fundamentals, the Beginner's Path points you to the document we suggest you read next, in order
-to get up to speed on the core Android concepts.</p>
--->
-<h2 id="Components">Application Components</h2>
+<h2 id="Components">App Components</h2>
-<p>Application components are the essential building blocks of an Android application. Each
-component is a different point through which the system can enter your application. Not all
+<p>App components are the essential building blocks of an Android app. Each
+component is a different point through which the system can enter your app. Not all
components are actual entry points for the user and some depend on each other, but each one exists
as its own entity and plays a specific role&mdash;each one is a unique building block that
-helps define your application's overall behavior.</p>
+helps define your app's overall behavior.</p>
-<p>There are four different types of application components. Each type serves a distinct purpose
+<p>There are four different types of app components. Each type serves a distinct purpose
and has a distinct lifecycle that defines how the component is created and destroyed.</p>
-<p>Here are the four types of application components:</p>
+<p>Here are the four types of app components:</p>
<dl>
<dt><b>Activities</b></dt>
<dd>An <i>activity</i> represents a single screen with a user interface. For example,
-an email application might have one activity that shows a list of new
+an email app might have one activity that shows a list of new
emails, another activity to compose an email, and another activity for reading emails. Although
-the activities work together to form a cohesive user experience in the email application, each one
-is independent of the others. As such, a different application can start any one of these
-activities (if the email application allows it). For example, a camera application can start the
-activity in the email application that composes new mail, in order for the user to share a picture.
+the activities work together to form a cohesive user experience in the email app, each one
+is independent of the others. As such, a different app can start any one of these
+activities (if the email app allows it). For example, a camera app can start the
+activity in the email app that composes new mail, in order for the user to share a picture.
<p>An activity is implemented as a subclass of {@link android.app.Activity} and you can learn more
about it in the <a href="{@docRoot}guide/components/activities.html">Activities</a>
@@ -133,7 +111,7 @@ developer guide.</p>
<dd>A <i>service</i> is a component that runs in the background to perform long-running
operations or to perform work for remote processes. A service
does not provide a user interface. For example, a service might play music in the background while
-the user is in a different application, or it might fetch data over the network without
+the user is in a different app, or it might fetch data over the network without
blocking user interaction with an activity. Another component, such as an activity, can start the
service and let it run or bind to it in order to interact with it.
@@ -145,21 +123,21 @@ guide.</p>
<dt><b>Content providers</b></dt>
-<dd>A <i>content provider</i> manages a shared set of application data. You can store the data in
+<dd>A <i>content provider</i> manages a shared set of app data. You can store the data in
the file system, an SQLite database, on the web, or any other persistent storage location your
-application can access. Through the content provider, other applications can query or even modify
+app can access. Through the content provider, other apps can query or even modify
the data (if the content provider allows it). For example, the Android system provides a content
-provider that manages the user's contact information. As such, any application with the proper
+provider that manages the user's contact information. As such, any app with the proper
permissions can query part of the content provider (such as {@link
android.provider.ContactsContract.Data}) to read and write information about a particular person.
<p>Content providers are also useful for reading and writing data that is private to your
-application and not shared. For example, the <a
-href="{@docRoot}resources/samples/NotePad/index.html">Note Pad</a> sample application uses a
+app and not shared. For example, the <a
+href="{@docRoot}resources/samples/NotePad/index.html">Note Pad</a> sample app uses a
content provider to save notes.</p>
<p>A content provider is implemented as a subclass of {@link android.content.ContentProvider}
-and must implement a standard set of APIs that enable other applications to perform
+and must implement a standard set of APIs that enable other apps to perform
transactions. For more information, see the <a
href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a> developer
guide.</p>
@@ -171,7 +149,7 @@ guide.</p>
<dd>A <i>broadcast receiver</i> is a component that responds to system-wide broadcast
announcements. Many broadcasts originate from the system&mdash;for example, a broadcast announcing
that the screen has turned off, the battery is low, or a picture was captured.
-Applications can also initiate broadcasts&mdash;for example, to let other applications know that
+Apps can also initiate broadcasts&mdash;for example, to let other apps know that
some data has been downloaded to the device and is available for them to use. Although broadcast
receivers don't display a user interface, they may <a
href="{@docRoot}guide/topics/ui/notifiers/notifications.html">create a status bar notification</a>
@@ -188,26 +166,26 @@ see the {@link android.content.BroadcastReceiver} class.</p>
-<p>A unique aspect of the Android system design is that any application can start another
-application’s component. For example, if you want the user to capture a
-photo with the device camera, there's probably another application that does that and your
-application can use it, instead of developing an activity to capture a photo yourself. You don't
-need to incorporate or even link to the code from the camera application.
-Instead, you can simply start the activity in the camera application that captures a
-photo. When complete, the photo is even returned to your application so you can use it. To the user,
-it seems as if the camera is actually a part of your application.</p>
+<p>A unique aspect of the Android system design is that any app can start another
+app’s component. For example, if you want the user to capture a
+photo with the device camera, there's probably another app that does that and your
+app can use it, instead of developing an activity to capture a photo yourself. You don't
+need to incorporate or even link to the code from the camera app.
+Instead, you can simply start the activity in the camera app that captures a
+photo. When complete, the photo is even returned to your app so you can use it. To the user,
+it seems as if the camera is actually a part of your app.</p>
-<p>When the system starts a component, it starts the process for that application (if it's not
+<p>When the system starts a component, it starts the process for that app (if it's not
already running) and instantiates the classes needed for the component. For example, if your
-application starts the activity in the camera application that captures a photo, that activity
-runs in the process that belongs to the camera application, not in your application's process.
-Therefore, unlike applications on most other systems, Android applications don't have a single entry
+app starts the activity in the camera app that captures a photo, that activity
+runs in the process that belongs to the camera app, not in your app's process.
+Therefore, unlike apps on most other systems, Android apps don't have a single entry
point (there's no {@code main()} function, for example).</p>
-<p>Because the system runs each application in a separate process with file permissions that
-restrict access to other applications, your application cannot directly activate a component from
-another application. The Android system, however, can. So, to activate a component in
-another application, you must deliver a message to the system that specifies your <em>intent</em> to
+<p>Because the system runs each app in a separate process with file permissions that
+restrict access to other apps, your app cannot directly activate a component from
+another app. The Android system, however, can. So, to activate a component in
+another app, you must deliver a message to the system that specifies your <em>intent</em> to
start a particular component. The system then activates the component for you.</p>
@@ -217,7 +195,7 @@ start a particular component. The system then activates the component for you.</
broadcast receivers&mdash;are activated by an asynchronous message called an <em>intent</em>.
Intents bind individual components to each other at runtime (you can think of them
as the messengers that request an action from other components), whether the component belongs
-to your application or another.</p>
+to your app or another.</p>
<p>An intent is created with an {@link android.content.Intent} object, which defines a message to
activate either a specific component or a specific <em>type</em> of component&mdash;an intent
@@ -273,21 +251,21 @@ href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers
<h2 id="Manifest">The Manifest File</h2>
-<p>Before the Android system can start an application component, the system must know that the
-component exists by reading the application's {@code AndroidManifest.xml} file (the "manifest"
-file). Your application must declare all its components in this file, which must be at the root of
-the application project directory.</p>
+<p>Before the Android system can start an app component, the system must know that the
+component exists by reading the app's {@code AndroidManifest.xml} file (the "manifest"
+file). Your app must declare all its components in this file, which must be at the root of
+the app project directory.</p>
-<p>The manifest does a number of things in addition to declaring the application's components,
+<p>The manifest does a number of things in addition to declaring the app's components,
such as:</p>
<ul>
- <li>Identify any user permissions the application requires, such as Internet access or
+ <li>Identify any user permissions the app requires, such as Internet access or
read-access to the user's contacts.</li>
<li>Declare the minimum <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">API Level</a>
-required by the application, based on which APIs the application uses.</li>
- <li>Declare hardware and software features used or required by the application, such as a camera,
+required by the app, based on which APIs the app uses.</li>
+ <li>Declare hardware and software features used or required by the app, such as a camera,
bluetooth services, or a multitouch screen.</li>
- <li>API libraries the application needs to be linked against (other than the Android framework
+ <li>API libraries the app needs to be linked against (other than the Android framework
APIs), such as the <a
href="http://code.google.com/android/add-ons/google-apis/maps-overview.html">Google Maps
library</a>.</li>
@@ -297,7 +275,7 @@ library</a>.</li>
<h3 id="DeclaringComponents">Declaring components</h3>
-<p>The primary task of the manifest is to inform the system about the application's components. For
+<p>The primary task of the manifest is to inform the system about the app's components. For
example, a manifest file can declare an activity as follows: </p>
<pre>
@@ -314,7 +292,7 @@ example, a manifest file can declare an activity as follows: </p>
<p>In the <code><a
href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code>
element, the {@code android:icon} attribute points to resources for an icon that identifies the
-application.</p>
+app.</p>
<p>In the <code><a
href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code> element,
@@ -322,7 +300,7 @@ the {@code android:name} attribute specifies the fully qualified class name of t
android.app.Activity} subclass and the {@code android:label} attributes specifies a string
to use as the user-visible label for the activity.</p>
-<p>You must declare all application components this way:</p>
+<p>You must declare all app components this way:</p>
<ul>
<li><code><a
href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code> elements
@@ -345,7 +323,7 @@ receivers can be either declared in the manifest or created dynamically in code
{@link android.content.BroadcastReceiver} objects) and registered with the system by calling
{@link android.content.Context#registerReceiver registerReceiver()}.</p>
-<p>For more about how to structure the manifest file for your application, see <a
+<p>For more about how to structure the manifest file for your app, see <a
href="{@docRoot}guide/topics/manifest/manifest-intro.html">The AndroidManifest.xml File</a>
documentation. </p>
@@ -356,28 +334,43 @@ documentation. </p>
<p>As discussed above, in <a href="#ActivatingComponents">Activating Components</a>, you can use an
{@link android.content.Intent} to start activities, services, and broadcast receivers. You can do so
by explicitly naming the target component (using the component class name) in the intent. However,
-the real power of intents lies in the concept of intent actions. With intent actions, you simply
-describe the type of action you want to perform (and optionally, the data upon which you’d like to
+the real power of intents lies in the concept of <em>implicit intents</em>. An implicit intent
+simply describe the type of action to perform (and optionally, the data upon which you’d like to
perform the action) and allow the system to find a component on the device that can perform the
action and start it. If there are multiple components that can perform the action described by the
intent, then the user selects which one to use.</p>
<p>The way the system identifies the components that can respond to an intent is by comparing the
-intent received to the <i>intent filters</i> provided in the manifest file of other applications on
+intent received to the <i>intent filters</i> provided in the manifest file of other apps on
the device.</p>
-<p>When you declare a component in your application's manifest, you can optionally include
-intent filters that declare the capabilities of the component so it can respond to intents
-from other applications. You can declare an intent filter for your component by
+<p>When you declare an activity in your app's manifest, you can optionally include
+intent filters that declare the capabilities of the activity so it can respond to intents
+from other apps. You can declare an intent filter for your component by
adding an <a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">{@code
&lt;intent-filter&gt;}</a> element as a child of the component's declaration element.</p>
-<p>For example, an email application with an activity for composing a new email might declare an
-intent filter in its manifest entry to respond to "send" intents (in order to send email). An
-activity in your application can then create an intent with the “send” action ({@link
-android.content.Intent#ACTION_SEND}), which the system matches to the email application’s “send”
-activity and launches it when you invoke the intent with {@link android.app.Activity#startActivity
-startActivity()}.</p>
+<p>For example, if you've built an email app with an activity for composing a new email, you can
+declare an intent filter to respond to "send" intents (in order to send a new email) like this:</p>
+<pre>
+&lt;manifest ... >
+ ...
+ &lt;application ... &gt;
+ &lt;activity android:name="com.example.project.ComposeEmailActivity">
+ &lt;intent-filter>
+ &lt;action android:name="android.intent.action.SEND" />
+ &lt;data android:type="*/*" />
+ &lt;category android:name="android.intent.category.DEFAULT" />
+ &lt;/intent-filter>
+ &lt;/activity>
+ &lt;/application&gt;
+&lt;/manifest>
+</pre>
+
+<p>Then, if another app creates an intent with the {@link
+android.content.Intent#ACTION_SEND} action and pass it to {@link android.app.Activity#startActivity
+startActivity()}, the system may start your activity so the user can draft and send an
+email.</p>
<p>For more about creating intent filters, see the <a
href="{@docRoot}guide/components/intents-filters.html">Intents and Intent Filters</a> document.
@@ -385,102 +378,57 @@ href="{@docRoot}guide/components/intents-filters.html">Intents and Intent Filter
-<h3 id="DeclaringRequirements">Declaring application requirements</h3>
+<h3 id="DeclaringRequirements">Declaring app requirements</h3>
<p>There are a variety of devices powered by Android and not all of them provide the
-same features and capabilities. In order to prevent your application from being installed on devices
-that lack features needed by your application, it's important that you clearly define a profile for
-the types of devices your application supports by declaring device and software requirements in your
+same features and capabilities. In order to prevent your app from being installed on devices
+that lack features needed by your app, it's important that you clearly define a profile for
+the types of devices your app supports by declaring device and software requirements in your
manifest file. Most of these declarations are informational only and the system does not read
them, but external services such as Google Play do read them in order to provide filtering
-for users when they search for applications from their device.</p>
-
-<p>For example, if your application requires a camera and uses APIs introduced in Android 2.1 (<a
-href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">API Level</a> 7), you should declare these as
-requirements in your manifest file. That way, devices that do <em>not</em> have a camera and have an
-Android version <em>lower</em> than 2.1 cannot install your application from Google Play.</p>
+for users when they search for apps from their device.</p>
-<p>However, you can also declare that your application uses the camera, but does not
-<em>require</em> it. In that case, your application must perform a check at runtime to determine
-if the device has a camera and disable any features that use the camera if one is not available.</p>
+<p>For example, if your app requires a camera and uses APIs introduced in Android 2.1 (<a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">API Level</a> 7),
+you should declare these as requirements in your manifest file like this:</p>
-<p>Here are some of the important device characteristics that you should consider as you design and
-develop your application:</p>
-
-<dl>
- <dt>Screen size and density</dt>
- <dd>In order to categorize devices by their screen type, Android defines two characteristics for
-each device: screen size (the physical dimensions of the screen) and screen density (the physical
-density of the pixels on the screen, or dpi&mdash;dots per inch). To simplify all the different
-types of screen configurations, the Android system generalizes them into select groups that make
-them easier to target.
-<p>The screen sizes are: small, normal, large, and extra large.<br/>
-The screen densities are: low density, medium density, high density, and extra high density.</p>
-
-<p>By default, your application is compatible with all screen sizes and densities,
-because the Android system makes the appropriate adjustments to your UI layout and image
-resources. However, you should create specialized layouts for certain screen sizes and provide
-specialized images for certain densities, using alternative layout resources, and by declaring in
-your manifest exactly which screen sizes your application supports with the <a
-href="{@docRoot}guide/topics/manifest/supports-screens-element.html">{@code
-&lt;supports-screens&gt;}</a> element.</p>
-<p>For more information, see the <a
-href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a>
-document.</p></dd>
-
- <dt>Input configurations</dt>
- <dd>Many devices provide a different type of user input mechanism, such as a hardware keyboard, a
-trackball, or a five-way navigation pad. If your application requires a particular kind of input
-hardware, then you should declare it in your manifest with the <a
-href="{@docRoot}guide/topics/manifest/uses-configuration-element.html">{@code
-&lt;uses-configuration&gt;}</a> element. However, it is rare that an application should require
-a certain input configuration.</dd>
-
- <dt>Device features</dt>
- <dd>There are many hardware and software features that may or may not exist on a given
-Android-powered device, such as a camera, a light sensor, bluetooth, a certain
-version of OpenGL, or the fidelity of the touchscreen. You should never assume that a certain
-feature is available on all Android-powered devices (other than the availability of the standard
-Android library), so you should declare any features used by your application with the <a
-href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
-element.</dd>
-
- <dt>Platform Version</dt>
- <dd>Different Android-powered devices often run different versions of the Android platform,
-such as Android 1.6 or Android 2.3. Each successive version often includes additional APIs not
-available in the previous version. In order to indicate which set of APIs are available, each
-platform version specifies an <a
-href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">API Level</a> (for example, Android 1.0 is API Level
-1 and Android 2.3 is API Level 9). If you use any APIs that were added to the platform after
-version 1.0, you should declare the minimum API Level in which those APIs were introduced using the
-<a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code &lt;uses-sdk&gt;}</a>
-element.</dd>
-</dl>
-
-<p>It's important that you declare all such requirements for your application, because, when you
-distribute your application on Google Play, the store uses these declarations to filter which
-applications are available on each device. As such, your application should be available only to
-devices that meet all your application requirements.</p>
-
-<p>For more information about how Google Play filters applications based on these (and other)
-requirements, see the <a href="{@docRoot}google/play/filters.html">Filters on Google Play</a>
+<pre>
+&lt;manifest ... >
+ &lt;uses-feature android:name="android.hardware.camera.any"
+ android:required="true" />
+ &lt;uses-sdk android:minSdkVersion="7" android:targetSdkVersion="19" />
+ ...
+&lt;/manifest>
+</pre>
+
+<p>Now, devices that do <em>not</em> have a camera and have an
+Android version <em>lower</em> than 2.1 cannot install your app from Google Play.</p>
+
+<p>However, you can also declare that your app uses the camera, but does not
+<em>require</em> it. In that case, your app must set the <a href=
+"{@docRoot}guide/topics/manifest/uses-feature-element.html#required">{@code required}</a>
+attribute to {@code "false"} and check at runtime whether
+the device has a camera and disable any camera features as appropriate.</p>
+
+<p>More information about how you can manage your app's compatibility with different devices
+is provided in the <a href="{@docRoot}guide/practices/compatibility.html">Device Compatibility</a>
document.</p>
-<h2 id="Resources">Application Resources</h2>
+<h2 id="Resources">App Resources</h2>
-<p>An Android application is composed of more than just code&mdash;it requires resources that are
+<p>An Android app is composed of more than just code&mdash;it requires resources that are
separate from the source code, such as images, audio files, and anything relating to the visual
-presentation of the application. For example, you should define animations, menus, styles, colors,
-and the layout of activity user interfaces with XML files. Using application resources makes it easy
-to update various characteristics of your application without modifying code and&mdash;by providing
-sets of alternative resources&mdash;enables you to optimize your application for a variety of
+presentation of the app. For example, you should define animations, menus, styles, colors,
+and the layout of activity user interfaces with XML files. Using app resources makes it easy
+to update various characteristics of your app without modifying code and&mdash;by providing
+sets of alternative resources&mdash;enables you to optimize your app for a variety of
device configurations (such as different languages and screen sizes).</p>
<p>For every resource that you include in your Android project, the SDK build tools define a unique
-integer ID, which you can use to reference the resource from your application code or from
-other resources defined in XML. For example, if your application contains an image file named {@code
+integer ID, which you can use to reference the resource from your app code or from
+other resources defined in XML. For example, if your app contains an image file named {@code
logo.png} (saved in the {@code res/drawable/} directory), the SDK tools generate a resource ID
named {@code R.drawable.logo}, which you can use to reference the image and insert it in your
user interface.</p>
@@ -504,15 +452,45 @@ depending on the orientation, you can define two different layouts and apply the
qualifier to each layout's directory name. Then, the system automatically applies the appropriate
layout depending on the current device orientation.</p>
-<p>For more about the different kinds of resources you can include in your application and how
-to create alternative resources for various device configurations, see the <a
-href="{@docRoot}guide/topics/resources/index.html">Application Resources</a> developer guide.</p>
-
-
-<!--
-<h2>Beginner's Path</h2>
+<p>For more about the different kinds of resources you can include in your application and how to
+create alternative resources for different device configurations, read <a href=
+"{@docRoot}guide/topics/resources/providing-resources.html">Providing Resources</a>.</p>
+
+
+
+<div class="next-docs">
+<div class="col-6">
+ <h2 class="norule">Continue reading about:</h2>
+ <dl>
+ <dt><a href="{@docRoot}guide/components/intents-filters.html">Intents and Intent Filters</a>
+ </dt>
+ <dd>Information about how to use the {@link android.content.Intent} APIs to
+ activate app components, such as activities and services, and how to make your app components
+ available for use by other apps.</dd>
+ <dt><a href="{@docRoot}guide/components/activities.html">Activities</a></dt>
+ <dd>Information about how to create an instance of the {@link android.app.Activity} class,
+ which provides a distinct screen in your application with a user interface.</dd>
+ <dt><a
+href="{@docRoot}guide/topics/resources/providing-resources.html">Providing Resources</a></dt>
+ <dd>Information about how Android apps are structured to separate app resources from the
+ app code, including how you can provide alternative resources for specific device
+ configurations.
+ </dd>
+ </dl>
+</div>
+<div class="col-6">
+ <h2 class="norule">You might also be interested in:</h2>
+ <dl>
+ <dt><a href="{@docRoot}guide/practices/compatibility.html"
+ >Device Compatibility</a></dt>
+ <dd>Information about Android works on different types of devices and an introduction
+ to how you can optimize your app for each device or restrict your app's availability
+ to different devices.</dd>
+ <dt><a href="{@docRoot}guide/topics/security/permissions.html"
+ >System Permissions</a></dt>
+ <dd>Information about how Android restricts app access to certain APIs with a permission
+ system that requires the user's consent for your app to use those APIs.</dd>
+ </dl>
+</div>
+</div>
-<p>For a close look at implementing activities&mdash;the components your users use to
-interact with your application&mdash;continue with the <b><a
-href="{@docRoot}guide/components/activities.html">Activities</a></b> document.</p>
--->
diff --git a/docs/html/guide/components/index.jd b/docs/html/guide/components/index.jd
index 87bae53..37fb7e9 100644
--- a/docs/html/guide/components/index.jd
+++ b/docs/html/guide/components/index.jd
@@ -1,6 +1,6 @@
page.title=App Components
page.landing=true
-page.landing.intro=Android's application framework lets you create extremely rich and innovative apps using a set of reusable components. This section explains how Android apps work and how you use components to build them.
+page.landing.intro=Android's application framework lets you create rich and innovative apps using a set of reusable components. This section explains how you can build the components that define the building blocks of your app and how to connect them together using intents.
page.landing.image=images/develop/app_components.png
@jd:body
diff --git a/docs/html/guide/components/intents-common.jd b/docs/html/guide/components/intents-common.jd
new file mode 100644
index 0000000..506cf9d
--- /dev/null
+++ b/docs/html/guide/components/intents-common.jd
@@ -0,0 +1,1316 @@
+page.title=Common Intents
+page.tags="IntentFilter"
+@jd:body
+
+<div id="qv-wrapper">
+<div id="qv">
+
+ <h2>In this document
+ <a href="#" onclick="hideNestedItems('#tocIntents',this);return false;" class="header-toggle">
+ <span class="more">show more</span>
+ <span class="less" style="display:none">show less</span></a></h2>
+
+<ol id="tocIntents" class="hide-nested">
+ <li><a href="#Camera">Camera</a>
+ <ol>
+ <li><a href="#ImageCapture">Capture a picture or video and return it</a></li>
+ </ol>
+ </li>
+ <li><a href="#Contacts">Contacts/People App</a>
+ <ol>
+ <li><a href="#PickContact">Select a contact</a></li>
+ <li><a href="#PickContactDat">Select specific contact data</a></li>
+ <li><a href="#ViewContact">View a contact</a></li>
+ <li><a href="#EditContact">Edit an existing contact</a></li>
+ <li><a href="#InsertContact">Insert a contact</a></li>
+ </ol>
+ </li>
+ <li><a href="#Email">Email</a>
+ <ol>
+ <li><a href="#ComposeEmail">Compose an email with optional attachments</a></li>
+ </ol>
+ </li>
+ <li><a href="#Storage">File Storage</a>
+ <ol>
+ <li><a href="#GetFile">Retrieve a specific type of file</a></li>
+ <li><a href="#OpenFile">Open a specific type of file</a></li>
+ </ol>
+ </li>
+ <li><a href="#Maps">Maps</a>
+ <ol>
+ <li><a href="#ViewMap">Show a location on a map</a></li>
+ </ol>
+ </li>
+ <li><a href="#Music">Music or Video</a>
+ <ol>
+ <li><a href="#PlayMedia">Play a media file</a></li>
+ </ol>
+ </li>
+ <li><a href="#Phone">Phone</a>
+ <ol>
+ <li><a href="#DialPhone">Initiate a phone call</a></li>
+ </ol>
+ </li>
+ <li><a href="#Settings">Settings</a>
+ <ol>
+ <li><a href="#OpenSettings">Open a specific section of Settings</a></li>
+ </ol>
+ </li>
+ <li><a href="#Messaging">Text Messaging</a>
+ <ol>
+ <li><a href="#SendMessage">Compose an SMS/MMS message with attachment</a></li>
+ </ol>
+ </li>
+ <li><a href="#Browser">Web Browser</a>
+ <ol>
+ <li><a href="#ViewUrl">Load a web URL</a></li>
+ <li><a href="#SearchWeb">Perform a web search</a></li>
+ </ol>
+ </li>
+</ol>
+
+ <h2>See also</h2>
+ <ol>
+ <li><a href="{@docRoot}guide/components/intents-filters.html">Intents and Intent
+Filters</a></li>
+ </ol>
+</div>
+</div>
+
+
+<p>An intent allows you to start an activity in another app by describing a simple
+action you'd like to perform (such as "view a map" or "take a picture")
+in an {@link android.content.Intent} object. This type of intent is
+called an <em>implicit</em> intent because it does not specify the app component
+to start, but instead specifies an <em>action</em> and provides some
+<em>data</em> with which to perform the action.</p>
+
+<p>When you call
+{@link android.content.Context#startActivity startActivity()} or
+{@link android.app.Activity#startActivityForResult startActivityForResult()} and pass it an
+implicit intent, the system <a href="{@docRoot}guide/components/intents-filters.html#Resolution"
+>resolves the intent</a> to an app that can handle the intent
+and starts its corresponding {@link android.app.Activity}. If there's more than one app
+that can handle the intent, the system presents the user with a dialog to pick which app
+to use.</p>
+
+<p>This page describes several implicit intents that you can use to perform common actions,
+organized by the type of app that handles the intent. Each section also shows how you can
+create an <a href="{@docRoot}guide/components/intents-filters.html#Receiving">intent filter</a> to
+advertise your app's ability to perform the same action.</p>
+
+<p class="caution"><strong>Caution:</strong> If there are no apps on the device that can receive
+the implicit intent, your app will crash when it calls {@link android.content.Context#startActivity
+startActivity()}. To first verify that an app exists to receive the intent, call {@link
+android.content.Intent#resolveActivity resolveActivity()} on your {@link android.content.Intent}
+object. If the result is non-null, there is at least one app that can handle the intent and
+it's safe to call {@link android.content.Context#startActivity startActivity()}. If the result is
+null, you should not use the intent and, if possible, you should disable the feature that invokes
+the intent.</p>
+
+
+<p>If you're not familiar with how to create intents or intent filters, you should first read
+<a href="{@docRoot}guide/components/intents-filters.html">Intents and Intent Filters</a>.</p>
+
+
+
+
+
+<h2 id="Camera">Camera</h2>
+
+
+
+<h3 id="ImageCapture">Capture a picture or video and return it</h3>
+
+<p>To open a camera app and receive the resulting photo or video, use the {@link
+android.provider.MediaStore#ACTION_IMAGE_CAPTURE} or {@link
+android.provider.MediaStore#ACTION_VIDEO_CAPTURE} action. Also specify the URI location where you'd
+like the camera to save the photo or video, in the {@link android.provider.MediaStore#EXTRA_OUTPUT}
+extra.</p>
+
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.provider.MediaStore#ACTION_IMAGE_CAPTURE} or<br>
+ {@link android.provider.MediaStore#ACTION_VIDEO_CAPTURE}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>None</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>None</dd>
+
+<dt><b>Extras</b></dt>
+<dd>
+ <dl>
+ <dt>{@link android.provider.MediaStore#EXTRA_OUTPUT}</dt>
+ <dd>The URI location where the camera app should save the photo or
+ video file (as a {@link android.net.Uri} object).</dd>
+ </dl>
+</dd>
+</dl>
+
+<p>When the camera app successfully returns
+focus to your activity (your app receives the {@link android.app.Activity#onActivityResult
+onActivityResult()} callback), you can access the photo or video at the URI you specified
+with the {@link android.provider.MediaStore#EXTRA_OUTPUT} value.</p>
+
+<p class="note"><strong>Note:</strong> When you use {@link
+android.provider.MediaStore#ACTION_IMAGE_CAPTURE} to capture a photo, the camera may also return a
+downscaled copy (a thumbnail) of the photo in the result {@link
+android.content.Intent}, saved as a {@link android.graphics.Bitmap} in an extra field named
+<code>"data"</code>.</p>
+
+
+<p><b>Example intent:</b></p>
+<pre>
+static final int REQUEST_IMAGE_CAPTURE = 1;
+static final Uri mLocationForPhotos;
+
+public void capturePhoto(String targetFilename) {
+ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
+ intent.putExtra(MediaStore.EXTRA_OUTPUT,
+ Uri.withAppendedPath(mLocationForPhotos, targetFilename);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
+ }
+}
+
+&#64;Override
+protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
+ Bitmap thumbnail = data.getParcelable("data");
+ // Do other work with full size photo saved in mLocationForPhotos
+ ...
+ }
+}
+</pre>
+
+<p>For more information about how to use this intent to capture a photo, including
+how to create an appropriate {@link android.net.Uri} for the output location, read
+<a href="{@docRoot}training/camera/photobasics.html">Taking Photos Simply</a> or
+<a href="{@docRoot}training/camera/videobasics.html">Taking Videos Simply</a>.</p>
+
+<p><b>Example intent filter:</b></p>
+<pre>
+&lt;activity ...>
+ &lt;intent-filter>
+ &lt;action android:name="android.media.action.IMAGE_CAPTURE" />
+ &lt;category android:name="android.intent.category.DEFAULT" />
+ &lt;/intent-filter>
+&lt;/activity>
+</pre>
+
+<p>When handling this intent, your activity should check for the {@link
+android.provider.MediaStore#EXTRA_OUTPUT} extra in the incoming {@link android.content.Intent},
+then save the captured image or video at the location specified by that extra and call {@link
+android.app.Activity#setResult(int,Intent) setResult()} with an
+{@link android.content.Intent} that includes a compressed thumbnail
+in an extra named <code>"data"</code>.</p>
+
+
+
+
+<h2 id="Contacts">Contacts/People App</h2>
+
+
+<h3 id="PickContact">Select a contact</h3>
+
+<p>To have the user select a contact and provide your app access to all the contact information,
+use the {@link android.content.Intent#ACTION_PICK} action and specify the MIME type to
+{@link android.provider.ContactsContract.Contacts#CONTENT_TYPE
+Contacts.CONTENT_TYPE}.</p>
+
+<p>The result {@link android.content.Intent} delivered to your {@link
+android.app.Activity#onActivityResult onActivityResult()} callback contains the
+<code>content:</code> URI pointing to the selected contact. The response grants
+your app temporary permissions to read that contact using the <a
+href="{@docRoot}guide/topics/providers/contacts-provider.html">Contacts Provider</a> API even if
+your app does not include the {@link android.Manifest.permission#READ_CONTACTS} permission.</p>
+
+<p class="note"><strong>Tip:</strong> If you need access to only a specific piece of contact
+information, such as a phone number or email address, instead see the next section about how to
+<a href="#PickContactData">select specific contact data</a>.</p>
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_PICK}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>None</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>{@link android.provider.ContactsContract.Contacts#CONTENT_TYPE
+Contacts.CONTENT_TYPE}
+</dd>
+</dl>
+
+<p><b>Example intent:</b></p>
+<pre>
+static final int REQUEST_SELECT_CONTACT = 1;
+
+public void selectContact() {
+ Intent intent = new Intent(Intent.ACTION_PICK);
+ intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivityForResult(intent, REQUEST_SELECT_CONTACT);
+ }
+}
+
+&#64;Override
+protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_SELECT_CONTACT && resultCode == RESULT_OK) {
+ Uri contactUri = data.getData();
+ // Do something with the selected contact at contactUri
+ ...
+ }
+}
+</pre>
+
+<p>For information about how to retrieve contact details once you have the contact URI,
+read <a href="{@docRoot}training/contacts-provider/retrieve-details.html">Retrieving Details
+for a Contact</a>. Remember, when you retrieve the contact URI with the above intent, you
+<strong>do not</strong> need the {@link android.Manifest.permission#READ_CONTACTS} permission
+to read details for that contact.</p>
+
+
+
+
+<h3 id="PickContactDat">Select specific contact data</h3>
+
+<p>To have the user select a specific piece of information from a contact, such as
+a phone number, email address, or other data type, use the
+{@link android.content.Intent#ACTION_PICK} action and specify the MIME type to one
+of the content types listed below, such as
+{@link android.provider.ContactsContract.CommonDataKinds.Phone#CONTENT_TYPE
+CommonDataKinds.Phone.CONTENT_TYPE} to get the contact's phone number.</p>
+
+<p>If you need to retrieve only one type of data from a contact, this technique with a
+{@code CONTENT_TYPE} from the
+{@link android.provider.ContactsContract.CommonDataKinds} classes is more efficient than
+using the {@link android.provider.ContactsContract.Contacts#CONTENT_TYPE
+Contacts.CONTENT_TYPE} (as shown in the previous section) because the result provides you direct
+access to the desired data without requiring you to perform a more complex query to <a
+href="{@docRoot}guide/topics/providers/contacts-provider.html">Contacts Provider</a>.</p>
+
+<p>The result {@link android.content.Intent} delivered to your {@link
+android.app.Activity#onActivityResult onActivityResult()} callback contains the
+<code>content:</code> URI pointing to the selected contact data. The response grants
+your app temporary permissions to read that contact data even if your app does
+not include the {@link android.Manifest.permission#READ_CONTACTS} permission.</p>
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_PICK}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>None</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>
+ <dl>
+ <dt>{@link android.provider.ContactsContract.CommonDataKinds.Phone#CONTENT_TYPE
+CommonDataKinds.Phone.CONTENT_TYPE}</dt>
+ <dd>Pick from contacts with a phone number.</dd>
+ <dt>{@link android.provider.ContactsContract.CommonDataKinds.Email#CONTENT_TYPE
+CommonDataKinds.Email.CONTENT_TYPE}</dt>
+ <dd>Pick from contacts with an email address.</dd>
+ <dt>{@link android.provider.ContactsContract.CommonDataKinds.StructuredPostal#CONTENT_TYPE
+CommonDataKinds.StructuredPostal.CONTENT_TYPE}</dt>
+ <dd>Pick from contacts with a postal address.</dd>
+ </dl>
+ <p>Or one of many other {@code CONTENT_TYPE} values
+ under {@link android.provider.ContactsContract}.</p>
+</dd>
+</dl>
+
+<p><b>Example intent:</b></p>
+<pre>
+static final int REQUEST_SELECT_PHONE_NUMBER = 1;
+
+public void selectContact() {
+ // Start an activity for the user to pick a phone number from contacts
+ Intent intent = new Intent(Intent.ACTION_PICK);
+ intent.setType(CommonDataKinds.Phone.CONTENT_TYPE);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivityForResult(intent, REQUEST_SELECT_PHONE_NUMBER);
+ }
+}
+
+&#64;Override
+protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_SELECT_PHONE_NUMBER && resultCode == RESULT_OK) {
+ // Get the URI and query the content provider for the phone number
+ Uri contactUri = data.getData();
+ String[] projection = new String[]{CommonDataKinds.Phone.NUMBER};
+ Cursor cursor = getContentResolver().query(contactUri, projection,
+ null, null, null);
+ // If the cursor returned is valid, get the phone number
+ if (cursor != null && cursor.moveToFirst()) {
+ int numberIndex = cursor.getColumnIndex(CommonDataKinds.Phone.NUMBER);
+ String number = cursor.getString(numberIndex);
+ // Do something with the phone number
+ ...
+ }
+ }
+}
+</pre>
+
+
+
+
+
+<h3 id="ViewContact">View a contact</h3>
+
+<p>To display the details for a known contact, use the {@link android.content.Intent#ACTION_VIEW}
+action and specify the contact with a {@code content:} URI as the intent data.</p>
+
+<p>There are primarily two ways to initially retrieve the contact's URI:</p>
+<ul>
+ <li>Use the contact URI returned by the {@link android.content.Intent#ACTION_PICK},
+ shown in the previous section (this does not require any app permissions).</li>
+ <li>Access the list of all contacts directly, as described in <a
+ href="{@docRoot}training/contacts-provider/retrieve-names.html">Retrieving a List of
+ Contacts</a> (this requires the {@link android.Manifest.permission#READ_CONTACTS}
+ permission).</li>
+</ul>
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_VIEW}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>{@code content:&lt;URI>}</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>None. The type is inferred from contact URI.
+</dd>
+</dl>
+
+<p><b>Example intent:</b></p>
+<pre>
+public void viewContact(Uri contactUri) {
+ Intent intent = new Intent(Intent.ACTION_VIEW, contactUri);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+
+
+<h3 id="EditContact">Edit an existing contact</h3>
+
+<p>To edit a known contact, use the {@link android.content.Intent#ACTION_EDIT}
+action, specify the contact with a {@code content:} URI
+as the intent data, and include any known contact information in extras specified by
+constants in {@link android.provider.ContactsContract.Intents.Insert}.</p>
+
+<p>There are primarily two ways to initially retrieve the contact URI:</p>
+<ul>
+ <li>Use the contact URI returned by the {@link android.content.Intent#ACTION_PICK},
+ shown in the previous section (this does not require any app permissions).</li>
+ <li>Access the list of all contacts directly, as described in <a
+ href="{@docRoot}training/contacts-provider/retrieve-names.html">Retrieving a List of
+ Contacts</a> (this requires the {@link android.Manifest.permission#READ_CONTACTS}
+ permission).</li>
+</ul>
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_EDIT}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>{@code content:&lt;URI>}</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>The type is inferred from contact URI.
+</dd>
+
+<dt><b>Extras</b> (optional)</dt>
+<dd>One or more of the extras defined in {@link android.provider.ContactsContract.Intents.Insert}
+so you can populate fields of the contact details.
+</dd>
+</dl>
+
+<p><b>Example intent:</b></p>
+<pre>
+public void editContact(Uri contactUri, String email) {
+ Intent intent = new Intent(Intent.ACTION_EDIT);
+ intent.setDataAndType(contactUri, Contacts.CONTENT_TYPE);
+ intent.putExtra(Intents.Insert.EMAIL, email);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+<p>For more information about how to edit a contact, read <a
+href="{@docRoot}training/contacts-provider/modify-data.html">Modifying
+Contacts Using Intents</a>.</p>
+
+
+
+
+<h3 id="InsertContact">Insert a contact</h3>
+
+<p>To insert a new contact, use the {@link android.content.Intent#ACTION_INSERT} action,
+specify {@link android.provider.ContactsContract.Contacts#CONTENT_TYPE Contacts.CONTENT_TYPE} as
+the MIME type, and include any known contact information in extras specified by
+constants in {@link android.provider.ContactsContract.Intents.Insert}.
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_INSERT}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>None</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>{@link android.provider.ContactsContract.Contacts#CONTENT_TYPE Contacts.CONTENT_TYPE}</dd>
+
+<dt><b>Extras</b> (optional)</dt>
+<dd>One or more of the extras defined in {@link android.provider.ContactsContract.Intents.Insert}.
+</dd>
+</dl>
+
+<p><b>Example intent:</b></p>
+<pre>
+public void insertContact(String name, String email) {
+ Intent intent = new Intent(Intent.ACTION_INSERT);
+ intent.setType(Contacts.CONTENT_TYPE);
+ intent.putExtra(Intents.Insert.NAME, name);
+ intent.putExtra(Intents.Insert.EMAIL, email);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+<p>For more information about how to insert a contact, read <a
+href="{@docRoot}training/contacts-provider/modify-data.html">Modifying
+Contacts Using Intents</a>.</p>
+
+
+
+
+
+
+
+<h2 id="Email">Email</h2>
+
+
+<h3 id="ComposeEmail">Compose an email with optional attachments</h3>
+
+
+<p>To compose an email, use one of the below actions based on whether you'll include attachments,
+and include email details such as the recipient and subject using the extra keys listed below.</p>
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_SENDTO} (for no attachment) or<br>
+ {@link android.content.Intent#ACTION_SEND} (for one attachment) or<br>
+ {@link android.content.Intent#ACTION_SEND_MULTIPLE} (for multiple attachments)</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>None</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>
+ <dl>
+ <dt>{@link org.apache.http.protocol.HTTP#PLAIN_TEXT_TYPE} ("text/plain")
+ <dt><code>"*/*"</code>
+ </dl>
+</dd>
+
+<dt><b>Extras</b> (optional)</dt>
+<dd>
+ <dl>
+ <dt>{@link android.content.Intent#EXTRA_EMAIL Intent.EXTRA_EMAIL}</dt>
+ <dd>A string array of all "To" recipient email addresses.</dd>
+ <dt>{@link android.content.Intent#EXTRA_CC Intent.EXTRA_CC}</dt>
+ <dd>A string array of all "CC" recipient email addresses.</dd>
+ <dt>{@link android.content.Intent#EXTRA_BCC Intent.EXTRA_BCC}</dt>
+ <dd>A string array of all "BCC" recipient email addresses.</dd>
+ <dt>{@link android.content.Intent#EXTRA_SUBJECT Intent.EXTRA_SUBJECT}</dt>
+ <dd>A string with the email subject.</dd>
+ <dt>{@link android.content.Intent#EXTRA_TEXT Intent.EXTRA_TEXT}</dt>
+ <dd>A string with the body of the email.</dd>
+ <dt>{@link android.content.Intent#EXTRA_STREAM Intent.EXTRA_STREAM}</dt>
+ <dd>A {@link android.net.Uri} pointing to the attachment. If using the
+ {@link android.content.Intent#ACTION_SEND_MULTIPLE} action, this should instead
+ be an {@link java.util.ArrayList} containing multiple {@link android.net.Uri} objects.</dd>
+ </dl>
+</dd>
+
+</dl>
+
+
+<p><b>Example intent:</b></p>
+<pre>
+public void composeEmail(String[] addresses, String subject, Uri attachment) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType("*/*");
+ intent.putExtra(Intent.EXTRA_EMAIL, addresses);
+ intent.putExtra(Intent.EXTRA_SUBJECT, subject);
+ intent.putExtra(Intent.EXTRA_STREAM, attachment);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+<p>If you want to ensure that your intent is handled only by an email app (and not other
+text messaging or social apps), then use the {@link android.content.Intent#ACTION_SENDTO} action
+and include the {@code "mailto:"} data scheme. For example:</p>
+
+<pre>
+public void composeEmail(String[] addresses, String subject) {
+ Intent intent = new Intent(Intent.ACTION_SENDTO);
+ intent.setData(Uri.parse("mailto:")); // only email apps should handle this
+ intent.putExtra(Intent.EXTRA_EMAIL, addresses);
+ intent.putExtra(Intent.EXTRA_SUBJECT, subject);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+
+<p><b>Example intent filter:</b></p>
+<pre>
+&lt;activity ...>
+ &lt;intent-filter>
+ &lt;action android:name="android.intent.action.SEND" />
+ &lt;data android:type="*/*" />
+ &lt;category android:name="android.intent.category.DEFAULT" />
+ &lt;/intent-filter>
+ &lt;intent-filter>
+ &lt;action android:name="android.intent.action.SENDTO" />
+ &lt;data android:scheme="mailto" />
+ &lt;category android:name="android.intent.category.DEFAULT" />
+ &lt;/intent-filter>
+&lt;/activity>
+</pre>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<h2 id="Storage">File Storage</h2>
+
+
+
+<h3 id="GetFile">Retrieve a specific type of file</h3>
+
+<p>To request that the user select a file such as a document or photo and return a reference to
+your app, use the {@link android.content.Intent#ACTION_GET_CONTENT} action and specify your desired
+MIME type. The file reference returned to your app is transient to your activity's current
+lifecycle, so if you want to access it later you must import a copy that you can read later.
+This intent also allows the user to create a new file in the process (for
+example, instead of selecting an existing photo, the user can capture a new photo with the camera).
+</p>
+
+<p>The result intent delivered to your {@link android.app.Activity#onActivityResult
+onActivityResult()} method includes data with a URI pointing to the file.
+The URI could be anything, such as an {@code http:} URI, {@code file:} URI, or {@code content:}
+URI. However, if you'd like to restrict selectable files to only those that are accessible
+from a content provider (a {@code content:} URI) and that are available as a file stream with {@link
+android.content.ContentResolver#openFileDescriptor openFileDescriptor()}, you should add
+the {@link android.content.Intent#CATEGORY_OPENABLE} category to your intent.</p>
+
+<p>On Android 4.3 (API level 18) and higher,
+you can also allow the user to select multiple files by adding
+{@link android.content.Intent#EXTRA_ALLOW_MULTIPLE} to the intent, set to {@code true}.
+You can then access each of the selected files in a {@link android.content.ClipData}
+object returned by {@link android.content.Intent#getClipData()}.</p>
+
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_GET_CONTENT}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>None</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>The MIME type corresponding to the file type the user should select.
+</dd>
+
+<dt><b>Extras</b> (optional)</dt>
+<dd>
+ <dl>
+ <dt>{@link android.content.Intent#EXTRA_ALLOW_MULTIPLE}
+ <dd>A boolean declaring whether the user can select more than one file at a time.
+ </dd>
+ <dt>{@link android.content.Intent#EXTRA_LOCAL_ONLY}
+ <dd>A boolean that declares whether the returned file must be available directly from
+ the device, rather than requiring a download from a remote service.
+ </dd>
+ </dl>
+</dd>
+
+<dt><b>Category</b> (optional)</dt>
+<dd>
+ <dl>
+ <dt>{@link android.content.Intent#CATEGORY_OPENABLE}</dt>
+ <dd>To return only "openable" files that can be represented as a file stream
+ with {@link android.content.ContentResolver#openFileDescriptor openFileDescriptor()}.</dd>
+ </dl>
+</dd>
+
+</dl>
+
+<p><b>Example intent to get a photo:</b></p>
+<pre>
+static final int REQUEST_IMAGE_GET = 1;
+
+public void selectImage() {
+ Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
+ intent.setType("image/*");
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivityForResult(intent, REQUEST_IMAGE_GET);
+ }
+}
+
+&#64;Override
+protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_IMAGE_GET && resultCode == RESULT_OK) {
+ Bitmap thumbnail = data.getParcelable("data");
+ Uri fullPhotoUri = data.getData();
+ // Do work with photo saved at fullPhotoUri
+ ...
+ }
+}
+</pre>
+
+<p><b>Example intent filter to return a photo:</b></p>
+<pre>
+&lt;activity ...>
+ &lt;intent-filter>
+ &lt;action android:name="android.intent.action.GET_CONTENT" />
+ &lt;data android:type="image/*" />
+ &lt;category android:name="android.intent.category.DEFAULT" />
+ &lt;!-- The OPENABLE category declares that the returned file is accessible
+ from a content provider that supports {@link android.provider.OpenableColumns}
+ and {@link android.content.ContentResolver#openFileDescriptor ContentResolver.openFileDescriptor()} -->
+ &lt;category android:name="android.intent.category.OPENABLE" />
+ &lt;/intent-filter>
+&lt;/activity>
+</pre>
+
+
+
+
+
+
+<h3 id="OpenFile">Open a specific type of file</h3>
+
+<p>Instead of retrieving a copy of a file that you must import to your app
+(by using the {@link android.content.Intent#ACTION_GET_CONTENT} action), when running on Android
+4.4 or higher, you can instead request to <em>open</em> a file that's managed by another app by
+using the {@link android.content.Intent#ACTION_OPEN_DOCUMENT} action and specifying a MIME type.
+To also allow the user to instead create a new document that your app can write to, use the {@link
+android.content.Intent#ACTION_CREATE_DOCUMENT} action instead. For example, instead of
+selecting from existing PDF documents, the {@link android.content.Intent#ACTION_CREATE_DOCUMENT}
+intent allows users to select where they'd like to create a new document (within another app
+that manages the document's storage)&mdash;your app then receives the URI location of where it
+can write the new document.</p>
+
+<p>Whereas the intent delivered to your {@link android.app.Activity#onActivityResult
+onActivityResult()} method from the {@link android.content.Intent#ACTION_GET_CONTENT} action may
+return a URI of any type, the result intent from {@link android.content.Intent#ACTION_OPEN_DOCUMENT}
+and {@link android.content.Intent#ACTION_CREATE_DOCUMENT} always specify the chosen file as a {@code
+content:} URI that's backed by a {@link android.provider.DocumentsProvider}. You can open the
+file with {@link android.content.ContentResolver#openFileDescriptor openFileDescriptor()} and
+query its details using columns from {@link android.provider.DocumentsContract.Document}.</p>
+
+<p>The returned URI grants your app long-term read access to the file (also possibly
+with write access). So the {@link android.content.Intent#ACTION_OPEN_DOCUMENT} action is
+particularly useful (instead of using {@link android.content.Intent#ACTION_GET_CONTENT})
+when you want to read an existing file without making a copy into your app,
+or when you want to open and edit a file in place.</p>
+
+<p>You can also allow the user to select multiple files by adding
+{@link android.content.Intent#EXTRA_ALLOW_MULTIPLE} to the intent, set to {@code true}.
+If the user selects just one item, then you can retrieve the item from {@link
+android.content.Intent#getData()}. If the user selects more than one item, then {@link
+android.content.Intent#getData()} returns null and you must instead
+retrieve each item from a {@link android.content.ClipData}
+object that is returned by {@link android.content.Intent#getClipData()}.</p>
+
+<p class="note"><strong>Note:</strong> Your intent <strong>must</strong> specify a MIME type and
+<strong>must</strong> declare the {@link android.content.Intent#CATEGORY_OPENABLE} category. If
+appropriate, you can specify more than one MIME type by adding an array of MIME types with the
+{@link android.content.Intent#EXTRA_MIME_TYPES} extra&mdash;if you do so, you must set the
+primary MIME type in {@link android.content.Intent#setType setType()} to {@code "*/*"}.</p>
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_OPEN_DOCUMENT} or<br/>
+{@link android.content.Intent#ACTION_CREATE_DOCUMENT}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>None</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>The MIME type corresponding to the file type the user should select.
+</dd>
+
+<dt><b>Extras</b> (optional)</dt>
+<dd>
+ <dl>
+ <dt>{@link android.content.Intent#EXTRA_MIME_TYPES}
+ <dd>An array of MIME types corresponding to the types of files your app is
+ requesting. When you use this extra, you must set the primary MIME type in
+ {@link android.content.Intent#setType setType()} to {@code "*/*"}.</dd>
+ <dt>{@link android.content.Intent#EXTRA_ALLOW_MULTIPLE}
+ <dd>A boolean that declares whether the user can select more than one file at a time.
+ </dd>
+ <dt>{@link android.content.Intent#EXTRA_TITLE}
+ <dd>For use with {@link android.content.Intent#ACTION_CREATE_DOCUMENT} to specify
+ an initial file name.
+ </dd>
+ <dt>{@link android.content.Intent#EXTRA_LOCAL_ONLY}
+ <dd>A boolean that declares whether the returned file must be available directly from
+ the device, rather than requiring a download from a remote service.
+ </dd>
+ </dl>
+</dd>
+
+<dt><b>Category</b></dt>
+<dd>
+ <dl>
+ <dt>{@link android.content.Intent#CATEGORY_OPENABLE}</dt>
+ <dd>To return only "openable" files that can be represented as a file stream
+ with {@link android.content.ContentResolver#openFileDescriptor openFileDescriptor()}.</dd>
+ </dl>
+</dd>
+
+</dl>
+
+<p><b>Example intent to get a photo:</b></p>
+<pre>
+static final int REQUEST_IMAGE_OPEN = 1;
+
+public void selectImage() {
+ Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
+ intent.setType("image/*");
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ // Only the system receives the ACTION_OPEN_DOCUMENT, so no need to test.
+ startActivityForResult(intent, REQUEST_IMAGE_OPEN);
+}
+
+&#64;Override
+protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == REQUEST_IMAGE_OPEN && resultCode == RESULT_OK) {
+ Uri fullPhotoUri = data.getData();
+ // Do work with full size photo saved at fullPhotoUri
+ ...
+ }
+}
+</pre>
+
+<p>Third party apps cannot actually respond to an intent with the
+{@link android.content.Intent#ACTION_OPEN_DOCUMENT} action. Instead, the system receives this
+intent and displays all the files available from various apps in a unified user interface.</p>
+
+<p>To provide your app's files in this UI and allow other apps to open them, you must implement
+a {@link android.provider.DocumentsProvider} and include an intent filter for
+{@link android.provider.DocumentsContract#PROVIDER_INTERFACE}
+({@code "android.content.action.DOCUMENTS_PROVIDER"}). For example:
+
+<pre>
+&lt;provider ...
+ android:grantUriPermissions="true"
+ android:exported="true"
+ android:permission="android.permission.MANAGE_DOCUMENTS">
+ &lt;intent-filter>
+ &lt;action android:name="android.content.action.DOCUMENTS_PROVIDER" />
+ &lt;/intent-filter>
+&lt;/provider>
+</pre>
+
+<p>For more information about how to make the files managed by your app openable from other apps,
+read the <a href="{@docRoot}guide/topics/providers/document-provider.html">Storage Access
+Framework</a> guide.</p>
+
+
+
+
+
+
+
+
+
+
+
+<h2 id="Maps">Maps</h2>
+
+<h3 id="ViewMap">Show a location on a map</h3>
+
+<p>To open a map, use the {@link android.content.Intent#ACTION_VIEW} action and specify
+the location information in the intent data with one of the schemes defined below.</p>
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_VIEW}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>
+<dl>
+ <dt><code>geo:<em>latitude</em>,<em>longitude</em></code></dt>
+ <dd>Show the map at the given longitude and latitude.
+ <p>Example: <code>"geo:47.6,-122.3"</code>
+ </dd>
+ <dt><code>geo:<em>latitude</em>,<em>longitude</em>?z=<em>zoom</em></code></dt>
+ <dd>Show the map at the given longitude and latitude at a certain zoom level. A zoom level of
+ 1 shows the whole Earth, centered at the given <em>lat</em>,<em>lng</em>. The highest
+ (closest) zoom level is 23.
+ <p>Example: <code>"geo:47.6,-122.3?z=11"</code>
+ </dd>
+ <dt><code>geo:0,0?q=lat,lng(label)</code></dt>
+ <dd>Show the map at the given longitude and latitude with a string label.
+ <p>Example: <code>"geo:0,0?q=34.99,-106.61(Treasure)"</code>
+ </dd>
+ <dt><code>geo:0,0?q=my+street+address</code></dt>
+ <dd>Show the location for "my street address" (may be a specific address or location query).
+ <p>Example: <code>"geo:0,0?q=1600+Amphitheatre+Parkway%2C+CA"</code></p>
+ <p class="note"><strong>Note:</strong> All strings passed in the {@code geo} URI must
+ be encoded. For example, the string {@code 1st & Pike, Seattle} should become
+ {@code 1st%20%26%20Pike%2C%20Seattle}. Spaces in the string can be encoded with
+ {@code %20} or replaced with the plus sign ({@code +}).</p>
+ </dd>
+</dl>
+</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>None</dd>
+
+</dl>
+
+<p><b>Example intent:</b></p>
+<pre>
+public void showMap(Uri geoLocation) {
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(geoLocation);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+<p><b>Example intent filter:</b></p>
+<pre>
+&lt;activity ...>
+ &lt;intent-filter>
+ &lt;action android:name="android.intent.action.VIEW" />
+ &lt;data android:scheme="geo" />
+ &lt;category android:name="android.intent.category.DEFAULT" />
+ &lt;/intent-filter>
+&lt;/activity>
+</pre>
+
+
+
+
+
+
+
+
+<h2 id="Music">Music or Video</h2>
+
+
+<h3 id="PlayMedia">Play a media file</h3>
+
+<p>To play a music file, use the {@link android.content.Intent#ACTION_VIEW} action and
+specify the URI location of the file in the intent data.</p>
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_VIEW}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>
+ <dl>
+ <dt>{@code file:<em>&lt;URI></em>}
+ <dt>{@code content:<em>&lt;URI></em>}
+ <dt>{@code http:<em>&lt;URL></em>}
+ </dl>
+</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>
+ <dl>
+ <dt><code>"audio/*"</code>
+ <dt><code>"application/ogg"</code>
+ <dt><code>"application/x-ogg"</code>
+ <dt><code>"application/itunes"</code>
+ <dt>Or any other that your app may require.
+ </dl>
+</dd>
+
+</dl>
+
+<p><b>Example intent:</b></p>
+<pre>
+public void playMedia(Uri file) {
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(file);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+
+<p><b>Example intent filter:</b></p>
+<pre>
+&lt;activity ...>
+ &lt;intent-filter>
+ &lt;action android:name="android.intent.action.VIEW" />
+ &lt;data android:type="audio/*" />
+ &lt;data android:type="application/ogg" />
+ &lt;category android:name="android.intent.category.DEFAULT" />
+ &lt;/intent-filter>
+&lt;/activity>
+</pre>
+
+
+
+
+
+
+
+
+<h2 id="Phone">Phone</h2>
+
+
+<h3 id="DialPhone">Initiate a phone call</h3>
+
+<p>To open the phone app and dial a phone number, use the {@link
+android.content.Intent#ACTION_DIAL} action and specify a phone number using
+the URI scheme defined below. When the phone app opens, it displays the phone number
+but the user must press the <em>Call</em> button to begin the phone call.</p>
+
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_DIAL}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>{@code tel:&lt;phone-number>}</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>None</dd>
+
+</dl>
+
+
+<p>Valid telephone numbers are those defined
+in <a href="http://tools.ietf.org/html/rfc3966">the IETF RFC 3966</a>.
+Valid examples include the following:</p>
+<ul>
+<li><code>tel:2125551212</code> </li>
+<li><code>tel:(212) 555 1212</code></li>
+</ul>
+<p>The Phone's dialer is good at normalizing schemes, such as
+telephone numbers. So the scheme described isn't strictly required in the
+{@link android.net.Uri#parse(String) Uri.parse()} method.
+However, if you have not tried a scheme or are unsure whether it
+can be handled, use the {@link android.net.Uri#fromParts Uri.fromParts()}
+method instead.</p>
+
+
+<p><b>Example intent:</b></p>
+<pre>
+public void dialPhoneNumber(String phoneNumber) {
+ Intent intent = new Intent(Intent.ACTION_DIAL);
+ intent.setData(Uri.parse("tel:" + phoneNumber));
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+
+
+
+
+
+
+
+
+
+<h2 id="Settings">Settings</h2>
+
+<h3 id="OpenSettings">Open a specific section of Settings</h3>
+
+<p>To open a screen in the system settings when your app requires the user to change something,
+use one of the following intent actions to open the settings screen respective to the action name.
+</p>
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>
+{@link android.provider.Settings#ACTION_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_WIRELESS_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_AIRPLANE_MODE_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_WIFI_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_APN_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_BLUETOOTH_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_DATE_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_LOCALE_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_INPUT_METHOD_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_DISPLAY_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_SECURITY_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_LOCATION_SOURCE_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_INTERNAL_STORAGE_SETTINGS}<br/>
+{@link android.provider.Settings#ACTION_MEMORY_CARD_SETTINGS}<br/>
+<p>See the {@link android.provider.Settings} documentation for additional settings screens
+that are available.</p>
+</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>None</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>None</dd>
+
+</dl>
+
+<p><b>Example intent:</b></p>
+<pre>
+public void openWifiSettings() {
+ Intent intent = new Intent(Intent.ACTION_WIFI_SETTINGS);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+
+
+
+
+
+
+<h2 id="Messaging">Text Messaging</h2>
+
+<h3 id="SendMessage">Compose an SMS/MMS message with attachment</h3>
+
+<p>To initiate an SMS or MMS text message, use one of the intent actions below and specify message
+details such as the phone number, subject, and message body using the extra keys listed below.</p>
+
+<dl>
+<dt><b>Action</b></dt>
+<dd>{@link android.content.Intent#ACTION_SENDTO} or<br>
+ {@link android.content.Intent#ACTION_SEND} or<br>
+ {@link android.content.Intent#ACTION_SEND_MULTIPLE}</dd>
+
+<dt><b>Data URI Scheme</b></dt>
+<dd>
+ <dl>
+ <dt>{@code sms:<em>&lt;phone_number></em>}
+ <dt>{@code smsto:<em>&lt;phone_number></em>}
+ <dt>{@code mms:<em>&lt;phone_number></em>}
+ <dt>{@code mmsto:<em>&lt;phone_number></em>}
+ </dl>
+ <p>Each of these schemes are handled the same.
+</dd>
+
+<dt><b>MIME Type</b></dt>
+<dd>
+ <dl>
+ <dt>{@link org.apache.http.protocol.HTTP#PLAIN_TEXT_TYPE} (<code>"text/plain"</code>)
+ <dt><code>"image/*"</code>
+ <dt><code>"video/*"</code>
+ </dl>
+</dd>
+
+<dt><b>Extras</b> (optional)</dt>
+<dd>
+ <dl>
+ <dt><code>"subject"</code></dt>
+ <dd>A string for the message subject (usually for MMS only).</dd>
+ <dt><code>"sms_body"</code></dt>
+ <dd>A string for the text message.</dd>
+ <dt>{@link android.content.Intent#EXTRA_STREAM}</dt>
+ <dd>A {@link android.net.Uri} pointing to the
+image or video to attach. If using the {@link android.content.Intent#ACTION_SEND_MULTIPLE} action,
+this extra should be an {@link java.util.ArrayList} of {@link
+android.net.Uri}s pointing to the images/videos to attach.</dd>
+ <dl>
+</dd>
+
+</dl>
+
+<p><b>Example intent:</b></p>
+<pre>
+public void composeMmsMessage(String message, Uri attachment) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType(HTTP.PLAIN_TEXT_TYPE);
+ intent.putExtra("sms_body", message);
+ intent.putExtra(Intent.EXTRA_STREAM, attachment);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+<p>If you want to ensure that your intent is handled only by a text messaging app (and not other
+email or social apps), then use the {@link android.content.Intent#ACTION_SENDTO} action
+and include the {@code "smsto:"} data scheme. For example:</p>
+
+<pre>
+public void composeMmsMessage(String message, Uri attachment) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setData(Uri.parse("smsto:")); // This ensures only SMS apps respond
+ intent.putExtra("sms_body", message);
+ intent.putExtra(Intent.EXTRA_STREAM, attachment);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+
+<p><b>Example intent filter:</b></p>
+<pre>
+&lt;activity ...>
+ &lt;intent-filter>
+ &lt;action android:name="android.intent.action.SEND" />
+ &lt;data android:type="text/plain" />
+ &lt;data android:type="image/*" />
+ &lt;category android:name="android.intent.category.DEFAULT" />
+ &lt;/intent-filter>
+&lt;/activity>
+</pre>
+
+<p class="note"><strong>Note:</strong> If you're developing an SMS/MMS messaging app, you must
+implement intent filters for several additional actions in order to be available as the
+<em>default SMS app</em> on Android 4.4 and higher. For more information, see the documentation
+at {@link android.provider.Telephony}.</p>
+
+
+
+
+
+
+
+
+
+
+<h2 id="Browser">Web Browser</h2>
+
+<h3 id="ViewUrl">Load a web URL</h3>
+
+<p>To open a web page, use the {@link android.content.Intent#ACTION_VIEW} action
+and specify the web URL in the intent data.</p>
+
+<dl>
+ <dt><b>Action</b></dt>
+ <dd>{@link android.content.Intent#ACTION_VIEW}<dd>
+
+ <dt><b>Data URI Scheme</b></dt>
+ <dd>{@code http:<em>&lt;URL></em>}<br/>
+ {@code https:<em>&lt;URL></em>}</dd>
+
+ <dt><b>MIME Type</b></dt>
+ <dd>
+ <dl>
+ <dt>{@link org.apache.http.protocol.HTTP#PLAIN_TEXT_TYPE} (<code>"text/plain"</code>)
+ <dt><code>"text/html"</code>
+ <dt><code>"application/xhtml+xml"</code>
+ <dt><code>"application/vnd.wap.xhtml+xml"</code>
+ </dl>
+ </dd>
+</dl>
+
+
+<p><b>Example intent:</b></p>
+<pre>
+public void openWebPage(String url) {
+ Uri webpage = Uri.parse(url);
+ Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+
+<p><b>Example intent filter:</b></p>
+<pre>
+&lt;activity ...>
+ &lt;intent-filter>
+ &lt;action android:name="android.intent.action.VIEW" />
+ &lt;!-- Include the host attribute if you want your app to respond
+ only to URLs with your app's domain. -->
+ &lt;data android:scheme="http" android:host="www.example.com" />
+ &lt;category android:name="android.intent.category.DEFAULT" />
+ &lt;!-- The BROWSABLE category is required to get links from web pages. -->
+ &lt;category android:name="android.intent.category.BROWSABLE" />
+ &lt;/intent-filter>
+&lt;/activity>
+</pre>
+
+
+<p class="note"><strong>Tip:</strong> If your Android app provides functionality similar to
+your web site, include an intent filter for URLs that point to your web site. Then,
+if users have your app installed, links from emails or other web pages pointing to your web site
+open your Android app instead of your web page.</p>
+
+
+
+
+<h3 id="SearchWeb">Perform a web search</h3>
+
+<p>To initiate a web search, use the {@link android.content.Intent#ACTION_WEB_SEARCH} action
+and specify the search string in the
+{@link android.app.SearchManager#QUERY SearchManager.QUERY} extra.</p>
+
+
+<dl>
+ <dt><b>Action</b></dt>
+ <dd>{@link android.content.Intent#ACTION_WEB_SEARCH}</dd>
+
+ <dt><b>Data URI Scheme</b></dt>
+ <dd>None</dd>
+
+ <dt><b>MIME Type</b></dt>
+ <dd>None</dd>
+
+ <dt><b>Extras</b></dt>
+ <dd>
+ <dl>
+ <dt>{@link android.app.SearchManager#QUERY SearchManager.QUERY}</dt>
+ <dd>The search string.</dd>
+ </dl>
+ </dd>
+</dl>
+
+<p><b>Example intent:</b></p>
+<pre>
+public void searchWeb(String query) {
+ Intent intent = new Intent(Intent.ACTION_SEARCH);
+ intent.putExtra(SearchManager.QUERY, query);
+ if (intent.resolveActivity(getPackageManager()) != null) {
+ startActivity(intent);
+ }
+}
+</pre>
+
+
+
diff --git a/docs/html/guide/components/intents-filters.jd b/docs/html/guide/components/intents-filters.jd
index dfe5fac..2f8c407 100644
--- a/docs/html/guide/components/intents-filters.jd
+++ b/docs/html/guide/components/intents-filters.jd
@@ -1,4 +1,5 @@
page.title=Intents and Intent Filters
+page.tags="IntentFilter"
@jd:body
<div id="qv-wrapper">
@@ -6,1049 +7,906 @@ page.title=Intents and Intent Filters
<h2>In this document</h2>
<ol>
-<li><a href="#iobjs">Intent Objects</a></li>
-<li><a href="#ires">Intent Resolution</a></li>
-<li style="margin-left: 2em"><a href="#ifs">Intent filters</a></li>
-<li style="margin-left: 2em"><a href="#ccases">Common cases</a></li>
-<li style="margin-left: 2em"><a href="#imatch">Using intent matching</a></li>
-<li><a href="#npex">Note Pad Example</a></li>
+ <li><a href="#Types">Intent Types</a></li>
+ <li><a href="#Building">Building an Intent</a>
+ <ol>
+ <li><a href="#ExampleExplicit">Example explicit intent</a></li>
+ <li><a href="#ExampleSend">Example implicit intent</a></li>
+ <li><a href="#ForceChooser">Forcing an app chooser</a></li>
+ </ol>
+ </li>
+ <li><a href="#Receiving">Receiving an Implicit Intent</a>
+ <ol>
+ <li><a href="#ExampleFilters">Example filters</a></li>
+ </ol>
+ </li>
+ <li><a href="#PendingIntent">Using a Pending Intent</a></li>
+ <li><a href="#Resolution">Intent Resolution</a>
+ <ol>
+ <li><a href="#ActionTest">Action test</a></li>
+ <li><a href="#CategoryTest">Category test</a></li>
+ <li><a href="#DataTest">Data test</a></li>
+ <li><a href="#imatch">Intent matching</a></li>
+ </ol>
+ </li>
</ol>
-<h2>Key classes</h2>
+<h2>See also</h2>
<ol>
-<li>{@link android.content.Intent}</li>
-<li>{@link android.content.IntentFilter}</li>
-<li>{@link android.content.BroadcastReceiver}</li>
-<li>{@link android.content.pm.PackageManager}</li>
+<li><a href="{@docRoot}training/basics/intents/index.html">Interacting with Other Apps</a></li>
+<li><a href="{@docRoot}training/sharing/index.html">Sharing Content</a></li>
</ol>
</div>
</div>
-<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, often 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:
-</p>
+
+
+<p>An {@link android.content.Intent} is a messaging object you can use to request an action
+from another <a href="{@docRoot}guide/components/fundamentals.html#Components">app component</a>.
+Although intents facilitate communication between components in several ways, there are three
+fundamental use-cases:</p>
<ul>
-<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. (It can also be passed to
-<code>{@link android.app.Activity#setResult(int, Intent) Activity.setResult()}</code>
-to return information to the activity that called {@code startActivityForResult()}.)</li>
-
-<li><p>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 can optionally
-initiate the service if it's not already running.</p></li>
-
-<li><p>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.</p></li>
+<li><b>To start an activity:</b>
+<p>An {@link android.app.Activity} represents a single screen in an app. You can start a new
+instance of an {@link android.app.Activity} by passing an {@link android.content.Intent}
+to {@link android.content.Context#startActivity startActivity()}. The {@link android.content.Intent}
+describes the activity to start and carries any necessary data.</p>
+
+<p>If you want to receive a result from the activity when it finishes,
+call {@link android.app.Activity#startActivityForResult
+startActivityForResult()}. Your activity receives the result
+as a separate {@link android.content.Intent} object in your activity's {@link
+android.app.Activity#onActivityResult onActivityResult()} callback.
+For more information, see the <a
+href="{@docRoot}guide/components/activities.html">Activities</a> guide.</p></li>
+
+<li><b>To start a service:</b>
+<p>A {@link android.app.Service} is a component that performs operations in the background
+without a user interface. You can start a service to perform a one-time operation
+(such as download a file) by passing an {@link android.content.Intent}
+to {@link android.content.Context#startService startService()}. The {@link android.content.Intent}
+describes the service to start and carries any necessary data.</p>
+
+<p>If the service is designed with a client-server interface, you can bind to the service
+from another component by passing an {@link android.content.Intent} to {@link
+android.content.Context#bindService bindService()}</code>. For more information, see the <a
+href="{@docRoot}guide/components/services.html">Services</a> guide.</p></li>
+
+<li><b>To deliver a broadcast:</b>
+<p>A broadcast is a message that any app can receive. The system delivers various
+broadcasts for system events, such as when the system boots up or the device starts charging.
+You can deliver a broadcast to other apps by passing an {@link android.content.Intent}
+to {@link android.content.Context#sendBroadcast(Intent) sendBroadcast()},
+{@link android.content.Context#sendOrderedBroadcast(Intent, String)
+sendOrderedBroadcast()}, or {@link
+android.content.Context#sendStickyBroadcast sendStickyBroadcast()}.</p>
+</li>
</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>
-<p>
-This document begins with a description of Intent objects. It then describes the
-rules Android uses to map intents to components &mdash; how it resolves which
-component should receive an intent message. For intents that don't explicitly
-name a target component, this process involves testing the Intent object against
-<i>intent filters</i> associated with potential targets.
-</p>
-<h2><a name="iobjs"></a>Intent Objects</h2>
+<h2 id="Types">Intent Types</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:
+<p>There are two types of intents:</p>
+
+<ul>
+<li><b>Explicit intents</b> specify the component to start by name (the
+fully-qualified class name). You'll typically use an explicit intent to start a component in
+your own app, because you know the class name of the activity or service you want to start. For
+example, start a new activity in response to a user action or start a service to download
+a file in the background.</li>
+
+<li><b>Implicit intents</b> do not name a specific component, but instead declare a general action
+to perform, which allows a component from another app to handle it. For example, if you want to
+show the user a location on a map, you can use an implicit intent to request that another capable
+app show a specified location on a map.</li>
+</ul>
+
+<p>When you create an explicit intent to start an activity or service, the system immediately
+starts the app component specified in the {@link android.content.Intent} object.</p>
+
+<div class="figure" style="width:446px">
+<img src="{@docRoot}images/components/intent-filters@2x.png" width="446" alt=""/>
+<p class="img-caption"><strong>Figure 1.</strong> Illustration of how an implicit intent is
+delivered through the system to start another activity: <b>[1]</b> <em>Activity A</em> creates an
+{@link android.content.Intent} with an action description and passes it to {@link
+android.content.Context#startActivity startActivity()}. <b>[2]</b> The Android System searches all
+apps for an intent filter that matches the intent. When a match is found, <b>[3]</b> the system
+starts the matching activity (<em>Activity B</em>) by invoking its {@link
+android.app.Activity#onCreate onCreate()} method and passing it the {@link android.content.Intent}.
</p>
+</div>
+
+<p>When you create an implicit intent, the Android system finds the appropriate component to start
+by comparing the contents of the intent to the <em>intent filters</em> declared in the <a href=
+"{@docRoot}guide/topics/manifest/manifest-intro.html">manifest file</a> of other apps on the
+device. If the intent matches an intent filter, the system starts that component and delivers it
+the {@link android.content.Intent} object. If multiple intent filters are compatible, the system
+displays a dialog so the user can pick which app to use.</p>
+
+<p>An intent filter is an expression in an app's manifest file that
+specifies the type of intents that the component
+would like to receive. For instance, by declaring an intent filter for an activity,
+you make it possible for other apps to directly start your activity with a certain kind of intent.
+Likewise, if you do <em>not</em> declare any intent filters for an activity, then it can be started
+only with an explicit intent.</p>
+
+<p class="caution"><strong>Caution:</strong> To ensure your app is secure, always use an explicit
+intent when starting a {@link android.app.Service} and do not
+declare intent filters for your services. Using an implicit intent to start a service is a
+security hazard because you cannot be certain what service will respond to the intent,
+and the user cannot see which service starts.</p>
+
+
+
+
+
+<h2 id="Building">Building an Intent</h2>
+
+<p>An {@link android.content.Intent} object carries information that the Android system uses
+to determine which component to start (such as the exact component name or component
+category that should receive the intent), plus information that the recipient component uses in
+order to properly perform the action (such as the action to take and the data to act upon).</p>
+
+
+<p>The primary information contained in an {@link android.content.Intent} is the following:</p>
<dl>
-<dt><b>Component name</b><a name="cname"></a></dt>
-<dd>The name of the component that should handle the intent. This field is
-a {@link android.content.ComponentName} object &mdash; a combination of the
-fully qualified class name of the target component (for example "{@code
-com.example.project.app.FreneticActivity}") and the package name set
-in the manifest file of the application where the component resides (for
-example, "{@code com.example.project}"). The package part of the component
-name and the package name set in the manifest do not necessarily have to match.
-
-<p>
-The component name is optional. If it is set, the Intent object is
-delivered to an instance of the designated class. If it is not set,
-Android uses other information in the Intent object to locate a suitable
-target &mdash; see <a href="#ires">Intent Resolution</a>, later in this
-document.
-</p>
+<dt><b>Component name</b></dt>
+<dd>The name of the component to start.
+
+<p>This is optional, but it's the critical piece of information that makes an intent
+<b>explicit</b>, meaning that the intent should be delivered only to the app component
+defined by the component name. Without a component name, the intent is <b>implicit</b> and the
+system decides which component should receive the intent based on the other intent information
+(such as the action, data, and category&mdash;described below). So if you need to start a specific
+component in your app, you should specify the component name.</p>
+
+<p class="note"><strong>Note:</strong> When starting a {@link android.app.Service}, you should
+<strong>always specify the component name</strong>. Otherwise, you cannot be certain what service
+will respond to the intent, and the user cannot see which service starts.</p>
+
+<p>This field of the {@link android.content.Intent} is a
+{@link android.content.ComponentName} object, which you can specify using a fully
+qualified class name of the target component, including the package name of the app. For example,
+{@code com.example.ExampleActivity}. You can set the component name with {@link
+android.content.Intent#setComponent setComponent()}, {@link android.content.Intent#setClass
+setClass()}, {@link android.content.Intent#setClassName(String, String) setClassName()}, or with the
+{@link android.content.Intent} constructor.</p>
-<p>
-The component name 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>
</dd>
<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. The Intent class defines
-a number of action constants, including these:
-</p>
+<dd>A string that specifies the generic action to perform (such as <em>view</em> or <em>pick</em>).
-<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, with no data input and no returned output.
-</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>In the case of a broadcast intent, this is the action that took place and is being reported.
+The action largely determines how the rest of the intent is structured&mdash;particularly
+what is contained in the data and extras.
-<p>
-See the {@link android.content.Intent} class description for a list of
-pre-defined constants for generic actions. Other actions are defined
-elsewhere in the Android API.
-You can also define your own action strings for activating the components
-in your application. Those you invent should include the application
-package as a prefix &mdash; for example:
-"<code>com.example.project.SHOW_COLOR</code>".
-</p>
+<p>You can specify your own actions for use by intents within your app (or for use by other
+apps to invoke components in your app), but you should usually use action constants
+defined by the {@link android.content.Intent} class or other framework classes. Here are some
+common actions for starting an activity:</p>
-<p>
-The action largely determines how the rest of the intent is structured
-&mdash; particularly the <a href="#data">data</a> and
-<a href="#extras">extras</a> fields &mdash;
-much as a method name determines a set of arguments and a return value.
-For this reason, it's a good idea to use action names that are
-as specific as possible, and to couple them tightly to the other fields of
-the intent. In other words, instead of defining an action in isolation,
-define an entire protocol for the Intent objects your components can handle.
-</p>
+<dl>
+<dt>{@link android.content.Intent#ACTION_VIEW}</dt>
+ <dd>Use this action in an intent with {@link
+ android.content.Context#startActivity startActivity()} when you have some information that
+ an activity can show to the user, such as a photo to view in a gallery app, or an address to
+ view in a map app.</dd>
+
+<dt>{@link android.content.Intent#ACTION_SEND}</dt>
+ <dd>Also known as the "share" intent, you should use this in an intent with {@link
+ android.content.Context#startActivity startActivity()} when you have some data that the user can
+ share through another app, such as an email app or social sharing app.</dd>
+</dl>
-<p>
-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>
-</dd>
+<p>See the {@link android.content.Intent} class reference for more
+constants that define generic actions. Other actions are defined
+elsewhere in the Android framework, such as in {@link android.provider.Settings} for actions
+that open specific screens in the system's Settings app.</p>
-<p><dt><b>Data</b><a name="data"></a></dt>
-<dd>The URI of the data to be acted on and the MIME type of that data. 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 an {@code http:} URI, the receiving activity would be called upon
-to download and display whatever data the URI refers to.
+<p>You can specify the action for an intent with {@link android.content.Intent#setAction
+setAction()} or with an {@link android.content.Intent} constructor.</p>
-<p>
-When matching an intent to a component that is capable of handling the data,
-it's often important to know the type of data (its MIME type) in addition to its URI.
-For example, a component able to display image data should not be called
-upon to play an audio file.
-</p>
+<p>If you define your own actions, be sure to include your app's package name
+as a prefix. For example:</p>
+<pre>static final String ACTION_TIMETRAVEL = "com.example.action.TIMETRAVEL";</pre>
+</dd>
-<p>
-In many cases, the data type can be inferred from the URI &mdash; particularly
-{@code content:} URIs, which indicate that the data is located on the device and
-controlled by a content provider (see the
-<a href="{@docRoot}guide/topics/providers/content-providers.html">separate
-discussion on content providers</a>). But the type can also be explicitly set
-in the Intent object.
-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 URI is read by <code>{@link
-android.content.Intent#getData getData()}</code> and the type by <code>{@link
-android.content.Intent#getType getType()}</code>.
-</p>
+<dt><b>Data</b></dt>
+<dd>The URI (a {@link android.net.Uri} object) that references the data to be acted on and/or the
+MIME type of that data. The type of data supplied is generally dictated by the intent's action. For
+example, if the action is {@link android.content.Intent#ACTION_EDIT}, the data should contain the
+URI of the document to edit.
+
+<p>When creating an intent,
+it's often important to specify the type of data (its MIME type) in addition to its URI.
+For example, an activity that's able to display images probably won't be able
+to play an audio file, even though the URI formats could be similar.
+So specifying the MIME type of your data helps the Android
+system find the best component to receive your intent.
+However, the MIME type can sometimes be inferred from the URI&mdash;particularly when the data is a
+{@code content:} URI, which indicates the data is located on the device and controlled by a
+{@link android.content.ContentProvider}, which makes the data MIME type visible to the system.</p>
+
+<p>To set only the data URI, call {@link android.content.Intent#setData setData()}.
+To set only the MIME type, call {@link android.content.Intent#setType setType()}. If necessary, you
+can set both explicitly with {@link
+android.content.Intent#setDataAndType setDataAndType()}.</p>
+
+<p class="caution"><strong>Caution:</strong> If you want to set both the URI and MIME type,
+<strong>do not</strong> call {@link android.content.Intent#setData setData()} and
+{@link android.content.Intent#setType setType()} because they each nullify the value of the other.
+Always use {@link android.content.Intent#setDataAndType setDataAndType()} to set both
+URI and MIME type.</p>
</dd>
<p><dt><b>Category</b></dt>
-<dd>A string containing additional information about the kind of component
-that should handle the intent. Any number of category descriptions can be
-placed in an Intent object. As it does for actions, the Intent class defines
-several category constants, including these:
-
-<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 <em>Home</em> button 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>
+<dd>A string containing additional information about the kind of component
+that should handle the intent. Any number of category descriptions can be
+placed in an intent, but most intents do not require a category.
+Here are some common categories:
-<p>
-See the {@link android.content.Intent} class description for the full list of
-categories.
-</p>
+<dl>
+<dt>{@link android.content.Intent#CATEGORY_BROWSABLE}</dt>
+ <dd>The target activity allows itself to be started by a web browser to display data
+ referenced by a link&mdash;such as an image or an e-mail message.
+ </dd>
+<dt>{@link android.content.Intent#CATEGORY_LAUNCHER}</dt>
+ <dd>The activity is the initial activity of a task and is listed in
+ the system's application launcher.
+ </dd>
+</dl>
-<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>
+<p>See the {@link android.content.Intent} class description for the full list of
+categories.</p>
+
+<p>You can specify a category with {@link android.content.Intent#addCategory addCategory()}.</p>
</dd>
+</dl>
-<p><dt><b>Extras</b><a name="extras"></a></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.
-If you were to invent a {@code SHOW_COLOR} action, the color value would
-be set in an extra key-value pair.
-<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>
+<p>These properties listed above (component name, action, data, and category) represent the
+defining characteristics of an intent. By reading these properties, the Android system
+is able to resolve which app component it should start.</p>
+
+<p>However, an intent can carry additional information that does not affect
+how it is resolved to an app component. An intent can also supply:</p>
+
+<dl>
+<dt><b>Extras</b></dt>
+<dd>Key-value pairs that carry additional information required to accomplish the requested action.
+Just as some actions use particular kinds of data URIs, some actions also use particular extras.
+
+<p>You can add extra data with various {@link android.content.Intent#putExtra putExtra()} methods,
+each accepting two parameters: the key name and the value.
+You can also create a {@link android.os.Bundle} object with all the extra data, then insert
+the {@link android.os.Bundle} in the {@link android.content.Intent} with {@link
+android.content.Intent#putExtras putExtras()}.</p>
+
+<p>For example, when creating an intent to send an email with
+{@link android.content.Intent#ACTION_SEND}, you can specify the "to" recipient with the
+{@link android.content.Intent#EXTRA_EMAIL} key, and specify the "subject" with the
+{@link android.content.Intent#EXTRA_SUBJECT} key.</p>
+
+<p>The {@link android.content.Intent} class specifies many {@code EXTRA_*} constants
+for standardized data types. If you need to declare your own extra keys (for intents that
+your app receives), be sure to include your app's package name
+as a prefix. For example:</p>
+<pre>static final String EXTRA_GIGAWATTS = "com.example.EXTRA_GIGAWATTS";</pre>
</dd>
-<p><dt><b>Flags</b></dt>
-<dd>Flags of various sorts. Many 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.
+<dt><b>Flags</b></dt>
+<dd>Flags defined in the {@link android.content.Intent} class that function as metadata for the
+intent. The flags may instruct the Android system how to launch an activity (for example, which
+<a href="{@docRoot}guide/components/tasks-and-back-stack.html">task</a> 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).
+
+<p>For more information, see the {@link android.content.Intent#setFlags setFlags()} method.</p>
</dd>
</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}guide/appendix/g-app-intents.html">list of intents</a>
-in the reference.
-</p>
-<h2><a name="ires"></a>Intent Resolution</h2>
-<p>
-Intents can be divided into two groups:
-</p>
+<h3 id="ExampleExplicit">Example explicit intent</h3>
-<ul>
-<li><i>Explicit intents</i> designate the target component by its
-name (the <a href="#cname">component name field</a>, mentioned earlier,
-has a value set). Since component names would generally not be known to
-developers of other applications, explicit intents are typically used
-for application-internal messages &mdash; such as an activity starting
-a subordinate service or launching a sister activity.</li>
-
-<li><p><i>Implicit intents</i> do not name a target (the field for
-the component name is blank). Implicit intents are often used to
-activate components in other applications.</p></li>
-</ul>
+<p>An explicit intent is one that you use to launch a specific app component, such as
+a particular activity or service in your app. To create an explicit intent, define
+the component name for the {@link android.content.Intent} object&mdash;all
+other intent properties are optional.</p>
-<p>
-Android delivers an explicit intent to an instance of the designated
-target class. Nothing in the Intent object other than the component
-name matters for determining which component should get the intent.
-</p>
+<p>For example, if you built a service in your app, named {@code DownloadService},
+designed to download a file from the web, you can start it with the following code:</p>
-<p>
-A different strategy is needed for implicit intents. In the absence of a
-designated target, the Android system must find the best component (or
-components) to handle the intent &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 contents of
-the Intent object to <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. They
-open the component to the possibility of receiving implicit intents of
-the advertised type. If a component does not have any intent filters,
-it can receive only explicit intents. A component with filters can
-receive both explicit and implicit intents.
-</p>
+<pre>
+// Executed in an Activity, so 'this' is the {@link android.content.Context}
+// The fileUrl is a string URL, such as "http://www.example.com/image.png"
+Intent downloadIntent = new Intent(this, DownloadService.class);
+downloadIntent.setData({@link android.net.Uri#parse Uri.parse}(fileUrl));
+startService(downloadIntent);
+</pre>
-<p>
-Only three aspects of an Intent object are consulted when the object
-is tested against an intent filter:
-</p>
+<p>The {@link android.content.Intent#Intent(Context,Class)}
+constructor supplies the app {@link android.content.Context} and the
+component a {@link java.lang.Class} object. As such,
+this intent explicitly starts the {@code DownloadService} class in the app.</p>
-<p style="margin-left: 2em">action
-<br/>data (both URI and data type)
-<br/>category</p>
+<p>For more information about building and starting a service, see the
+<a href="{@docRoot}guide/components/services.html">Services</a> guide.</p>
-<p>
-The extras and flags play no part in resolving which component receives
-an intent.
-</p>
-<h3><a name="ifs"></a>Intent filters</h3>
-<p>
-To inform the system which implicit 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 in
-intents of a desired type, while filtering out unwanted
-intents &mdash; but only unwanted implicit intents (those that don't name
-a target class). An explicit intent is always delivered to its target,
-no matter what it contains; the filter is not consulted. But an implicit
-intent is delivered to a component only if it can pass through one of the
-component's filters.
-</p>
+<h3 id="ExampleSend">Example implicit intent</h3>
-<p>
-A component has separate filters for each job it can do, each face it can
-present to the user. For example, the NoteEditor activity of the sample
-Note Pad application has two filters &mdash; one for starting up with a
-specific note that the user can view or edit, and another for starting
-with a new, blank note that the user can fill in and save. (All of Note
-Pad's filters are described in the <a href="#npex">Note Pad Example</a>
-section, later.)
-</p>
+<p>An implicit intent specifies an action that can invoke any app on the device able
+to perform the action. Using an implicit intent is useful when your app cannot perform the
+action, but other apps probably can and you'd like the user to pick which app to use.</p>
-<div class="sidebox-wrapper">
-<div class="sidebox">
-<h2>Filters and security</h2>
-<p>An intent filter cannot be relied on for security. While it opens a
-component to receiving only certain kinds of implicit intents, it does
-nothing to prevent explicit intents from targeting the component. Even
-though a filter restricts the intents a component will be asked to handle
-to certain actions and data sources, someone could always put
-together an explicit intent with a different action and data source, and
-name the component as the target.
-</p>
+<p>For example, if you have content you want the user to share with other people, create an intent
+with the {@link android.content.Intent#ACTION_SEND} action
+and add extras that specify the content to share. When you call
+{@link android.content.Context#startActivity startActivity()} with that intent, the user can
+pick an app through which to share the content.</p>
+
+<p class="caution"><strong>Caution:</strong> It's possible that a user won't have <em>any</em>
+apps that handle the implicit intent you send to {@link android.content.Context#startActivity
+startActivity()}. If that happens, the call will fail and your app will crash. To verify
+that an activity will receive the intent, call {@link android.content.Intent#resolveActivity
+resolveActivity()} on your {@link android.content.Intent} object. If the result is non-null,
+then there is at least one app that can handle the intent and it's safe to call
+{@link android.content.Context#startActivity startActivity()}. If the result is null,
+you should not use the intent and, if possible, you should disable the feature that issues
+the intent.</p>
+
+
+<pre>
+// Create the text message with a string
+Intent sendIntent = new Intent();
+sendIntent.setAction(Intent.ACTION_SEND);
+sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
+sendIntent.setType({@link
+ org.apache.http.protocol.HTTP#PLAIN_TEXT_TYPE
+ HTTP.PLAIN_TEXT_TYPE}); // "text/plain" MIME type
+
+// Verify that the intent will resolve to an activity
+if (sendIntent.resolveActivity(getPackageManager()) != null) {
+ startActivity(sendIntent);
+}
+</pre>
+
+<p class="note"><strong>Note:</strong> In this case, a URI is not used, but the intent's data type
+is declared to specify the content carried by the extras.</p>
+
+
+<p>When {@link android.content.Context#startActivity startActivity()} is called, the system
+examines all of the installed apps to determine which ones can handle this kind of intent (an
+intent with the {@link android.content.Intent#ACTION_SEND} action and that carries "text/plain"
+data). If there's only one app that can handle it, that app opens immediately and is given the
+intent. If multiple activities accept the intent, the system
+displays a dialog so the user can pick which app to use..</p>
+
+
+<div class="figure" style="width:200px">
+ <img src="{@docRoot}images/training/basics/intent-chooser.png" alt="">
+ <p class="img-caption"><strong>Figure 2.</strong> A chooser dialog.</p>
</div>
-</div>
-<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><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code>
-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>
+<h3 id="ForceChooser">Forcing an app chooser</h3>
-<p>
-A filter has fields that parallel the action, data, and category fields of an
-Intent object. An implicit 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 intent that does not pass
-through one of a component's filters might make it through on another.
-</p>
+<p>When there is more than one app that responds to your implicit intent,
+the user can select which app to use and make that app the default choice for the
+action. This is nice when performing an action for which the user
+probably wants to use the same app from now on, such as when opening a web page (users
+often prefer just one web browser) .</p>
-<p>
-Each of the three tests is described in detail below:
-</p>
+<p>However, if multiple apps can respond to the intent and the user might want to use a different
+app each time, you should explicitly show a chooser dialog. The chooser dialog asks the
+user to select which app to use for the action every time (the user cannot select a default app for
+the action). For example, when your app performs "share" with the {@link
+android.content.Intent#ACTION_SEND} action, users may want to share using a different app depending
+on their current situation, so you should always use the chooser dialog, as shown in figure 2.</p>
-<dl>
-<dt><b>Action test</b></dt>
-<dd>An
-<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code>
-element in the manifest file lists actions as
-<code><a href="{@docRoot}guide/topics/manifest/action-element.html">&lt;action&gt;</a></code>
-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. The list cannot be empty; a filter must
-contain at least one {@code &lt;action&gt;} element, or it
-will block all intents.
-</p>
-<p>
-To pass this test, the action specified in the Intent object must match
-one of the actions listed in the filter. If the object or the filter
-does not specify an action, the results are as follows:
-</p>
+<p>To show the chooser, create an {@link android.content.Intent} using {@link
+android.content.Intent#createChooser createChooser()} and pass it to {@link
+android.app.Activity#startActivity startActivity()}. For example:</p>
-<ul>
-<li>If the filter fails to list any actions, there is nothing for an
-intent to match, so all intents fail the test. No intents can get
-through the filter.</li>
-
-<li><p>On the other hand, an Intent object that doesn't specify an
-action automatically passes the test &mdash; as long as the filter
-contains at least one action.</p></li>
-</ul
-</dd>
+<pre>
+Intent intent = new Intent(Intent.ACTION_SEND);
+...
-<dt><b>Category test</b></dt>
-<dd>An
-<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code>
-element also lists categories as subelements. For example:
+// Always use string resources for UI text.
+// This says something like "Share this photo with"
+String title = getResources().getString(R.string.chooser_title);
+// Create intent to show chooser
+Intent chooser = Intent.createChooser(intent, title);
-<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>
+// Verify the intent will resolve to at least one activity
+if (sendIntent.resolveActivity(getPackageManager()) != null) {
+ startActivity(sendIntent);
+}
+</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>
+<p>This displays a dialog with a list of apps that respond to the intent passed to the {@link
+android.content.Intent#createChooser createChooser()} method and uses the supplied text as the
+dialog title.</p>
-<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 that are in the intent.
-</p>
-<p>
-In principle, therefore, an Intent object with no categories should always pass
-this test, regardless of what's in the filter. That's mostly true. However,
-with one exception, Android treats all implicit intents passed to {@link
-android.content.Context#startActivity startActivity()} as if they contained
-at least one category: "{@code android.intent.category.DEFAULT}" (the
-{@code CATEGORY_DEFAULT} constant).
-Therefore, activities that are willing to receive implicit intents must
-include "{@code android.intent.category.DEFAULT}" in their intent filters.
-(Filters with "{@code android.intent.action.MAIN}" and
-"{@code android.intent.category.LAUNCHER}" settings are the exception.
-They mark activities that begin new tasks and that are represented on the
-launcher screen. They can include "{@code android.intent.category.DEFAULT}"
-in the list of categories, but don't need to.) See <a href="#imatch">Using
-intent matching</a>, later, for more on these filters.)
-</p>
-<dd>
-<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:mimeType="video/mpeg" android:scheme="http" . . . /&gt;
- &lt;data android:mimeType="audio/mpeg" android:scheme="http" . . . /&gt;
- . . .
-&lt;/intent-filter&gt;</pre>
-<p>
-Each
-<code><a href="{@docRoot}guide/topics/manifest/data-element.html">&lt;data&gt;</a></code>
-element can specify a URI and a data type (MIME media type). There are separate
-attributes &mdash; {@code scheme}, {@code host}, {@code port},
-and {@code path} &mdash; for each part of the URI:
-</p>
-<p style="margin-left: 2em">{@code scheme://host:port/path}</p>
-<p>
-For example, in the following URI,
-</p>
-<p style="margin-left: 2em">{@code content://com.example.project:200/folder/subfolder/etc}</p>
-<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>
+<h2 id="Receiving">Receiving an Implicit Intent</h2>
-<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>
+<p>To advertise which implicit intents your app can receive, declare one or more intent filters for
+each of your app components with an <a href=
+"{@docRoot}guide/topics/manifest/intent-filter-element.html">{@code &lt;intent-filter&gt;}</a>
+element in your <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest file</a>.
+Each intent filter specifies the type of intents it accepts based on the intent's action,
+data, and category. The system will deliver an implicit intent to your app component only if the
+intent can pass through one of your intent filters.</p>
-<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 mentioned 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>
+<p class="note"><strong>Note:</strong> An explicit intent is always delivered to its target,
+regardless of any intent filters the component declares.</p>
-<p>
-The {@code type} attribute of a {@code &lt;data&gt;} element specifies the MIME type
-of the data. It's more common in filters than a URI. Both the Intent object and
-the filter can use a "*" wildcard for the subtype field &mdash; for example,
-"{@code text/*}" or "{@code audio/*}" &mdash; indicating any subtype matches.
-</p>
+<p>An app component should declare separate filters for each unique job it can do.
+For example, one activity in an image gallery app may have two filters: one filter
+to view an image, and another filter to edit an image. When the activity starts,
+it inspects the {@link android.content.Intent} and decides how to behave based on the information
+in the {@link android.content.Intent} (such as to show the editor controls or not).</p>
-<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:
-</p>
+<p>Each intent filter is defined by an <a
+href="{@docRoot}guide/topics/manifest/intent-filter-element.html">{@code &lt;intent-filter>}</a>
+element in the app's manifest file, nested in the corresponding app component (such
+as an <a href="{@docRoot}guide/topics/manifest/activity-element.html">{@code &lt;activity>}</a>
+element). Inside the <a
+href="{@docRoot}guide/topics/manifest/intent-filter-element.html">{@code &lt;intent-filter>}</a>,
+you can specify the type of intents to accept using one or more
+of these three elements:</p>
-<ol type="a">
-<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.</li>
-
-<li><p>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>
-
-<li><p>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>
-
-<li><p>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 lists only a data type.</p></li>
-</ol>
+<dl>
+<dt><a href="{@docRoot}guide/topics/manifest/action-element.html">{@code &lt;action>}</a></dt>
+ <dd>Declares the intent action accepted, in the {@code name} attribute. The value
+ must be the literal string value of an action, not the class constant.</dd>
+<dt><a href="{@docRoot}guide/topics/manifest/data-element.html">{@code &lt;data>}</a></dt>
+ <dd>Declares the type of data accepted, using one or more attributes that specify various
+ aspects of the data URI (<code>scheme</code>, <code>host</code>, <code>port</code>,
+ <code>path</code>, etc.) and MIME type.</dd>
+<dt><a href="{@docRoot}guide/topics/manifest/category-element.html">{@code &lt;category>}</a></dt>
+ <dd>Declares the intent category accepted, in the {@code name} attribute. The value
+ must be the literal string value of an action, not the class constant.
+
+ <p class="note"><strong>Note:</strong> In order to receive implicit intents, you
+ <strong>must include</strong> the
+ {@link android.content.Intent#CATEGORY_DEFAULT} category in the intent filter. The methods
+ {@link android.app.Activity#startActivity startActivity()} and
+ {@link android.app.Activity#startActivityForResult startActivityForResult()} treat all intents
+ as if they declared the {@link android.content.Intent#CATEGORY_DEFAULT} category.
+ If you do not declare this category in your intent filter, no implicit intents will resolve to
+ your activity.</p>
+ </dd>
</dl>
-<p>
-If an intent can pass through the filters of more than one activity or service,
-the user may be asked which component to activate. An exception is raised if
-no target can be found.
-</p>
+<p>For example, here's an activity declaration with an intent filter to receive an
+{@link android.content.Intent#ACTION_SEND} intent when the data type is text:</p>
+<pre>
+&lt;activity android:name="ShareActivity">
+ &lt;intent-filter>
+ &lt;action android:name="android.intent.action.SEND"/>
+ &lt;category android:name="android.intent.category.DEFAULT"/>
+ &lt;data android:mimeType="text/plain"/>
+ &lt;/intent-filter>
+&lt;/activity>
+</pre>
-<h3><a name="ccases"></a>Common cases</h3>
+<p>It's okay to create a filter that includes more than one instance of
+<a href="{@docRoot}guide/topics/manifest/action-element.html">{@code &lt;action>}</a>,
+<a href="{@docRoot}guide/topics/manifest/data-element.html">{@code &lt;data>}</a>, or
+<a href="{@docRoot}guide/topics/manifest/category-element.html">{@code &lt;category>}</a>.
+If you do, you simply need to be certain that the component can handle any and all combinations
+of those filter elements.</p>
-<p>
-The last rule shown above for the data test, rule (d), reflects the expectation
-that components are able to get local data from a file or content provider.
-Therefore, their filters can list just a data type and do not need to explicitly
-name the {@code content:} and {@code file:} schemes.
-This is a typical case. A {@code &lt;data&gt;} element like the following,
-for example, tells Android that the component can get image data from a content
-provider and display it:
-</p>
+<p>When you want to handle multiple kinds of intents, but only in specific combinations of
+action, data, and category type, then you need to create multiple intent filters.</p>
-<pre>&lt;data android:mimeType="image/*" /&gt;</pre>
-<p>
-Since most available data is dispensed by content providers, filters that
-specify a data type but not a URI are perhaps the most common.
+<div class="sidebox-wrapper">
+<div class="sidebox">
+<h2>Restricting access to components</h2>
+<p>Using an intent filter is not a secure way to prevent other apps from starting
+your components. Although intent filters restrict a component to respond to only
+certain kinds of implicit intents, another app can potentially start your app component
+by using an explicit intent if the developer determines your component names.
+If it's important that <em>only your own app</em> is able to start one of your components,
+set the <a href="{@docRoot}guide/topics/manifest/activity-element.html#exported">{@code
+exported}</a> attribute to {@code "false"} for that component.
</p>
+</div>
+</div>
-<p>
-Another common configuration is filters with a scheme and a data type. For
-example, a {@code &lt;data&gt;} element like the following tells Android that
-the component can get video data from the network and display it:
-</p>
+<p>An implicit intent is tested against a filter by comparing the intent to each of the
+three elements. To be delivered to the component, the intent must pass all three tests.
+If it fails to match even one of them, the Android system won't deliver the intent to the
+component. However, because a component may have multiple intent filters, an intent that does
+not pass through one of a component's filters might make it through on another filter.
+More information about how the system resolves intents is provided in the section below
+about <a href="#Resolution">Intent Resolution</a>.</p>
+
+<p class="caution"><strong>Caution:</strong> To avoid inadvertently running a different app's
+{@link android.app.Service}, always use an explicit intent to start your own service and do not
+declare intent filters for your service.</p>
+
+<p class="note"><strong>Note:</strong>
+For all activities, you must declare your intent filters in the manifest file.
+However, filters for broadcast receivers can be registered dynamically by calling
+{@link android.content.Context#registerReceiver(BroadcastReceiver, IntentFilter, String,
+Handler) registerReceiver()}. You can then unregister the receiver with {@link
+android.content.Context#unregisterReceiver unregisterReceiver()}. Doing so allows your app
+to listen for specific broadcasts during only a specified period of time while your app
+is running.</p>
+
+
+
+
+
+
+
+<h3 id="ExampleFilters">Example filters</h3>
+
+<p>To better understand some of the intent filter behaviors, look at the following snippet
+from the manifest file of a social-sharing app.</p>
+
+<pre>
+&lt;activity android:name="MainActivity">
+ &lt;!-- This activity is the main entry, should appear in app launcher -->
+ &lt;intent-filter>
+ &lt;action android:name="android.intent.action.MAIN" />
+ &lt;category android:name="android.intent.category.LAUNCHER" />
+ &lt;/intent-filter>
+&lt;/activity>
+
+&lt;activity android:name="ShareActivity">
+ &lt;!-- This activity handles "SEND" actions with text data -->
+ &lt;intent-filter&gt;
+ &lt;action android:name="android.intent.action.SEND"/>
+ &lt;category android:name="android.intent.category.DEFAULT"/>
+ &lt;data android:mimeType="text/plain"/>
+ &lt;/intent-filter&gt;
+ &lt;!-- This activity also handles "SEND" and "SEND_MULTIPLE" with media data -->
+ &lt;intent-filter&gt;
+ &lt;action android:name="android.intent.action.SEND"/>
+ &lt;action android:name="android.intent.action.SEND_MULTIPLE"/>
+ &lt;category android:name="android.intent.category.DEFAULT"/>
+ &lt;data android:mimeType="application/vnd.google.panorama360+jpg"/>
+ &lt;data android:mimeType="image/*"/>
+ &lt;data android:mimeType="video/*"/>
+ &lt;/intent-filter&gt;
+&lt;/activity&gt;
+</pre>
+
+<p>The first activity, {@code MainActivity}, is the app's main entry point&mdash;the activity that
+opens when the user initially launches the app with the launcher icon:</p>
+<ul>
+ <li>The {@link android.content.Intent#ACTION_MAIN} action
+ indicates this is the main entry point and does not expect any intent data.</li>
+ <li>The {@link android.content.Intent#CATEGORY_LAUNCHER} category indicates that this activity's
+ icon should be placed in the system's app launcher. If the <a
+ href="{@docRoot}guide/topics/manifest/activity-element.html">{@code &lt;activity>}</a> element
+ does not specify an icon with {@code icon}, then the system uses the icon from the <a
+ href="{@docRoot}guide/topics/manifest/application-element.html">{@code &lt;application>}</a>
+ element.</li>
+</ul>
+<p>These two must be paired together in order for the activity to appear in the app launcher.</p>
-<pre>&lt;data android:scheme="http" android:type="video/*" /&gt;</pre>
+<p>The second activity, {@code ShareActivity}, is intended to facilitate sharing text and media
+content. Although users might enter this activity by navigating to it from {@code MainActivity},
+they can also enter {@code ShareActivity} directly from another app that issues an implicit
+intent matching one of the two intent filters.</p>
-<p>
-Consider, for example, what the browser application does when
-the user follows a link on a web page. It first tries to display the data
-(as it could if the link was to an HTML page). If it can't display the data,
-it puts together an implicit intent with the scheme and data type and tries
-to start an activity that can do the job. If there are no takers, it asks the
-download manager to download the data. That puts it under the control
-of a content provider, so a potentially larger pool of activities
-(those with filters that just name a data type) can respond.
-</p>
+<p class="note"><strong>Note:</strong> The MIME type,
+<a href="https://developers.google.com/panorama/android/">{@code
+application/vnd.google.panorama360+jpg}</a>, is a special data type that specifies
+panoramic photos, which you can handle with the <a
+href="{@docRoot}reference/com/google/android/gms/panorama/package-summary.html">Google
+panorama</a> APIs.</p>
-<p>
-Most applications also have a way to start fresh, without a reference
-to any particular data. Activities that can initiate applications
-have filters with "{@code android.intent.action.MAIN}" specified as
-the action. If they are to be represented in the application launcher,
-they also specify the "{@code android.intent.category.LAUNCHER}"
-category:
-</p>
-<pre>&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;</pre>
-<h3><a name="imatch"></a>Using intent matching</h3>
-<p>
-Intents are matched against intent filters not only to discover a target
-component to activate, but also to discover something about the set of
-components on the device. For example, the Android system populates the
-application launcher, the top-level screen that shows the applications
-that are available for the user to launch, by finding all the activities
- with intent filters that specify the "{@code android.intent.action.MAIN}"
-action and "{@code android.intent.category.LAUNCHER}" category
-(as illustrated in the previous section). It then displays the icons and
-labels of those activities in the launcher. Similarly, it discovers the
-home screen by looking for the activity with
-"{@code android.intent.category.HOME}" in its filter.
-</p>
-<p>
-Your application can use intent matching is a similar way.
-The {@link android.content.pm.PackageManager} has a set of {@code query...()}
-methods that return all components that can accept a particular intent, and
-a similar series of {@code resolve...()} methods that determine the best
-component to respond to an intent. For example,
-{@link android.content.pm.PackageManager#queryIntentActivities
-queryIntentActivities()} returns a list of all activities that can perform
-the intent passed as an argument, and {@link
-android.content.pm.PackageManager#queryIntentServices
-queryIntentServices()} returns a similar list of services.
-Neither method activates the components; they just list the ones that
-can respond. There's a similar method,
-{@link android.content.pm.PackageManager#queryBroadcastReceivers
-queryBroadcastReceivers()}, for broadcast receivers.
-</p>
-<h2 id="npex">Note Pad Example</h2>
-<p>
-The Note Pad sample application enables users to browse through a list
-of notes, view details about individual items in the list, edit the items,
-and add a new item to the list. This section looks at the intent filters
-declared in its manifest file. (If you're working offline in the SDK, you
-can find all the source files for this sample application, including its
-manifest file, at {@code &lt;sdk&gt;/samples/NotePad/index.html}.
-If you're viewing the documentation online, the source files are in the
-<a href="{@docRoot}resources/samples/index.html">Tutorials and Sample Code</a>
-section <a href="{@docRoot}resources/samples/NotePad/index.html">here</a>.)
-</p>
-<p>
-In its manifest file, the Note Pad application declares three activities,
-each with at least one intent filter. It also declares a content provider
-that manages the note data. Here is the manifest file in its entirety:
-</p>
-<pre>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.android.notepad"&gt;
- &lt;application android:icon="@drawable/app_notes"
- android:label="@string/app_name" &gt;
-
- &lt;provider android:name="NotePadProvider"
- android:authorities="com.google.provider.NotePad" /&gt;
-
- &lt;activity android:name="NotesList" android:label="@string/title_notes_list"&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;intent-filter&gt;
- &lt;action android:name="android.intent.action.VIEW" /&gt;
- &lt;action android:name="android.intent.action.EDIT" /&gt;
- &lt;action android:name="android.intent.action.PICK" /&gt;
- &lt;category android:name="android.intent.category.DEFAULT" /&gt;
- &lt;data android:mimeType="vnd.android.cursor.dir/vnd.google.note" /&gt;
- &lt;/intent-filter&gt;
- &lt;intent-filter&gt;
- &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
- &lt;category android:name="android.intent.category.DEFAULT" /&gt;
- &lt;data android:mimeType="vnd.android.cursor.item/vnd.google.note" /&gt;
- &lt;/intent-filter&gt;
- &lt;/activity&gt;
-
- &lt;activity android:name="NoteEditor"
- android:theme="@android:style/Theme.Light"
- android:label="@string/title_note" &gt;
- &lt;intent-filter android:label="@string/resolve_edit"&gt;
- &lt;action android:name="android.intent.action.VIEW" /&gt;
- &lt;action android:name="android.intent.action.EDIT" /&gt;
- &lt;action android:name="com.android.notepad.action.EDIT_NOTE" /&gt;
- &lt;category android:name="android.intent.category.DEFAULT" /&gt;
- &lt;data android:mimeType="vnd.android.cursor.item/vnd.google.note" /&gt;
- &lt;/intent-filter&gt;
- &lt;intent-filter&gt;
- &lt;action android:name="android.intent.action.INSERT" /&gt;
- &lt;category android:name="android.intent.category.DEFAULT" /&gt;
- &lt;data android:mimeType="vnd.android.cursor.dir/vnd.google.note" /&gt;
- &lt;/intent-filter&gt;
- &lt;/activity&gt;
-
- &lt;activity android:name="TitleEditor"
- android:label="@string/title_edit_title"
- android:theme="@android:style/Theme.Dialog"&gt;
- &lt;intent-filter android:label="@string/resolve_title"&gt;
- &lt;action android:name="com.android.notepad.action.EDIT_TITLE" /&gt;
- &lt;category android:name="android.intent.category.DEFAULT" /&gt;
- &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
- &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
- &lt;data android:mimeType="vnd.android.cursor.item/vnd.google.note" /&gt;
- &lt;/intent-filter&gt;
- &lt;/activity&gt;
-
- &lt;/application&gt;
-&lt;/manifest&gt;</pre>
-<p>
-The first activity, NotesList, is
-distinguished from the other activities by the fact that it operates
-on a directory of notes (the note list) rather than on a single note.
-It would generally serve as the initial user interface into the
-application. It can do three things as described by its three intent
-filters:
-</p>
-<ol>
-<li><pre>&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;</pre>
-<p>
-This filter declares the main entry point into the Note Pad application.
-The standard {@code MAIN} action is an entry point that does not require
-any other information in the Intent (no data specification, for example),
-and the {@code LAUNCHER} category says that this entry point should be
-listed in the application launcher.
-</p></li>
-
-<li><pre>&lt;intent-filter&gt;
- &lt;action android:name="android.intent.action.VIEW" /&gt;
- &lt;action android:name="android.intent.action.EDIT" /&gt;
- &lt;action android:name="android.intent.action.PICK" /&gt;
- &lt;category android:name="android.intent.category.DEFAULT" /&gt;
- &lt;data android:mimeType="vnd.android.cursor.dir/vnd.google.note" /&gt;
-&lt;/intent-filter&gt;</pre>
+<h2 id="PendingIntent">Using a Pending Intent</h2>
-<p>
-This filter declares the things that the activity can do on a directory
-of notes. It can allow the user to view or edit the directory (via
-the {@code VIEW} and {@code EDIT} actions), or to pick a particular note
-from the directory (via the {@code PICK} action).
-</p>
+<p>A {@link android.app.PendingIntent} object is a wrapper around an {@link
+android.content.Intent} object. The primary purpose of a {@link android.app.PendingIntent}
+is to grant permission to a foreign application
+to use the contained {@link android.content.Intent} as if it were executed from your
+app's own process.</p>
-<p>
-The {@code mimeType} attribute of the
-<code><a href="{@docRoot}guide/topics/manifest/data-element.html">&lt;data&gt;</a></code>
-element specifies the kind of data that these actions operate on. It
-indicates that the activity can get a Cursor over zero or more items
-({@code vnd.android.cursor.dir}) from a content provider that holds
-Note Pad data ({@code vnd.google.note}). The Intent object that launches
-the activity would include a {@code content:} URI specifying the exact
-data of this type that the activity should open.
-</p>
+<p>Major use cases for a pending intent include:</p>
+<ul>
+ <li>Declare an intent to be executed when the user performs an action with your <a
+ href="{@docRoot}guide/topics/ui/notifiers/notifications.html">Notification</a>
+ (the Android system's {@link android.app.NotificationManager}
+ executes the {@link android.content.Intent}).
+ <li>Declare an intent to be executed when the user performs an action with your
+ <a href="{@docRoot}guide/topics/appwidgets/index.html">App Widget</a>
+ (the Home screen app executes the {@link android.content.Intent}).
+ <li>Declare an intent to be executed at a specified time in the future (the Android
+ system's {@link android.app.AlarmManager} executes the {@link android.content.Intent}).
+</ul>
-<p>
-Note also the {@code DEFAULT} category supplied in this filter. It's
-there because the <code>{@link android.content.Context#startActivity
-Context.startActivity()}</code> and
-<code>{@link android.app.Activity#startActivityForResult
-Activity.startActivityForResult()}</code> methods treat all intents
-as if they contained the {@code DEFAULT} category &mdash; with just
-two exceptions:
-</p>
+<p>Because each {@link android.content.Intent} object is designed to be handled by a specific
+type of app component (either an {@link android.app.Activity}, a {@link android.app.Service}, or
+a {@link android.content.BroadcastReceiver}), so too must a {@link android.app.PendingIntent} be
+created with the same consideration. When using a pending intent, your app will not
+execute the intent with a call such as {@link android.content.Context#startActivity
+startActivity()}. You must instead declare the intended component type when you create the
+{@link android.app.PendingIntent} by calling the respective creator method:</p>
<ul>
-<li>Intents that explicitly name the target activity</li>
-<li>Intents consisting of the {@code MAIN} action and {@code LAUNCHER}
-category</li>
+ <li>{@link android.app.PendingIntent#getActivity PendingIntent.getActivity()} for an
+ {@link android.content.Intent} that starts an {@link android.app.Activity}.</li>
+ <li>{@link android.app.PendingIntent#getService PendingIntent.getService()} for an
+ {@link android.content.Intent} that starts a {@link android.app.Service}.</li>
+ <li>{@link android.app.PendingIntent#getBroadcast PendingIntent.getBroadcast()} for a
+ {@link android.content.Intent} that starts an {@link android.content.BroadcastReceiver}.</li>
</ul>
-<p>
-Therefore, the {@code DEFAULT} category is <em>required</em> for all
-filters &mdash; except for those with the {@code MAIN} action and
-{@code LAUNCHER} category. (Intent filters are not consulted for
-explicit intents.)
-</p></li>
-
-<li><pre>&lt;intent-filter&gt;
- &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
- &lt;category android:name="android.intent.category.DEFAULT" /&gt;
- &lt;data android:mimeType="vnd.android.cursor.item/vnd.google.note" /&gt;
-&lt;/intent-filter&gt;</pre>
+<p>Unless your app is <em>receiving</em> pending intents from other apps,
+the above methods to create a {@link android.app.PendingIntent} are the only
+{@link android.app.PendingIntent} methods you'll probably ever need.</p>
-<p>
-This filter describes the activity's ability to return a note selected by
-the user without requiring any specification of the directory the user should
-choose from. The {@code GET_CONTENT} action is similar to the {@code PICK}
-action. In both cases, the activity returns the URI for a note selected by
-the user. (In each case, it's returned to the activity that called
-<code>{@link android.app.Activity#startActivityForResult
-startActivityForResult()}</code> to start the NoteList activity.) Here,
-however, the caller specifies the type of data desired instead of the
-directory of data the user will be picking from.
-</p>
+<p>Each method takes the current app {@link android.content.Context}, the
+{@link android.content.Intent} you want to wrap, and one or more flags that specify
+how the intent should be used (such as whether the intent can be used more than once).</p>
-<p>
-The data type, <code>vnd.android.cursor.item/vnd.google.note</code>,
-indicates the type of data the activity can return &mdash; a URI for
-a single note. From the returned URI, the caller can get a Cursor for
-exactly one item ({@code vnd.android.cursor.item}) from the content
-provider that holds Note Pad data ({@code vnd.google.note}).
-</p>
+<p>More information about using pending intents is provided with the documentation for each
+of the respective use cases, such as in the <a
+href="{@docRoot}guide/topics/ui/notifiers/notifications.html">Notifications</a>
+and <a href="{@docRoot}guide/topics/appwidgets/index.html">App Widgets</a> API guides.</p>
-<p>
-In other words, for the {@code PICK} action in the previous filter,
-the data type indicates the type of data the activity could display to the
-user. For the {@code GET_CONTENT} filter, it indicates the type of data
-the activity can return to the caller.
-</p></li>
-</ol>
-<p>
-Given these capabilities, the following intents will resolve to the
-NotesList activity:
-</p>
-<dl style="margin-left: 2em">
-<dt>action: <code>android.intent.action.MAIN</code></dt>
-<dd>Launches the activity with no data specified.</dd>
-
-<dt>action: <code>android.intent.action.MAIN</code>
-<br/>category: <code>android.intent.category.LAUNCHER</code></dt>
-<dd> Launches the activity with no data selected specified.
-This is the actual intent used by the Launcher to populate its top-level
-list. All activities with filters that match this action and category
-are added to the list.</dd>
-
-<dt>action: <code>android.intent.action.VIEW</code>
-<br/>data: <code>content://com.google.provider.NotePad/notes</code></dt>
-<dd>Asks the activity to display a list of all the notes under
-<code>content://com.google.provider.NotePad/notes</code>. The user can then
-browse through the list and get information about the items in it.</dd>
-
-<dt>action: <code>android.intent.action.PICK</code>
-<br/>data: <code>content://com.google.provider.NotePad/notes</code></dt>
-<dd>Asks the activity to display a list of the notes under
-<code>content://com.google.provider.NotePad/notes</code>.
-The user can then pick a note from the list, and the activity will return
-the URI for that item back to the activity that started the NoteList activity.</dd>
-
-<dt>action: <code>android.intent.action.GET_CONTENT</code>
-<br/>data type: <code>vnd.android.cursor.item/vnd.google.note</code></dt>
-<dd>Asks the activity to supply a single item of Note Pad data.</dd>
-</dl>
-<p>
-The second activity, NoteEditor, shows
-users a single note entry and allows them to edit it. It can do two things
-as described by its two intent filters:
-<ol>
-<li><pre>&lt;intent-filter android:label="@string/resolve_edit"&gt;
- &lt;action android:name="android.intent.action.VIEW" /&gt;
+
+
+<h2 id="Resolution">Intent Resolution</h2>
+
+
+<p>When the system receives an implicit intent to start an activity, it searches for the
+best activity for the intent by comparing the intent to intent filters based on three aspects:</p>
+
+<ul>
+ <li>The intent action
+ <li>The intent data (both URI and data type)
+ <li>The intent category
+</ul>
+
+<p>The following sections describe how an intents are matched to the appropriate component(s)
+in terms of how the intent filter is declared in an app's manifest file.</p>
+
+
+<h3 id="ActionTest">Action test</h3>
+
+<p>To specify accepted intent actions, an intent filter can declare zero or more
+<a href="{@docRoot}guide/topics/manifest/action-element.html">{@code
+&lt;action&gt;}</a> elements. For example:</p>
+
+<pre>
+&lt;intent-filter&gt;
&lt;action android:name="android.intent.action.EDIT" /&gt;
- &lt;action android:name="com.android.notepad.action.EDIT_NOTE" /&gt;
- &lt;category android:name="android.intent.category.DEFAULT" /&gt;
- &lt;data android:mimeType="vnd.android.cursor.item/vnd.google.note" /&gt;
-&lt;/intent-filter&gt;</pre>
+ &lt;action android:name="android.intent.action.VIEW" /&gt;
+ ...
+&lt;/intent-filter&gt;
+</pre>
-<p>
-The first, primary, purpose of this activity is to enable the user to
-interact with a single note &mdash; to either {@code VIEW} the note or
-{@code EDIT} it. (The {@code EDIT_NOTE} category is a synonym for
-{@code EDIT}.) The intent would contain the URI for data matching the
-MIME type <code>vnd.android.cursor.item/vnd.google.note</code> &mdash;
-that is, the URI for a single, specific note. It would typically be a
-URI that was returned by the {@code PICK} or {@code GET_CONTENT}
-actions of the NoteList activity.
-</p>
+<p>To get through this filter, the action specified in the {@link android.content.Intent}
+ must match one of the actions listed in the filter.</p>
-<p>
-As before, this filter lists the {@code DEFAULT} category so that the
-activity can be launched by intents that don't explicitly specify the
-NoteEditor class.
-</p></li>
+<p>If the filter does not list any actions, there is nothing for an
+intent to match, so all intents fail the test. However, if an {@link android.content.Intent}
+does not specify an action, it will pass the test (as long as the filter
+contains at least one action).</p>
+
+
+
+<h3 id="CategoryTest">Category test</h3>
+
+<p>To specify accepted intent categories, an intent filter can declare zero or more
+<a href="{@docRoot}guide/topics/manifest/category-element.html">{@code
+&lt;category&gt;}</a> elements. For example:</p>
-<li><pre>&lt;intent-filter&gt;
- &lt;action android:name="android.intent.action.INSERT" /&gt;
+<pre>
+&lt;intent-filter&gt;
&lt;category android:name="android.intent.category.DEFAULT" /&gt;
- &lt;data android:mimeType="vnd.android.cursor.dir/vnd.google.note" /&gt;
-&lt;/intent-filter&gt;</pre>
+ &lt;category android:name="android.intent.category.BROWSABLE" /&gt;
+ ...
+&lt;/intent-filter&gt;
+</pre>
-<p>
-The secondary purpose of this activity is to enable the user to create a new
-note, which it will {@code INSERT} into an existing directory of notes. The
-intent would contain the URI for data matching the MIME type
-<code>vnd.android.cursor.dir/vnd.google.note</code> &mdash; that
-is, the URI for the directory where the note should be placed.
-</p></li>
-</ol>
+<p>For an intent to pass the category test, every category in the {@link android.content.Intent}
+must match a category in the filter. The reverse is not necessary&mdash;the intent filter may
+declare more categories than are specified in the {@link android.content.Intent} and the
+{@link android.content.Intent} will still pass. Therefore, an intent with no categories should
+always pass this test, regardless of what categories are declared in the filter.</p>
+
+<p class="note"><strong>Note:</strong>
+Android automatically applies the the {@link android.content.Intent#CATEGORY_DEFAULT} category
+to all implicit intents passed to {@link
+android.content.Context#startActivity startActivity()} and {@link
+android.app.Activity#startActivityForResult startActivityForResult()}.
+So if you want your activity to receive implicit intents, it must
+include a category for {@code "android.intent.category.DEFAULT"} in its intent filters (as
+shown in the previous {@code &lt;intent-filter>} example.</p>
+
+
+
+<h3 id="DataTest">Data test</h3>
+
+<p>To specify accepted intent data, an intent filter can declare zero or more
+<a href="{@docRoot}guide/topics/manifest/data-element.html">{@code
+&lt;data&gt;}</a> elements. For example:</p>
+
+<pre>
+&lt;intent-filter&gt;
+ &lt;data android:mimeType="video/mpeg" android:scheme="http" ... /&gt;
+ &lt;data android:mimeType="audio/mpeg" android:scheme="http" ... /&gt;
+ ...
+&lt;/intent-filter&gt;
+</pre>
+
+<p>Each <code><a href="{@docRoot}guide/topics/manifest/data-element.html">&lt;data&gt;</a></code>
+element can specify a URI structure and a data type (MIME media type). There are separate
+attributes &mdash; {@code scheme}, {@code host}, {@code port},
+and {@code path} &mdash; for each part of the URI:
+</p>
+
+<p style="margin-left: 2em">{@code &lt;scheme>://&lt;host>:&lt;port>/&lt;path>}</p>
<p>
-Given these capabilities, the following intents will resolve to the
-NoteEditor activity:
+For example:
</p>
-<dl style:"margin-left: 2em">
-<dt>action: <code>android.intent.action.VIEW</code>
-<br/>data: <code>content://com.google.provider.NotePad/notes/<var>ID</var></code></dt>
-<dd>Asks the activity to display the content of the note identified
-by {@code <var>ID</var>}. (For details on how {@code content:} URIs
-specify individual members of a group, see
-<a href="{@docRoot}guide/topics/providers/content-providers.html">Content Providers</a>.)
-
-<dt>action: <code>android.intent.action.EDIT</code>
-<br/>data: <code>content://com.google.provider.NotePad/notes/<var>ID</var></code></dt>
-<dd>Asks the activity to display the content of the note identified
-by {@code <var>ID</var>}, and to let the user edit it. If the user
-saves the changes, the activity updates the data for the note in the
-content provider.</dd>
-
-<dt>action: <code>android.intent.action.INSERT</code>
-<br/>data: <code>content://com.google.provider.NotePad/notes</code></dt>
-<dd>Asks the activity to create a new, empty note in the notes list at
-<code>content://com.google.provider.NotePad/notes</code>
-and allow the user to edit it. If the user saves the note, its URI
-is returned to the caller.
-</dd>
-</dl>
+<p style="margin-left: 2em">{@code content://com.example.project:200/folder/subfolder/etc}</p>
-<p>The last activity, TitleEditor,
-enables the user to edit the title of a note. This could be implemented
-by directly invoking the activity (by explicitly setting its component
-name in the Intent), without using an intent filter. But here we take
-the opportunity to show how to publish alternative operations on existing
-data:
+<p>In this URI, 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}.
</p>
-<pre>&lt;intent-filter android:label="@string/resolve_title"&gt;
- &lt;action android:name="com.android.notepad.action.EDIT_TITLE" /&gt;
- &lt;category android:name="android.intent.category.DEFAULT" /&gt;
- &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
- &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
- &lt;data android:mimeType="vnd.android.cursor.item/vnd.google.note" /&gt;
-&lt;/intent-filter&gt;</pre>
+<p>Each of these attributes is optional in a <a
+href="{@docRoot}guide/topics/manifest/data-element.html">{@code &lt;data>}</a> element,
+but there are linear dependencies:</p>
+<ul>
+ <li>If a scheme is not specified, the host is ignored.</li>
+ <li>If a host is not specified, the port is ignored.</li>
+ <li>If both the scheme and host are not specified, the path is ignored.</li>
+</ul>
-<p>
-The single intent filter for this activity uses a custom action called
-"<code>com.android.notepad.action.EDIT_TITLE</code>". It must be invoked on
-a specific note (data type <code>vnd.android.cursor.item/vnd.google.note</code>),
-like the previous {@code VIEW} and {@code EDIT} actions. However, here the
-activity displays the title contained in the note data, not the content of
-the note itself.
+<p>When the URI in an intent is compared to a URI specification in a filter,
+it's compared only to the parts of the URI included in the filter. For example:</p>
+<ul>
+ <li>If a filter specifies only a scheme, all URIs with that scheme match
+the filter.</li>
+ <li>If a filter specifies a scheme and an authority but no path, all URIs
+with the same scheme and authority pass the filter, regardless of their paths.</li>
+ <li>If a filter specifies a scheme, an authority, and a path, only URIs with the same scheme,
+authority, and path pass the filter.</li>
+</ul>
+
+<p class="note"><strong>Note:</strong> A path specification can
+contain a wildcard asterisk (*) to require only a partial match of the path name.</p>
+
+<p>The data test compares both the URI and the MIME type in the intent to a URI
+and MIME type specified in the filter. The rules are as follows:
</p>
+<ol type="a">
+<li>An intent that contains neither a URI nor a MIME type passes the
+test only if the filter does not specify any URIs or MIME types.</li>
+
+<li>An intent that contains a URI but no MIME type (neither explicit nor inferable from the
+URI) passes the test only if its URI matches the filter's URI format
+and the filter likewise does not specify a MIME type.</li>
+
+<li>An intent that contains a MIME type but not a URI passes the test
+only if the filter lists the same MIME type and does not specify a URI format.</li>
+
+<li>An intent that contains both a URI and a MIME type (either explicit or inferable from the
+URI) passes the MIME type part of the test only if that
+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 lists <em>only</em> a MIME type.</p></li>
+</ol>
+
<p>
-In addition to supporting the usual {@code DEFAULT} category, the title
-editor also supports two other standard categories:
-<code>{@link android.content.Intent#CATEGORY_ALTERNATIVE ALTERNATIVE}</code>
-and <code>{@link android.content.Intent#CATEGORY_SELECTED_ALTERNATIVE
-SELECTED_ALTERNATIVE}</code>.
-These categories identify activities that can be presented to users in
-a menu of options (much as the {@code LAUNCHER} category identifies
-activities that should be presented to user in the application launcher).
-Note that the filter also supplies an explicit label (via
-<code>android:label="@string/resolve_title"</code>) to better control
-what users see when presented with this activity as an alternative
-action to the data they are currently viewing. (For more information
-on these categories and building options menus, see the
-<code>{@link android.content.pm.PackageManager#queryIntentActivityOptions
-PackageManager.queryIntentActivityOptions()}</code> and
-<code>{@link android.view.Menu#addIntentOptions Menu.addIntentOptions()}</code>
-methods.)
+This last rule, rule (d), reflects the expectation
+that components are able to get local data from a file or content provider.
+Therefore, their filters can list just a data type and do not need to explicitly
+name the {@code content:} and {@code file:} schemes.
+This is a typical case. A <a
+href="{@docRoot}guide/topics/manifest/data-element.html">{@code &lt;data>}</a> element
+like the following, for example, tells Android that the component can get image data from a content
+provider and display it:
</p>
+<pre>
+&lt;intent-filter&gt;
+ &lt;data android:mimeType="image/*" /&gt;
+ ...
+&lt;/intent-filter&gt;</pre>
+
<p>
-Given these capabilities, the following intent will resolve to the
-TitleEditor activity:
+Because most available data is dispensed by content providers, filters that
+specify a data type but not a URI are perhaps the most common.
</p>
-<dl style="margin-left: 2em">
-<dt>action: <code>com.android.notepad.action.EDIT_TITLE</code>
-<br/>data: <code>content://com.google.provider.NotePad/notes/<var>ID</var></code></dt>
-<dd>Asks the activity to display the title associated with note <var>ID</var>, and
-allow the user to edit the title.</dd>
-</dl>
+<p>
+Another common configuration is filters with a scheme and a data type. For
+example, a <a
+href="{@docRoot}guide/topics/manifest/data-element.html">{@code &lt;data>}</a>
+element like the following tells Android that
+the component can retrieve video data from the network in order to perform the action:
+</p>
+<pre>
+&lt;intent-filter&gt;
+ &lt;data android:scheme="http" android:type="video/*" /&gt;
+ ...
+&lt;/intent-filter&gt;</pre>
+<h3 id="imatch">Intent matching</h3>
+<p>Intents are matched against intent filters not only to discover a target
+component to activate, but also to discover something about the set of
+components on the device. For example, the Home app populates the app launcher
+by finding all the activities with intent filters that specify the
+{@link android.content.Intent#ACTION_MAIN} action and
+{@link android.content.Intent#CATEGORY_LAUNCHER} category.</p>
-
+<p>Your application can use intent matching in a similar way.
+The {@link android.content.pm.PackageManager} has a set of {@code query...()}
+methods that return all components that can accept a particular intent, and
+a similar series of {@code resolve...()} methods that determine the best
+component to respond to an intent. For example,
+{@link android.content.pm.PackageManager#queryIntentActivities
+queryIntentActivities()} returns a list of all activities that can perform
+the intent passed as an argument, and {@link
+android.content.pm.PackageManager#queryIntentServices
+queryIntentServices()} returns a similar list of services.
+Neither method activates the components; they just list the ones that
+can respond. There's a similar method,
+{@link android.content.pm.PackageManager#queryBroadcastReceivers
+queryBroadcastReceivers()}, for broadcast receivers.
+</p>
diff --git a/docs/html/guide/components/services.jd b/docs/html/guide/components/services.jd
index 30da33a..da01d2c 100644
--- a/docs/html/guide/components/services.jd
+++ b/docs/html/guide/components/services.jd
@@ -212,41 +212,35 @@ element. For example:</p>
&lt;/manifest&gt;
</pre>
+<p>See the <a
+href="{@docRoot}guide/topics/manifest/service-element.html">{@code &lt;service&gt;}</a> element
+reference for more information about declaring your service in the manifest.</p>
+
<p>There are other attributes you can include in the <a
href="{@docRoot}guide/topics/manifest/service-element.html">{@code &lt;service&gt;}</a> element to
define properties such as permissions required to start the service and the process in
which the service should run. The <a
href="{@docRoot}guide/topics/manifest/service-element.html#nm">{@code android:name}</a>
attribute is the only required attribute&mdash;it specifies the class name of the service. Once
-you publish your application, you should not change this name, because if you do, you might break
-some functionality where explicit intents are used to reference your service (read the blog post, <a
+you publish your application, you should not change this name, because if you do, you risk breaking
+code due to dependence on explicit intents to start or bind the service (read the blog post, <a
href="http://android-developers.blogspot.com/2011/06/things-that-cannot-change.html">Things
That Cannot Change</a>).
-<p>See the <a
-href="{@docRoot}guide/topics/manifest/service-element.html">{@code &lt;service&gt;}</a> element
-reference for more information about declaring your service in the manifest.</p>
-
-<p>Just like an activity, a service can define intent filters that allow other components to
-invoke the service using implicit intents. By declaring intent filters, components
-from any application installed on the user's device can potentially start your service if your
-service declares an intent filter that matches the intent another application passes to {@link
-android.content.Context#startService startService()}.</p>
-
-<p>If you plan on using your service only locally (other applications do not use it), then you
-don't need to (and should not) supply any intent filters. Without any intent filters, you must
-start the service using an intent that explicitly names the service class. More information
-about <a href="#StartingAService">starting a service</a> is discussed below.</p>
+<p>To ensure your app is secure, <strong>always use an explicit intent when starting or binding
+your {@link android.app.Service}</strong> and do not declare intent filters for the service. If
+it's critical that you allow for some amount of ambiguity as to which service starts, you can
+supply intent filters for your services and exclude the component name from the {@link
+android.content.Intent}, but you then must set the package for the intent with {@link
+android.content.Intent#setPackage setPackage()}, which provides sufficient disambiguation for the
+target service.</p>
-<p>Additionally, you can ensure that your service is private to your application only if
-you include the <a
+<p>Additionally, you can ensure that your service is available to only your app by
+including the <a
href="{@docRoot}guide/topics/manifest/service-element.html#exported">{@code android:exported}</a>
-attribute and set it to {@code "false"}. This is effective even if your service supplies intent
-filters.</p>
+attribute and setting it to {@code "false"}. This effectively stops other apps from starting your
+service, even when using an explicit intent.</p>
-<p>For more information about creating intent filters for your service, see the <a
-href="{@docRoot}guide/components/intents-filters.html">Intents and Intent Filters</a>
-document.</p>
@@ -333,7 +327,7 @@ client. (Though, you also need to provide a small constructor for the service.)<
<pre>
public class HelloIntentService extends IntentService {
- /**
+ /**
* A constructor is required, and must call the super {@link android.app.IntentService#IntentService}
* constructor with a name for the worker thread.
*/
@@ -443,8 +437,8 @@ public class HelloService extends Service {
HandlerThread thread = new HandlerThread("ServiceStartArguments",
Process.THREAD_PRIORITY_BACKGROUND);
thread.start();
-
- // Get the HandlerThread's Looper and use it for our Handler
+
+ // Get the HandlerThread's Looper and use it for our Handler
mServiceLooper = thread.getLooper();
mServiceHandler = new ServiceHandler(mServiceLooper);
}
@@ -458,7 +452,7 @@ public class HelloService extends Service {
Message msg = mServiceHandler.obtainMessage();
msg.arg1 = startId;
mServiceHandler.sendMessage(msg);
-
+
// If we get killed, after returning from here, restart
return START_STICKY;
}
@@ -468,10 +462,10 @@ public class HelloService extends Service {
// We don't provide binding, so return null
return null;
}
-
+
&#64;Override
public void onDestroy() {
- Toast.makeText(this, "service done", Toast.LENGTH_SHORT).show();
+ Toast.makeText(this, "service done", Toast.LENGTH_SHORT).show();
}
}
</pre>
@@ -652,7 +646,7 @@ developer guides for more information.</p>
<h2 id="Foreground">Running a Service in the Foreground</h2>
<p>A foreground service is a service that's considered to be something the
-user is actively aware of and thus not a candidate for the system to kill when low on memory. A
+user is actively aware of and thus not a candidate for the system to kill when low on memory. A
foreground service must provide a notification for the status bar, which is placed under the
"Ongoing" heading, which means that the notification cannot be dismissed unless the service is
either stopped or removed from the foreground.</p>
diff --git a/docs/html/guide/guide_toc.cs b/docs/html/guide/guide_toc.cs
index 8f2795a..73d5b74 100644
--- a/docs/html/guide/guide_toc.cs
+++ b/docs/html/guide/guide_toc.cs
@@ -6,17 +6,41 @@
localized titles are added in the language order specified below.
?>
<ul id="nav">
- <!-- Walkthrough for Developers -- quick overview of what it's like to develop on Android -->
- <!--<li style="color:red">Overview</li> -->
<li class="nav-section">
- <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/components/index.html">
- <span class="en">App Components</span>
+ <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/index.html">
+ <span class="en">Introduction</span>
</a></div>
<ul>
<li><a href="<?cs var:toroot ?>guide/components/fundamentals.html">
<span class="en">App Fundamentals</span></a>
</li>
+ <li><a href="<?cs var:toroot ?>guide/practices/compatibility.html">
+ <span class="en">Device Compatibility</span>
+ </a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/security/permissions.html">
+ <span class="en">System Permissions</span>
+ </a>
+ </li>
+ </ul>
+ </li>
+
+
+ <li class="nav-section">
+ <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/components/index.html">
+ <span class="en">App Components</span>
+ </a></div>
+ <ul>
+ <li class="nav-section">
+ <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/components/intents-filters.html">
+ <span class="en">Intents and Intent Filters</span>
+ </a></div>
+ <ul>
+ <li><a href="<?cs var:toroot ?>guide/components/intents-common.html">
+ <span class="en">Common Intents</span>
+ </a></li>
+ </ul>
+ </li>
<li class="nav-section">
<div class="nav-section-header"><a href="<?cs var:toroot ?>guide/components/activities.html">
<span class="en">Activities</span>
@@ -68,17 +92,6 @@
</a></li>
</ul>
</li>
- <li><a href="<?cs var:toroot ?>guide/components/intents-filters.html">
- <span class="en">Intents and Intent Filters</span>
- </a></li>
- <li><a href="<?cs var:toroot ?>guide/components/processes-and-threads.html">
- <span class="en">Processes and Threads</span>
- </a>
- </li>
- <li><a href="<?cs var:toroot ?>guide/topics/security/permissions.html">
- <span class="en">Permissions</span>
- </a>
- </li>
<li class="nav-section">
<div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/appwidgets/index.html">
<span class="en">App Widgets</span>
@@ -89,42 +102,89 @@
</a></li>
</ul>
</li>
+ <li><a href="<?cs var:toroot ?>guide/components/processes-and-threads.html">
+ <span class="en">Processes and Threads</span>
+ </a>
+ </li>
+ </ul>
+ </li>
+
+
+ <li class="nav-section">
+ <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/resources/index.html">
+ <span class="en">App Resources</span>
+ </a></div>
+ <ul>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/overview.html">
+ <span class="en">Overview</span>
+ </a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/providing-resources.html">
+ <span class="en">Providing Resources</span>
+ </a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/accessing-resources.html">
+ <span class="en">Accessing Resources</span>
+ </a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/runtime-changes.html">
+ <span class="en">Handling Runtime Changes</span>
+ </a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/localization.html">
+ <span class="en">Localization</span>
+ </a></li>
<li class="nav-section">
- <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/manifest/manifest-intro.html">
- <span class="en">Android Manifest</span>
- </a></div>
+ <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/resources/available-resources.html">
+ <span class="en">Resource Types</span>
+ </a></div>
<ul>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/action-element.html">&lt;action&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/activity-alias-element.html">&lt;activity-alias&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/application-element.html">&lt;application&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/category-element.html">&lt;category&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/compatible-screens-element.html">&lt;compatible-screens&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/data-element.html">&lt;data&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/grant-uri-permission-element.html">&lt;grant-uri-permission&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/instrumentation-element.html">&lt;instrumentation&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/path-permission-element.html">&lt;path-permission&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-group-element.html">&lt;permission-group&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-tree-element.html">&lt;permission-tree&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/service-element.html">&lt;service&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/supports-gl-texture-element.html">&lt;supports-gl-texture&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></li><!-- ##api level 4## -->
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></li> <!-- ##api level 4## -->
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/animation-resource.html">Animation</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/color-list-resource.html">Color State List</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/drawable-resource.html">Drawable</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/layout-resource.html">Layout</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/menu-resource.html">Menu</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/string-resource.html">String</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/style-resource.html">Style</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/resources/more-resources.html">More Types</a></li>
</ul>
- </li><!-- end of the manifest file -->
+ </li><!-- end of resource types -->
+ </ul>
+ </li><!-- end of app resources -->
+
+
+ <li class="nav-section">
+ <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/manifest/manifest-intro.html">
+ <span class="en">App Manifest</span>
+ </a></div>
+ <ul>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/action-element.html">&lt;action&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/activity-alias-element.html">&lt;activity-alias&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/application-element.html">&lt;application&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/category-element.html">&lt;category&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/compatible-screens-element.html">&lt;compatible-screens&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/data-element.html">&lt;data&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/grant-uri-permission-element.html">&lt;grant-uri-permission&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/instrumentation-element.html">&lt;instrumentation&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/path-permission-element.html">&lt;path-permission&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-group-element.html">&lt;permission-group&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/permission-tree-element.html">&lt;permission-tree&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/service-element.html">&lt;service&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/supports-gl-texture-element.html">&lt;supports-gl-texture&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></li><!-- ##api level 4## -->
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></li> <!-- ##api level 4## -->
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></li>
+ <li><a href="<?cs var:toroot ?>guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a></li>
</ul>
- </li>
+ </li><!-- end of the manifest file -->
+
+
<li class="nav-section">
<div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/ui/index.html">
@@ -252,44 +312,6 @@
</ul>
</li><!-- end of User Interface -->
- <li class="nav-section">
- <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/resources/index.html">
- <span class="en">App Resources</span>
- </a></div>
- <ul>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/overview.html">
- <span class="en">Overview</span>
- </a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/providing-resources.html">
- <span class="en">Providing Resources</span>
- </a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/accessing-resources.html">
- <span class="en">Accessing Resources</span>
- </a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/runtime-changes.html">
- <span class="en">Handling Runtime Changes</span>
- </a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/localization.html">
- <span class="en">Localization</span>
- </a></li>
- <li class="nav-section">
- <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/resources/available-resources.html">
- <span class="en">Resource Types</span>
- </a></div>
- <ul>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/animation-resource.html">Animation</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/color-list-resource.html">Color State List</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/drawable-resource.html">Drawable</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/layout-resource.html">Layout</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/menu-resource.html">Menu</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/string-resource.html">String</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/style-resource.html">Style</a></li>
- <li><a href="<?cs var:toroot ?>guide/topics/resources/more-resources.html">More Types</a></li>
- </ul>
- </li><!-- end of resource types -->
- </ul>
- </li><!-- end of app resources -->
-
<li class="nav-section">
<div class="nav-section-header"><a href="<?cs var:toroot ?>guide/topics/graphics/index.html">
<span class="en">Animation and Graphics</span>
@@ -345,6 +367,9 @@
<li><a href="<?cs var:toroot ?>guide/topics/media/mediaplayer.html">
<span class="en">Media Playback</span></a>
</li>
+ <li><a href="<?cs var:toroot ?>guide/topics/media/mediarouter.html">
+ <span class="en">MediaRouter</span></a>
+ </li>
<li><a href="<?cs var:toroot ?>guide/appendix/media-formats.html">
<span class="en">Supported Media Formats</span></a>
</li>
@@ -520,9 +545,6 @@
<span class="zh-tw" style="display:none">最佳實務</span>
</div></a>
<ul>
- <li><a href="<?cs var:toroot ?>guide/practices/compatibility.html">
- <span class="en">Compatibility</span>
- </a></li>
<li class="nav-section">
<div class="nav-section-header"><a href="<?cs var:toroot ?>guide/practices/screens_support.html">
<span class="en">Supporting Multiple Screens</span>
@@ -543,74 +565,7 @@
</ul>
</li>
- <!-- this needs to move
- <li class="nav-section">
- <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/index.html">
- <span class="en">UI Guidelines</span>
- </a></div>
- <ul>
- <li class="nav-section">
- <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/icon_design.html">
- <span class="en">Icon Design</span>
- </a></div>
- <ul>
- <li><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/icon_design_launcher.html">
- <span class="en">Launcher Icons</span>
- </a></li>
- <li><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/icon_design_menu.html">
- <span class="en">Menu Icons</span>
- </a></li>
- <li><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/icon_design_action_bar.html">
- <span class="en">Action Bar Icons</span>
- </a></li>
- <li><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/icon_design_status_bar.html">
- <span class="en">Status Bar Icons</span>
- </a></li>
- <li><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/icon_design_tab.html">
- <span class="en">Tab Icons</span>
- </a></li>
- <li><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/icon_design_dialog.html">
- <span class="en">Dialog Icons</span>
- </a></li>
- <li><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/icon_design_list.html">
- <span class="en">List View Icons</span>
- </a></li>
- </ul>
- </li>
- <li><div><a href="<?cs var:toroot ?>guide/practices/ui_guidelines/widget_design.html">
- <span class="en">App Widget Design</span>
- </a></div>
- </li>
- </ul>
- </li>
- </ul> -->
-<!-- Remove
- <li class="nav-section">
- <div class="nav-section-header"><a href="<?cs var:toroot ?>guide/appendix/index.html">
- <span class="en">Appendix</span>
- <span class="de" style="display:none">Anhang</span>
- <span class="es" style="display:none">Apéndice</span>
- <span class="fr" style="display:none">Annexes</span>
- <span class="it" style="display:none">Appendice</span>
- <span class="ja" style="display:none">付録</span>
- <span class="zh-cn" style="display:none">附录</span>
- <span class="zh-tw" style="display:none">附錄</span>
- </a></div>
- <ul>
- <li><a href="<?cs var:toroot ?>guide/appendix/g-app-intents.html">
- <span class="en">Intents List: Google Apps</span>
- </a></li>
-
-
- <li><a href="<?cs var:toroot ?>guide/appendix/glossary.html">
- <span class="en">Glossary</span>
- </a></li>
- </ul>
- </li>
-
-</li>
--->
</ul>
diff --git a/docs/html/guide/index.jd b/docs/html/guide/index.jd
new file mode 100644
index 0000000..d78a1b1
--- /dev/null
+++ b/docs/html/guide/index.jd
@@ -0,0 +1,75 @@
+page.title=Introduction to Android
+
+@jd:body
+
+
+<div class="sidebox" style="width:220px"><!-- width to match col-4 below -->
+<p>To learn how apps work, start with
+<a href="{@docRoot}guide/components/fundamentals.html">App Fundamentals</a>.</p>
+<p>To begin coding right away, read <a
+href="{@docRoot}training/basics/firstapp/index.html">Building Your First App</a>.</p>
+</div>
+
+<p>Android provides a rich application framework that allows you to build innovative apps and games
+for mobile devices in a Java language environment. The documents listed in the left
+navigation provide details about how to build apps using Android's various APIs.</p>
+
+<p>If you're new to Android development, it's important that you understand
+the following fundamental concepts about the Android app framework:</p>
+
+
+<div class="landing-banner">
+
+<div class="col-6">
+
+<h4>Apps provide multiple entry points</h4>
+
+<p>Android apps are built as a combination of distinct components that can be invoked
+individually. For instance, an individual <em>activity</em> provides a single
+screen for a user interface, and a <em>service</em> independently performs
+work in the background.</p>
+
+<p>From one component you can start another component using an <em>intent</em>. You can even start
+a component in a different app, such an activity in a maps app to show an address. This model
+provides multiple entry points for a single app and allows any app to behave as a user's "default"
+for an action that other apps may invoke.</p>
+
+
+<p><b>Learn more:</b></p>
+<ul class="nolist">
+<li><a href="{@docRoot}guide/components/fundamentals.html">App Fundamentals</a>
+<li><a href="{@docRoot}guide/components/intents-filters.html">Intents and Intent Filters</a>
+<li><a href="{@docRoot}guide/components/activities.html">Activities</a>
+</ul>
+
+</div>
+
+
+<div class="col-6">
+
+<h4>Apps adapt to different devices</h4>
+
+<p>Android provides an adaptive app framework that allows you to provide unique resources
+for different device configurations. For example, you can create different XML
+layout files for different screen sizes and the system
+determines which layout to apply based on the current device's screen size.</p>
+
+<p>You can query the availability of device features at runtime if any app features require
+specific hardware such as a camera. If necessary, you can also declare features your app requires
+so app markets such as Google Play Store do not allow installation on devices that do not support
+that feature.</p>
+
+
+<p><b>Learn more:</b></p>
+<ul class="nolist">
+<li><a href="{@docRoot}guide/practices/compatibility.html">Device Compatibility</a>
+<li><a href="{@docRoot}guide/topics/resources/overview.html">Resources Overview</a>
+<li><a href="{@docRoot}guide/topics/ui/overview.html">User Interface Overview</a>
+</ul>
+
+</div>
+
+</div><!-- end landing-banner -->
+
+
+
diff --git a/docs/html/guide/practices/compatibility.jd b/docs/html/guide/practices/compatibility.jd
index 9e3d461..db1642e 100644
--- a/docs/html/guide/practices/compatibility.jd
+++ b/docs/html/guide/practices/compatibility.jd
@@ -1,248 +1,333 @@
-page.title=Android Compatibility
+page.title=Device Compatibility
excludeFromSuggestions=true
@jd:body
<div id="qv-wrapper">
<div id="qv">
+<h2>In this document</h2>
+<ol>
+ <li><a href="#defined">What Does "Compatibility" Mean?</a></li>
+ <li><a href="#how">Controlling Your App's Availability to Devices</a>
+ <ol>
+ <li><a href="#Features">Device features</a></li>
+ <li><a href="#Versions">Platform version</a></li>
+ <li><a href="#Screens">Screen configuration</a></li>
+ </ol>
+ </li>
+ <li><a href="#filtering">Controlling Your App's Availability for Business Reasons</a></li>
+</ol>
<h2>See also</h2>
<ol>
<li><a
href="{@docRoot}google/play/filters.html">Filtering on Google Play</a></li>
<li><a
-href="{@docRoot}guide/topics/resources/providing-resources.html#AlternativeResources">Providing Alternative Resources</a></li>
-<li><a
-href="{@docRoot}guide/practices/screens_support.html">Supporting Multiple Screens</a></li>
-<li style="margin-top:3px;"><code><a
-href="{@docRoot}guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></code></li>
-<li><code><a
-href="{@docRoot}guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></code></li>
-<li><code><a
-href="{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></code></li>
-<li><code><a
-href="{@docRoot}guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></code></li>
-<li><code><a
-href="{@docRoot}guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></code></li>
-<li><code><a
-href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</code></a></li>
+href="{@docRoot}guide/topics/resources/providing-resources.html">Providing Resources</a></li>
+<li><a href="http://source.android.com/compatibility/index.html" class="external-link">
+Android Compatibility</a></li>
</ol>
</div> </div>
-<p>Android is designed to run on many different types of devices. For
-developers, the range and number of devices means a huge potential audience: the
-more devices that run Android apps, the more users who can access your app. In
-exchange, however, it also means that your apps will have to cope with that same
-variety of hardware.</p>
+<p>Android is designed to run on many different types of devices, from phones
+to tablets and televisions. As a developer,
+the range of devices provides a huge potential audience for your app. In order for your app
+to be successful on all these devices, it should tolerate some feature variability
+and provide a flexible user interface that adapts to different screen
+configurations.</p>
+
+<p>To facilitate your effort toward that goal, Android provides a dynamic app framework in which
+you can provide configuration-specific <a href="{@docRoot}guide/topics/resources/overview.html"
+>app resources</a> in static files (such as different XML layouts
+for different screen sizes). Android then loads the appropriate resources based on
+the current device configuration. So with some forethought to your app design and some additional
+app resources, you can publish a single application package (APK) that provides an optimized user
+experience on a variety of devices.
-<p>Fortunately, Android has built-in tools and support that make it easy for
-your apps to do that, while at the same time letting you maintain control of
-what types of devices your app is available to. With a bit of forethought and
-some minor changes in your app's manifest file, you can ensure that users
-whose devices can’t run your app will never see it on Google Play, and
-will not get in trouble by downloading it. This page explains how you can
-control which devices have access to your apps, and how to prepare your apps to
-make sure they reach the right audience.</p>
+<p>If necessary, however, you can specify your app's feature requirements and control
+which types of devices can install your app from Google Play Store. This page explains how you can
+control which devices have access to your apps, and how to prepare your apps to make sure they
+reach the right audience. For more information about how you can make your app adapt
+to different devices, read <a href="{@docRoot}training/basics/supporting-devices/index.html"
+>Supporting Different Devices</a>.</p>
-<h3 id="defined">What does “compatibility” mean?</h3>
-<p>A device is “Android compatible” if it can correctly run apps written for the
+<h2 id="defined">What Does "Compatibility" Mean?</h2>
+
+<p>As you read more about Android development, you'll probably encounter the term "compatibility"
+in various situations. There are two types of compatibility: <em>device compatibility</em>
+and <em>app compatibility</em>.
+
+<p>Because Android is an open source project, any hardware manufacturer can build a device
+that runs the Android operating system. Yet, a <b>device is "Android compatible"</b> only if
+it can correctly run apps written for the
<em>Android execution environment</em>. The exact details of the Android execution
-environment</em> are defined by the Android Compatibility Definition Document,
-but the single most important characteristic of a compatible device is the
-ability to install and correctly run an Android <code>.apk</code> file.</p>
+environment are defined by the <a href="http://source.android.com/compatibility/overview.html"
+class="external-link">Android compatibility program</a> and each device must pass the Compatibility
+Test Suite (CTS) in order to be considered compatible.</p>
-<p>There is exactly one Android API for each <a
-href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">API level</a>, and it’s the same
-API no matter what kind of device it’s installed on. No parts of the API are
-optional, and you never have to worry about parts of the API missing on some
-devices. Every compatible Android device your app will land on will include
-every class and every API for that API level.</p>
+<p>As an app developer, you don't need to worry about whether a device is Android compatible, because
+only devices that are Android compatible include Google Play Store. So you can rest assured that
+users who install your app from Google Play Store are using an Android compatible device.</p>
-<p>Of course, some APIs won’t work correctly if a particular device lacks the
-corresponding hardware or feature. But that’s not a problem: we also designed
-Android to prevent apps from being visible to devices which don’t have features
-the apps require. We’ve built support for this right into the SDK tools, and
-it’s part of the Android platform itself, as well as part of Google Play.</p>
-<p>As a developer, you have complete control of how and where your apps are
-available. Android provides tools as a first-class part of the platform that let
-you manage this. You control the availability of your apps, so that they reach
-only the devices capable of running them.</p>
+<p>However, you do need to consider whether your <b>app is compatible</b> with each potential
+device configuration. Because Android runs on a wide range of device configurations, some features are not
+available on all devices. For example, some devices may not include a
+compass sensor. If your app's core functionality requires the use
+of a compass sensor, then your app is compatible only with devices that
+include a compass sensor.</p>
-<h3 id="how">How does it work?</h3>
-<p>You manage your app’s availability through a simple three-step process:</p>
-<ol>
-<li>You state the features your app requires by declaring <a
-href="{@docRoot}guide/topics/manifest/uses-feature-element.html"><code>&lt;uses-feature&gt;</code></a>
-elements its manifest file.</li>
-<li>Devices are required to declare the features they include to Google
-Play.</li>
-<li>Google Play uses your app’s stated requirements to filter it from devices
-that don’t meet those requirements.</li>
-</ol>
-<p>This way, users never even see apps that won’t work properly on their
-devices. As long as you accurately describe your app’s requirements, you don’t
-need to worry about users blaming you for compatibility problems.</p>
-
-<p>If you’re familiar with web development, you may recognize this model as
-“capability detection”. Web developers typically prefer this approach to
-“browser detection”, because it’s very difficult to keep up as new browsers and
-new versions of current browsers are released. By checking for support for
-specific required capabilities instead of the current browser, web developers
-get better fine-grained control. That’s the same approach Android uses: since
-it’s impossible to keep up with all the Android devices being released, you
-instead use the fine-grained controls Android provides.</p>
-
-<h3>Filtering for technical reasons</h3>
-
- <div class="sidebox-wrapper">
- <img id="rule" src="{@docRoot}assets/images/grad-rule-qv.png">
- <div id="qv-sub-rule">
- <img src="{@docRoot}assets/images/icon_play.png" style="float:left;margin:0;padding:0;">
- <p style="color:#669999;">Filtering on Google Play</p>
-
- <p>Google Play filters the applications that are visible to users, so
-that users can see and download only those applications that are compatible with
-their devices.</p>
-
- <p style="margin-top:1em;">One of the ways Google Play filters applications is by
-feature compatibility. To do this, Google Play checks the
-<code>&lt;uses-feature&gt;</code> elements in each application's manifest, to
-establish the app's feature needs. Google Play then shows or hides the application to
-each user, based on a comparison with the features available on the user's
-device.
-
-<p style="margin-top:1em;">For information about other filters that you can
-use to control the availability of your apps, see the
-<a href="{@docRoot}google/play/filters.html">Filters on Google Play</a>
-document.</p>
- </div>
-</div>
+<h2 id="how">Controlling Your App's Availability to Devices</h2>
+
+<p>Android supports a variety of features your app can leverage through platform APIs. Some
+features are hardware-based (such as a compass sensor), some are software-based (such as app
+widgets), and some are dependent on the platform version. Not every device supports every feature,
+so you may need to control your app's availability to devices based on your app's required
+features.</p>
-<p>Android includes support for a lot of features, some hardware and some
-software. Examples include compass and accelerometer sensors, cameras, and Live
-Wallpapers. However, not every device will support every feature. For instance,
-some devices don’t have the hardware horsepower to display Live Wallpapers
-well.</p>
-
-<p>To manage this, Android defines <em>feature IDs</em>. Every capability has a
-corresponding feature ID defined by the Android platform. For instance, the
-feature ID for compass is <code>“android.hardware.sensor.compass”</code>,
-while the feature
-ID for Live Wallpapers is <code>“android.software.live_wallpapers”</code>. Each of these IDs
-also has a corresponding Java-language constant on the
-{@link android.content.pm.PackageManager} class that you can use to query whether
-feature is supported at runtime. As Android adds support for new features in
-future versions, new feature IDs will be added as well.</p>
-
-<p>When you write your application, you specify which features your app requires
-by listing their feature IDs in <code>&lt;uses-feature&gt;</code> elements in
-the <code>AndroidManifest.xml</code> file. This is the information that Google
-Play uses to match your app to devices that can run it. For instance, if you
-state that your app requires android.software.live_wallpapers, it won’t be shown
-to devices that don’t support Live Wallpapers.</p>
-
-<p>This puts you in total control of your app &mdash; because you don’t have to
-declare these features. Consider an example involving cameras.</p>
-
-<p>If you’re building a really impressive next-generation augmented-reality app,
-your app won’t function at all without a camera. However, if you’re building a
-shopping app that only uses the camera for barcode scanning, users without
-cameras might still find it useful even if they can’t scan barcodes. While both
-apps need to acquire the permission to access the camera, only the first app
-needs to state that it requires a camera. (The shopping app can simply check at
-runtime and disable the camera-related features if there’s no camera
-present.)</p>
-
-<p>Since only you can say what the best approach is for your app, Android
-provides the tools and lets you make your own tradeoff between maximizing
-audience size and minimizing development costs.</p>
-
-
-<h3 id="filtering">Filtering for business reasons</h3>
-
-<p>It’s possible that you may need to restrict your app’s availability for
-business or legal reasons. For instance, an app that displays train schedules
-for the London Underground is unlikely to be useful to users outside the United
-Kingdom. Other apps might not be permitted in certain countries for business or
-legal reasons. For cases such as these, Google Play itself provides
-developers with filtering options that allow them control their app’s
-availability for non-technical reasons.</p>
-<p>The help information for Google Play provides full details, but in a
-nutshell, developers can use the Google Play publisher UI to:</p>
+<p>To achieve the largest user-base possible for your app, you should strive to support as many
+device configurations as possible using a single APK. In most situations, you can do so by
+disabling optional features at runtime and <a
+href="{@docRoot}guide/topics/resources/providing-resources.html">providing app resources</a>
+with alternatives for different configurations (such as different layouts for different
+screen sizes).
+If necessary, however, you can restrict your app's availability to devices through Google Play
+Store based on the following device characteristics:</p>
<ul>
-<li>List the countries an app is available in.</li>
-<li>Select which carrier’s users are able to access the app.</li>
+ <li><a href="#Features">Device features</a>
+ <li><a href="#Version">Platform version</a>
+ <li><a href="#Screens">Screen configuration</a>
</ul>
-<p>Filtering for technical compatibility (such as required hardware components)
-is always based on information contained within your <code>.apk</code> file. But
-filtering for non-technical reasons (such as geographic restrictions) is always
-handled in the Google Play user interface.</p>
-<h3 id="futureproofing">Future-proofing</h3>
+<h3 id="Features">Device features</h3>
+
+<p>In order for you to manage your app’s availability based on device features,
+Android defines <em>feature IDs</em> for any hardware or software feature
+that may not be available on all devices. For instance, the
+feature ID for the compass sensor is {@link
+android.content.pm.PackageManager#FEATURE_SENSOR_COMPASS} and the feature ID for app widgets
+is {@link android.content.pm.PackageManager#FEATURE_APP_WIDGETS}.</p>
+
+<p>If necessary, you can prevent users from installing your app when their devices don't provide a
+given feature by declaring it with a <a href=
+"{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a>
+element in your app's <a href="{@docRoot}guide/topics/manifest/manifest-intro.html">manifest
+file</a>.</p>
+
+<p>For example, if your app does not make sense on a device that lacks a compass sensor,
+you can declare the compass sensor as required with the following manifest tag:</p>
+
+<pre>
+&lt;manifest ... >
+ &lt;uses-feature android:name="android.hardware.sensor.compass"
+ android:required="true" />
+ ...
+&lt;/manifest>
+</pre>
+
+<p>Google Play Store compares the features your app requires to the features available on
+each user's device to determine whether your app is compatible with each device.
+If the device does not provide all the features your app requires, the user cannot install
+your app.</p>
+
+<p>However, if your app's primary functionality does not <em>require</em>
+a device feature, you should set the <a href=
+"{@docRoot}guide/topics/manifest/uses-feature-element.html#required">{@code required}</a>
+attribute to {@code "false"} and check
+for the device feature at runtime. If the app feature is not available on the current device,
+gracefully degrade the corresponding app feature. For example, you can query whether
+a feature is available by calling
+{@link android.content.pm.PackageManager#hasSystemFeature hasSystemFeature()} like this:</p>
+
+<pre>
+PackageManager pm = getPackageManager();
+if (!pm.hasSystemFeature(PackageManager.FEATURE_SENSOR_COMPASS)) {
+ // This device does not have a compass, turn off the compass feature
+ disableCompassFeature();
+}
+</pre>
+
+<p>For information about all the filters you can
+use to control the availability of your app to users through Google Play Store, see the
+<a href="{@docRoot}google/play/filters.html">Filters on Google Play</a>
+document.</p>
+
+<p class="note"><strong>Note:</strong> Some <a href=
+"{@docRoot}guide/topics/security/permissions.html">system permissions</a> implicitly require the
+availability of a device feature. For example, if your app requests permission to access to {@link
+android.Manifest.permission#BLUETOOTH}, this implicitly requires the {@link
+android.content.pm.PackageManager#FEATURE_BLUETOOTH} device feature. You can disable filtering based
+on this feature and make your app available to devices without Bluetooth by setting the <a href=
+"{@docRoot}guide/topics/manifest/uses-feature-element.html#required">{@code required}</a> attribute
+to {@code "false"} in the <a href=
+"{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a> tag.
+For more information about implicitly required device features, read <a href=
+"{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions">Permissions that Imply
+Feature Requirements</a>.</p>
+
+
+
+
+
+
+
+<h3 id="Versions">Platform version</h3>
+
+<p>Different devices may run different versions of the Android platform,
+such as Android 4.0 or Android 4.4. Each successive platform version often adds new APIs not
+available in the previous version. To indicate which set of APIs are available, each
+platform version specifies an <a
+href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#ApiLevels">API level</a>. For instance,
+Android 1.0 is API level 1 and Android 4.4 is API level 19.</p>
+
+<p>The API level allows you to declare the minimum version with which your app is
+compatible, using the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">{@code
+&lt;uses-sdk>}</a> manifest tag and its <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code minSdkVersion}</a> attribute.</p>
+
+<p>For example, the <a href="{@docRoot}guide/topics/providers/calendar-provider.html">Calendar
+Provider</a> APIs were added in Android 4.0 (API level 14). If your app cannot function without
+these APIs, you should declare API level 14 as your app's minimum supported
+version like this:</p>
-<p>There’s one additional quirk that we haven’t yet addressed: protecting apps
-from changes made to future versions of Android. If the Android platform
-introduces a new feature or changes how existing features are handled, what
-happens to existing apps that were written without any knowledge of the new
-behavior?</p>
+<pre>
+&lt;manifest ... >
+ &lt;uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
+ ...
+&lt;/manifest>
+</pre>
-<p>Simply put, Android commits to not making existing apps available to devices
-where they won’t work properly, even when the platform changes. The best way to
-explain this is through examples, so here are two:</p>
+<p>The <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
+minSdkVersion}</a> attribute declares the minimum version with which your app is compatible
+and the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
+targetSdkVersion}</a> attribute declares the highest version on which you've optimized
+your app.</p>
+
+<p>Each successive version of Android provides compatibility for apps that were built using
+the APIs from previous platform versions, so your app should always be compitible with future
+versions of Android while using the documented Android APIs.</p>
+
+<p class="note"><strong>Note:</strong>
+The <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
+targetSdkVersion}</a> attribute does not prevent your app from being installed on platform
+versions that are higher than the specified value,
+but it is important because it indicates to the system whether your
+app should inherit behavior changes in newer versions. If you don't update the
+<a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#target">{@code
+targetSdkVersion}</a> to the latest version, the system assumes that your
+app requires some backward-compatibility behaviors when running on the latest version.
+For example, among the <a href="{@docRoot}about/versions/android-4.4.html#Behaviors"
+>behavior changes in Android 4.4</a>, alarms created with the {@link android.app.AlarmManager} APIs
+are now inexact by default so the system can batch app alarms and preserve system power,
+but the system will retain the previous API behavior for your app if your target API level
+is lower than "19".</p>
+
+<p>However, if your app uses APIs added in a more recent
+platform version, but does not require them for its primary functionality,
+you should check the API level at runtime and gracefully degrade
+the corresponding features when the API level is too low. In this case,
+set the <a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html#min">{@code
+minSdkVersion}</a> to the lowest value possible for your app's primary functionality,
+then compare the current system's version, {@link android.os.Build.VERSION#SDK_INT}, to one the
+codename constants in {@link android.os.Build.VERSION_CODES} that corresponds to the
+API level you want to check. For example:</p>
+
+<pre>
+if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
+ // Running on something older than API level 11, so disable
+ // the drag/drop features that use {@link android.content.ClipboardManager} APIs
+ disableDragAndDrop();
+}
+</pre>
+
+
+
+
+
+
+<h3 id="Screens">Screen configuration</h3>
+
+<p>Android runs on devices of various sizes, from phones to tablets and TVs.
+In order to categorize devices by their screen type, Android defines two characteristics for
+each device: screen size (the physical size of the screen) and screen density (the physical
+density of the pixels on the screen, known as <acronym title="dots per inch">DPI</acronym>).
+To simplify the different configurations, Android generalizes these variants into groups that make
+them easier to target:</p>
<ul>
-<li>Android 1.0 through 1.5 required a 2 megapixel camera with auto-focus.
-However, with version 1.6, Android devices were permitted to omit the auto-focus
-capability, though a (fixed-focus) camera was still required. Some apps such as
-barcode scanners do not function as well with cameras that do not auto-focus. To
-prevent users from having a bad experience with those apps, existing apps that
-obtain permission to use the Camera were assumed by default to require
-auto-focus. This allowed Google Play to filter those apps from devices that
-lack auto-focus.</li>
-
-<li>Android 2.2, meanwhile, allowed the microphone to be optional on some
-devices, such as set-top boxes. Android 2.2 included a new feature ID for the
-microphone which allows developers to filter their apps if necessary, but
-&mdash; as with camera &mdash; apps that obtain permission to record audio are
-assumed to require the microphone feature by default. If your app can use a
-microphone but doesn’t strictly need it, you can explicitly state that you don’t
-require it; but unless you do that, your app won’t be shown to devices without
-microphones.</li>
+ <li>Four generalized sizes: small, normal, large, and xlarge.</li>
+ <li>And several generalized densities: mdpi (medium), hdpi (hdpi), xhdpi (extra high),
+ xxhdpi (extra-extra high), and others.</li>
</ul>
-<p>In other words, whenever Android introduces new features or changes existing
-ones, we will always take steps to protect existing applications so that they
-don’t end up being available to devices where they won’t work.</p>
+<p>By default, your app is compatible with all screen sizes and densities,
+because the system makes the appropriate adjustments to your UI layout and image
+resources as necessary for each screen. However, you should optimize the user experience for each
+screen configuration by adding specialized layouts for different screen sizes and
+optimized bitmap images for common screen densities.</p>
+
+<p>For information about how to create alternative resources for different screens
+and how to restrict your app to certain screen sizes when necessary, read <a
+href="{@docRoot}training/basics/supporting-devices/screens.html">Supporting Different Screens</a>.
+</p>
+
+
-<p>This is implemented, in part, using the <code>aapt</code> tool in the SDK.
-To see which features your app explicitly requires or is implicitly assumed to
-require, you can use the command <code>aapt dump badging</code>.</p>
-<h3 id="conclusion">Conclusion</h3>
-<p>The goal of Android is to create a huge installed base for developers to take
-advantage of. One of the ways we will achieve this is through different kinds of
-hardware running the same software environment. But we also recognize that only
-developers know which kinds of devices their apps make sense on. We’ve built in
-tools to the SDK and set up policies and requirements to ensure that developers
-remain in control of their apps, today and in the future. With the information
-you just read, and the resources listed in the sidebar of this document, you
-can publish your app with the confidence that only users who can run it will
-see it.</p>
-<p>For more information about Android device compatibility, please visit:</p>
-<p style="margin-left:2em;"><a href="http://source.android.com/compatibility/index.html">http://source.android.com/compatibility/index.html</a></p>
+<h2 id="filtering">Controlling Your App's Availability for Business Reasons</h2>
- \ No newline at end of file
+<p>In addition to restricting your app's availability based on device characteristics,
+it’s possible you may need to restrict your app’s availability for
+business or legal reasons. For instance, an app that displays train schedules
+for the London Underground is unlikely to be useful to users outside the United
+Kingdom. For this type of situation, Google Play Store provides
+filtering options in the developer console that allow you to control your app’s
+availability for non-technical reasons such as the user's locale or wireless carrier.</p>
+
+<p>Filtering for technical compatibility (such as required hardware components)
+is always based on information contained within your APK file. But
+filtering for non-technical reasons (such as geographic locale) is always
+handled in the Google Play developer console.</p>
+
+
+
+
+
+
+<div class="next-docs">
+<div class="col-6">
+ <h2 class="norule">Continue reading about:</h2>
+ <dl>
+ <dt><a
+href="{@docRoot}guide/topics/resources/providing-resources.html">Providing Resources</a></dt>
+ <dd>Information about how Android apps are structured to separate app resources from the
+ app code, including how you can provide alternative resources for specific device
+ configurations.
+ </dd>
+ <dt><a href="{@docRoot}google/play/filters.html">Filters on Google Play</a></dt>
+ <dd>Information about the different ways that Google Play Store can prevent your app
+ from being installed on different devices.</dd>
+ </dl>
+</div>
+<div class="col-6">
+ <h2 class="norule">You might also be interested in:</h2>
+ <dl>
+ <dt><a href="{@docRoot}guide/topics/security/permissions.html"
+ >System Permissions</a></dt>
+ <dd>How Android restricts app access to certain APIs with a permission system that requires
+ the user's consent for your app to use those APIs.</dd>
+ </dl>
+</div>
+</div>
diff --git a/docs/html/guide/practices/screens_support.jd b/docs/html/guide/practices/screens_support.jd
index ca29589..8c76411 100644
--- a/docs/html/guide/practices/screens_support.jd
+++ b/docs/html/guide/practices/screens_support.jd
@@ -25,8 +25,7 @@ page.title=Supporting Multiple Screens
<li><a href="#qualifiers">Using configuration qualifiers</a></li>
<li><a href="#DesigningResources">Designing alternative layouts and drawables</a></li>
</ol></li>
- <li><a href="#DeclaringTabletLayouts">Declaring Tablet Layouts for Android 3.2</a> <span
-class="new">new!</span>
+ <li><a href="#DeclaringTabletLayouts">Declaring Tablet Layouts for Android 3.2</a>
<ol>
<li><a href="#NewQualifiers">Using new size qualifiers</a></li>
<li><a href="#ConfigurationExamples">Configuration examples</a></li>
diff --git a/docs/html/guide/topics/connectivity/bluetooth-le.jd b/docs/html/guide/topics/connectivity/bluetooth-le.jd
index 21950c2..449c892 100644
--- a/docs/html/guide/topics/connectivity/bluetooth-le.jd
+++ b/docs/html/guide/topics/connectivity/bluetooth-le.jd
@@ -44,6 +44,15 @@ page.tags="wireless","bluetoothadapter","bluetoothdevice","BLE","BTLE"
</div>
</div>
+<a class="notice-developers-video" href="http://www.youtube.com/watch?v=vUbFB1Qypg8">
+<div>
+ <h3>Video</h3>
+ <p>DevBytes: Bluetooth Low Energy API</p>
+</div>
+</a>
+
+
+
<p>
Android 4.3 (API Level 18) introduces built-in platform support for Bluetooth Low
diff --git a/docs/html/guide/topics/connectivity/nfc/hce.jd b/docs/html/guide/topics/connectivity/nfc/hce.jd
index 4ef6859..d6efaa7 100644
--- a/docs/html/guide/topics/connectivity/nfc/hce.jd
+++ b/docs/html/guide/topics/connectivity/nfc/hce.jd
@@ -33,13 +33,13 @@ page.tags="host card emulation", "hce","HostApduService","OffHostApduService","t
-<p>Many Android-powered devices that offer NFC functionality already support NFC card
-emulation. In most cases, the card is emulated by a separate
-chip in the device, called a <em>secure element</em>. Many SIM cards provided by
+<p>Many Android-powered devices that offer NFC functionality already support NFC card
+emulation. In most cases, the card is emulated by a separate
+chip in the device, called a <em>secure element</em>. Many SIM cards provided by
wireless carriers also contain a secure element.</p>
-<p>Android 4.4 introduces an additional method of card emulation that does not
-involve a secure element, called <em>host-based card emulation</em>. This allows any
+<p>Android 4.4 introduces an additional method of card emulation that does not
+involve a secure element, called <em>host-based card emulation</em>. This allows any
Android application to emulate a card and talk directly to the NFC reader. This
document describes how host-based card emulation (HCE) works on Android and how you
can develop an app that emulates an NFC card using this technique.</p>
@@ -48,23 +48,23 @@ can develop an app that emulates an NFC card using this technique.</p>
<h2 id="SecureElement">Card Emulation with a Secure Element</h2>
<p>When NFC card emulation is provided using a secure element, the card to be emulated
-is provisioned into the secure element on
-the device through an Android application. Then, when the user holds the
-device over an NFC terminal, the NFC controller in the device routes all data
+is provisioned into the secure element on
+the device through an Android application. Then, when the user holds the
+device over an NFC terminal, the NFC controller in the device routes all data
from the reader directly to the secure element. Figure 1 illustrates this concept.</p>
<img src="{@docRoot}images/nfc/secure-element.png" />
<p class="img-caption"><strong>Figure 1.</strong> NFC card emulation with a secure element.</p>
-<p>The secure element itself performs the communication with the NFC terminal,
-and no Android application is involved in the transaction at all. After the
-transaction is complete, an Android application can query the secure element
+<p>The secure element itself performs the communication with the NFC terminal,
+and no Android application is involved in the transaction at all. After the
+transaction is complete, an Android application can query the secure element
directly for the transaction status and notify the user.</p>
<h2 id="HCE">Host-based Card Emulation</h2>
-<p>When an NFC card is emulated using host-based card emulation, the data is routed to
+<p>When an NFC card is emulated using host-based card emulation, the data is routed to
the host CPU on which Android applications are running directly, instead of routing the NFC
protocol frames to a secure element. Figure 2 illustrates how host-based card emulation
works.</p>
@@ -80,23 +80,23 @@ works.</p>
<p class="img-caption"><strong>Figure 3.</strong> Android's HCE protocol stack.</p>
</div>
-<p>The NFC standards offer support for many different protocols, and there are
+<p>The NFC standards offer support for many different protocols, and there are
different types of cards that can be emulated.</p>
-<p>Android 4.4 supports several protocols that are common in the
-market today. Many existing contactless cards are already based on these
-protocols, such as contactless payment cards. These protocols are also
-supported by many NFC readers in the market today, including Android NFC
+<p>Android 4.4 supports several protocols that are common in the
+market today. Many existing contactless cards are already based on these
+protocols, such as contactless payment cards. These protocols are also
+supported by many NFC readers in the market today, including Android NFC
devices functioning as readers themselves (see the {@link android.nfc.tech.IsoDep} class).
-This allows you to build and deploy an end-to-end NFC solution
+This allows you to build and deploy an end-to-end NFC solution
around HCE using only Android-powered devices.</p>
-<p>Specifically, Android 4.4 supports emulating cards that are based on the
-NFC-Forum ISO-DEP specification (based on ISO/IEC 14443-4) and process
-Application Protocol Data Units (APDUs) as defined in the ISO/IEC 7816-4
-specification. Android mandates emulating ISO-DEP only on top of the
-Nfc-A (ISO/IEC 14443-3 Type A) technology. Support for Nfc-B (ISO/IEC 14443-4
-Type B) technology is optional. The layering of all these specifications is
+<p>Specifically, Android 4.4 supports emulating cards that are based on the
+NFC-Forum ISO-DEP specification (based on ISO/IEC 14443-4) and process
+Application Protocol Data Units (APDUs) as defined in the ISO/IEC 7816-4
+specification. Android mandates emulating ISO-DEP only on top of the
+Nfc-A (ISO/IEC 14443-3 Type A) technology. Support for Nfc-B (ISO/IEC 14443-4
+Type B) technology is optional. The layering of all these specifications is
shown in the figure 3.</p>
@@ -105,12 +105,12 @@ shown in the figure 3.</p>
<p>The HCE architecture in Android is based around Android {@link android.app.Service} components
(known as "HCE services").
-One of the key advantages of a service is that it can run in the background without
-any user interface. This is a natural fit for many HCE applications like loyalty or transit cards,
-with which the user shouldn't need to launch the app to use it.
-Instead, tapping the device against the NFC reader starts the correct service (if not already
-running) and executes the transaction in the background. Of course, you are free
-to launch additional UI (such as user notifications) from your service if that makes
+One of the key advantages of a service is that it can run in the background without
+any user interface. This is a natural fit for many HCE applications like loyalty or transit cards,
+with which the user shouldn't need to launch the app to use it.
+Instead, tapping the device against the NFC reader starts the correct service (if not already
+running) and executes the transaction in the background. Of course, you are free
+to launch additional UI (such as user notifications) from your service if that makes
sense.</p>
@@ -118,72 +118,78 @@ sense.</p>
<h3 id="ServiceSelection">Service selection</h3>
<p>When the user taps a device to an NFC reader, the Android system needs to
- know which HCE service the NFC reader actually wants to talk to.
-This is where the ISO/IEC 7816-4 specification comes in: it defines a way to
-select applications, centered around an Application ID (AID). An AID
-consists of up to 16 bytes. If you are emulating cards for an existing NFC reader
-infrastructure, the AIDs that those readers are looking for are typically
-well-known and publicly registered (for example, the AIDs of payment networks
+know which HCE service the NFC reader actually wants to talk to.
+This is where the ISO/IEC 7816-4 specification comes in: it defines a way to
+select applications, centered around an Application ID (AID). An AID
+consists of up to 16 bytes. If you are emulating cards for an existing NFC reader
+infrastructure, the AIDs that those readers are looking for are typically
+well-known and publicly registered (for example, the AIDs of payment networks
such as Visa and MasterCard).</p>
-<p>If you want to deploy new reader infrastructure for your own application, you
-will need to register your own AID(s). The registration procedure for AIDs is
-defined in the ISO/IEC 7816-5 specification. Google recommends registering an
-AID as per 7816-5 if you are deploying a HCE application for Android, as it will avoid
+<p>If you want to deploy new reader infrastructure for your own application, you
+will need to register your own AID(s). The registration procedure for AIDs is
+defined in the ISO/IEC 7816-5 specification. Google recommends registering an
+AID as per 7816-5 if you are deploying a HCE application for Android, as it will avoid
collisions with other applications.</p>
<h3 id="AidGroups">AID groups</h3>
-<p>In some cases, an HCE service may need to register multiple AIDs to implement a
-certain application, and it needs to be sure that it is the default handler for
-all of these AIDs (as opposed to some AIDs in the group going to another
+<p>In some cases, an HCE service may need to register multiple AIDs to implement a
+certain application, and it needs to be sure that it is the default handler for
+all of these AIDs (as opposed to some AIDs in the group going to another
service).</p>
-<p>An AID group is a list of AIDs that should be considered as belonging together
-by the OS. For all AIDs in an AID group, Android guarantees one of the
+<p>An AID group is a list of AIDs that should be considered as belonging together
+by the OS. For all AIDs in an AID group, Android guarantees one of the
following:</p>
<ul>
<li>All AIDs in the group are routed to this HCE service</li>
-<li>No AIDs in the group are routed to this HCE service (for example, because the user
-preferred another service which requested one or more AIDs in your group as
+<li>No AIDs in the group are routed to this HCE service (for example, because the user
+preferred another service which requested one or more AIDs in your group as
well)</li>
</ul>
-<p>In other words, there is no in-between state, where some AIDs in the group can
+<p>In other words, there is no in-between state, where some AIDs in the group can
be routed to one HCE service, and some to another.</p>
<h3 id="GroupsCategories">AID groups and categories</h3>
-<p>Each AID group can be associated with a category. This allows Android to group
-HCE services together by category, and that in turn allows the user to set
-defaults at the category level instead of the AID level. In general, avoid
-mentioning AIDs in any user-facing parts of your application: they do not mean
+<p>Each AID group can be associated with a category. This allows Android to group
+HCE services together by category, and that in turn allows the user to set
+defaults at the category level instead of the AID level. In general, avoid
+mentioning AIDs in any user-facing parts of your application: they do not mean
anything to the average user.</p>
<p>Android 4.4 supports two categories: {@link
- android.nfc.cardemulation.CardEmulation#CATEGORY_PAYMENT} (covering payment
+android.nfc.cardemulation.CardEmulation#CATEGORY_PAYMENT} (covering industry-standard payment
apps) and {@link android.nfc.cardemulation.CardEmulation#CATEGORY_OTHER}
(for all other HCE apps).</p>
-
+<div class="note">
+ <p><strong>Note:</strong>
+ Only one AID group in the {@link
+ android.nfc.cardemulation.CardEmulation#CATEGORY_PAYMENT} category may be enabled in the system at any given time. Typically, this will be an app that understands major credit card payment protcols and which can work at any merchant.</p>
+ <p>For <em>closed-loop</em> payment apps that only work at one merchant (such as stored-value cards), you should use {@link
+ android.nfc.cardemulation.CardEmulation#CATEGORY_OTHER}. AID groups in this category can be always active, and can be given priority by NFC readers during AID selection if necessary.</p>
+</div>
<h2 id="ImplementingService">Implementing an HCE Service</h2>
<p>To emulate an NFC card using host-based card emulation, you need to create
- a {@link android.app.Service} component that handles the NFC transactions.
+ a {@link android.app.Service} component that handles the NFC transactions.
<h3 id="CheckingforSupport">Checking for HCE support</h3>
-<p>Your application can check whether a device supports HCE by checking for the
-{@link android.content.pm.PackageManager#FEATURE_NFC_HOST_CARD_EMULATION} feature. You should use the
-<a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature>}</a> tag in the manifest of your application to declare that your app
+<p>Your application can check whether a device supports HCE by checking for the
+{@link android.content.pm.PackageManager#FEATURE_NFC_HOST_CARD_EMULATION} feature. You should use the
+<a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">{@code &lt;uses-feature&gt;}</a> tag in the manifest of your application to declare that your app
uses the HCE feature, and whether it is required for the app to function or not.</p>
<h3 id="ServiceImplementation">Service implementation</h3>
-<p>Android 4.4 comes with a convenience {@link android.app.Service} class that can be used as a
+<p>Android 4.4 comes with a convenience {@link android.app.Service} class that can be used as a
basis for implementing a HCE service: the {@link android.nfc.cardemulation.HostApduService} class.</p>
<p>The first step is therefore to extend {@link android.nfc.cardemulation.HostApduService}.</p>
@@ -197,7 +203,7 @@ public class MyHostApduService extends HostApduService {
&#64;Override
public void onDeactivated(int reason) {
...
- }
+ }
}
</pre>
@@ -205,238 +211,237 @@ public class MyHostApduService extends HostApduService {
declares two abstract methods that need to be overridden and implemented.</p>
<p>{@link android.nfc.cardemulation.HostApduService#processCommandApdu processCommandApdu()}
- is called whenever a NFC reader sends an Application
-Protocol Data Unit (APDU) to your service. APDUs are defined in the ISO/IEC
-7816-4 specification as well. APDUs are the application-level packets being
-exchanged between the NFC reader and your HCE service. That application-level
-protocol is half-duplex: the NFC reader will send you a command APDU, and it
+is called whenever a NFC reader sends an Application
+Protocol Data Unit (APDU) to your service. APDUs are defined in the ISO/IEC
+7816-4 specification as well. APDUs are the application-level packets being
+exchanged between the NFC reader and your HCE service. That application-level
+protocol is half-duplex: the NFC reader will send you a command APDU, and it
will wait for you to send a response APDU in return.</p>
<p class="note"><strong>Note:</strong>
- The ISO/IEC 7816-4 specification also defines the concept of multiple logical channels,
- where you can have multiple parallel APDU exchanges on separate logical channels. Android’s
- HCE implementation however only supports a single logical channel, so there’s only a
- single-threaded exchange of APDUs.</p>
-
-
-<p>As mentioned previously, Android uses the AID to determine which HCE service the
-reader wants to talk to. Typically, the first APDU an NFC reader sends to your
-device is a "SELECT AID" APDU; this APDU contains the AID that the reader wants
-to talk to. Android extracts that AID from the APDU, resolves it to an HCE service,
+ The ISO/IEC 7816-4 specification also defines the concept of multiple logical channels,
+ where you can have multiple parallel APDU exchanges on separate logical channels. Android’s
+ HCE implementation however only supports a single logical channel, so there’s only a
+ single-threaded exchange of APDUs.</p>
+
+
+<p>As mentioned previously, Android uses the AID to determine which HCE service the
+reader wants to talk to. Typically, the first APDU an NFC reader sends to your
+device is a "SELECT AID" APDU; this APDU contains the AID that the reader wants
+to talk to. Android extracts that AID from the APDU, resolves it to an HCE service,
then forwards that APDU to the resolved service.</p>
-<p>You can send a response APDU by returning the bytes of the response APDU from
+<p>You can send a response APDU by returning the bytes of the response APDU from
{@link android.nfc.cardemulation.HostApduService#processCommandApdu processCommandApdu()}.
- Note that this method will be called on the main thread of
-your application, which shouldn't be blocked. So if you can't compute and return
-a response APDU immediately, return null. You can then do the necessary work on
-another thread, and use the {@link android.nfc.cardemulation.HostApduService#sendResponseApdu
- sendResponseApdu()} method defined
+ Note that this method will be called on the main thread of
+your application, which shouldn't be blocked. So if you can't compute and return
+a response APDU immediately, return null. You can then do the necessary work on
+another thread, and use the {@link android.nfc.cardemulation.HostApduService#sendResponseApdu sendResponseApdu()} method defined
in the {@link android.nfc.cardemulation.HostApduService} class to send the response when you are done.</p>
-<p>Android will keep forwarding new APDUs from the reader to your service, until
+<p>Android will keep forwarding new APDUs from the reader to your service, until
either:</p>
<ol>
-<li>The NFC reader sends another "SELECT AID" APDU, which the OS resolves to a
+<li>The NFC reader sends another "SELECT AID" APDU, which the OS resolves to a
different service;</li>
<li>The NFC link between the NFC reader and your device is broken.</li>
</ol>
<p>In both of these cases, your class's
- {@link android.nfc.cardemulation.HostApduService#onDeactivated onDeactivated()}
- implementation is
+{@link android.nfc.cardemulation.HostApduService#onDeactivated onDeactivated()}
+implementation is
called with an argument indicating which of the two happened.</p>
-<p>If you are working with existing reader infrastructure, you need to
-implement the existing application-level protocol that the readers expect in
+<p>If you are working with existing reader infrastructure, you need to
+implement the existing application-level protocol that the readers expect in
your HCE service.</p>
-<p>If you are deploying new reader infrastructure which you control as well, you
-can define your own protocol and APDU sequence. In general try to limit the
-amount of APDUs and the size of the data that needs to be exchanged: this makes
-sure that your users will only have to hold their device over the NFC reader for
-a short amount of time. A sane upper bound is about 1KB of data, which can
+<p>If you are deploying new reader infrastructure which you control as well, you
+can define your own protocol and APDU sequence. In general try to limit the
+amount of APDUs and the size of the data that needs to be exchanged: this makes
+sure that your users will only have to hold their device over the NFC reader for
+a short amount of time. A sane upper bound is about 1KB of data, which can
usually be exchanged within 300ms.</p>
<h3 id="ManifestDeclaration">Service manifest declaration and AID registration</h3>
-<p>Your service must be declared in the manifest as usual, but some additional
+<p>Your service must be declared in the manifest as usual, but some additional
pieces must be added to the service declaration as well.</p>
-<p>First, to tell the platform that it is a HCE service implementing a
-{@link android.nfc.cardemulation.HostApduService} interface, your service declaration must contain an
+<p>First, to tell the platform that it is a HCE service implementing a
+{@link android.nfc.cardemulation.HostApduService} interface, your service declaration must contain an
intent filter for the {@link android.nfc.cardemulation.HostApduService#SERVICE_INTERFACE} action.</p>
-<p>Additionally, to tell the platform which AIDs groups are requested by this
-service, a {@link android.nfc.cardemulation.HostApduService#SERVICE_META_DATA}
-<code>&lt;meta-data></code> tag must be included in
-the declaration of the service, pointing to an XML resource with additional
+<p>Additionally, to tell the platform which AIDs groups are requested by this
+service, a {@link android.nfc.cardemulation.HostApduService#SERVICE_META_DATA}
+<code>&lt;meta-data&gt;</code> tag must be included in
+the declaration of the service, pointing to an XML resource with additional
information about the HCE service.</p>
-<p>Finally, you must set the {@code android:exported} attribute to true, and require the
-{@code "android.permission.BIND_NFC_SERVICE"} permission in your service declaration.
-The former ensures that the service can be bound to by external applications.
-The latter then enforces that only external applications that hold the
-{@code ""android.permission.BIND_NFC_SERVICE"} permission can bind to your service. Since
-{@code ""android.permission.BIND_NFC_SERVICE"} is a system permission, this effectively
+<p>Finally, you must set the {@code android:exported} attribute to true, and require the
+{@code "android.permission.BIND_NFC_SERVICE"} permission in your service declaration.
+The former ensures that the service can be bound to by external applications.
+The latter then enforces that only external applications that hold the
+{@code "android.permission.BIND_NFC_SERVICE"} permission can bind to your service. Since
+{@code "android.permission.BIND_NFC_SERVICE"} is a system permission, this effectively
enforces that only the Android OS can bind to your service. </p>
<p>Here's an example of a {@link android.nfc.cardemulation.HostApduService} manifest declaration:</p>
<pre>
&lt;service android:name=".MyHostApduService" android:exported="true"
- android:permission="android.permission.BIND_NFC_SERVICE">
- &lt;intent-filter>
- &lt;action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE"/>
- &lt;/intent-filter>
+ android:permission="android.permission.BIND_NFC_SERVICE"&gt;
+ &lt;intent-filter&gt;
+ &lt;action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE"/&gt;
+ &lt;/intent-filter&gt;
&lt;meta-data android:name="android.nfc.cardemulation.host_apdu_service"
- android:resource="@xml/apduservice"/>
-&lt;/service>
+ android:resource="@xml/apduservice"/&gt;
+&lt;/service&gt;
</pre>
-<p>This meta-data tag points to an {@code apduservice.xml} file. An example of such a file
-with a single AID group declaration containing two proprietary AIDs is shown
+<p>This meta-data tag points to an {@code apduservice.xml} file. An example of such a file
+with a single AID group declaration containing two proprietary AIDs is shown
below:</p>
<pre>
&lt;host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
- android:description="@string/servicedesc"
- android:requireDeviceUnlock="false">
- &lt;aid-group android:description="@string/aiddescription"
- android:category="other">
- &lt;aid-filter android:name="F0010203040506"/>
- &lt;aid-filter android:name="F0394148148100"/>
- &lt;/aid-group>
-&lt;/host-apdu-service>
+ android:description="@string/servicedesc"
+ android:requireDeviceUnlock="false"&gt;
+ &lt;aid-group android:description="@string/aiddescription"
+ android:category="other"&gt;
+ &lt;aid-filter android:name="F0010203040506"/&gt;
+ &lt;aid-filter android:name="F0394148148100"/&gt;
+ &lt;/aid-group&gt;
+&lt;/host-apdu-service&gt;
</pre>
-<p>The <code>&lt;host-apdu-service></code> tag is required to contain a <code>&lt;android:description></code>
-attribute that contains a user-friendly description of the service that may be
-shown in UI. The <code>&lt;requireDeviceUnlock></code> attribute can be used to specify that the
+<p>The <code>&lt;host-apdu-service&gt;</code> tag is required to contain a <code>&lt;android:description&gt;</code>
+attribute that contains a user-friendly description of the service that may be
+shown in UI. The <code>requireDeviceUnlock</code> attribute can be used to specify that the
device must be unlocked before this service can be invoked to handle APDUs.</p>
-<p>The <code>&lt;host-apdu-service></code> must contain one or more <code>&lt;aid-group></code> tags. Each
-<code>&lt;aid-group></code> tag is required to contain a <code>android:description</code> attribute that
-contains a user-friendly description of the AID group that may be shown in UI.
-Each <code>&lt;aid-group></code> tag must also have the android:category attribute set to
-indicate the category the AID group belongs to, e.g. the string constants
-defined by CardEmulation.CATEGORY_PAYMENT or CardEmulation.CATEGORY_OTHER. Each
-<code>&lt;aid-group></code> must contain one or more <code>&lt;aid-filter></code> tags, each of which contains a
-single AID. The AID must be specified in hexadecimal format, and contain an even
-number of characters.</p>
-
-<p>As a final note, your application also needs to hold the NFC permission,
- {@link android.Manifest.permission#NFC} to be able to register as a HCE service.</p>
-
+<p>The <code>&lt;host-apdu-service&gt;</code> must contain one or more <code>&lt;aid-group&gt;</code> tags. Each
+<code>&lt;aid-group&gt;</code> tag is required to:</p>
+<ul>
+<li>Contain an <code>android:description</code> attribute that
+contains a user-friendly description of the AID group, suitable for display in UI.</li>
+<li>Have its <code>android:category</code> attribute set to
+indicate the category the AID group belongs to, e.g. the string constants
+defined by {@link android.nfc.cardemulation.CardEmulation#CATEGORY_PAYMENT}
+or {@link android.nfc.cardemulation.CardEmulation#CATEGORY_OTHER}.</li>
+<li>Each <code>&lt;aid-group&gt;</code> must contain one or more
+<code>&lt;aid-filter&gt;</code> tags, each of which contains a single AID. The AID
+must be specified in hexadecimal format, and contain an even number of characters.</li>
+</ul>
+<p>As a final note, your application also needs to hold the
+{@link android.Manifest.permission#NFC} permission to be able to register as a HCE service.</p>
<h2 id="AidConflicts">AID Conflict Resolution</h2>
<p>Multiple {@link android.nfc.cardemulation.HostApduService} components
- may be installed on a single device, and the same AID
-can be registered by more than one service. The Android platform resolves AID
-conflicts depending on which category an AID belongs to. Each category may have
-a different conflict resolution policy. </p>
-
-<p>For example, for some categories (like payment) the user may be able to select a
-default service in the Android settings UI. For other categories, the policy may
-be to always ask the user which service is to be invoked in case of conflict. To
-query the conflict resolution policy for a certain category, see
+may be installed on a single device, and the same AID
+can be registered by more than one service. The Android platform resolves AID
+conflicts depending on which category an AID belongs to. Each category may have
+a different conflict resolution policy.</p>
+
+<p>For example, for some categories (like payment) the user may be able to select a
+default service in the Android settings UI. For other categories, the policy may
+be to always ask the user which service is to be invoked in case of conflict. To
+query the conflict resolution policy for a certain category, see
{@link android.nfc.cardemulation.CardEmulation#getSelectionModeForCategory
- getSelectionModeForCategory()}.</p>
+getSelectionModeForCategory()}.</p>
<h3 id="CheckingIfDefault">Checking if your service is the default</h3>
-<p>Applications can check whether their HCE service is the default service for a
-certain category by using the
+<p>Applications can check whether their HCE service is the default service for a
+certain category by using the
{@link android.nfc.cardemulation.CardEmulation#isDefaultServiceForCategory} API.</p>
-<p>If your service is not the default, you can request it to be made the default.
+<p>If your service is not the default, you can request it to be made the default.
See {@link android.nfc.cardemulation.CardEmulation#ACTION_CHANGE_DEFAULT}.</p>
-
-
<h2 id="PaymentApps">Payment Applications</h2>
-<p>Android considers HCE services that have declared an AID group with the
-"payment" category as payment applications. The Android 4.4 release contains a
-top-level Settings menu entry called "tap &amp; pay", which enumerates all such
-payment applications. In this settings menu, the user can select the default
+<p>Android considers HCE services that have declared an AID group with the
+"payment" category as payment applications. The Android 4.4 release contains a
+top-level Settings menu entry called "tap &amp; pay", which enumerates all such
+payment applications. In this settings menu, the user can select the default
payment application that will be invoked when a payment terminal is tapped.</p>
<h3 id="RequiredAssets">Required assets for payment applications</h3>
-<p>To provide a more visually attractive user experience, HCE payment applications
-are required to provide an additional asset for their service: a so-called
+<p>To provide a more visually attractive user experience, HCE payment applications
+are required to provide an additional asset for their service: a so-called
service banner.</p>
-<p>This asset should be sized 260x96 dp, and can be specified in your meta-data XML
-file by adding the <code>android:apduServiceBanner</code> attribute to the
-<code>&lt;host-apdu-service></code> tag, which points to the drawable resource. An example is
+<p>This asset should be sized 260x96 dp, and can be specified in your meta-data XML
+file by adding the <code>android:apduServiceBanner</code> attribute to the
+<code>&lt;host-apdu-service&gt;</code> tag, which points to the drawable resource. An example is
shown below:</p>
<pre>
&lt;host-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
- android:description="@string/servicedesc"
+ android:description="@string/servicedesc"
android:requireDeviceUnlock="false"
- android:apduServiceBanner="@drawable/my_banner">
+ android:apduServiceBanner="@drawable/my_banner"&gt;
&lt;aid-group android:description="@string/aiddescription"
- android:category="payment">
- &lt;aid-filter android:name="F0010203040506"/>
- &lt;aid-filter android:name="F0394148148100"/>
- &lt;/aid-group>
-&lt;/host-apdu-service>
+ android:category="payment"&gt;
+ &lt;aid-filter android:name="F0010203040506"/&gt;
+ &lt;aid-filter android:name="F0394148148100"/&gt;
+ &lt;/aid-group&gt;
+&lt;/host-apdu-service&gt;
</pre>
<h2 id="ScreenOffBehavior">Screen Off and Lock-screen Behavior</h2>
-<p>Current Android implementations turn the NFC controller and the application
-processor off completely when the screen of the device is turned off. HCE
+<p>Current Android implementations turn the NFC controller and the application
+processor off completely when the screen of the device is turned off. HCE
services will therefore not work when the screen is off.</p>
-<p>HCE services can function from the lock-screen however: this is controlled by
-the <code>android:requireDeviceUnlock</code> attribute in the <code>&lt;host-apdu-service></code> tag of your
-HCE service. By default, device unlock is not required, and your service will be
+<p>HCE services can function from the lock-screen however: this is controlled by
+the <code>android:requireDeviceUnlock</code> attribute in the <code>&lt;host-apdu-service&gt;</code> tag of your
+HCE service. By default, device unlock is not required, and your service will be
invoked even if the device is locked.</p>
-<p>If you set the <code>&lt;android:requireDeviceUnlock</code> attribute to "true" for your HCE
-service, Android will prompt the user to unlock the device when you tap an NFC
-reader that selects an AID that is resolved to your service. After unlocking,
-Android will show a dialog prompting the user to tap again to complete the
-transaction. This is necessary because the user may have moved the device away
+<p>If you set the <code>android:requireDeviceUnlock</code> attribute to "true" for your HCE
+service, Android will prompt the user to unlock the device when you tap an NFC
+reader that selects an AID that is resolved to your service. After unlocking,
+Android will show a dialog prompting the user to tap again to complete the
+transaction. This is necessary because the user may have moved the device away
from the NFC reader in order to unlock it.</p>
<h2 id="Coexistence">Coexistence with Secure Element Cards</h2>
-<p>This section is of interest for developers that have deployed an application
-that relies on a secure element for card emulation. Android's HCE implementation
-is designed to work in parallel with other methods of implementing card
+<p>This section is of interest for developers that have deployed an application
+that relies on a secure element for card emulation. Android's HCE implementation
+is designed to work in parallel with other methods of implementing card
emulation, including the use of secure elements.</p>
<p class="note"><strong>Note:</strong> Android does not offer APIs for directly communicating with a secure element itself.</p>
-<p>This coexistence is based on a principle called "AID routing": the NFC
-controller keeps a routing table that consists of a (finite) list of routing
-rules. Each routing rule contains an AID and a destination. The destination can
-either be the host CPU (where Android apps are running), or a connected secure
+<p>This coexistence is based on a principle called "AID routing": the NFC
+controller keeps a routing table that consists of a (finite) list of routing
+rules. Each routing rule contains an AID and a destination. The destination can
+either be the host CPU (where Android apps are running), or a connected secure
element.</p>
-<p>When the NFC reader sends an APDU with a "SELECT AID", the NFC controller parses
-it and checks whether the AIDs matchesNo converter for: FOOTNOTE with any AID in
-its routing table. If it matches, that APDU and all APDUs following it will be
-sent to the destination associated with the AID, until another "SELECT AID" APDU
-is received or the NFC link is broken.</p>
+<p>When the NFC reader sends an APDU with a "SELECT AID", the NFC controller parses
+it and checks whether the AIDs matches with any AID in its routing table. If it
+matches, that APDU and all APDUs following it will be sent to the destination
+associated with the AID, until another "SELECT AID" APDU is received or the NFC
+link is broken.</p>
<p class="note"><strong>Note:</strong>
- While ISO/IEC 7816-4 defines the concept of “partial matches” as well, this is currently not supported by Android HCE devices.</p>
-
+While ISO/IEC 7816-4 defines the concept of “partial matches” as well, this is currently not supported by Android HCE devices.</p>
+
<p>This architecture is illustrated in figure 4.</p>
@@ -445,46 +450,46 @@ is received or the NFC link is broken.</p>
and host-card emulation.</p>
-<p>The NFC controller typically also contains a default route for APDUs. When an
-AID is not found in the routing table, the default route is used. Beginning with Android
-4.4, the default route is required to be set to the host CPU. This
-means that the routing table typically only contains entries for AIDs that need
+<p>The NFC controller typically also contains a default route for APDUs. When an
+AID is not found in the routing table, the default route is used. Beginning with Android
+4.4, the default route is required to be set to the host CPU. This
+means that the routing table typically only contains entries for AIDs that need
to go to a secure element.</p>
-<p>Android applications that implement a HCE service or that use a secure element
-don't have to worry about configuring the routing table - that is taking care of
-by Android automatically. Android merely needs to know which AIDs can be handled
-by HCE services and which ones can be handled by the secure element. Based on
-which services are installed and which the user has configured as preferred, the
+<p>Android applications that implement a HCE service or that use a secure element
+don't have to worry about configuring the routing table - that is taking care of
+by Android automatically. Android merely needs to know which AIDs can be handled
+by HCE services and which ones can be handled by the secure element. Based on
+which services are installed and which the user has configured as preferred, the
routing table is configured automatically.</p>
-<p>We've already described how to declare AIDs for HCE services. The following
-section explains how to declare AIDs for applications that use a secure element
+<p>We've already described how to declare AIDs for HCE services. The following
+section explains how to declare AIDs for applications that use a secure element
for card emulation.</p>
<h3 id="SecureElementReg">Secure element AID registration</h3>
-<p>Applications using a secure element for card emulation can declare a so-called
-"off host service" in their manifest. The declaration of such a service is
+<p>Applications using a secure element for card emulation can declare a so-called
+"off host service" in their manifest. The declaration of such a service is
almost identical to the declaration of a HCE service. The exceptions are:</p>
<ul>
-<li>The action used in the intent-filter must be set to
-{@link android.nfc.cardemulation.OffHostApduService#SERVICE_INTERFACE}</li>
-<li>The meta-data name attribute must be set to
-{@link android.nfc.cardemulation.OffHostApduService#SERVICE_META_DATA}</li>
-<li><p>The meta-data XML file must use the <code>&lt;offhost-apdu-service></code> root tag</p>
+<li>The action used in the intent-filter must be set to
+{@link android.nfc.cardemulation.OffHostApduService#SERVICE_INTERFACE}.</li>
+<li>The meta-data name attribute must be set to
+{@link android.nfc.cardemulation.OffHostApduService#SERVICE_META_DATA}.</li>
+<li><p>The meta-data XML file must use the <code>&lt;offhost-apdu-service&gt;</code> root tag.</p>
<pre>
&lt;service android:name=".MyOffHostApduService" android:exported="true"
- android:permission="android.permission.BIND_NFC_SERVICE">
- &lt;intent-filter>
- &lt;action android:name="android.nfc.cardemulation.action.OFF_HOST_APDU_SERVICE"/>
- &lt;/intent-filter>
+ android:permission="android.permission.BIND_NFC_SERVICE"&gt;
+ &lt;intent-filter&gt;
+ &lt;action android:name="android.nfc.cardemulation.action.OFF_HOST_APDU_SERVICE"/&gt;
+ &lt;/intent-filter&gt;
&lt;meta-data android:name="android.nfc.cardemulation.off_host_apdu_ervice"
- android:resource="@xml/apduservice"/>
-&lt;/service>
+ android:resource="@xml/apduservice"/&gt;
+&lt;/service&gt;
</pre>
</li>
</ul>
@@ -493,126 +498,126 @@ almost identical to the declaration of a HCE service. The exceptions are:</p>
<pre>
&lt;offhost-apdu-service xmlns:android="http://schemas.android.com/apk/res/android"
- android:description="@string/servicedesc">
- &lt;aid-group android:description="@string/subscription" android:category="other">
- &lt;aid-filter android:name="F0010203040506"/>
- &lt;aid-filter android:name="F0394148148100"/>
- &lt;/aid-group>
-&lt;/offhost-apdu-service>
+ android:description="@string/servicedesc"&gt;
+ &lt;aid-group android:description="@string/subscription" android:category="other"&gt;
+ &lt;aid-filter android:name="F0010203040506"/&gt;
+ &lt;aid-filter android:name="F0394148148100"/&gt;
+ &lt;/aid-group&gt;
+&lt;/offhost-apdu-service&gt;
</pre>
-<p>The <code>android:requireDeviceUnlock</code> attribute does not apply to off host services,
-because the host CPU is not involved in the transaction and therefore cannot
-prevent the secure element from executing transactions when the device is
+<p>The <code>android:requireDeviceUnlock</code> attribute does not apply to off host services,
+because the host CPU is not involved in the transaction and therefore cannot
+prevent the secure element from executing transactions when the device is
locked.</p>
-<p>The <code>android:apduServiceBanner</code> attribute must be used for off host services that
-are payment applications as well in order to be selectable as a default payment
+<p>The <code>android:apduServiceBanner</code> attribute must be used for off host services that
+are payment applications as well in order to be selectable as a default payment
application.</p>
<h3 id="OffHostInvocation">Off host service invocation</h3>
-<p>Android itself will never start or bind to a service that is declared as "off
-host". This is because the actual transactions are executed by the secure
-element and not by the Android service itself. The service declaration merely
+<p>Android itself will never start or bind to a service that is declared as "off
+host". This is because the actual transactions are executed by the secure
+element and not by the Android service itself. The service declaration merely
allows applications to register AIDs present on the secure element.</p>
<h2 id="HceSecurity">HCE and Security</h2>
-<p>The HCE architecture itself provides one core piece of security: because your
+<p>The HCE architecture itself provides one core piece of security: because your
service is protected by the {@link android.Manifest.permission#BIND_NFC_SERVICE}
- system permission, only the OS can
-bind to and communicate with your service. This ensures that any APDU you
-receive is actually an APDU that was received by the OS from the NFC controller,
-and that any APDU you send back will only go to the OS, which in turn directly
+ system permission, only the OS can
+bind to and communicate with your service. This ensures that any APDU you
+receive is actually an APDU that was received by the OS from the NFC controller,
+and that any APDU you send back will only go to the OS, which in turn directly
forwards the APDUs to the NFC controller.</p>
-<p>The core remaining piece is where you get the data from that you're sending back
-to the NFC reader. This is intentionally decoupled in the HCE design: it does
-not care where the data comes from, it just makes sure that it is safely
+<p>The core remaining piece is where you get your data that your app sends
+to the NFC reader. This is intentionally decoupled in the HCE design: it does
+not care where the data comes from, it just makes sure that it is safely
transported to the NFC controller and out to the NFC reader.</p>
-<p>For securely storing and retrieving the data that you want to send from your HCE
-service, you can for example rely on the Android Application Sandbox, which
-isolates your app's data from other apps. For more details on Android security,
-read
-<a href="{@docRoot}training/articles/security-tips.html">Security Tips</a>
+<p>For securely storing and retrieving the data that you want to send from your HCE
+service, you can, for example, rely on the Android Application Sandbox, which
+isolates your app's data from other apps. For more details on Android security,
+read
+<a href="{@docRoot}training/articles/security-tips.html">Security Tips</a>
.</p>
<h2 id="ProtocolParams">Protocol parameters and details</h2>
-<p>This section is of interest for developers that want to understand what protocol
-parameters HCE devices use during the anti-collision and activations phases of
-the NFC protocols. This allows them to build a reader infrastructure that is
+<p>This section is of interest for developers that want to understand what protocol
+parameters HCE devices use during the anti-collision and activation phases of
+the NFC protocols. This allows building a reader infrastructure that is
compatible with Android HCE devices.</p>
<h3 id="AntiCollisionAct">Nfc-A (ISO/IEC 14443 type A) protocol anti-collision and activation</h3>
<p>As part of the Nfc-A protocol activation, multiple frames are exchanged.</p>
-<p>In the first part of the exchange the HCE device will present its UID; HCE
-devices should be assumed to have a random UID. This means that on every tap,
-the UID that is presented to the reader will be a randomly generated UID.
-Because of this, NFC readers should not depend on the UID of HCE devices as a
+<p>In the first part of the exchange the HCE device will present its UID; HCE
+devices should be assumed to have a random UID. This means that on every tap,
+the UID that is presented to the reader will be a randomly generated UID.
+Because of this, NFC readers should not depend on the UID of HCE devices as a
form of authentication or identification.</p>
-<p>The NFC reader can subsequently select the HCE device by sending a SEL_REQ
-command. The SEL_RES response of the HCE device will at least have the 6th bit
-(0x20) set, indicating that the device supports ISO-DEP. Note that other bits in
-the SEL_RES may be set as well, indicating for example support for the NFC-DEP
-(p2p) protocol. Since other bits may be set, readers wanting to interact with
-HCE devices should explicitly check for the 6th bit only, and <stront>not</strong> compare the
+<p>The NFC reader can subsequently select the HCE device by sending a SEL_REQ
+command. The SEL_RES response of the HCE device will at least have the 6th bit
+(0x20) set, indicating that the device supports ISO-DEP. Note that other bits in
+the SEL_RES may be set as well, indicating for example support for the NFC-DEP
+(p2p) protocol. Since other bits may be set, readers wanting to interact with
+HCE devices should explicitly check for the 6th bit only, and <stront>not</strong> compare the
complete SEL_RES with a value of 0x20.</p>
<h3 id="IsoDepAct">ISO-DEP activation</h3>
-<p>After the Nfc-A protocol is activated, the ISO-DEP protocol activation is
-initiated by the NFC reader. It sends a "RATS" (Request for Answer To Select)
-command. The RATS response, the ATS, is completely generated by the NFC
-controller and not configurable by HCE services. However, HCE implementations
-are required to meet NFC Forum requirements for the ATS response, so NFC readers
-can count on these parameters being set in accordance with NFC Forum
+<p>After the Nfc-A protocol is activated, the ISO-DEP protocol activation is
+initiated by the NFC reader. It sends a "RATS" (Request for Answer To Select)
+command. The RATS response, the ATS, is completely generated by the NFC
+controller and not configurable by HCE services. However, HCE implementations
+are required to meet NFC Forum requirements for the ATS response, so NFC readers
+can count on these parameters being set in accordance with NFC Forum
requirements for any HCE device.</p>
-<p>The section below provides more details on the individual bytes of the ATS
+<p>The section below provides more details on the individual bytes of the ATS
response provided by the NFC controller on a HCE device:</p>
<ul>
-<li>TL: length of the ATS response. Must not indicate a length greater than 20
+<li>TL: length of the ATS response. Must not indicate a length greater than 20
bytes.</li>
-<li>T0: bits 5, 6 and 7 must be set on all HCE devices, indicating TA(1), TB(1)
-and TC(1) are included in the ATS response. Bits 1 to 4 indicate the FSCI,
-coding the maximum frame size. On HCE devices the value of FSCI must be
+<li>T0: bits 5, 6 and 7 must be set on all HCE devices, indicating TA(1), TB(1)
+and TC(1) are included in the ATS response. Bits 1 to 4 indicate the FSCI,
+coding the maximum frame size. On HCE devices the value of FSCI must be
between 0h and 8h.</li>
-<li>T(A)1: defines bitrates between reader and emulator, and whether they can be
+<li>T(A)1: defines bitrates between reader and emulator, and whether they can be
asymmetric. There are no bitrate requirements or guarantees for HCE devices.</li>
-<li>T(B)1: bits 1 to 4 indicate the Start-up Frame Guard time Integer (SFGI). On
-HCE devices, SFGI must be &lt;= 8h. Bits 5 to 8 indicate the Frame Waiting time
-Integer (FWI) and codes the Frame Waiting Time (FWT). On HCE devices, FWI must
+<li>T(B)1: bits 1 to 4 indicate the Start-up Frame Guard time Integer (SFGI). On
+HCE devices, SFGI must be &lt;= 8h. Bits 5 to 8 indicate the Frame Waiting time
+Integer (FWI) and codes the Frame Waiting Time (FWT). On HCE devices, FWI must
be &lt;= 8h.</li>
-<li>T(C)1: bit 5 indicates support for "Advanced Protocol features". HCE devices
-may or may not support "Advanced Protocol features". Bit 2 indicates support
-for DID. HCE devices may or may not support DID. Bit 1 indicates support for
+<li>T(C)1: bit 5 indicates support for "Advanced Protocol features". HCE devices
+may or may not support "Advanced Protocol features". Bit 2 indicates support
+for DID. HCE devices may or may not support DID. Bit 1 indicates support for
NAD. HCE devices must not support NAD and set bit 1 to zero.</li>
-<li>Historical bytes: HCE devices may return up to 15 historical bytes. NFC
-readers willing to interact with HCE services should make no assumptions about
+<li>Historical bytes: HCE devices may return up to 15 historical bytes. NFC
+readers willing to interact with HCE services should make no assumptions about
the contents of the historical bytes or their presence.</li>
</ul>
-<p>Note that many HCE devices are likely made compliant with protocol requirements
-that the payment networks united in EMVCo have specified in their "Contactless
+<p>Note that many HCE devices are likely made compliant with protocol requirements
+that the payment networks united in EMVCo have specified in their "Contactless
Communication Protocol" specification. In particular:</p>
<ul>
<li>FSCI in T0 must be between 2h and 8h.</li>
-<li>T(A)1 must be set to 0x80, indicating only the 106 kbit/s bitrate is
-supported, and asymmetric bitrates between reader and emulator are not
+<li>T(A)1 must be set to 0x80, indicating only the 106 kbit/s bitrate is
+supported, and asymmetric bitrates between reader and emulator are not
supported.</li>
<li>FWI in T(B)1 must be &lt;= 7h.</li>
</ul>
<h3 id="ApduExchange">APDU data exchange</h3>
-<p>As noted earlier, HCE implementations only support a single logical channel.
-Attempting to select applications on different logical channels will not work on
+<p>As noted earlier, HCE implementations only support a single logical channel.
+Attempting to select applications on different logical channels will not work on
a HCE device.</p>
diff --git a/docs/html/guide/topics/data/data-storage.jd b/docs/html/guide/topics/data/data-storage.jd
index 385c116..4b8a647 100644
--- a/docs/html/guide/topics/data/data-storage.jd
+++ b/docs/html/guide/topics/data/data-storage.jd
@@ -233,138 +233,197 @@ save files. This can be a removable storage media (such as an SD card) or an int
(non-removable) storage. Files saved to the external storage are world-readable and can
be modified by the user when they enable USB mass storage to transfer files on a computer.</p>
-<p>It's possible that a device using a partition of the
-internal storage for the external storage may also offer an SD card slot. In this case,
-the SD card is <em>not</em> part of the external storage and your app cannot access it (the extra
-storage is intended only for user-provided media that the system scans).</p>
-
<p class="caution"><strong>Caution:</strong> External storage can become unavailable if the user mounts the
external storage on a computer or removes the media, and there's no security enforced upon files you
save to the external storage. All applications can read and write files placed on the external
storage and the user can remove them.</p>
+<h3 id="ExternalPermissions">Getting access to external storage</h3>
+
+<p>In order to read or write files on the external storage, your app must acquire the
+{@link android.Manifest.permission#READ_EXTERNAL_STORAGE}
+or {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} system
+permissions. For example:</p>
+<pre>
+&lt;manifest ...>
+ &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+ ...
+&lt;/manifest>
+</pre>
+
+<p>If you need to both read and write files, then you need to request only the
+{@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE} permission, because it
+implicitly requires read access as well.</p>
+
+<p class="note"><strong>Note:</strong> Beginning with Android 4.4, these permissions are not
+required if you're reading or writing only files that are private to your app. For more
+information, see the section below about
+<a href="#AccessingExtFiles">saving files that are app-private</a>.</p>
+
+
<h3 id="MediaAvail">Checking media availability</h3>
<p>Before you do any work with the external storage, you should always call {@link
android.os.Environment#getExternalStorageState()} to check whether the media is available. The
media might be mounted to a computer, missing, read-only, or in some other state. For example,
-here's how you can check the availability:</p>
+here are a couple methods you can use to check the availability:</p>
<pre>
-boolean mExternalStorageAvailable = false;
-boolean mExternalStorageWriteable = false;
-String state = Environment.getExternalStorageState();
-
-if (Environment.MEDIA_MOUNTED.equals(state)) {
- // We can read and write the media
- mExternalStorageAvailable = mExternalStorageWriteable = true;
-} else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
- // We can only read the media
- mExternalStorageAvailable = true;
- mExternalStorageWriteable = false;
-} else {
- // Something else is wrong. It may be one of many other states, but all we need
- // to know is we can neither read nor write
- mExternalStorageAvailable = mExternalStorageWriteable = false;
+/* Checks if external storage is available for read and write */
+public boolean isExternalStorageWritable() {
+ String state = Environment.getExternalStorageState();
+ if (Environment.MEDIA_MOUNTED.equals(state)) {
+ return true;
+ }
+ return false;
+}
+
+/* Checks if external storage is available to at least read */
+public boolean isExternalStorageReadable() {
+ String state = Environment.getExternalStorageState();
+ if (Environment.MEDIA_MOUNTED.equals(state) ||
+ Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
+ return true;
+ }
+ return false;
}
</pre>
-<p>This example checks whether the external storage is available to read and write. The
-{@link android.os.Environment#getExternalStorageState()} method returns other states that you
+<p>The {@link android.os.Environment#getExternalStorageState()} method returns other states that you
might want to check, such as whether the media is being shared (connected to a computer), is missing
entirely, has been removed badly, etc. You can use these to notify the user with more information
when your application needs to access the media.</p>
-<h3 id="AccessingExtFiles">Accessing files on external storage</h3>
-
-<p>If you're using API Level 8 or greater, use {@link
-android.content.Context#getExternalFilesDir(String) getExternalFilesDir()} to open a {@link
-java.io.File} that represents the external storage directory where you should save your
-files. This method takes a <code>type</code> parameter that specifies the type of subdirectory you
-want, such as {@link android.os.Environment#DIRECTORY_MUSIC} and
-{@link android.os.Environment#DIRECTORY_RINGTONES} (pass <code>null</code> to receive
-the root of your application's file directory). This method will create the
-appropriate directory if necessary. By specifying the type of directory, you
-ensure that the Android's media scanner will properly categorize your files in the system (for
-example, ringtones are identified as ringtones and not music). If the user uninstalls your
-application, this directory and all its contents will be deleted.</p>
-
-<p>If you're using API Level 7 or lower, use {@link
-android.os.Environment#getExternalStorageDirectory()}, to open a {@link
-java.io.File} representing the root of the external storage. You should then write your data in the
-following directory:</p>
-<pre class="no-pretty-print classic">
-/Android/data/<em>&lt;package_name&gt;</em>/files/
-</pre>
-<p>The {@code <em>&lt;package_name&gt;</em>} is your Java-style package name, such as "{@code
-com.example.android.app}". If the user's device is running API Level 8 or greater and they
-uninstall your application, this directory and all its contents will be deleted.</p>
+<h3 id="SavingSharedFiles">Saving files that can be shared with other apps</h3>
-
-<div class="sidebox-wrapper" style="margin-top:3em">
+<div class="sidebox-wrapper" >
<div class="sidebox">
<h4>Hiding your files from the Media Scanner</h4>
<p>Include an empty file named {@code .nomedia} in your external files directory (note the dot
-prefix in the filename). This will prevent Android's media scanner from reading your media
-files and including them in apps like Gallery or Music.</p>
+prefix in the filename). This prevents media scanner from reading your media
+files and providing them to other apps through the {@link android.provider.MediaStore}
+content provider. However, if your files are truly private to your app, you should
+<a href="#AccessingExtFiles">save them in an app-private directory</a>.</p>
</div>
</div>
+<p>Generally, new files that the user may acquire through your app should be saved to a "public"
+location on the device where other apps can access them and the user can easily copy them from the
+device. When doing so, you should use to one of the shared public directories, such as {@code
+Music/}, {@code Pictures/}, and {@code Ringtones/}.</p>
-<h3 id="SavingSharedFiles">Saving files that should be shared</h3>
-
-<p>If you want to save files that are not specific to your application and that should <em>not</em>
-be deleted when your application is uninstalled, save them to one of the public directories on the
-external storage. These directories lay at the root of the external storage, such as {@code
-Music/}, {@code Pictures/}, {@code Ringtones/}, and others.</p>
-
-<p>In API Level 8 or greater, use {@link
+<p>To get a {@link java.io.File} representing the appropriate public directory, call {@link
android.os.Environment#getExternalStoragePublicDirectory(String)
-getExternalStoragePublicDirectory()}, passing it the type of public directory you want, such as
+getExternalStoragePublicDirectory()}, passing it the type of directory you want, such as
{@link android.os.Environment#DIRECTORY_MUSIC}, {@link android.os.Environment#DIRECTORY_PICTURES},
-{@link android.os.Environment#DIRECTORY_RINGTONES}, or others. This method will create the
-appropriate directory if necessary.</p>
-
-<p>If you're using API Level 7 or lower, use {@link
-android.os.Environment#getExternalStorageDirectory()} to open a {@link java.io.File} that represents
-the root of the external storage, then save your shared files in one of the following
-directories:</p>
-
-<ul class="nolist"></li>
- <li><code>Music/</code> - Media scanner classifies all media found here as user music.</li>
- <li><code>Podcasts/</code> - Media scanner classifies all media found here as a podcast.</li>
- <li><code>Ringtones/ </code> - Media scanner classifies all media found here as a ringtone.</li>
- <li><code>Alarms/</code> - Media scanner classifies all media found here as an alarm sound.</li>
- <li><code>Notifications/</code> - Media scanner classifies all media found here as a notification
-sound.</li>
- <li><code>Pictures/</code> - All photos (excluding those taken with the camera).</li>
- <li><code>Movies/</code> - All movies (excluding those taken with the camcorder).</li>
- <li><code>Download/</code> - Miscellaneous downloads.</li>
-</ul>
+{@link android.os.Environment#DIRECTORY_RINGTONES}, or others. By saving your files to the
+corresponding media-type directory,
+the system's media scanner can properly categorize your files in the system (for
+instance, ringtones appear in system settings as ringtones, not as music).</p>
-<h3 id="ExternalCache">Saving cache files</h3>
+<p>For example, here's a method that creates a directory for a new photo album in
+the public pictures directory:</p>
-<p>If you're using API Level 8 or greater, use {@link
-android.content.Context#getExternalCacheDir()} to open a {@link java.io.File} that represents the
-external storage directory where you should save cache files. If the user uninstalls your
-application, these files will be automatically deleted. However, during the life of your
-application, you should manage these cache files and remove those that aren't needed in order to
-preserve file space.</p>
-
-<p>If you're using API Level 7 or lower, use {@link
-android.os.Environment#getExternalStorageDirectory()} to open a {@link java.io.File} that represents
-the root of the external storage, then write your cache data in the following directory:</p>
-<pre class="no-pretty-print classic">
-/Android/data/<em>&lt;package_name&gt;</em>/cache/
+<pre>
+public File getAlbumStorageDir(String albumName) {
+ // Get the directory for the user's public pictures directory.
+ File file = new File(Environment.getExternalStoragePublicDirectory(
+ Environment.DIRECTORY_PICTURES), albumName);
+ if (!file.mkdirs()) {
+ Log.e(LOG_TAG, "Directory not created");
+ }
+ return file;
+}
+</pre>
+
+
+
+<h3 id="AccessingExtFiles">Saving files that are app-private</h3>
+
+<p>If you are handling files that are not intended for other apps to use
+(such as graphic textures or sound effects used by only your app), you should use
+a private storage directory on the external storage by calling {@link
+android.content.Context#getExternalFilesDir(String) getExternalFilesDir()}.
+This method also takes a <code>type</code> argument to specify the type of subdirectory
+(such as {@link android.os.Environment#DIRECTORY_MOVIES}). If you don't need a specific
+media directory, pass <code>null</code> to receive
+the root directory of your app's private directory.</p>
+
+<p>Beginning with Android 4.4, reading or writing files in your app's private
+directories does not require the {@link android.Manifest.permission#READ_EXTERNAL_STORAGE}
+or {@link android.Manifest.permission#WRITE_EXTERNAL_STORAGE}
+permissions. So you can declare the permission should be requested only on the lower versions
+of Android by adding the <a
+href="{@docRoot}guide/topics/manifest/uses-permission-element.html#maxSdk">{@code maxSdkVersion}</a>
+attribute:</p>
+<pre>
+&lt;manifest ...>
+ &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
+ android:maxSdkVersion="18" />
+ ...
+&lt;/manifest>
</pre>
-<p>The {@code <em>&lt;package_name&gt;</em>} is your Java-style package name, such as "{@code
-com.example.android.app}".</p>
+
+<p class="note"><strong>Note:</strong>
+When the user uninstalls your application, this directory and all its contents are deleted.
+Also, the system media scanner does not read files in these directories, so they are not accessible
+from the {@link android.provider.MediaStore} content provider. As such, you <b>should not
+use these directories</b> for media that ultimately belongs to the user, such as photos
+captured or edited with your app, or music the user has purchased with your app&mdash;those
+files should be <a href="#SavingSharedFiles">saved in the public directories</a>.</p>
+
+<p>Sometimes, a device that has allocated a partition of the
+internal memory for use as the external storage may also offer an SD card slot.
+When such a device is running Android 4.3 and lower, the {@link
+android.content.Context#getExternalFilesDir(String) getExternalFilesDir()} method provides
+access to only the internal partition and your app cannot read or write to the SD card.
+Beginning with Android 4.4, however, you can access both locations by calling
+{@link android.content.Context#getExternalFilesDirs getExternalFilesDirs()},
+which returns a {@link
+java.io.File} array with entries each location. The first entry in the array is considered
+the primary external storage and you should use that location unless it's full or
+unavailable. If you'd like to access both possible locations while also supporting Android
+4.3 and lower, use the <a href="{@docRoot}tools/support-library/index.html">support library's</a>
+static method, {@link android.support.v4.content.ContextCompat#getExternalFilesDirs
+ContextCompat.getExternalFilesDirs()}. This also returns a {@link
+java.io.File} array, but always includes only one entry on Android 4.3 and lower.</p>
+
+<p class="caution"><strong>Caution</strong> Although the directories provided by {@link
+android.content.Context#getExternalFilesDir(String) getExternalFilesDir()} and {@link
+android.content.Context#getExternalFilesDirs getExternalFilesDirs()} are not accessible by the
+{@link android.provider.MediaStore} content provider, other apps with the {@link
+android.Manifest.permission#READ_EXTERNAL_STORAGE} permission can access all files on the external
+storage, including these. If you need to completely restrict access for your files, you should
+instead write your files to the <a href="#filesInternal">internal storage</a>.</p>
+
+
+
+
+
+<h3 id="ExternalCache">Saving cache files</h3>
+
+<p>To open a {@link java.io.File} that represents the
+external storage directory where you should save cache files, call {@link
+android.content.Context#getExternalCacheDir()}. If the user uninstalls your
+application, these files will be automatically deleted.</p>
+
+<p>Similar to {@link android.support.v4.content.ContextCompat#getExternalFilesDirs
+ContextCompat.getExternalFilesDirs()}, mentioned above, you can also access a cache directory on
+a secondary external storage (if available) by calling
+{@link android.support.v4.content.ContextCompat#getExternalCacheDirs
+ContextCompat.getExternalCacheDirs()}.</p>
+
+<p class="note"><strong>Tip:</strong>
+To preserve file space and maintain your app's performance,
+it's important that you carefully manage your cache files and remove those that aren't
+needed anymore throughout your app's lifecycle.</p>
+
diff --git a/docs/html/guide/topics/manifest/action-element.jd b/docs/html/guide/topics/manifest/action-element.jd
index 037d0dc..54ee6ae 100644
--- a/docs/html/guide/topics/manifest/action-element.jd
+++ b/docs/html/guide/topics/manifest/action-element.jd
@@ -12,7 +12,7 @@ parent.link=manifest-intro.html
<p>
<dt>description:</dt>
-<dd>Adds an action to an intent filter.
+<dd itemprop="description">Adds an action to an intent filter.
An <code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code> element must contain
one or more {@code &lt;action&gt;} elements. If it doesn't contain any, no
Intent objects will get through the filter. See
diff --git a/docs/html/guide/topics/manifest/activity-alias-element.jd b/docs/html/guide/topics/manifest/activity-alias-element.jd
index d3df08b..343b02e 100644
--- a/docs/html/guide/topics/manifest/activity-alias-element.jd
+++ b/docs/html/guide/topics/manifest/activity-alias-element.jd
@@ -23,7 +23,7 @@ parent.link=manifest-intro.html
<br/><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></code></dd>
<dt>description:</dt>
-<dd>An alias for an activity, named by the {@code targetActivity}
+<dd itemprop="description">An alias for an activity, named by the {@code targetActivity}
attribute. The target must be in the same application as the
alias and it must be declared before the alias in the manifest.
diff --git a/docs/html/guide/topics/manifest/activity-element.jd b/docs/html/guide/topics/manifest/activity-element.jd
index 8df1fdf..bd1edc2 100644
--- a/docs/html/guide/topics/manifest/activity-element.jd
+++ b/docs/html/guide/topics/manifest/activity-element.jd
@@ -54,7 +54,7 @@ parent.link=manifest-intro.html
<br/><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Declares an activity (an {@link android.app.Activity} subclass) that
+<dd itemprop="description">Declares an activity (an {@link android.app.Activity} subclass) that
implements part of the application's visual user interface. All activities
must be represented by {@code &lt;activity&gt;}
elements in the manifest file. Any that are not declared there will not be seen
diff --git a/docs/html/guide/topics/manifest/application-element.jd b/docs/html/guide/topics/manifest/application-element.jd
index 6bfa3dc..28deed9 100644
--- a/docs/html/guide/topics/manifest/application-element.jd
+++ b/docs/html/guide/topics/manifest/application-element.jd
@@ -40,13 +40,14 @@ page.title=&lt;application&gt;
<dt>can contain:</dt>
<dd><code><a href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/activity-alias-element.html">&lt;activity-alias&gt;</a></code>
+<br/><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/service-element.html">&lt;service&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></code></dd>
<dt>description:</dt>
-<dd>The declaration of the application. This element contains subelements
+<dd itemprop="description">The declaration of the application. This element contains subelements
that declare each of the application's components and has attributes
that can affect all the components. Many of these attributes (such as
{@code icon}, {@code label}, {@code permission}, {@code process},
diff --git a/docs/html/guide/topics/manifest/category-element.jd b/docs/html/guide/topics/manifest/category-element.jd
index 41a2cfd..563ed10 100644
--- a/docs/html/guide/topics/manifest/category-element.jd
+++ b/docs/html/guide/topics/manifest/category-element.jd
@@ -11,7 +11,7 @@ parent.link=manifest-intro.html
<dd><code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Adds a category name to an intent filter. See
+<dd itemprop="description">Adds a category name to an intent filter. See
<a href="{@docRoot}guide/components/intents-filters.html">Intents and
Intent Filters</a> for details on intent filters and the role of category
specifications within a filter.</dd>
@@ -27,6 +27,14 @@ by prefixing "{@code android.intent.category.}" to the
the string value for {@code CATEGORY_LAUNCHER} is
"{@code android.intent.category.LAUNCHER}".
+<p class="note"><strong>Note:</strong> In order to receive implicit intents, you must include the
+{@link android.content.Intent#CATEGORY_DEFAULT} category in the intent filter. The methods
+{@link android.app.Activity#startActivity startActivity()} and
+{@link android.app.Activity#startActivityForResult startActivityForResult()} treat all intents
+as if they declared the {@link android.content.Intent#CATEGORY_DEFAULT} category.
+If you do not declare it in your intent filter, no implicit intents will resolve to
+your activity.</p>
+
<p>
Custom categories should use the package name as a prefix, to ensure
that they are unique.
diff --git a/docs/html/guide/topics/manifest/compatible-screens-element.jd b/docs/html/guide/topics/manifest/compatible-screens-element.jd
index 00cbfe5..3606b15 100644
--- a/docs/html/guide/topics/manifest/compatible-screens-element.jd
+++ b/docs/html/guide/topics/manifest/compatible-screens-element.jd
@@ -20,7 +20,7 @@ parent.link=manifest-intro.html
href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Specifies each screen configuration with which the application is compatible. Only one instance
+<dd itemprop="description">Specifies each screen configuration with which the application is compatible. Only one instance
of the {@code &lt;compatible-screens&gt;} element is allowed in the manifest, but it can
contain multiple <code>&lt;screen&gt;</code> elements. Each <code>&lt;screen&gt;</code> element
specifies a specific screen size-density combination with which the application is compatible.
diff --git a/docs/html/guide/topics/manifest/data-element.jd b/docs/html/guide/topics/manifest/data-element.jd
index 766d2d7..ecba508 100644
--- a/docs/html/guide/topics/manifest/data-element.jd
+++ b/docs/html/guide/topics/manifest/data-element.jd
@@ -5,34 +5,35 @@ parent.link=manifest-intro.html
<dl class="xml">
<dt>syntax:</dt>
-<dd><pre class="stx">&lt;data android:<a href="#host">host</a>="<i>string</i>"
- android:<a href="#mime">mimeType</a>="<i>string</i>"
+<dd><pre class="stx">&lt;data android:<a href="#scheme">scheme</a>="<i>string</i>"
+ android:<a href="#host">host</a>="<i>string</i>"
+ android:<a href="#port">port</a>="<i>string</i>"
android:<a href="#path">path</a>="<i>string</i>"
android:<a href="#path">pathPattern</a>="<i>string</i>"
android:<a href="#path">pathPrefix</a>="<i>string</i>"
- android:<a href="#port">port</a>="<i>string</i>"
- android:<a href="#scheme">scheme</a>="<i>string</i>" /&gt;</pre></dd>
+ android:<a href="#mime">mimeType</a>="<i>string</i>" /&gt;</pre></dd>
<dt>contained in:</dt>
<dd><code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Adds a data specification to an intent filter. The specification can
-be just a data type (the <code><a href="{@docRoot}guide/topics/manifest/data-element.html#mime">mimeType</a></code> attribute),
-just a URI, or both a data type and a URI. A URI is specified by separate
+<dd itemprop="description">Adds a data specification to an intent filter. The specification can
+be just a data type (the <code><a href="{@docRoot}guide/topics/manifest/data-element.html#mime">mimeType</a></code> attribute),
+just a URI, or both a data type and a URI. A URI is specified by separate
attributes for each of its parts:
-<p style="margin-left: 2em">{@code scheme://host:port/path} <i>or</i>
-{@code pathPrefix} <i>or</i> {@code pathPattern}</p>
+<p style="margin-left: 2em">
+{@code &lt;scheme>://&lt;host>:&lt;port>/[&lt;path>|&lt;pathPrefix>|&lt;pathPattern>]}</p>
<p>
-These attributes are optional, but also mutually dependent:
-If a <code><a href="{@docRoot}guide/topics/manifest/data-element.html#scheme">scheme</a></code> is not specified for the
-intent filter, all the other URI attributes are ignored. If a
-<code><a href="{@docRoot}guide/topics/manifest/data-element.html#host">host</a></code> is not specified for the filter,
-the {@code port} attribute and all the path attributes are ignored.
-</p>
+These attributes that specify the URL format are optional, but also mutually dependent:
+<ul>
+ <li>If a <code><a href="{@docRoot}guide/topics/manifest/data-element.html#scheme">scheme</a></code>
+is not specified for the intent filter, all the other URI attributes are ignored.</li>
+ <li>If a <code><a href="{@docRoot}guide/topics/manifest/data-element.html#host">host</a></code>
+is not specified for the filter, the {@code port} attribute and all the path attributes are ignored.
+</ul>
<p>
All the {@code &lt;data&gt;} elements contained within the same
@@ -54,111 +55,117 @@ the same filter. So, for example, the following filter specification,
&lt;/intent-filter&gt;</pre>
<p>
-You can place any number of &lt;data&gt; elements inside an
-<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code> to give it multiple data
-options. None of its attributes have default values.
+You can place any number of {@code &lt;data&gt;} elements inside an
+<code><a href="{@docRoot}guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></code> to give it multiple data
+options. None of its attributes have default values.
</p>
<p>
Information on how intent filters work, including the rules for how Intent objects
are matched against filters, can be found in another document,
<a href="{@docRoot}guide/components/intents-filters.html">Intents and
-Intent Filters</a>. See also the
-<a href="{@docRoot}guide/topics/manifest/manifest-intro.html#ifs">Intent Filters</a>
-section in the introduction.
+Intent Filters</a>. See also the
+<a href="{@docRoot}guide/topics/manifest/manifest-intro.html#ifs">Intent Filters</a>
+section in the manifest file overview.
</p></dd>
<dt>attributes:</dt>
<dd><dl class="attr">
+
+<dt><a name="scheme"></a>{@code android:scheme}</dt>
+<dd>The scheme part of a URI. This is the minimal essential attribute for
+specifying a URI; at least one {@code scheme} attribute must be set
+for the filter, or none of the other URI attributes are meaningful.
+
+<p>
+A scheme is specified without the trailing colon (for example,
+{@code http}, rather than {@code http:}).
+</p>
+
+<p>
+If the filter has a data type set (the <code><a
+href="{@docRoot}guide/topics/manifest/data-element.html#mime">mimeType</a></code>
+attribute) but no scheme, the {@code content:} and {@code file:} schemes are
+assumed.
+</p>
+
+<p class="note"><strong>Note</strong>: Scheme matching in the Android framework is
+case-sensitive, unlike the RFC. As a result, you should always specify schemes
+using lowercase letters.</p>
+</dd>
+
<dt><a name="host"></a>{@code android:host}</dt>
<dd>The host part of a URI authority. This attribute is meaningless
-unless a <code><a href="{@docRoot}guide/topics/manifest/data-element.html#scheme">scheme</a></code> attribute is also
+unless a <code><a href="{@docRoot}guide/topics/manifest/data-element.html#scheme">scheme</a></code> attribute is also
specified for the filter.
-<p class="note">Note: host name matching in the Android framework is
+<p class="note"><strong>Note</strong>: host name matching in the Android framework is
case-sensitive, unlike the formal RFC. As a result, you should always specify
host names using lowercase letters.</p>
</dd>
-<dt><a name="mime"></a>{@code android:mimeType}</dt>
-<dd>A MIME media type, such as {@code image/jpeg} or {@code audio/mpeg4-generic}.
-The subtype can be the asterisk wildcard ({@code *}) to indicate that any
-subtype matches.
-<p>It's common for an intent filter to declare a {@code &lt;data>} that includes
-only the {@code android:mimeType} attribute.</p>
+<dt><a name="port"></a>{@code android:port}</dt>
+<dd>The port part of a URI authority. This attribute is meaningful only
+if the <code><a href="#scheme">scheme</a></code> and
+<code><a href="#host">host</a></code> attributes are also specified for
+the filter.</dd>
-<p class="note">Note: MIME type matching in the Android framework is
-case-sensitive, unlike formal RFC MIME types. As a result, you should always
-specify MIME types using lowercase letters.</p>
-</dd>
<dt><a name="path"></a>{@code android:path}
<br/>{@code android:pathPrefix}
<br/>{@code android:pathPattern}</dt>
-<dd>The path part of a URI. The {@code path} attribute specifies a complete
-path that is matched against the complete path in an Intent object. The
-{@code pathPrefix} attribute specifies a partial path that is matched against
-only the initial part of the path in the Intent object. The {@code pathPattern}
-attribute specifies a complete path that is matched against the complete path
-in the Intent object, but it can contain the following wildcards:
+<dd>The path part of a URI. The {@code path} attribute specifies a complete
+path that is matched against the complete path in an Intent object. The
+{@code pathPrefix} attribute specifies a partial path that is matched against
+only the initial part of the path in the Intent object. The {@code pathPattern}
+attribute specifies a complete path that is matched against the complete path
+in the Intent object, but it can contain the following wildcards:
<ul>
<li>An asterisk ('{@code *}') matches a sequence of 0 to many occurrences of
the immediately preceding character.</li>
-<li>A period followed by an asterisk ("{@code .*}") matches any sequence of
+<li>A period followed by an asterisk ("{@code .*}") matches any sequence of
0 to many characters.</li>
</ul>
<p>
-Because '{@code \}' is used as an escape character when the string is read
-from XML (before it is parsed as a pattern), you will need to double-escape:
-For example, a literal '{@code *}' would be written as "{@code \\*}" and a
-literal '{@code \}' would be written as "{@code \\\\}". This is basically
+Because '{@code \}' is used as an escape character when the string is read
+from XML (before it is parsed as a pattern), you will need to double-escape:
+For example, a literal '{@code *}' would be written as "{@code \\*}" and a
+literal '{@code \}' would be written as "{@code \\\\}". This is basically
the same as what you would need to write if constructing the string in Java code.
</p>
<p>
-For more information on these three types of patterns, see the descriptions of
+For more information on these three types of patterns, see the descriptions of
{@link android.os.PatternMatcher#PATTERN_LITERAL},
{@link android.os.PatternMatcher#PATTERN_PREFIX}, and
{@link android.os.PatternMatcher#PATTERN_SIMPLE_GLOB} in the
{@link android.os.PatternMatcher} class.
</p>
-<p>These attributes are meaningful only if the
-<code><a href="#scheme">scheme</a></code> and <code><a href="#host">host</a></code>
+<p>These attributes are meaningful only if the
+<code><a href="#scheme">scheme</a></code> and <code><a href="#host">host</a></code>
attributes are also specified for the filter.
</p></dd>
-<dt><a name="port"></a>{@code android:port}</dt>
-<dd>The port part of a URI authority. This attribute is meaningful only
-if the <code><a href="#scheme">scheme</a></code> and
-<code><a href="#host">host</a></code> attributes are also specified for
-the filter.</dd>
-
-<dt><a name="scheme"></a>{@code android:scheme}</dt>
-<dd>The scheme part of a URI. This is the minimal essential attribute for
-specifying a URI; at least one {@code scheme} attribute must be set
-for the filter, or none of the other URI attributes are meaningful.
+<dt><a name="mime"></a>{@code android:mimeType}</dt>
+<dd>A MIME media type, such as {@code image/jpeg} or {@code audio/mpeg4-generic}.
+The subtype can be the asterisk wildcard ({@code *}) to indicate that any
+subtype matches.
-<p>
-A scheme is specified without the trailing colon (for example,
-{@code http}, rather than {@code http:}).
-</p>
+<p>It's common for an intent filter to declare a {@code &lt;data>} that includes
+only the {@code android:mimeType} attribute.</p>
-<p>
-If the filter has a data type set (the <code><a href="{@docRoot}guide/topics/manifest/data-element.html#mime">mimeType</a></code>
-attribute) but no scheme, the {@code content:} and {@code file:} schemes are
-assumed.
-</p>
-<p class="note">Note: scheme matching in the Android framework is
-case-sensitive, unlike the RFC. As a result, you should always specify schemes
-using lowercase letters.</p>
+<p class="note"><strong>Note</strong>: MIME type matching in the Android framework is
+case-sensitive, unlike formal RFC MIME types. As a result, you should always
+specify MIME types using lowercase letters.</p>
</dd>
-</dl></dd>
+
+</dl></dd>
<!-- ##api level indication## -->
<dt>introduced in:</dt>
diff --git a/docs/html/guide/topics/manifest/grant-uri-permission-element.jd b/docs/html/guide/topics/manifest/grant-uri-permission-element.jd
index dc98cbb..2179359 100644
--- a/docs/html/guide/topics/manifest/grant-uri-permission-element.jd
+++ b/docs/html/guide/topics/manifest/grant-uri-permission-element.jd
@@ -13,7 +13,7 @@ parent.link=manifest-intro.html
<dd><code><a href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Specifies which data subsets of the parent content provider permission
+<dd itemprop="description">Specifies which data subsets of the parent content provider permission
can be granted for. Data subsets are indicated by the path part of a
{@code content:} URI. (The authority part of the URI identifies the
content provider.)
diff --git a/docs/html/guide/topics/manifest/instrumentation-element.jd b/docs/html/guide/topics/manifest/instrumentation-element.jd
index 9408b84..74be559 100644
--- a/docs/html/guide/topics/manifest/instrumentation-element.jd
+++ b/docs/html/guide/topics/manifest/instrumentation-element.jd
@@ -16,7 +16,7 @@ parent.link=manifest-intro.html
<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Declares an {@link android.app.Instrumentation} class that enables you
+<dd itemprop="description">Declares an {@link android.app.Instrumentation} class that enables you
to monitor an application's interaction with the system. The Instrumentation
object is instantiated before any of the application's components.</dd>
diff --git a/docs/html/guide/topics/manifest/intent-filter-element.jd b/docs/html/guide/topics/manifest/intent-filter-element.jd
index 68da981..14b4e03 100644
--- a/docs/html/guide/topics/manifest/intent-filter-element.jd
+++ b/docs/html/guide/topics/manifest/intent-filter-element.jd
@@ -25,7 +25,7 @@ parent.link=manifest-intro.html
<br/><code><a href="{@docRoot}guide/topics/manifest/data-element.html">&lt;data&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Specifies the types of intents that an activity, service, or broadcast
+<dd itemprop="description">Specifies the types of intents that an activity, service, or broadcast
receiver can respond to. An intent filter declares the capabilities of its
parent component &mdash; what an activity or service can do and what types
of broadcasts a receiver can handle. It opens the component to receiving
diff --git a/docs/html/guide/topics/manifest/manifest-element.jd b/docs/html/guide/topics/manifest/manifest-element.jd
index cce951e..20dc4ea 100644
--- a/docs/html/guide/topics/manifest/manifest-element.jd
+++ b/docs/html/guide/topics/manifest/manifest-element.jd
@@ -25,17 +25,21 @@ parent.link=manifest-intro.html
<dd><code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code></dd>
<dt>can contain:</dt>
-<dd><code><a href="{@docRoot}guide/topics/manifest/instrumentation-element.html">&lt;instrumentation&gt;</a></code>
+<dd><code><a href="{@docRoot}guide/topics/manifest/compatible-screens-element.html">&lt;compatible-screens&gt;</a></code>
+<br/><code><a href="{@docRoot}guide/topics/manifest/instrumentation-element.html">&lt;instrumentation&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/permission-group-element.html">&lt;permission-group&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/permission-tree-element.html">&lt;permission-tree&gt;</a></code>
+<br/><code><a href="{@docRoot}guide/topics/manifest/supports-gl-texture.html">&lt;supports-gl-texture&gt;</a></code
+<br/><code><a href="{@docRoot}guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></code> <!-- ##api level 3## -->
-<br/><code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></code></dd>
+<br/><code><a href="{@docRoot}guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></code>
+<br/><code><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a></code></dd>
<p>
<dt>description:</dt>
-<dd>The root element of the AndroidManifest.xml file. It must
+<dd itemprop="description">The root element of the AndroidManifest.xml file. It must
contain an <code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code> element
and specify {@code xmlns:android} and {@code package} attributes.</dd>
@@ -189,4 +193,4 @@ more information about using this attribute (including how to maintain backward
<dd>
<code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code></dd>
-</dl>
+</dl> \ No newline at end of file
diff --git a/docs/html/guide/topics/manifest/manifest-intro.jd b/docs/html/guide/topics/manifest/manifest-intro.jd
index d25a513..d2a9308 100644
--- a/docs/html/guide/topics/manifest/manifest-intro.jd
+++ b/docs/html/guide/topics/manifest/manifest-intro.jd
@@ -1,4 +1,4 @@
-page.title=The AndroidManifest.xml File
+page.title=App Manifest
@jd:body
<div id="qv-wrapper">
@@ -20,11 +20,11 @@ page.title=The AndroidManifest.xml File
</div>
<p>
-Every application must have an AndroidManifest.xml file (with precisely that
-name) in its root directory. The manifest presents essential information about
-the application to the Android system, information the system must have before
-it can run any of the application's code. Among other things, the manifest
-does the following:
+ Every application must have an AndroidManifest.xml file (with precisely that
+ name) in its root directory. <span itemprop="description">The manifest file
+ presents essential information about your app to the Android system,
+ information the system must have before it can run any of the app's
+ code.</span> Among other things, the manifest does the following:
</p>
<ul>
diff --git a/docs/html/guide/topics/manifest/meta-data-element.jd b/docs/html/guide/topics/manifest/meta-data-element.jd
index 56a214c..241153b 100644
--- a/docs/html/guide/topics/manifest/meta-data-element.jd
+++ b/docs/html/guide/topics/manifest/meta-data-element.jd
@@ -12,11 +12,13 @@ parent.link=manifest-intro.html
<dt>contained in:</dt>
<dd><code><a href="{@docRoot}guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/activity-alias-element.html">&lt;activity-alias&gt;</a></code>
-<br/><code><a href="{@docRoot}guide/topics/manifest/service-element.html">&lt;service&gt;</a></code>
+<br/><code><a href="{@docRoot}guide/topics/manifest/application-element.html">&lt;application&gt;</a></code>
+<br/><code><a href="{@docRoot}guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></code>
<br/><code><a href="{@docRoot}guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></code></dd>
+<br/><code><a href="{@docRoot}guide/topics/manifest/service-element.html">&lt;service&gt;</a></code>
<dt>description:</dt>
-<dd>A name-value pair for an item of additional, arbitrary data that can
+<dd itemprop="description">A name-value pair for an item of additional, arbitrary data that can
be supplied to the parent component. A component element can contain any
number of {@code &lt;meta-data&gt;} subelements. The values from all of
them are collected in a single {@link android.os.Bundle} object and made
diff --git a/docs/html/guide/topics/manifest/path-permission-element.jd b/docs/html/guide/topics/manifest/path-permission-element.jd
index e644d68..cdaf82b 100644
--- a/docs/html/guide/topics/manifest/path-permission-element.jd
+++ b/docs/html/guide/topics/manifest/path-permission-element.jd
@@ -23,7 +23,7 @@ parent.link=manifest-intro.html
-->
<dt>description:</dt>
-<dd>Defines the path and required permissions for a specific subset of data
+<dd itemprop="description">Defines the path and required permissions for a specific subset of data
within a content provider. This element can be
specified multiple times to supply multiple paths.
diff --git a/docs/html/guide/topics/manifest/permission-element.jd b/docs/html/guide/topics/manifest/permission-element.jd
index a23fb4b..4bb5f6a 100644
--- a/docs/html/guide/topics/manifest/permission-element.jd
+++ b/docs/html/guide/topics/manifest/permission-element.jd
@@ -17,7 +17,7 @@ parent.link=manifest-intro.html
<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Declares a security permission that can be used to limit access
+<dd itemprop="description">Declares a security permission that can be used to limit access
to specific components or features of this or other applications.
See the <a href="{@docRoot}guide/topics/manifest/manifest-intro.html#perms">Permissions</a>
section in the introduction,
diff --git a/docs/html/guide/topics/manifest/permission-group-element.jd b/docs/html/guide/topics/manifest/permission-group-element.jd
index fc1de1f..3221d4b 100644
--- a/docs/html/guide/topics/manifest/permission-group-element.jd
+++ b/docs/html/guide/topics/manifest/permission-group-element.jd
@@ -14,7 +14,7 @@ parent.link=manifest-intro.html
<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Declares a name for a logical grouping of related permissions. Individual
+<dd itemprop="description">Declares a name for a logical grouping of related permissions. Individual
permission join the group through the {@code permissionGroup} attribute of the
<code><a href="{@docRoot}guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></code> element. Members of a group are
presented together in the user interface.
diff --git a/docs/html/guide/topics/manifest/permission-tree-element.jd b/docs/html/guide/topics/manifest/permission-tree-element.jd
index a9c00cd..21d7352 100644
--- a/docs/html/guide/topics/manifest/permission-tree-element.jd
+++ b/docs/html/guide/topics/manifest/permission-tree-element.jd
@@ -13,7 +13,7 @@ parent.link=manifest-intro.html
<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Declares the base name for a tree of permissions. The application takes
+<dd itemprop="description">Declares the base name for a tree of permissions. The application takes
ownership of all names within the tree. It can dynamically add new permissions
to the tree by calling <code>{@link android.content.pm.PackageManager#addPermission PackageManager.addPermission()}</code>. Names within the tree are separated by
periods ('{@code .}'). For example, if the base name is
diff --git a/docs/html/guide/topics/manifest/provider-element.jd b/docs/html/guide/topics/manifest/provider-element.jd
index 6cf6843..f3ffd58 100644
--- a/docs/html/guide/topics/manifest/provider-element.jd
+++ b/docs/html/guide/topics/manifest/provider-element.jd
@@ -36,7 +36,7 @@ parent.link=manifest-intro.html
<br/><code><a href="{@docRoot}guide/topics/manifest/path-permission-element.html">&lt;path-permission&gt;</a></code></dd>
<dt>description:</dt>
-<dd>
+<dd itemprop="description">
Declares a content provider component. A content provider is a subclass of
{@link android.content.ContentProvider} that supplies structured access to data managed by the
application. All content providers in your application must be defined in a
diff --git a/docs/html/guide/topics/manifest/receiver-element.jd b/docs/html/guide/topics/manifest/receiver-element.jd
index 8416c0c..df2437e 100644
--- a/docs/html/guide/topics/manifest/receiver-element.jd
+++ b/docs/html/guide/topics/manifest/receiver-element.jd
@@ -23,7 +23,7 @@ parent.link=manifest-intro.html
<br/><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Declares a broadcast receiver (a {@link android.content.BroadcastReceiver}
+<dd itemprop="description">Declares a broadcast receiver (a {@link android.content.BroadcastReceiver}
subclass) as one of the application's components. Broadcast receivers enable
applications to receive intents that are broadcast by the system or by other
applications, even when other components of the application are not running.
diff --git a/docs/html/guide/topics/manifest/service-element.jd b/docs/html/guide/topics/manifest/service-element.jd
index 14eed67..2213b72 100644
--- a/docs/html/guide/topics/manifest/service-element.jd
+++ b/docs/html/guide/topics/manifest/service-element.jd
@@ -24,7 +24,7 @@ parent.link=manifest-intro.html
<br/><code><a href="{@docRoot}guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Declares a service (a {@link android.app.Service} subclass) as one
+<dd itemprop="description">Declares a service (a {@link android.app.Service} subclass) as one
of the application's components. Unlike activities, services lack a
visual user interface. They're used to implement long-running background
operations or a rich communications API that can be called by other
diff --git a/docs/html/guide/topics/manifest/supports-gl-texture-element.jd b/docs/html/guide/topics/manifest/supports-gl-texture-element.jd
index fa39317..ab751c2 100644
--- a/docs/html/guide/topics/manifest/supports-gl-texture-element.jd
+++ b/docs/html/guide/topics/manifest/supports-gl-texture-element.jd
@@ -34,7 +34,7 @@ parent.link=manifest-intro.html
<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Declares a single GL texture compression format that is supported by
+<dd itemprop="description">Declares a single GL texture compression format that is supported by
the application.
<p>An application "supports" a GL texture compression format if it is capable of
diff --git a/docs/html/guide/topics/manifest/supports-screens-element.jd b/docs/html/guide/topics/manifest/supports-screens-element.jd
index ae14121..bbeceb7 100644
--- a/docs/html/guide/topics/manifest/supports-screens-element.jd
+++ b/docs/html/guide/topics/manifest/supports-screens-element.jd
@@ -24,7 +24,7 @@ parent.link=manifest-intro.html
<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Lets you specify the screen sizes your application supports and enable <a
+<dd itemprop="description">Lets you specify the screen sizes your application supports and enable <a
href="{@docRoot}guide/practices/screen-compat-mode.html">screen compatibility mode</a> for screens
larger than what your application supports. It's important that you always use this element in your
application to specify the screen sizes your application supports.
diff --git a/docs/html/guide/topics/manifest/uses-configuration-element.jd b/docs/html/guide/topics/manifest/uses-configuration-element.jd
index e9a0ba4..15fd49c 100644
--- a/docs/html/guide/topics/manifest/uses-configuration-element.jd
+++ b/docs/html/guide/topics/manifest/uses-configuration-element.jd
@@ -27,7 +27,7 @@ easier to update the doc when the change is made... Nov 2013, this still seems u
<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Indicates what hardware and software features the application requires.
+<dd itemprop="description">Indicates what hardware and software features the application requires.
For example, an application might specify that it requires a physical keyboard
or a particular navigation device, like a trackball. The specification is
used to avoid installing the application on devices where it will not work.
diff --git a/docs/html/guide/topics/manifest/uses-feature-element.jd b/docs/html/guide/topics/manifest/uses-feature-element.jd
index 95f62a5..d421591 100644
--- a/docs/html/guide/topics/manifest/uses-feature-element.jd
+++ b/docs/html/guide/topics/manifest/uses-feature-element.jd
@@ -62,7 +62,7 @@ below.</p>
href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Declares a single hardware or software feature that is used by the
+<dd itemprop="description">Declares a single hardware or software feature that is used by the
application.
<p>The purpose of a <code>&lt;uses-feature&gt;</code> declaration is to inform
@@ -136,7 +136,7 @@ device compatibility.</p>
<dd>Specifies a single hardware or software feature used by the application,
as a descriptor string. Valid descriptor values are listed in the <a
href="#hw-features">Hardware features</a> and <a href="#sw-features">Software
-features</a> tables, below. </dd>
+features</a> tables, below. Descriptor string values are case-sensitive.</dd>
<dt><a name="required"></a><code>android:required</code></dt> <!-- added in api level 5 -->
<dd>Boolean value that indicates whether the application requires
@@ -549,11 +549,15 @@ is sensitive to delays or lag in sound input or output.</td>
</td>
</tr>
<tr>
- <td>Bluetooth</td>
- <td><code>android.hardware.bluetooth</td>
+ <td rowspan="2">Bluetooth</td>
+ <td><code>android.hardware.bluetooth</code></td>
<td>The application uses Bluetooth radio features in the device.</td>
- <td>If your app uses Bluetooth Low Energy, also declare
- {@code android.software.bluetooth_le}.</td>
+ <td></td>
+ </tr>
+ <tr>
+ <td><code>android.hardware.bluetooth_le</code></td>
+ <td>The application uses Bluetooth Low Energy radio features in the device.</td>
+ <td></td>
</tr>
<tr>
<td rowspan="5">Camera</td>
@@ -586,6 +590,13 @@ not required.</td>
</tr>
<tr>
+ <td>Infrared</td>
+ <td><code>android.hardware.consumerir</code></td>
+ <td>The application uses the consumer IR capabilities on the device.</td>
+ <td></td>
+</tr>
+
+<tr>
<td rowspan="3">Location</td>
<td><code>android.hardware.location</code></td>
<td>The application uses one or more features on the device for determining
@@ -613,13 +624,18 @@ from a Global Positioning System receiver on the device. </td>
<td></td>
</tr>
<tr>
- <td>NFC</td>
+ <td rowspan="2">NFC</td>
<td><code>android.hardware.nfc</td>
<td>The application uses Near Field Communications radio features in the device.</td>
<td></td>
</tr>
<tr>
- <td rowspan="6">Sensors</td>
+ <td><code>android.hardware.nfc.hce</code></td>
+ <td>The application uses the NFC card emulation feature in the device.</td>
+ <td></td>
+</tr>
+<tr>
+ <td rowspan="8">Sensors</td>
<td><code>android.hardware.sensor.accelerometer</code></td>
<td>The application uses motion readings from an accelerometer on the
device.</td>
@@ -651,6 +667,16 @@ the device.</td>
<td>The application uses the device's proximity sensor.</td>
<td></td>
</tr>
+<tr>
+ <td><code>android.hardware.sensor.stepcounter</code></td>
+ <td>The application uses the device's step counter.</td>
+ <td></td>
+</tr>
+<tr>
+ <td><code>android.hardware.sensor.stepdetector</code></td>
+ <td>The application uses the device's step detector.</td>
+ <td></td>
+</tr>
<tr>
<td rowspan="2">Screen</td>
@@ -828,11 +854,15 @@ hosts).</td>
</tr>
<tr>
- <td>Wifi</td>
+ <td rowspan="2">Wi-Fi</td>
<td><code>android.hardware.wifi</code></td>
- <td>The application uses 802.11 networking (wifi) features on the device.</td>
+ <td>The application uses 802.11 networking (Wi-Fi) features on the device.</td>
<td></td>
</tr>
+<tr>
+ <td><code>android.hardware.wifi.direct</code></td>
+ <td>The application uses the Wi-Fi Direct networking features on the device.</td>
+</tr>
</table>
@@ -857,11 +887,9 @@ in a separate <code>&lt;uses-feature&gt;</code> element. </p>
that include a Home screen or similar location where users can embed App Widgets.</td>
</tr>
<tr>
- <td>Bluetooth Low Energy</td>
- <td><code>android.software.bluetooth_le</code></td>
- <td><p>The application uses Bluetooth Low Energy APIs and should be installed only on devices
- that are capable of communicating with other devices via Bluetooth Low Energy.
- <p>This implicitly also declares the {@code android.hardware.bluetooth} feature.</td>
+ <td>Device Management</td>
+ <td><code>android.software.device_admin</code></td>
+ <td>The application uses device policy enforcement via device administrators.</td>
</tr>
<tr>
<td>Home Screen</td>
@@ -1056,7 +1084,7 @@ filtering based on the <code>CAMERA</code> permission, you would add this
</tr>
<tr>
- <td rowspan="3">Wifi</td>
+ <td rowspan="3">Wi-Fi</td>
<td><code>ACCESS_WIFI_STATE</code></td>
<td><code>android.hardware.wifi</code></td>
<!-- <td></td> -->
diff --git a/docs/html/guide/topics/manifest/uses-library-element.jd b/docs/html/guide/topics/manifest/uses-library-element.jd
index 253807e..aa7ca82 100644
--- a/docs/html/guide/topics/manifest/uses-library-element.jd
+++ b/docs/html/guide/topics/manifest/uses-library-element.jd
@@ -31,7 +31,7 @@ parent.link=manifest-intro.html
</code>
</dd>
<dt>description:</dt>
-<dd>
+<dd itemprop="descridption">
Specifies a shared library that the application must be linked against.
This element tells the system to include the library's code in the class
loader for the package.
diff --git a/docs/html/guide/topics/manifest/uses-permission-element.jd b/docs/html/guide/topics/manifest/uses-permission-element.jd
index bd7091e..9394114 100644
--- a/docs/html/guide/topics/manifest/uses-permission-element.jd
+++ b/docs/html/guide/topics/manifest/uses-permission-element.jd
@@ -42,7 +42,7 @@ href="{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions-feat
<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Requests a permission that the application must be granted in
+<dd itemprop="description">Requests a permission that the application must be granted in
order for it to operate correctly. Permissions are granted by the user when the
application is installed, not while it's running.
diff --git a/docs/html/guide/topics/manifest/uses-sdk-element.jd b/docs/html/guide/topics/manifest/uses-sdk-element.jd
index 9169658..b372592 100644
--- a/docs/html/guide/topics/manifest/uses-sdk-element.jd
+++ b/docs/html/guide/topics/manifest/uses-sdk-element.jd
@@ -48,7 +48,7 @@ page.tags="api levels","sdk version","minsdkversion","targetsdkversion","maxsdkv
<dd><code><a href="{@docRoot}guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></code></dd>
<dt>description:</dt>
-<dd>Lets you express an application's compatibility with one or more versions of the Android platform,
+<dd itemprop="description"><p> Lets you express an application's compatibility with one or more versions of the Android platform,
by means of an API Level integer. The API Level expressed by an application will be compared to the
API Level of a given Android system, which may vary among different Android devices.
</p>
@@ -273,55 +273,55 @@ Highlights</a>--></td></tr>
<td>{@link android.os.Build.VERSION_CODES#HONEYCOMB_MR1}</td>
<td><a href="{@docRoot}about/versions/android-3.1-highlights.html">Platform Highlights</a></td></tr>
- <tr><td><a href="{@docRoot}about/versions/android-3.0.html">Android 3.0.x</td>
+ <tr><td><a href="{@docRoot}about/versions/android-3.0.html">Android 3.0.x</a></td>
<td><a href="{@docRoot}sdk/api_diff/11/changes.html" title="Diff Report">11</a></td>
<td>{@link android.os.Build.VERSION_CODES#HONEYCOMB}</td>
<td><a href="{@docRoot}about/versions/android-3.0-highlights.html">Platform Highlights</a></td></tr>
- <tr><td><a href="{@docRoot}about/versions/android-2.3.3.html">Android 2.3.4<br>Android 2.3.3</td>
+ <tr><td><a href="{@docRoot}about/versions/android-2.3.3.html">Android 2.3.4<br>Android 2.3.3</a></td>
<td><a href="{@docRoot}sdk/api_diff/10/changes.html" title="Diff Report">10</a></td>
<td>{@link android.os.Build.VERSION_CODES#GINGERBREAD_MR1}</td>
<td rowspan="2"><a href="{@docRoot}about/versions/android-2.3-highlights.html">Platform
Highlights</a></td></tr>
- <tr><td><a href="{@docRoot}about/versions/android-2.3.html">Android 2.3.2<br>Android 2.3.1<br>Android
-2.3</td>
+ <tr><td><a href="{@docRoot}about/versions/android-2.3.html">Android 2.3.2<br>Android 2.3.1<br>
+ Android 2.3</a></td>
<td><a href="{@docRoot}sdk/api_diff/9/changes.html" title="Diff Report">9</a></td>
<td>{@link android.os.Build.VERSION_CODES#GINGERBREAD}</td>
</tr>
- <tr><td><a href="{@docRoot}about/versions/android-2.2.html">Android 2.2.x</td>
+ <tr><td><a href="{@docRoot}about/versions/android-2.2.html">Android 2.2.x</a></td>
<td ><a href="{@docRoot}sdk/api_diff/8/changes.html" title="Diff Report">8</a></td>
<td>{@link android.os.Build.VERSION_CODES#FROYO}</td>
<td><a href="{@docRoot}about/versions/android-2.2-highlights.html">Platform Highlights</a></td></tr>
- <tr><td><a href="{@docRoot}about/versions/android-2.1.html">Android 2.1.x</td>
+ <tr><td><a href="{@docRoot}about/versions/android-2.1.html">Android 2.1.x</a></td>
<td><a href="{@docRoot}sdk/api_diff/7/changes.html" title="Diff Report">7</a></td>
<td>{@link android.os.Build.VERSION_CODES#ECLAIR_MR1}</td>
<td rowspan="3" ><a href="{@docRoot}about/versions/android-2.0-highlights.html">Platform
Highlights</a></td></tr>
- <tr><td><a href="{@docRoot}about/versions/android-2.0.1.html">Android 2.0.1</td>
+ <tr><td><a href="{@docRoot}about/versions/android-2.0.1.html">Android 2.0.1</a></td>
<td><a href="{@docRoot}sdk/api_diff/6/changes.html" title="Diff Report">6</a></td>
<td>{@link android.os.Build.VERSION_CODES#ECLAIR_0_1}</td>
</tr>
- <tr><td><a href="{@docRoot}about/versions/android-2.0.html">Android 2.0</td>
+ <tr><td><a href="{@docRoot}about/versions/android-2.0.html">Android 2.0</a></td>
<td><a href="{@docRoot}sdk/api_diff/5/changes.html" title="Diff Report">5</a></td>
<td>{@link android.os.Build.VERSION_CODES#ECLAIR}</td>
</tr>
- <tr><td><a href="{@docRoot}about/versions/android-1.6.html">Android 1.6</td>
+ <tr><td><a href="{@docRoot}about/versions/android-1.6.html">Android 1.6</a></td>
<td><a href="{@docRoot}sdk/api_diff/4/changes.html" title="Diff Report">4</a></td>
<td>{@link android.os.Build.VERSION_CODES#DONUT}</td>
<td><a href="{@docRoot}about/versions/android-1.6-highlights.html">Platform Highlights</a></td></tr>
- <tr><td><a href="{@docRoot}about/versions/android-1.5.html">Android 1.5</td>
+ <tr><td><a href="{@docRoot}about/versions/android-1.5.html">Android 1.5</a></td>
<td><a href="{@docRoot}sdk/api_diff/3/changes.html" title="Diff Report">3</a></td>
<td>{@link android.os.Build.VERSION_CODES#CUPCAKE}</td>
<td><a href="{@docRoot}about/versions/android-1.5-highlights.html">Platform Highlights</a></td></tr>
- <tr><td><a href="{@docRoot}about/versions/android-1.1.html">Android 1.1</td>
+ <tr><td><a href="{@docRoot}about/versions/android-1.1.html">Android 1.1</a></td>
<td>2</td>
<td>{@link android.os.Build.VERSION_CODES#BASE_1_1}</td><td></td></tr>
diff --git a/docs/html/guide/topics/media/mediaplayer.jd b/docs/html/guide/topics/media/mediaplayer.jd
index fb272d2..dc789d2 100644
--- a/docs/html/guide/topics/media/mediaplayer.jd
+++ b/docs/html/guide/topics/media/mediaplayer.jd
@@ -119,7 +119,7 @@ mediaPlayer.start(); // no need to call prepare(); create() does that for you
<p>In this case, a "raw" resource is a file that the system does not
try to parse in any particular way. However, the content of this resource should not
-be raw audio. It should be a properly encoded and formatted media file in one
+be raw audio. It should be a properly encoded and formatted media file in one
of the supported formats.</p>
<p>And here is how you might play from a URI available locally in the system
@@ -207,7 +207,7 @@ call {@link android.media.MediaPlayer#stop stop()}, however, notice that you
cannot call {@link android.media.MediaPlayer#start start()} again until you
prepare the {@link android.media.MediaPlayer} again.</p>
-<p>Always keep <a href='{@docRoot}images/mediaplayer_state_diagram.gif'>the state diagram</a>
+<p>Always keep <a href='{@docRoot}images/mediaplayer_state_diagram.gif'>the state diagram</a>
in mind when writing code that interacts with a
{@link android.media.MediaPlayer} object, because calling its methods from the wrong state is a
common cause of bugs.</p>
@@ -238,7 +238,7 @@ mediaPlayer = null;
<p>As an example, consider the problems that could happen if you
forgot to release the {@link android.media.MediaPlayer} when your activity is stopped, but create a
new one when the activity starts again. As you may know, when the user changes the
-screen orientation (or changes the device configuration in another way),
+screen orientation (or changes the device configuration in another way),
the system handles that by restarting the activity (by default), so you might quickly
consume all of the system resources as the user
rotates the device back and forth between portrait and landscape, because at each
@@ -287,7 +287,7 @@ For example:</p>
<pre>
public class MyService extends Service implements MediaPlayer.OnPreparedListener {
- private static final ACTION_PLAY = "com.example.action.PLAY";
+ private static final String ACTION_PLAY = "com.example.action.PLAY";
MediaPlayer mMediaPlayer = null;
public int onStartCommand(Intent intent, int flags, int startId) {
@@ -346,7 +346,7 @@ and you must reset it before you can use it again.
<p>When designing applications that play media
in the background, the device may go to sleep
while your service is running. Because the Android system tries to conserve
-battery while the device is sleeping, the system tries to shut off any
+battery while the device is sleeping, the system tries to shut off any
of the phone's features that are
not necessary, including the CPU and the WiFi hardware.
However, if your service is playing or streaming music, you want to prevent
@@ -473,7 +473,7 @@ the user might not hear the notification tone due to the loud music. Starting wi
Android 2.2, the platform offers a way for applications to negotiate their
use of the device's audio output. This mechanism is called Audio Focus.</p>
-<p>When your application needs to output audio such as music or a notification,
+<p>When your application needs to output audio such as music or a notification,
you should always request audio focus. Once it has focus, it can use the sound output freely, but it
should
always listen for focus changes. If it is notified that it has lost the audio
@@ -691,7 +691,7 @@ adding the following to your manifest:</p>
intent. You should then implement this class:</p>
<pre>
-public class MusicIntentReceiver implements android.content.BroadcastReceiver {
+public class MusicIntentReceiver extends android.content.BroadcastReceiver {
&#64;Override
public void onReceive(Context ctx, Intent intent) {
if (intent.getAction().equals(
diff --git a/docs/html/guide/topics/media/mediarouter.jd b/docs/html/guide/topics/media/mediarouter.jd
new file mode 100644
index 0000000..1b10265
--- /dev/null
+++ b/docs/html/guide/topics/media/mediarouter.jd
@@ -0,0 +1,670 @@
+page.title=MediaRouter
+page.tags="cast","chromecast","wireless display","miracast"
+@jd:body
+
+<div id="qv-wrapper">
+ <div id="qv">
+ <h2>In this document</h2>
+ <ol>
+ <li><a href="#overview">Overview</a>
+ <ol>
+ <li><a href="#mr-packages">Media router packages</a></li>
+ </ol>
+ </li>
+ <li><a href="#cast-ui">Cast User Interface</a>
+ <ol>
+ <li><a href="#cast-button">Cast button</a></li>
+ <li><a href="#selector">Media route selector</a></li>
+ </ol>
+ </li>
+ <li><a href="#media-routes">Connecting to Media Routes</a>
+ <ol>
+ <li><a href="#create-mr-callback">Creating a MediaRouter callback</a></li>
+ <li><a href="#attach-mr-callback">Attaching a callback to MediaRouter</a></li>
+ </ol>
+ <li><a href="#remote-playback">Remote Playback</a></li>
+ <li><a href="#secondary-output">Secondary Output</a>
+ <ol>
+ <li><a href="#pres-obj">Creating a Presentation object</a></li>
+ <li><a href="#pres-cntrlr">Creating a Presentation controller</a></li>
+ </ol>
+ </li>
+ </ol>
+ <h2>Key Classes</h2>
+ <ol>
+ <li>{@link android.support.v7.media.MediaRouter}</li>
+ <li>{@link android.support.v7.media.MediaRouter.Callback}</li>
+ <li>{@link android.support.v7.media.MediaRouteProvider}</li>
+ </ol>
+ </div>
+</div>
+
+<p>As users connect their televisions, home theater systems and music players with wireless
+ technologies, they want to be able to play content from Android apps on these larger,
+ louder devices. Enabling this kind of playback can turn your one-device, one-user app
+ into a shared experience that delights and inspires multiple users.</p>
+
+<p>The Android media router APIs are designed to enable media display and playback on these
+ secondary devices. There are two main approaches you can use to play content using these
+ APIs:</p>
+
+<ul>
+ <li><strong>Remote Playback</strong> &mdash; This approach uses the receiving device to handle
+ the content data retrieval, decoding, and playback, while an Android device in the user's hand
+ is used as a remote control. This approach is used by Android apps that support
+ <a href="https://developers.google.com/cast/">Google Cast</a>.</li>
+ <li><strong>Secondary Output</strong> &mdash; With this approach, your app retrieves, renders
+ and streams video or music directly to the receiving device. This approach is used to support
+ Wireless Display output
+ on Android.</li>
+</ul>
+
+<p>This guide explains how your app can deliver media to secondary playback devices using either
+ of these approaches.</p>
+
+
+<h2 id="overview">Overview</h2>
+
+<p>The media router APIs enable a broad range of media output to playback equipment connected to
+ Android devices through wireless and wired means. To enable these connections,
+ the media router framework abstracts the logical paths for audio and video output for an Android
+ device. This architecture allows your app to quickly channel media content to
+ connected playback devices such as home theaters and sound systems that provide Android media
+ route support.</p>
+
+<p>In order to use this framework within your app, you must get an instance
+ of the {@link android.support.v7.media.MediaRouter} framework object and attach a {@link
+ android.support.v7.media.MediaRouter.Callback} object to listen for events in
+ available media routes. Content channelled through a media route passes through the route's
+ associated {@link android.support.v7.media.MediaRouteProvider} (except in a few special cases,
+ such as a Bluetooth output device). The following diagram provides a high-level view of the
+ classes your app can use to play content with the media router framework.
+</p>
+
+<img src="{@docRoot}images/mediarouter/mediarouter-framework.png" alt="" id="figure1"/>
+<p class="img-caption">
+ <strong>Figure 1.</strong> Overview of key media router classes used by apps.
+</p>
+
+<p>Manufacturers of media playback hardware that is not supported by the media router framework
+ can add support for their devices by implementing a
+ {@link android.support.v7.media.MediaRouteProvider} and distributing it as an application.
+ For more information on implementing a media route provider, see the {@link
+ android.support.v7.media.MediaRouteProvider} reference documentation and the v7-mediarouter
+ support library sample {@code &lt;sdk&gt;/extras/android/compatibility/v7/mediarouter}.
+</p>
+
+
+<h3 id="mr-packages">Media router packages</h3>
+
+<p>The media router APIs are provided as part of the Android Support Library version 18 and
+ higher, in the
+ <a href="{@docRoot}tools/support-library/features.html#v7-mediarouter">v7-mediarouter support
+ library</a>. Specifically, you should use the classes in the {@link android.support.v7.media}
+ package for media router functions. These APIs are compatible with devices running Android 2.1
+ (API level 7) and higher.
+</p>
+
+<p class="note">
+ <strong>Note:</strong> There is another set of media router APIs provided in the
+ {@link android.media} that have been superseded by the v7-mediarouter support library.
+ You <em>should not</em> use the {@link android.media} classes for media router functions.
+</p>
+
+<p>In order to use the {@link android.support.v7.media} media router classes, you must add
+ the <a href="{@docRoot}tools/support-library/features.html#v7-mediarouter">v7-mediarouter
+ support library package</a> to your app development project.
+</p>
+
+
+<h2 id="cast-ui">Cast User Interface</h2>
+
+<p>
+ Android apps that implement the media router API should include a Cast button
+ as part of their user interface, to allow users to select a media route to play media on
+ a secondary output device. The media router framework provides a standard interface for
+ the button, which you should use to help users recognize and use the feature in your app.
+ Figure 2 illustrates how the Cast button should appear in an app.
+</p>
+
+<img src="{@docRoot}images/mediarouter/mediarouter-actionbar.png" alt="" width="428" id="figure2"/>
+<p class="img-caption">
+ <strong>Figure 2.</strong> A Cast button shown on the right side of the action bar.
+</p>
+
+<p class="caution">
+ <strong>Caution:</strong> When implementing an activity that provides a media router interface
+ you <em>must</em> extend either {@link android.support.v7.app.ActionBarActivity}
+ or {@link android.support.v4.app.FragmentActivity} from the Android Support Library, even if
+ your {@code android:minSdkVersion} is API 11 or higher.
+</p>
+
+
+<h3 id="cast-button">Cast button</h3>
+
+<p>The recommended way to implement the Cast button user interface is to extend your activity
+ from {@link android.support.v7.app.ActionBarActivity} and use the {@link
+ android.app.Activity#onCreateOptionsMenu onCreateOptionsMenu()} method to add an options menu.
+ The Cast button must use the {@link android.support.v7.app.MediaRouteActionProvider} class
+ as its action:</p>
+
+<pre>
+&lt;?xml version="1.0" encoding="utf-8"?&gt;
+&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ &gt;
+
+ &lt;item android:id="@+id/media_route_menu_item"
+ android:title="@string/media_route_menu_title"
+ <strong>app:actionProviderClass="android.support.v7.app.MediaRouteActionProvider"</strong>
+ app:showAsAction="always"
+ /&gt;
+&lt;/menu&gt;
+</pre>
+
+<p>For more information about implementing the action bar in your app,
+ see the <a href="{@docRoot}guide/topics/ui/actionbar.html">Action Bar</a>
+ developer guide.
+</p>
+
+<p>Once you have added the Cast button to your user interface, you must attach a media
+ route selector object. Building a selector is discussed in the next section.
+</p>
+
+<p>If you do not want a menu in your action bar, you can also add a Cast button to your app using
+ {@link android.support.v7.app.MediaRouteButton}. If you choose this approach, you should add
+ this button to your app's action bar according to the
+ <a href="https://developers.google.com/cast/docs/design_checklist">Google Cast Design
+ Checklist</a>. You must also attach a media route selector to the button using the
+ {@link android.support.v7.app.MediaRouteButton#setRouteSelector setRouteSelector()} method.
+</p>
+
+<p>For guidelines on incorporating the Cast button into your application, review the
+ <a href="https://developers.google.com/cast/docs/design_checklist">Google Cast Design
+ Checklist</a>.</p>
+
+
+<h3 id="selector">Media route selector</h3>
+
+<p>When a user presses the Cast button, the media router framework looks for available media
+ routes and presents a list of choices to the user, as shown in figure 3.</p>
+
+<img src="{@docRoot}images/mediarouter/mediarouter-selector-ui.png" alt="" width="500" id="figure3"/>
+<p class="img-caption">
+ <strong>Figure 3.</strong> A list of available media routes, shown after pressing the Cast button.
+</p>
+
+
+<p>The <em>types</em> of media routes that appear on this list&mdash;Remote Playback, Secondary
+ Output or others&mdash;are defined by your app.You define these type by creating a {@link
+ android.support.v7.media.MediaRouteSelector}, which accepts {@link
+ android.support.v7.media.MediaControlIntent} objects provided by the framework and other media
+ route providers created by you or other developers. The framework-provided route categories are as
+ follows:
+</p>
+
+<ul>
+ <li>{@link android.support.v7.media.MediaControlIntent#CATEGORY_LIVE_AUDIO
+ CATEGORY_LIVE_AUDIO} &mdash; Output of audio to a secondary output device, such as a
+ wireless-enabled music system.</li>
+ <li>{@link android.support.v7.media.MediaControlIntent#CATEGORY_LIVE_VIDEO
+ CATEGORY_LIVE_VIDEO} &mdash; Output of video to a secondary output device, such as Wireless
+ Display devices.</li>
+ <li>{@link android.support.v7.media.MediaControlIntent#CATEGORY_REMOTE_PLAYBACK
+ CATEGORY_REMOTE_PLAYBACK} &mdash; Play video or audio on a separate device that supports the
+ <a href="https://developers.google.com/cast/">Google Cast</a> remote control protocol, such
+ as <a href="https://www.google.com/url?q=http://www.google.com/chromecast">Chromecast</a>.
+ </li>
+</ul>
+
+<p>When creating a {@link android.support.v7.media.MediaRouteSelector} object, use the
+ {@link android.support.v7.media.MediaRouteSelector.Builder} class to create the object and set
+ the media playback categories (control categories), as shown
+ in the following code sample:</p>
+
+<pre>
+public class MediaRouterPlaybackActivity extends ActionBarActivity {
+ private MediaRouteSelector mSelector;
+
+ &#64;Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ // Create a route selector for the type of routes your app supports.
+ <strong>mSelector = new MediaRouteSelector.Builder()
+ // These are the framework-supported intents
+ .addControlCategory(MediaControlIntent.CATEGORY_LIVE_AUDIO)
+ .addControlCategory(MediaControlIntent.CATEGORY_LIVE_VIDEO)
+ .addControlCategory(MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)</strong>
+ .build();
+ }
+}
+</pre>
+
+<p>The media router framework uses this selector object to provide an interface for selecting
+ media routes that your app supports, as shown in figure 3. Once you have defined this selector,
+ you attach it to the {@link android.support.v7.app.MediaRouteActionProvider} object associated
+ with the Cast menu item, as shown in the following code sample:</p>
+
+<pre>
+&#64;Override
+public boolean onCreateOptionsMenu(Menu menu) {
+ super.onCreateOptionsMenu(menu);
+
+ // Inflate the menu and configure the media router action provider.
+ getMenuInflater().inflate(R.menu.sample_media_router_menu, menu);
+
+ // Attach the MediaRouteSelector to the menu item
+ MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
+ MediaRouteActionProvider mediaRouteActionProvider =
+ (MediaRouteActionProvider)MenuItemCompat.getActionProvider(
+ mediaRouteMenuItem);
+ <strong>mediaRouteActionProvider.setRouteSelector(mSelector);</strong>
+
+ // Return true to show the menu.
+ return true;
+}
+</pre>
+
+<p>Once you have made these changes to your app, you might expect the Cast button to appear in your
+ activity. Alas, it does not (unless your device is already paired with a Wireless Display). In
+ most cases, you must also connect with the media route framework, which is discussed in the next
+ section.
+</p>
+
+
+<h2 id="media-routes">Connecting to Media Routes</h2>
+
+<p>In order to connect to a media route selected by the user, your app must obtain the {@link
+ android.support.v7.media.MediaRouter} framework object and then attach a {@link
+ android.support.v7.media.MediaRouter.Callback} object. The callback object receives messages
+ from the media router framework when a route selected, changed or disconnected by the user.</p>
+
+<p>To obtain an instance of the {@link android.support.v7.media.MediaRouter} framework object,
+ call {@link android.support.v7.media.MediaRouter#getInstance MediaRouter.getInstance()}
+ from the {@link android.app.Activity#onCreate onCreate()} method of an activity that supports
+ the media router API.</p>
+
+<p class="note">
+ <strong>Note:</strong> The {@link android.support.v7.media.MediaRouter} object is a singleton
+ that is maintained by the framework. However, once your application obtains an instance of the
+ object you must retain that instance until your application terminates to prevent it from being
+ garbage collected.
+</p>
+
+
+<h3 id="create-mr-callback">Creating a MediaRouter callback</h3>
+
+<p>The media router framework communicates with an app through a callback object that
+ you attach to the {@link android.support.v7.media.MediaRouter} framework object. An app
+ that uses the media router framework must extend the {@link
+ android.support.v7.media.MediaRouter.Callback} object to receive messages when a media route is
+ connected and provide content to the connected device through that route.</p>
+
+<p>There are several methods in the callback that can be overwritten to receive messages about
+ media router events. At the minimum, your implementation of the {@link
+ android.support.v7.media.MediaRouter.Callback} class should override the following
+ methods:</p>
+
+<ul>
+ <li>{@link android.support.v7.media.MediaRouter.Callback#onRouteSelected onRouteSelected()}
+ &mdash; Called when the user connects to a media router output device.</li>
+ <li>{@link android.support.v7.media.MediaRouter.Callback#onRouteUnselected
+ onRouteUnselected()} &mdash; Called when the user disconnects from a media router output device.</li>
+ <li>{@link android.support.v7.media.MediaRouter.Callback#onRoutePresentationDisplayChanged
+ onRoutePresentationDisplayChanged()} &mdash; Called when the presentation display changes its
+ display metrics, such as changing from 720 pixel to 1080 pixel resolution.</li>
+</ul>
+
+<p>The methods of your {@link android.support.v7.media.MediaRouter.Callback}
+ implementation are the first opportunity to determine if the connected route is a remote playback
+ device, such as Chromecast, or a secondary output device, such as a Wireless Display device.
+ If your app supports both device types, then your implementation should branch here, as
+ shown in this sample code:</p>
+
+<pre>
+private final MediaRouter.Callback mMediaRouterCallback =
+ new MediaRouter.Callback() {
+
+ &#64;Override
+ public void onRouteSelected(MediaRouter router, RouteInfo route) {
+ Log.d(TAG, "onRouteSelected: route=" + route);
+
+ if (route.supportsControlCategory(
+ MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)){
+ // remote playback device
+ updateRemotePlayer(route);
+ } else {
+ // secondary output device
+ updatePresentation(route);
+ }
+ }
+
+ &#64;Override
+ public void onRouteUnselected(MediaRouter router, RouteInfo route) {
+ Log.d(TAG, "onRouteUnselected: route=" + route);
+
+ if (route.supportsControlCategory(
+ MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)){
+ // remote playback device
+ updateRemotePlayer(route);
+ } else {
+ // secondary output device
+ updatePresentation(route);
+ }
+ }
+
+ &#64;Override
+ public void onRoutePresentationDisplayChanged(
+ MediaRouter router, RouteInfo route) {
+ Log.d(TAG, "onRoutePresentationDisplayChanged: route=" + route);
+
+ if (route.supportsControlCategory(
+ MediaControlIntent.CATEGORY_REMOTE_PLAYBACK)){
+ // remote playback device
+ updateRemotePlayer(route);
+ } else {
+ // secondary output device
+ updatePresentation(route);
+ }
+ }
+}
+</pre>
+
+<p>After defining your callback object for the media router, you still need to attach it to
+ the main media router framework object. The next section discusses the appropriate way to attach
+ your callbacks for media routes.</p>
+
+
+<h3 id="attach-mr-callback">Attaching a callback to MediaRouter</h3>
+
+<p>Since media routes are a shared interface, your app must attach and detach your
+ {@link android.support.v7.media.MediaRouter.Callback} object as your app starts up and shuts
+ down. To accomplish this, you must add and remove your app's
+ callback object from the media router framework as part of your app's activity lifecycle. This
+ approach allows other apps to make use of media route outputs while your app
+ is in the background or not running.</p>
+
+<p class="note">
+ <strong>Note:</strong> If you are writing a music playback app and want to allow music to play
+ while your app is in the background, you must build a {@link android.app.Service} for playback
+ and connect that service and it's lifecycle to the media router framework.
+</p>
+
+<p>The following code sample demonstrates how to use the lifecycle methods to appropriately
+ add and remove your app's media router callback object:</p>
+
+<pre>
+public class MediaRouterPlaybackActivity extends ActionBarActivity {
+ private MediaRouter mMediaRouter;
+ private MediaRouteSelector mSelector;
+ private Callback mMediaRouterCallback;
+
+ // your app works with so the framework can discover them.
+ &#64;Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ // Get the media router service.
+ mMediaRouter = MediaRouter.getInstance(this);
+ ...
+ }
+
+ // Add the callback on start to tell the media router what kinds of routes
+ // your app works with so the framework can discover them.
+ &#64;Override
+ public void onStart() {
+ mMediaRouter.addCallback(mSelector, mMediaRouterCallback,
+ MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
+ super.onStart();
+ }
+
+ // Remove the selector on stop to tell the media router that it no longer
+ // needs to discover routes for your app.
+ &#64;Override
+ public void onStop() {
+ mMediaRouter.removeCallback(mMediaRouterCallback);
+ super.onStop();
+ }
+ ...
+}
+</pre>
+
+<p>You should add and remove the media router callback only in the {@link
+ android.app.Activity#onStart onStart()} and {@link android.app.Activity#onStop onStop()}
+ lifecycle methods. Do not include these calls in the {@link android.app.Activity#onResume
+ onResume()} or {@link android.app.Activity#onPause onPause()} methods.
+</p>
+
+<p class="note">
+ <strong>Note:</strong> The media route framework also provides a
+ {@link android.support.v7.app.MediaRouteDiscoveryFragment} class which takes care of adding and
+ removing the call back for an activity.
+</p>
+
+<p>Now when you run your application, you should see a Cast button appear in your activity.
+ When you press the button the media router framework, a route selection dialog appears as shown
+ in figure 3, allowing your user to select an available media route. Make sure you have a
+ supported device available on your local network when testing this interface.</p>
+
+<p class="note">
+ <strong>Note:</strong> In order for Wireless Display routes to show up in the media route
+ selection dialog, users must enable this option in the Settings app. The option is under
+ the <em>Display</em> category and is called <em>Cast screen</em> on Android 4.4 (KitKat) and higher
+ devices and <em>Wireless Display</em> on Android 4.2.x (Jelly Bean) devices. For more information
+ on enabling this feature see this
+ <a href="https://support.google.com/nexus/answer/2865484">Wireless display</a> support page.
+</p>
+
+
+<h2 id="remote-playback">Remote Playback</h2>
+
+<p>The remote playback approach sends control commands to a secondary device to initiate playback
+ and to control playback that is in progress (pause, rewind, fast-forward, volume up and down).
+ Using this approach, the receiving device (such as a Chromecast) is responsible for retrieving
+ and rendering content.</p>
+
+<p>When your app supports this type of media route, you must create a {@link
+ android.support.v7.media.RemotePlaybackClient} object using a remote playback {@link
+ android.support.v7.media.MediaRouter.RouteInfo} object received through your app's
+ {@link android.support.v7.media.MediaRouter.Callback} object. The following sample
+ code demonstrates a controller method that creates a new remote playback client and sends it a
+ video for playback:</p>
+
+<pre>
+private void updateRemotePlayer(RouteInfo route) {
+ // Changed route: tear down previous client
+ if (mRoute != null && mRemotePlaybackClient != null) {
+ mRemotePlaybackClient.release();
+ mRemotePlaybackClient = null;
+ }
+
+ // Save new route
+ mRoute = route;
+
+ // Attach new playback client
+ mRemotePlaybackClient = new RemotePlaybackClient(this, mRoute);
+
+ // Send file for playback
+ mRemotePlaybackClient.play(Uri.parse(
+ "http://archive.org/download/Sintel/sintel-2048-stereo_512kb.mp4"),
+ "video/mp4", null, 0, null, new ItemActionCallback() {
+
+ &#64;Override
+ public void onResult(Bundle data, String sessionId,
+ MediaSessionStatus sessionStatus,
+ String itemId, MediaItemStatus itemStatus) {
+ logStatus("play: succeeded for item " + itemId);
+ }
+
+ &#64;Override
+ public void onError(String error, int code, Bundle data) {
+ logStatus("play: failed - error:"+ code +" - "+ error);
+ }
+ });
+ }
+}
+</pre>
+
+<p>The {@link android.support.v7.media.RemotePlaybackClient} class provides additional methods
+ for managing content playback. Here are a few of the key playback methods from the {@link
+ android.support.v7.media.RemotePlaybackClient} class:</p>
+
+<ul>
+ <li>{@link android.support.v7.media.RemotePlaybackClient#play play()} &mdash; Play a specific
+ media file, specified by a {@link android.net.Uri}.</li>
+ <li>{@link android.support.v7.media.RemotePlaybackClient#pause pause()} &mdash; Pause the
+ currently playing media track.</li>
+ <li>{@link android.support.v7.media.RemotePlaybackClient#resume resume()} &mdash; Continue
+ playing the current track after a pause command.</li>
+ <li>{@link android.support.v7.media.RemotePlaybackClient#seek seek()} &mdash; Move to a specific
+ position in the current track.</li>
+ <li>{@link android.support.v7.media.RemotePlaybackClient#release release()} &mdash; Tear down the
+ connection from your app to the remote playback device.</li>
+</ul>
+
+<p>You can use these methods to attach actions to playback controls you provide in your
+ app. Most of these methods also allow you to include a callback object so you can monitor
+ the progress of the playback task or control request.</p>
+
+<p>
+ The {@link android.support.v7.media.RemotePlaybackClient} class also supports queueing of
+ multiple media items for playback and management of the media queue. For a comprehensive sample
+ implementation of these features, see {@code SampleMediaRouterActivity} and its associated
+ classes in the v7 mediarouter support library sample
+ {@code &lt;sdk&gt;/extras/android/compatibility/v7/mediarouter}.
+</p>
+
+<p>
+ For additional information on using the Google Cast API for Chromecast devices, see the
+ <a href="http://developers.google.com/cast/">Google Cast</a> developer documentation.
+</p>
+
+
+<h2 id="secondary-output">Secondary Output</h2>
+
+<p>The secondary output approach sends prepared media content to a connected secondary device
+ for playback. Secondary devices can include televisions or wireless sound systems and can be
+ attached through wireless protocols or wires, such as an HDMI cable. With this approach, your
+ app is responsible for processing media content for playback (downloading, decoding,
+ synchronization of audio and video tracks), while the secondary device only outputs the content
+ in its final form.</p>
+
+<p class="note">
+ <strong>Note:</strong> Using the secondary output display routes with the media router framework
+ requires classes that are available only in Android 4.2 (API level 17) and higher, specifically the
+ {@link android.app.Presentation} class. If you are building an app that supports both
+ remote playback and secondary output devices, you must include checks that disable this code
+ below the supported Android version level.
+</p>
+
+
+<h3 id="pres-obj">Creating a Presentation object</h3>
+
+<p>When using a secondary output display with the media router framework, you create a {@link
+ android.app.Presentation} object that contains the content you want to show on that display. The
+ {@link android.app.Presentation} is extended from the {@link android.app.Dialog} class, so can
+ add layouts and views to a {@link android.app.Presentation}.</p>
+
+<p>You should be aware that the {@link android.app.Presentation} object has its own
+ {@link android.content.Context} and
+ {@link android.content.res.Resources},
+ separate from the app activity that created the object. Having a secondary
+ context is required, because the content of the {@link android.app.Presentation} is drawn on a
+ display that is separate from your app's display on the local Android device.
+ Specifically, the secondary display needs a separate context because it may need to load
+ resources based on its specific screen metrics.</p>
+
+<p>The following code sample shows a minimal implementation of a
+ {@link android.app.Presentation} object, including a {@link android.opengl.GLSurfaceView}
+ object.</p>
+
+<pre>
+public class SamplePresentation extends Presentation {
+ public SamplePresentation(Context outerContext, Display display) {
+ super(outerContext, display);
+ }
+
+ &#64;Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // Notice that we get resources from the context of the Presentation
+ Resources resources = getContext().getResources();
+
+ // Inflate a layout.
+ setContentView(R.layout.presentation_with_media_router_content);
+
+ // Add presentation content here:
+ // Set up a surface view for visual interest
+ mSurfaceView = (GLSurfaceView)findViewById(R.id.surface_view);
+ mSurfaceView.setRenderer(new CubeRenderer(false));
+ }
+}
+</pre>
+
+
+<h3 id="pres-cntrlr">Creating a Presentation controller</h3>
+
+<p>In order to display a {@link android.app.Presentation} object, you should write a
+ controller layer that handles responses to the messages received by the {@link
+ android.support.v7.media.MediaRouter.Callback} object and manages the creation and
+ removal of the {@link android.app.Presentation} object. The controller layer should also handle
+ attaching presentations to a selected {@link android.view.Display} object, which represents the
+ separate physical display device chosen by the user. The controller layer can simply be a method
+ in the activity that supports a secondary display.</p>
+
+<p>The following code sample shows a controller layer for a {@link android.app.Presentation}
+ implemented as a single method. This method handles dismissing invalid presentations when a
+ {@link android.view.Display} is unselected or disconnected, and creates the {@link
+ android.app.Presentation} object when a display device is connected.</p>
+
+<pre>
+private void updatePresentation(RouteInfo route) {
+ // Get its Display if a valid route has been selected
+ Display selectedDisplay = null;
+ if (route != null) {
+ selectedDisplay = route.getPresentationDisplay();
+ }
+
+ // Dismiss the current presentation if the display has changed or no new
+ // route has been selected
+ if (mPresentation != null && mPresentation.getDisplay() != selectedDisplay) {
+ mPresentation.dismiss();
+ mPresentation = null;
+ }
+
+ // Show a new presentation if the previous one has been dismissed and a
+ // route has been selected.
+ if (mPresentation == null && selectedDisplay != null) {
+ // Initialize a new Presentation for the Display
+ mPresentation = new SamplePresentation(this, selectedDisplay);
+ mPresentation.setOnDismissListener(
+ new DialogInterface.OnDismissListener() {
+ // Listen for presentation dismissal and then remove it
+ &#64;Override
+ public void onDismiss(DialogInterface dialog) {
+ if (dialog == mPresentation) {
+ mPresentation = null;
+ }
+ }
+ });
+
+ // Try to show the presentation, this might fail if the display has
+ // gone away in the meantime
+ try {
+ mPresentation.show();
+ } catch (WindowManager.InvalidDisplayException ex) {
+ // Couldn't show presentation - display was already removed
+ mPresentation = null;
+ }
+ }
+}
+</pre>
+
+<p class="note">
+ <strong>Note:</strong> When the a user connects to a Wireless Display, the media router
+ framework automatically provides a notification that it is displaying screen content on a
+ connected device.
+</p>
diff --git a/docs/html/guide/topics/providers/document-provider.jd b/docs/html/guide/topics/providers/document-provider.jd
index 9af8d5a..8ea08bd 100644
--- a/docs/html/guide/topics/providers/document-provider.jd
+++ b/docs/html/guide/topics/providers/document-provider.jd
@@ -3,8 +3,11 @@ page.title=Storage Access Framework
<div id="qv-wrapper">
<div id="qv">
-<h2>In this document</h2>
-<ol>
+<h2>In this document
+ <a href="#" onclick="hideNestedItems('#toc44',this);return false;" class="header-toggle">
+ <span class="more">show more</span>
+ <span class="less" style="display:none">show less</span></a></h2>
+<ol id="toc44" class="hide-nested">
<li>
<a href="#overview">Overview</a>
</li>
@@ -38,8 +41,25 @@ page.title=Storage Access Framework
<ol>
<li>{@link android.provider.DocumentsProvider}</li>
<li>{@link android.provider.DocumentsContract}</li>
- <li>{@link android.provider.DocumentsContract.Document}</li>
- <li>{@link android.provider.DocumentsContract.Root}</li>
+</ol>
+
+<h2>Videos</h2>
+
+<ol>
+ <li><a href="http://www.youtube.com/watch?v=zxHVeXbK1P4">
+DevBytes: Android 4.4 Storage Access Framework: Provider</a></li>
+ <li><a href="http://www.youtube.com/watch?v=UFj9AEz0DHQ">
+DevBytes: Android 4.4 Storage Access Framework: Client</a></li>
+</ol>
+
+
+<h2>Code Samples</h2>
+
+<ol>
+ <li><a href="{@docRoot}samples/StorageProvider/index.html">
+Storage Provider</a></li>
+ <li><a href="{@docRoot}samples/StorageClient/index.html">
+StorageClient</a></li>
</ol>
<h2>See Also</h2>
@@ -50,18 +70,28 @@ page.title=Storage Access Framework
</a>
</li>
</ol>
+
</div>
</div>
-<p>Android 4.4 (API level 19) introduces the Storage Access Framework. The
-Storage Access Framework encapsulates capabilities in the Android platform that
-allow apps to request files from file storage services. The Storage Access
-Framework includes the following:</p>
+
+
+<p>Android 4.4 (API level 19) introduces the Storage Access Framework (SAF). The SAF
+ makes it simple for users to browse and open documents, images, and other files
+across all of their their preferred document storage providers. A standard, easy-to-use UI
+lets users browse files and access recents in a consistent way across apps and providers.</p>
+
+<p>Cloud or local storage services can participate in this ecosystem by implementing a
+{@link android.provider.DocumentsProvider} that encapsulates their services. Client
+apps that need access to a provider's documents can integrate with the SAF with just a few
+lines of code.</p>
+
+<p>The SAF includes the following:</p>
<ul>
<li><strong>Document provider</strong>&mdash;A content provider that allows a
-storage service (such as Google Drive) to reveal the files it manages. This is
+storage service (such as Google Drive) to reveal the files it manages. A document provider is
implemented as a subclass of the {@link android.provider.DocumentsProvider} class.
-The document provider schema is based on a traditional file hierarchy,
+The document-provider schema is based on a traditional file hierarchy,
though how your document provider physically stores data is up to you.
The Android platform includes several built-in document providers, such as
Downloads, Images, and Videos.</li>
@@ -75,7 +105,7 @@ files returned by document providers.</li>
document providers that satisfy the client app's search criteria.</li>
</ul>
-<p>Some of the features offered by the Storage Access Framework are as follows:</p>
+<p>Some of the features offered by the SAF are as follows:</p>
<ul>
<li>Lets users browse content from all document providers, not just a single app.</li>
<li>Makes it possible for your app to have long term, persistent access to
@@ -87,7 +117,7 @@ providers, which only appear if the drive is plugged in. </li>
<h2 id ="overview">Overview</h2>
-<p>The Storage Access Framework centers around a content provider that is a
+<p>The SAF centers around a content provider that is a
subclass of the {@link android.provider.DocumentsProvider} class. Within a <em>document provider</em>, data is
structured as a traditional file hierarchy:</p>
<p><img src="{@docRoot}images/providers/storage_datamodel.png" alt="data model" /></p>
@@ -134,7 +164,7 @@ file hierarchy. However, you can physically store your data however you like, as
long as it can be accessed through the {@link android.provider.DocumentsProvider} API. For example, you
could use tag-based cloud storage for your data.</p>
-<p>Figure 2 shows an example of how a photo app might use the Storage Access Framework
+<p>Figure 2 shows an example of how a photo app might use the SAF
to access stored data:</p>
<p><img src="{@docRoot}images/providers/storage_dataflow.png" alt="app" /></p>
@@ -143,7 +173,7 @@ to access stored data:</p>
<p>Note the following:</p>
<ul>
-<li>In the Storage Access Framework, providers and clients don't interact
+<li>In the SAF, providers and clients don't interact
directly. A client requests permission to interact
with files (that is, to read, edit, create, or delete files).</li>
@@ -430,7 +460,7 @@ DocumentsContract.deleteDocument(getContentResolver(), uri);
<h3 id="edit">Edit a document</h3>
-<p>You can use the Storage Access Framework to edit a text document in place.
+<p>You can use the SAF to edit a text document in place.
This snippet fires
the {@link android.content.Intent#ACTION_OPEN_DOCUMENT} intent and uses the
category {@link android.content.Intent#CATEGORY_OPENABLE} to to display only
@@ -513,8 +543,8 @@ freshest data.</p>
<p>
If you're developing an app that provides storage services for files (such as
-a cloud save service), you can make your files available through the Storage
-Access Framework by writing a custom document provider. This section describes
+a cloud save service), you can make your files available through the
+SAF by writing a custom document provider. This section describes
how to do this.</p>
@@ -540,13 +570,25 @@ For example: <code>com.example.android.storageprovider.MyCloudProvider</code>.</
You must export your provider so that other apps can see it.</li>
<li>The attribute <code>android:grantUriPermissions</code> set to
-<code>&quot;true&quot;</code>. This allows the system to grant other apps access
+<code>&quot;true&quot;</code>. This setting allows the system to grant other apps access
to content in your provider. For a discussion of how to persist a grant for
a particular document, see <a href="#permissions">Persist permissions</a>.</li>
<li>The {@code MANAGE_DOCUMENTS} permission. By default a provider is available
-to everyone. Adding this permission restricts your provider to the system,
-which is important for security. </li>
+to everyone. Adding this permission restricts your provider to the system.
+This restriction is important for security.</li>
+
+<li>The {@code android:enabled} attribute set to a boolean value defined in a resource
+file. The purpose of this attribute is to disable the provider on devices running Android 4.3 or lower.
+For example, {@code android:enabled=&quot;&#64;bool/atLeastKitKat&quot;}. In
+addition to including this attribute in the manifest, you need to do the following:
+<ul>
+<li>In your {@code bool.xml} resources file under {@code res/values/}, add
+this line: <pre>&lt;bool name=&quot;atLeastKitKat&quot;&gt;false&lt;/bool&gt;</pre></li>
+
+<li>In your {@code bool.xml} resources file under {@code res/values-v19/}, add
+this line: <pre>&lt;bool name=&quot;atLeastKitKat&quot;&gt;true&lt;/bool&gt;</pre></li>
+</ul></li>
<li>An intent filter that includes the
{@code android.content.action.DOCUMENTS_PROVIDER} action, so that your provider
@@ -566,7 +608,8 @@ appears in the picker when the system searches for providers.</li>
android:authorities=&quot;com.example.android.storageprovider.documents&quot;
android:grantUriPermissions=&quot;true&quot;
android:exported=&quot;true&quot;
- android:permission=&quot;android.permission.MANAGE_DOCUMENTS&quot;&gt;
+ android:permission=&quot;android.permission.MANAGE_DOCUMENTS&quot;
+ android:enabled=&quot;&#64;bool/atLeastKitKat&quot;&gt;
&lt;intent-filter&gt;
&lt;action android:name=&quot;android.content.action.DOCUMENTS_PROVIDER&quot; /&gt;
&lt;/intent-filter&gt;
@@ -575,7 +618,7 @@ appears in the picker when the system searches for providers.</li>
&lt;/manifest&gt;</pre>
-<h4>Supporting devices running Android 4.3 and lower</h4>
+<h4 id="43">Supporting devices running Android 4.3 and lower</h4>
<p>The
{@link android.content.Intent#ACTION_OPEN_DOCUMENT} intent is only available
@@ -583,7 +626,7 @@ on devices running Android 4.4 and higher.
If you want your application to support {@link android.content.Intent#ACTION_GET_CONTENT}
to accommodate devices that are running Android 4.3 and lower, you should
disable the {@link android.content.Intent#ACTION_GET_CONTENT} intent filter in
-your manifest if a device is running Android 4.4 or higher. A
+your manifest for devices running Android 4.4 or higher. A
document provider and {@link android.content.Intent#ACTION_GET_CONTENT} should be considered
mutually exclusive. If you support both of them simultaneously, your app will
appear twice in the system picker UI, offering two different ways of accessing
@@ -630,7 +673,7 @@ implementing contract classes, as described in the
<a href="{@docRoot}guide/topics/providers/content-provider-creating.html#ContractClass">
Content Providers</a> developers guide. A contract class is a {@code public final} class
that contains constant definitions for the URIs, column names, MIME types, and
-other metadata that pertain to the provider. The Storage Access Framework
+other metadata that pertain to the provider. The SAF
provides these contract classes for you, so you don't need to write your
own:</p>
@@ -872,4 +915,4 @@ available if the user is logged into the provider.</p>
getContentResolver().notifyChange(DocumentsContract
.buildRootsUri(AUTHORITY), null);
}
-</pre>
+</pre> \ No newline at end of file
diff --git a/docs/html/guide/topics/resources/runtime-changes.jd b/docs/html/guide/topics/resources/runtime-changes.jd
index 45a548a..d074873 100644
--- a/docs/html/guide/topics/resources/runtime-changes.jd
+++ b/docs/html/guide/topics/resources/runtime-changes.jd
@@ -53,7 +53,7 @@ situation, you have two other options:</p>
<ol type="a">
<li><a href="#RetainingAnObject">Retain an object during a configuration change</a>
<p>Allow your activity to restart when a configuration changes, but carry a stateful
-{@link java.lang.Object} to the new instance of your activity.</p>
+object to the new instance of your activity.</p>
</li>
<li><a href="#HandlingTheChange">Handle the configuration change yourself</a>
@@ -73,40 +73,53 @@ activity state with the {@link android.os.Bundle} that the system saves for you
android.app.Activity#onSaveInstanceState(Bundle) onSaveInstanceState()} callback&mdash;it is not
designed to carry large objects (such as bitmaps) and the data within it must be serialized then
deserialized, which can consume a lot of memory and make the configuration change slow. In such a
-situation, you can alleviate the burden of reinitializing your activity by retaining a stateful
-{@link java.lang.Object} when your activity is restarted due to a configuration change.</p>
+situation, you can alleviate the burden of reinitializing your activity by retaining a {@link
+android.app.Fragment} when your activity is restarted due to a configuration change. This fragment
+can contain references to stateful objects that you want to retain.</p>
+
+<p>When the Android system shuts down your activity due to a configuration change, the fragments
+of your activity that you have marked to retain are not destroyed. You can add such fragments to
+your activity to preserve stateful objects.</p>
+
+<p>To retain stateful objects in a fragment during a runtime configuration change:</p>
-<p>To retain an object during a runtime configuration change:</p>
<ol>
- <li>Override the {@link android.app.Activity#onRetainNonConfigurationInstance()} method to return
-the object you would like to retain.</li>
- <li>When your activity is created again, call {@link
-android.app.Activity#getLastNonConfigurationInstance()} to recover your object.</li>
+ <li>Extend the {@link android.app.Fragment} class and declare references to your stateful
+ objects.</li>
+ <li>Call {@link android.app.Fragment#setRetainInstance(boolean)} when the fragment is created.
+ </li>
+ <li>Add the fragment to your activity.</li>
+ <li>Use {@link android.app.FragmentManager} to retrieve the fragment when the activity is
+ restarted.</li>
</ol>
-<p>When the Android system shuts down your activity due to a configuration change, it calls {@link
-android.app.Activity#onRetainNonConfigurationInstance()} between the {@link
-android.app.Activity#onStop()} and {@link android.app.Activity#onDestroy()} callbacks. In your
-implementation of {@link android.app.Activity#onRetainNonConfigurationInstance()}, you can return
-any {@link java.lang.Object} that you need in order to efficiently restore your state after the
-configuration change.</p>
-
-<p>A scenario in which this can be valuable is if your application loads a lot of data from the
-web. If the user changes the orientation of the device and the activity restarts, your application
-must re-fetch the data, which could be slow. What you can do instead is implement
-{@link android.app.Activity#onRetainNonConfigurationInstance()} to return an object carrying your
-data and then retrieve the data when your activity starts again with {@link
-android.app.Activity#getLastNonConfigurationInstance()}. For example:</p>
+<p>For example, define your fragment as follows:</p>
<pre>
-&#64;Override
-public Object onRetainNonConfigurationInstance() {
- final MyDataObject data = collectMyLoadedData();
- return data;
+public class RetainedFragment extends Fragment {
+
+ // data object we want to retain
+ private MyDataObject data;
+
+ // this method is only called once for this fragment
+ &#64;Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ // retain this fragment
+ setRetainInstance(true);
+ }
+
+ public void setData(MyDataObject data) {
+ this.data = data;
+ }
+
+ public MyDataObject getData() {
+ return data;
+ }
}
</pre>
-<p class="caution"><strong>Caution:</strong> While you can return any object, you
+<p class="caution"><strong>Caution:</strong> While you can store any object, you
should never pass an object that is tied to the {@link android.app.Activity}, such as a {@link
android.graphics.drawable.Drawable}, an {@link android.widget.Adapter}, a {@link android.view.View}
or any other object that's associated with a {@link android.content.Context}. If you do, it will
@@ -114,26 +127,51 @@ leak all the views and resources of the original activity instance. (Leaking res
means that your application maintains a hold on them and they cannot be garbage-collected, so
lots of memory can be lost.)</p>
-<p>Then retrieve the data when your activity starts again:</p>
+<p>Then use {@link android.app.FragmentManager} to add the fragment to the activity.
+You can obtain the data object from the fragment when the activity starts again during runtime
+configuration changes. For example, define your activity as follows:</p>
<pre>
-&#64;Override
-public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
+public class MyActivity extends Activity {
+
+ private RetainedFragment dataFragment;
+
+ &#64;Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ // find the retained fragment on activity restarts
+ FragmentManager fm = getFragmentManager();
+ dataFragment = (DataFragment) fm.findFragmentByTag(“data”);
+
+ // create the fragment and data the first time
+ if (dataFragment == null) {
+ // add the fragment
+ dataFragment = new DataFragment();
+ fm.beginTransaction().add(dataFragment, “data”).commit();
+ // load the data from the web
+ dataFragment.setData(loadMyData());
+ }
+
+ // the data is available in dataFragment.getData()
+ ...
+ }
- final MyDataObject data = (MyDataObject) getLastNonConfigurationInstance();
- if (data == null) {
- data = loadMyData();
+ &#64;Override
+ public void onDestroy() {
+ super.onDestroy();
+ // store the data in the fragment
+ dataFragment.setData(collectMyLoadedData());
}
- ...
}
</pre>
-<p>In this case, {@link android.app.Activity#getLastNonConfigurationInstance()} returns the data
-saved by {@link android.app.Activity#onRetainNonConfigurationInstance()}. If {@code data} is null
-(which happens when the activity starts due to any reason other than a configuration change) then
-this code loads the data object from the original source.</p>
+<p>In this example, {@link android.app.Activity#onCreate(Bundle) onCreate()} adds a fragment
+or restores a reference to it. {@link android.app.Activity#onCreate(Bundle) onCreate()} also
+stores the stateful object inside the fragment instance.
+{@link android.app.Activity#onDestroy() onDestroy()} updates the stateful object inside the
+retained fragment instance.</p>
diff --git a/docs/html/guide/topics/security/permissions.jd b/docs/html/guide/topics/security/permissions.jd
index 4ad9b7c..6f919da 100644
--- a/docs/html/guide/topics/security/permissions.jd
+++ b/docs/html/guide/topics/security/permissions.jd
@@ -1,4 +1,4 @@
-page.title=Permissions
+page.title=System Permissions
@jd:body
<div id="qv-wrapper">
@@ -20,10 +20,6 @@ page.title=Permissions
</ol>
</div>
</div>
-<p>This document describes how application developers can use the
-security features provided by Android. A more general <a
-href="http://source.android.com/tech/security/index.html"> Android Security
-Overview</a> is provided in the Android Open Source Project.</p>
<p>Android is a privilege-separated operating system, in which each
application runs with a distinct system identity (Linux user ID and group
@@ -33,7 +29,13 @@ Linux thereby isolates applications from each other and from the system.</p>
<p>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>
+ad hoc access to specific pieces of data.</p>
+
+<p>This document describes how application developers can use the
+security features provided by Android. A more general <a
+href="http://source.android.com/tech/security/index.html"> Android Security
+Overview</a> is provided in the Android Open Source Project.</p>
+
<a name="arch"></a>
<h2>Security Architecture</h2>
@@ -42,10 +44,10 @@ ad-hoc access to specific pieces of data.</p>
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>
+emails), reading or writing another application's files, performing
+network access, keeping the device awake, and so on.</p>
-<p>Because Android sandboxes applications from each other, applications
+<p>Because each Android application operates in a process sandbox, applications
must explicitly share resources and data. They do this by declaring the
<em>permissions</em> they need for additional capabilities not provided by
the basic sandbox. Applications statically declare the permissions they
@@ -65,10 +67,10 @@ other.</p>
<a name="signing"></a>
<h2>Application Signing</h2>
-<p>All Android applications (.apk files) must be signed with a certificate
+<p>All APKs ({@code .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,
+signed by a certificate authority; it is perfectly allowable, and typical,
for Android applications to use self-signed certificates. The purpose of
certificates in Android is to distinguish application authors. This allows
the system to grant or deny applications access to <a
@@ -86,7 +88,7 @@ device. On a different device, the same package may have a different UID;
what matters is that each package has a distinct UID on a given device.</p>
<p>Because security enforcement happens at the
-process level, the code of any two packages can not normally
+process level, the code of any two packages cannot 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
@@ -114,7 +116,7 @@ been set appropriately so any other application can see it.</p>
<h2>Using Permissions</h2>
<p>A basic Android application has no permissions associated with it by default,
-meaning it can not do anything that would adversely impact the user experience
+meaning it cannot 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>
@@ -133,9 +135,9 @@ specify:</p>
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
+are done while an application is running; the app is either 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
+permission is not granted and any attempt to use the feature fails
without prompting the user.</p>
<p>Often times a permission failure will result in a {@link
@@ -146,6 +148,12 @@ 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>However, in a normal user situation (such as when the app is installed
+from Google Play Store), an app cannot be installed if the user does not grant the app
+each of the requested permissions. So you generally don't need to worry about runtime failures
+caused by missing permissions because the mere fact that the app is installed at all
+means that your app has been granted its desired permissions.</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
@@ -433,3 +441,37 @@ android:grantUriPermissions} attribute or
{@link android.content.Context#checkUriPermission Context.checkUriPermission()}
methods.</p>
+
+
+
+
+<div class="next-docs">
+<div class="col-6">
+ <h2 class="norule">Continue reading about:</h2>
+ <dl>
+ <dt><a href="{@docRoot}guide/topics/manifest/uses-feature-element.html#permissions"
+ >Permissions that Imply Feature Requirements</a></dt>
+ <dd>Information about how requesting some permissions will implicitly restrict your app
+ to devices that include the corresponding hardware or software feature.</dd>
+ <dt><a href="{@docRoot}guide/topics/manifest/uses-permission-element.html">{@code
+ &lt;uses-permission>}</a></dt>
+ <dd>API reference for the manifest tag that declare's your app's required system permissions.
+ </dd>
+ <dt>{@link android.Manifest.permission}</dt>
+ <dd>API reference for all system permissions.</dd>
+ </dl>
+</div>
+<div class="col-6">
+ <h2 class="norule">You might also be interested in:</h2>
+ <dl>
+ <dt><a href="{@docRoot}guide/practices/compatibility.html"
+ >Device Compatibility</a></dt>
+ <dd>Information about Android works on different types of devices and an introduction
+ to how you can optimize your app for each device or restrict your app's availability
+ to different devices.</dd>
+ <dt><a href="{@docRoot}http://source.android.com/devices/tech/security/index.html"
+ class="external-link">Android Security Overview</a></dt>
+ <dd>A detailed discussion about the Android platform's security model.</dd>
+ </dl>
+</div>
+</div>
diff --git a/docs/html/guide/topics/ui/dialogs.jd b/docs/html/guide/topics/ui/dialogs.jd
index d934c4b..043879c 100644
--- a/docs/html/guide/topics/ui/dialogs.jd
+++ b/docs/html/guide/topics/ui/dialogs.jd
@@ -281,7 +281,7 @@ use the {@link android.app.AlertDialog.Builder#setItems setItems()} method:</p>
&#64;Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setTitle(R.string.pick_color);
+ builder.setTitle(R.string.pick_color)
.setItems(R.array.colors_array, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
// The 'which' argument contains the index position