Home | History | Annotate | Download | only in content
      1 /*
      2  * Copyright (C) 2006 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.content;
     18 
     19 import org.xmlpull.v1.XmlPullParser;
     20 import org.xmlpull.v1.XmlPullParserException;
     21 
     22 import android.annotation.SdkConstant;
     23 import android.annotation.SdkConstant.SdkConstantType;
     24 import android.content.pm.ActivityInfo;
     25 import android.content.pm.PackageManager;
     26 import android.content.pm.ResolveInfo;
     27 import android.content.res.Resources;
     28 import android.content.res.TypedArray;
     29 import android.graphics.Rect;
     30 import android.net.Uri;
     31 import android.os.Bundle;
     32 import android.os.IBinder;
     33 import android.os.Parcel;
     34 import android.os.Parcelable;
     35 import android.util.AttributeSet;
     36 import android.util.Log;
     37 
     38 import com.android.internal.util.XmlUtils;
     39 
     40 import java.io.IOException;
     41 import java.io.Serializable;
     42 import java.net.URISyntaxException;
     43 import java.util.ArrayList;
     44 import java.util.HashSet;
     45 import java.util.Iterator;
     46 import java.util.Set;
     47 
     48 /**
     49  * An intent is an abstract description of an operation to be performed.  It
     50  * can be used with {@link Context#startActivity(Intent) startActivity} to
     51  * launch an {@link android.app.Activity},
     52  * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
     53  * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
     54  * and {@link android.content.Context#startService} or
     55  * {@link android.content.Context#bindService} to communicate with a
     56  * background {@link android.app.Service}.
     57  *
     58  * <p>An Intent provides a facility for performing late runtime binding between the code in
     59  * different applications. Its most significant use is in the launching of activities, where it
     60  * can be thought of as the glue between activities. It is basically a passive data structure
     61  * holding an abstract description of an action to be performed.</p>
     62  *
     63  * <div class="special reference">
     64  * <h3>Developer Guides</h3>
     65  * <p>For information about how to create and resolve intents, read the
     66  * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
     67  * developer guide.</p>
     68  * </div>
     69  *
     70  * <a name="IntentStructure"></a>
     71  * <h3>Intent Structure</h3>
     72  * <p>The primary pieces of information in an intent are:</p>
     73  *
     74  * <ul>
     75  *   <li> <p><b>action</b> -- The general action to be performed, such as
     76  *     {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
     77  *     etc.</p>
     78  *   </li>
     79  *   <li> <p><b>data</b> -- The data to operate on, such as a person record
     80  *     in the contacts database, expressed as a {@link android.net.Uri}.</p>
     81  *   </li>
     82  * </ul>
     83  *
     84  *
     85  * <p>Some examples of action/data pairs are:</p>
     86  *
     87  * <ul>
     88  *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
     89  *     information about the person whose identifier is "1".</p>
     90  *   </li>
     91  *   <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
     92  *     the phone dialer with the person filled in.</p>
     93  *   </li>
     94  *   <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
     95  *     the phone dialer with the given number filled in.  Note how the
     96  *     VIEW action does what what is considered the most reasonable thing for
     97  *     a particular URI.</p>
     98  *   </li>
     99  *   <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
    100  *     the phone dialer with the given number filled in.</p>
    101  *   </li>
    102  *   <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
    103  *     information about the person whose identifier is "1".</p>
    104  *   </li>
    105  *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
    106  *     a list of people, which the user can browse through.  This example is a
    107  *     typical top-level entry into the Contacts application, showing you the
    108  *     list of people. Selecting a particular person to view would result in a
    109  *     new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
    110  *     being used to start an activity to display that person.</p>
    111  *   </li>
    112  * </ul>
    113  *
    114  * <p>In addition to these primary attributes, there are a number of secondary
    115  * attributes that you can also include with an intent:</p>
    116  *
    117  * <ul>
    118  *     <li> <p><b>category</b> -- Gives additional information about the action
    119  *         to execute.  For example, {@link #CATEGORY_LAUNCHER} means it should
    120  *         appear in the Launcher as a top-level application, while
    121  *         {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
    122  *         of alternative actions the user can perform on a piece of data.</p>
    123  *     <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
    124  *         intent data.  Normally the type is inferred from the data itself.
    125  *         By setting this attribute, you disable that evaluation and force
    126  *         an explicit type.</p>
    127  *     <li> <p><b>component</b> -- Specifies an explicit name of a component
    128  *         class to use for the intent.  Normally this is determined by looking
    129  *         at the other information in the intent (the action, data/type, and
    130  *         categories) and matching that with a component that can handle it.
    131  *         If this attribute is set then none of the evaluation is performed,
    132  *         and this component is used exactly as is.  By specifying this attribute,
    133  *         all of the other Intent attributes become optional.</p>
    134  *     <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
    135  *         This can be used to provide extended information to the component.
    136  *         For example, if we have a action to send an e-mail message, we could
    137  *         also include extra pieces of data here to supply a subject, body,
    138  *         etc.</p>
    139  * </ul>
    140  *
    141  * <p>Here are some examples of other operations you can specify as intents
    142  * using these additional parameters:</p>
    143  *
    144  * <ul>
    145  *   <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
    146  *     Launch the home screen.</p>
    147  *   </li>
    148  *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
    149  *     <i>{@link android.provider.Contacts.Phones#CONTENT_URI
    150  *     vnd.android.cursor.item/phone}</i></b>
    151  *     -- Display the list of people's phone numbers, allowing the user to
    152  *     browse through them and pick one and return it to the parent activity.</p>
    153  *   </li>
    154  *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
    155  *     <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
    156  *     -- Display all pickers for data that can be opened with
    157  *     {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
    158  *     allowing the user to pick one of them and then some data inside of it
    159  *     and returning the resulting URI to the caller.  This can be used,
    160  *     for example, in an e-mail application to allow the user to pick some
    161  *     data to include as an attachment.</p>
    162  *   </li>
    163  * </ul>
    164  *
    165  * <p>There are a variety of standard Intent action and category constants
    166  * defined in the Intent class, but applications can also define their own.
    167  * These strings use java style scoping, to ensure they are unique -- for
    168  * example, the standard {@link #ACTION_VIEW} is called
    169  * "android.intent.action.VIEW".</p>
    170  *
    171  * <p>Put together, the set of actions, data types, categories, and extra data
    172  * defines a language for the system allowing for the expression of phrases
    173  * such as "call john smith's cell".  As applications are added to the system,
    174  * they can extend this language by adding new actions, types, and categories, or
    175  * they can modify the behavior of existing phrases by supplying their own
    176  * activities that handle them.</p>
    177  *
    178  * <a name="IntentResolution"></a>
    179  * <h3>Intent Resolution</h3>
    180  *
    181  * <p>There are two primary forms of intents you will use.
    182  *
    183  * <ul>
    184  *     <li> <p><b>Explicit Intents</b> have specified a component (via
    185  *     {@link #setComponent} or {@link #setClass}), which provides the exact
    186  *     class to be run.  Often these will not include any other information,
    187  *     simply being a way for an application to launch various internal
    188  *     activities it has as the user interacts with the application.
    189  *
    190  *     <li> <p><b>Implicit Intents</b> have not specified a component;
    191  *     instead, they must include enough information for the system to
    192  *     determine which of the available components is best to run for that
    193  *     intent.
    194  * </ul>
    195  *
    196  * <p>When using implicit intents, given such an arbitrary intent we need to
    197  * know what to do with it. This is handled by the process of <em>Intent
    198  * resolution</em>, which maps an Intent to an {@link android.app.Activity},
    199  * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
    200  * more activities/receivers) that can handle it.</p>
    201  *
    202  * <p>The intent resolution mechanism basically revolves around matching an
    203  * Intent against all of the &lt;intent-filter&gt; descriptions in the
    204  * installed application packages.  (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
    205  * objects explicitly registered with {@link Context#registerReceiver}.)  More
    206  * details on this can be found in the documentation on the {@link
    207  * IntentFilter} class.</p>
    208  *
    209  * <p>There are three pieces of information in the Intent that are used for
    210  * resolution: the action, type, and category.  Using this information, a query
    211  * is done on the {@link PackageManager} for a component that can handle the
    212  * intent. The appropriate component is determined based on the intent
    213  * information supplied in the <code>AndroidManifest.xml</code> file as
    214  * follows:</p>
    215  *
    216  * <ul>
    217  *     <li> <p>The <b>action</b>, if given, must be listed by the component as
    218  *         one it handles.</p>
    219  *     <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
    220  *         already supplied in the Intent.  Like the action, if a type is
    221  *         included in the intent (either explicitly or implicitly in its
    222  *         data), then this must be listed by the component as one it handles.</p>
    223  *     <li> For data that is not a <code>content:</code> URI and where no explicit
    224  *         type is included in the Intent, instead the <b>scheme</b> of the
    225  *         intent data (such as <code>http:</code> or <code>mailto:</code>) is
    226  *         considered. Again like the action, if we are matching a scheme it
    227  *         must be listed by the component as one it can handle.
    228  *     <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
    229  *         by the activity as categories it handles.  That is, if you include
    230  *         the categories {@link #CATEGORY_LAUNCHER} and
    231  *         {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
    232  *         with an intent that lists <em>both</em> of those categories.
    233  *         Activities will very often need to support the
    234  *         {@link #CATEGORY_DEFAULT} so that they can be found by
    235  *         {@link Context#startActivity Context.startActivity()}.</p>
    236  * </ul>
    237  *
    238  * <p>For example, consider the Note Pad sample application that
    239  * allows user to browse through a list of notes data and view details about
    240  * individual items.  Text in italics indicate places were you would replace a
    241  * name with one specific to your own package.</p>
    242  *
    243  * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    244  *       package="<i>com.android.notepad</i>"&gt;
    245  *     &lt;application android:icon="@drawable/app_notes"
    246  *             android:label="@string/app_name"&gt;
    247  *
    248  *         &lt;provider class=".NotePadProvider"
    249  *                 android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
    250  *
    251  *         &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
    252  *             &lt;intent-filter&gt;
    253  *                 &lt;action android:name="android.intent.action.MAIN" /&gt;
    254  *                 &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
    255  *             &lt;/intent-filter&gt;
    256  *             &lt;intent-filter&gt;
    257  *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
    258  *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
    259  *                 &lt;action android:name="android.intent.action.PICK" /&gt;
    260  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    261  *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
    262  *             &lt;/intent-filter&gt;
    263  *             &lt;intent-filter&gt;
    264  *                 &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
    265  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    266  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    267  *             &lt;/intent-filter&gt;
    268  *         &lt;/activity&gt;
    269  *
    270  *         &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
    271  *             &lt;intent-filter android:label="@string/resolve_edit"&gt;
    272  *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
    273  *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
    274  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    275  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    276  *             &lt;/intent-filter&gt;
    277  *
    278  *             &lt;intent-filter&gt;
    279  *                 &lt;action android:name="android.intent.action.INSERT" /&gt;
    280  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    281  *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
    282  *             &lt;/intent-filter&gt;
    283  *
    284  *         &lt;/activity&gt;
    285  *
    286  *         &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
    287  *                 android:theme="@android:style/Theme.Dialog"&gt;
    288  *             &lt;intent-filter android:label="@string/resolve_title"&gt;
    289  *                 &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
    290  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    291  *                 &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
    292  *                 &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
    293  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    294  *             &lt;/intent-filter&gt;
    295  *         &lt;/activity&gt;
    296  *
    297  *     &lt;/application&gt;
    298  * &lt;/manifest&gt;</pre>
    299  *
    300  * <p>The first activity,
    301  * <code>com.android.notepad.NotesList</code>, serves as our main
    302  * entry into the app.  It can do three things as described by its three intent
    303  * templates:
    304  * <ol>
    305  * <li><pre>
    306  * &lt;intent-filter&gt;
    307  *     &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
    308  *     &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
    309  * &lt;/intent-filter&gt;</pre>
    310  * <p>This provides a top-level entry into the NotePad application: the standard
    311  * MAIN action is a main entry point (not requiring any other information in
    312  * the Intent), and the LAUNCHER category says that this entry point should be
    313  * listed in the application launcher.</p>
    314  * <li><pre>
    315  * &lt;intent-filter&gt;
    316  *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
    317  *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
    318  *     &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
    319  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
    320  *     &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
    321  * &lt;/intent-filter&gt;</pre>
    322  * <p>This declares the things that the activity can do on a directory of
    323  * notes.  The type being supported is given with the &lt;type&gt; tag, where
    324  * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
    325  * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
    326  * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
    327  * The activity allows the user to view or edit the directory of data (via
    328  * the VIEW and EDIT actions), or to pick a particular note and return it
    329  * to the caller (via the PICK action).  Note also the DEFAULT category
    330  * supplied here: this is <em>required</em> for the
    331  * {@link Context#startActivity Context.startActivity} method to resolve your
    332  * activity when its component name is not explicitly specified.</p>
    333  * <li><pre>
    334  * &lt;intent-filter&gt;
    335  *     &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
    336  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
    337  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    338  * &lt;/intent-filter&gt;</pre>
    339  * <p>This filter describes the ability return to the caller a note selected by
    340  * the user without needing to know where it came from.  The data type
    341  * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
    342  * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
    343  * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
    344  * The GET_CONTENT action is similar to the PICK action, where the activity
    345  * will return to its caller a piece of data selected by the user.  Here,
    346  * however, the caller specifies the type of data they desire instead of
    347  * the type of data the user will be picking from.</p>
    348  * </ol>
    349  *
    350  * <p>Given these capabilities, the following intents will resolve to the
    351  * NotesList activity:</p>
    352  *
    353  * <ul>
    354  *     <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
    355  *         activities that can be used as top-level entry points into an
    356  *         application.</p>
    357  *     <li> <p><b>{ action=android.app.action.MAIN,
    358  *         category=android.app.category.LAUNCHER }</b> is the actual intent
    359  *         used by the Launcher to populate its top-level list.</p>
    360  *     <li> <p><b>{ action=android.intent.action.VIEW
    361  *          data=content://com.google.provider.NotePad/notes }</b>
    362  *         displays a list of all the notes under
    363  *         "content://com.google.provider.NotePad/notes", which
    364  *         the user can browse through and see the details on.</p>
    365  *     <li> <p><b>{ action=android.app.action.PICK
    366  *          data=content://com.google.provider.NotePad/notes }</b>
    367  *         provides a list of the notes under
    368  *         "content://com.google.provider.NotePad/notes", from which
    369  *         the user can pick a note whose data URL is returned back to the caller.</p>
    370  *     <li> <p><b>{ action=android.app.action.GET_CONTENT
    371  *          type=vnd.android.cursor.item/vnd.google.note }</b>
    372  *         is similar to the pick action, but allows the caller to specify the
    373  *         kind of data they want back so that the system can find the appropriate
    374  *         activity to pick something of that data type.</p>
    375  * </ul>
    376  *
    377  * <p>The second activity,
    378  * <code>com.android.notepad.NoteEditor</code>, shows the user a single
    379  * note entry and allows them to edit it.  It can do two things as described
    380  * by its two intent templates:
    381  * <ol>
    382  * <li><pre>
    383  * &lt;intent-filter android:label="@string/resolve_edit"&gt;
    384  *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
    385  *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
    386  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
    387  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    388  * &lt;/intent-filter&gt;</pre>
    389  * <p>The first, primary, purpose of this activity is to let the user interact
    390  * with a single note, as decribed by the MIME type
    391  * <code>vnd.android.cursor.item/vnd.google.note</code>.  The activity can
    392  * either VIEW a note or allow the user to EDIT it.  Again we support the
    393  * DEFAULT category to allow the activity to be launched without explicitly
    394  * specifying its component.</p>
    395  * <li><pre>
    396  * &lt;intent-filter&gt;
    397  *     &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
    398  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
    399  *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
    400  * &lt;/intent-filter&gt;</pre>
    401  * <p>The secondary use of this activity is to insert a new note entry into
    402  * an existing directory of notes.  This is used when the user creates a new
    403  * note: the INSERT action is executed on the directory of notes, causing
    404  * this activity to run and have the user create the new note data which
    405  * it then adds to the content provider.</p>
    406  * </ol>
    407  *
    408  * <p>Given these capabilities, the following intents will resolve to the
    409  * NoteEditor activity:</p>
    410  *
    411  * <ul>
    412  *     <li> <p><b>{ action=android.intent.action.VIEW
    413  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
    414  *         shows the user the content of note <var>{ID}</var>.</p>
    415  *     <li> <p><b>{ action=android.app.action.EDIT
    416  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
    417  *         allows the user to edit the content of note <var>{ID}</var>.</p>
    418  *     <li> <p><b>{ action=android.app.action.INSERT
    419  *          data=content://com.google.provider.NotePad/notes }</b>
    420  *         creates a new, empty note in the notes list at
    421  *         "content://com.google.provider.NotePad/notes"
    422  *         and allows the user to edit it.  If they keep their changes, the URI
    423  *         of the newly created note is returned to the caller.</p>
    424  * </ul>
    425  *
    426  * <p>The last activity,
    427  * <code>com.android.notepad.TitleEditor</code>, allows the user to
    428  * edit the title of a note.  This could be implemented as a class that the
    429  * application directly invokes (by explicitly setting its component in
    430  * the Intent), but here we show a way you can publish alternative
    431  * operations on existing data:</p>
    432  *
    433  * <pre>
    434  * &lt;intent-filter android:label="@string/resolve_title"&gt;
    435  *     &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
    436  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
    437  *     &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
    438  *     &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
    439  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    440  * &lt;/intent-filter&gt;</pre>
    441  *
    442  * <p>In the single intent template here, we
    443  * have created our own private action called
    444  * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
    445  * edit the title of a note.  It must be invoked on a specific note
    446  * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
    447  * view and edit actions, but here displays and edits the title contained
    448  * in the note data.
    449  *
    450  * <p>In addition to supporting the default category as usual, our title editor
    451  * also supports two other standard categories: ALTERNATIVE and
    452  * SELECTED_ALTERNATIVE.  Implementing
    453  * these categories allows others to find the special action it provides
    454  * without directly knowing about it, through the
    455  * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
    456  * more often to build dynamic menu items with
    457  * {@link android.view.Menu#addIntentOptions}.  Note that in the intent
    458  * template here was also supply an explicit name for the template
    459  * (via <code>android:label="@string/resolve_title"</code>) to better control
    460  * what the user sees when presented with this activity as an alternative
    461  * action to the data they are viewing.
    462  *
    463  * <p>Given these capabilities, the following intent will resolve to the
    464  * TitleEditor activity:</p>
    465  *
    466  * <ul>
    467  *     <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
    468  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
    469  *         displays and allows the user to edit the title associated
    470  *         with note <var>{ID}</var>.</p>
    471  * </ul>
    472  *
    473  * <h3>Standard Activity Actions</h3>
    474  *
    475  * <p>These are the current standard actions that Intent defines for launching
    476  * activities (usually through {@link Context#startActivity}.  The most
    477  * important, and by far most frequently used, are {@link #ACTION_MAIN} and
    478  * {@link #ACTION_EDIT}.
    479  *
    480  * <ul>
    481  *     <li> {@link #ACTION_MAIN}
    482  *     <li> {@link #ACTION_VIEW}
    483  *     <li> {@link #ACTION_ATTACH_DATA}
    484  *     <li> {@link #ACTION_EDIT}
    485  *     <li> {@link #ACTION_PICK}
    486  *     <li> {@link #ACTION_CHOOSER}
    487  *     <li> {@link #ACTION_GET_CONTENT}
    488  *     <li> {@link #ACTION_DIAL}
    489  *     <li> {@link #ACTION_CALL}
    490  *     <li> {@link #ACTION_SEND}
    491  *     <li> {@link #ACTION_SENDTO}
    492  *     <li> {@link #ACTION_ANSWER}
    493  *     <li> {@link #ACTION_INSERT}
    494  *     <li> {@link #ACTION_DELETE}
    495  *     <li> {@link #ACTION_RUN}
    496  *     <li> {@link #ACTION_SYNC}
    497  *     <li> {@link #ACTION_PICK_ACTIVITY}
    498  *     <li> {@link #ACTION_SEARCH}
    499  *     <li> {@link #ACTION_WEB_SEARCH}
    500  *     <li> {@link #ACTION_FACTORY_TEST}
    501  * </ul>
    502  *
    503  * <h3>Standard Broadcast Actions</h3>
    504  *
    505  * <p>These are the current standard actions that Intent defines for receiving
    506  * broadcasts (usually through {@link Context#registerReceiver} or a
    507  * &lt;receiver&gt; tag in a manifest).
    508  *
    509  * <ul>
    510  *     <li> {@link #ACTION_TIME_TICK}
    511  *     <li> {@link #ACTION_TIME_CHANGED}
    512  *     <li> {@link #ACTION_TIMEZONE_CHANGED}
    513  *     <li> {@link #ACTION_BOOT_COMPLETED}
    514  *     <li> {@link #ACTION_PACKAGE_ADDED}
    515  *     <li> {@link #ACTION_PACKAGE_CHANGED}
    516  *     <li> {@link #ACTION_PACKAGE_REMOVED}
    517  *     <li> {@link #ACTION_PACKAGE_RESTARTED}
    518  *     <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
    519  *     <li> {@link #ACTION_UID_REMOVED}
    520  *     <li> {@link #ACTION_BATTERY_CHANGED}
    521  *     <li> {@link #ACTION_POWER_CONNECTED}
    522  *     <li> {@link #ACTION_POWER_DISCONNECTED}
    523  *     <li> {@link #ACTION_SHUTDOWN}
    524  * </ul>
    525  *
    526  * <h3>Standard Categories</h3>
    527  *
    528  * <p>These are the current standard categories that can be used to further
    529  * clarify an Intent via {@link #addCategory}.
    530  *
    531  * <ul>
    532  *     <li> {@link #CATEGORY_DEFAULT}
    533  *     <li> {@link #CATEGORY_BROWSABLE}
    534  *     <li> {@link #CATEGORY_TAB}
    535  *     <li> {@link #CATEGORY_ALTERNATIVE}
    536  *     <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
    537  *     <li> {@link #CATEGORY_LAUNCHER}
    538  *     <li> {@link #CATEGORY_INFO}
    539  *     <li> {@link #CATEGORY_HOME}
    540  *     <li> {@link #CATEGORY_PREFERENCE}
    541  *     <li> {@link #CATEGORY_TEST}
    542  *     <li> {@link #CATEGORY_CAR_DOCK}
    543  *     <li> {@link #CATEGORY_DESK_DOCK}
    544  *     <li> {@link #CATEGORY_LE_DESK_DOCK}
    545  *     <li> {@link #CATEGORY_HE_DESK_DOCK}
    546  *     <li> {@link #CATEGORY_CAR_MODE}
    547  *     <li> {@link #CATEGORY_APP_MARKET}
    548  * </ul>
    549  *
    550  * <h3>Standard Extra Data</h3>
    551  *
    552  * <p>These are the current standard fields that can be used as extra data via
    553  * {@link #putExtra}.
    554  *
    555  * <ul>
    556  *     <li> {@link #EXTRA_ALARM_COUNT}
    557  *     <li> {@link #EXTRA_BCC}
    558  *     <li> {@link #EXTRA_CC}
    559  *     <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
    560  *     <li> {@link #EXTRA_DATA_REMOVED}
    561  *     <li> {@link #EXTRA_DOCK_STATE}
    562  *     <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
    563  *     <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
    564  *     <li> {@link #EXTRA_DOCK_STATE_CAR}
    565  *     <li> {@link #EXTRA_DOCK_STATE_DESK}
    566  *     <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
    567  *     <li> {@link #EXTRA_DONT_KILL_APP}
    568  *     <li> {@link #EXTRA_EMAIL}
    569  *     <li> {@link #EXTRA_INITIAL_INTENTS}
    570  *     <li> {@link #EXTRA_INTENT}
    571  *     <li> {@link #EXTRA_KEY_EVENT}
    572  *     <li> {@link #EXTRA_PHONE_NUMBER}
    573  *     <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
    574  *     <li> {@link #EXTRA_REPLACING}
    575  *     <li> {@link #EXTRA_SHORTCUT_ICON}
    576  *     <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
    577  *     <li> {@link #EXTRA_SHORTCUT_INTENT}
    578  *     <li> {@link #EXTRA_STREAM}
    579  *     <li> {@link #EXTRA_SHORTCUT_NAME}
    580  *     <li> {@link #EXTRA_SUBJECT}
    581  *     <li> {@link #EXTRA_TEMPLATE}
    582  *     <li> {@link #EXTRA_TEXT}
    583  *     <li> {@link #EXTRA_TITLE}
    584  *     <li> {@link #EXTRA_UID}
    585  * </ul>
    586  *
    587  * <h3>Flags</h3>
    588  *
    589  * <p>These are the possible flags that can be used in the Intent via
    590  * {@link #setFlags} and {@link #addFlags}.  See {@link #setFlags} for a list
    591  * of all possible flags.
    592  */
    593 public class Intent implements Parcelable, Cloneable {
    594     // ---------------------------------------------------------------------
    595     // ---------------------------------------------------------------------
    596     // Standard intent activity actions (see action variable).
    597 
    598     /**
    599      *  Activity Action: Start as a main entry point, does not expect to
    600      *  receive data.
    601      *  <p>Input: nothing
    602      *  <p>Output: nothing
    603      */
    604     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    605     public static final String ACTION_MAIN = "android.intent.action.MAIN";
    606 
    607     /**
    608      * Activity Action: Display the data to the user.  This is the most common
    609      * action performed on data -- it is the generic action you can use on
    610      * a piece of data to get the most reasonable thing to occur.  For example,
    611      * when used on a contacts entry it will view the entry; when used on a
    612      * mailto: URI it will bring up a compose window filled with the information
    613      * supplied by the URI; when used with a tel: URI it will invoke the
    614      * dialer.
    615      * <p>Input: {@link #getData} is URI from which to retrieve data.
    616      * <p>Output: nothing.
    617      */
    618     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    619     public static final String ACTION_VIEW = "android.intent.action.VIEW";
    620 
    621     /**
    622      * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
    623      * performed on a piece of data.
    624      */
    625     public static final String ACTION_DEFAULT = ACTION_VIEW;
    626 
    627     /**
    628      * Used to indicate that some piece of data should be attached to some other
    629      * place.  For example, image data could be attached to a contact.  It is up
    630      * to the recipient to decide where the data should be attached; the intent
    631      * does not specify the ultimate destination.
    632      * <p>Input: {@link #getData} is URI of data to be attached.
    633      * <p>Output: nothing.
    634      */
    635     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    636     public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
    637 
    638     /**
    639      * Activity Action: Provide explicit editable access to the given data.
    640      * <p>Input: {@link #getData} is URI of data to be edited.
    641      * <p>Output: nothing.
    642      */
    643     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    644     public static final String ACTION_EDIT = "android.intent.action.EDIT";
    645 
    646     /**
    647      * Activity Action: Pick an existing item, or insert a new item, and then edit it.
    648      * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
    649      * The extras can contain type specific data to pass through to the editing/creating
    650      * activity.
    651      * <p>Output: The URI of the item that was picked.  This must be a content:
    652      * URI so that any receiver can access it.
    653      */
    654     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    655     public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
    656 
    657     /**
    658      * Activity Action: Pick an item from the data, returning what was selected.
    659      * <p>Input: {@link #getData} is URI containing a directory of data
    660      * (vnd.android.cursor.dir/*) from which to pick an item.
    661      * <p>Output: The URI of the item that was picked.
    662      */
    663     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    664     public static final String ACTION_PICK = "android.intent.action.PICK";
    665 
    666     /**
    667      * Activity Action: Creates a shortcut.
    668      * <p>Input: Nothing.</p>
    669      * <p>Output: An Intent representing the shortcut. The intent must contain three
    670      * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
    671      * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
    672      * (value: ShortcutIconResource).</p>
    673      *
    674      * @see #EXTRA_SHORTCUT_INTENT
    675      * @see #EXTRA_SHORTCUT_NAME
    676      * @see #EXTRA_SHORTCUT_ICON
    677      * @see #EXTRA_SHORTCUT_ICON_RESOURCE
    678      * @see android.content.Intent.ShortcutIconResource
    679      */
    680     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    681     public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
    682 
    683     /**
    684      * The name of the extra used to define the Intent of a shortcut.
    685      *
    686      * @see #ACTION_CREATE_SHORTCUT
    687      */
    688     public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
    689     /**
    690      * The name of the extra used to define the name of a shortcut.
    691      *
    692      * @see #ACTION_CREATE_SHORTCUT
    693      */
    694     public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
    695     /**
    696      * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
    697      *
    698      * @see #ACTION_CREATE_SHORTCUT
    699      */
    700     public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
    701     /**
    702      * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
    703      *
    704      * @see #ACTION_CREATE_SHORTCUT
    705      * @see android.content.Intent.ShortcutIconResource
    706      */
    707     public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
    708             "android.intent.extra.shortcut.ICON_RESOURCE";
    709 
    710     /**
    711      * Represents a shortcut/live folder icon resource.
    712      *
    713      * @see Intent#ACTION_CREATE_SHORTCUT
    714      * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
    715      * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
    716      * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
    717      */
    718     public static class ShortcutIconResource implements Parcelable {
    719         /**
    720          * The package name of the application containing the icon.
    721          */
    722         public String packageName;
    723 
    724         /**
    725          * The resource name of the icon, including package, name and type.
    726          */
    727         public String resourceName;
    728 
    729         /**
    730          * Creates a new ShortcutIconResource for the specified context and resource
    731          * identifier.
    732          *
    733          * @param context The context of the application.
    734          * @param resourceId The resource idenfitier for the icon.
    735          * @return A new ShortcutIconResource with the specified's context package name
    736          *         and icon resource idenfitier.
    737          */
    738         public static ShortcutIconResource fromContext(Context context, int resourceId) {
    739             ShortcutIconResource icon = new ShortcutIconResource();
    740             icon.packageName = context.getPackageName();
    741             icon.resourceName = context.getResources().getResourceName(resourceId);
    742             return icon;
    743         }
    744 
    745         /**
    746          * Used to read a ShortcutIconResource from a Parcel.
    747          */
    748         public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
    749             new Parcelable.Creator<ShortcutIconResource>() {
    750 
    751                 public ShortcutIconResource createFromParcel(Parcel source) {
    752                     ShortcutIconResource icon = new ShortcutIconResource();
    753                     icon.packageName = source.readString();
    754                     icon.resourceName = source.readString();
    755                     return icon;
    756                 }
    757 
    758                 public ShortcutIconResource[] newArray(int size) {
    759                     return new ShortcutIconResource[size];
    760                 }
    761             };
    762 
    763         /**
    764          * No special parcel contents.
    765          */
    766         public int describeContents() {
    767             return 0;
    768         }
    769 
    770         public void writeToParcel(Parcel dest, int flags) {
    771             dest.writeString(packageName);
    772             dest.writeString(resourceName);
    773         }
    774 
    775         @Override
    776         public String toString() {
    777             return resourceName;
    778         }
    779     }
    780 
    781     /**
    782      * Activity Action: Display an activity chooser, allowing the user to pick
    783      * what they want to before proceeding.  This can be used as an alternative
    784      * to the standard activity picker that is displayed by the system when
    785      * you try to start an activity with multiple possible matches, with these
    786      * differences in behavior:
    787      * <ul>
    788      * <li>You can specify the title that will appear in the activity chooser.
    789      * <li>The user does not have the option to make one of the matching
    790      * activities a preferred activity, and all possible activities will
    791      * always be shown even if one of them is currently marked as the
    792      * preferred activity.
    793      * </ul>
    794      * <p>
    795      * This action should be used when the user will naturally expect to
    796      * select an activity in order to proceed.  An example if when not to use
    797      * it is when the user clicks on a "mailto:" link.  They would naturally
    798      * expect to go directly to their mail app, so startActivity() should be
    799      * called directly: it will
    800      * either launch the current preferred app, or put up a dialog allowing the
    801      * user to pick an app to use and optionally marking that as preferred.
    802      * <p>
    803      * In contrast, if the user is selecting a menu item to send a picture
    804      * they are viewing to someone else, there are many different things they
    805      * may want to do at this point: send it through e-mail, upload it to a
    806      * web service, etc.  In this case the CHOOSER action should be used, to
    807      * always present to the user a list of the things they can do, with a
    808      * nice title given by the caller such as "Send this photo with:".
    809      * <p>
    810      * As a convenience, an Intent of this form can be created with the
    811      * {@link #createChooser} function.
    812      * <p>Input: No data should be specified.  get*Extra must have
    813      * a {@link #EXTRA_INTENT} field containing the Intent being executed,
    814      * and can optionally have a {@link #EXTRA_TITLE} field containing the
    815      * title text to display in the chooser.
    816      * <p>Output: Depends on the protocol of {@link #EXTRA_INTENT}.
    817      */
    818     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    819     public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
    820 
    821     /**
    822      * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
    823      *
    824      * @param target The Intent that the user will be selecting an activity
    825      * to perform.
    826      * @param title Optional title that will be displayed in the chooser.
    827      * @return Return a new Intent object that you can hand to
    828      * {@link Context#startActivity(Intent) Context.startActivity()} and
    829      * related methods.
    830      */
    831     public static Intent createChooser(Intent target, CharSequence title) {
    832         Intent intent = new Intent(ACTION_CHOOSER);
    833         intent.putExtra(EXTRA_INTENT, target);
    834         if (title != null) {
    835             intent.putExtra(EXTRA_TITLE, title);
    836         }
    837         return intent;
    838     }
    839     /**
    840      * Activity Action: Allow the user to select a particular kind of data and
    841      * return it.  This is different than {@link #ACTION_PICK} in that here we
    842      * just say what kind of data is desired, not a URI of existing data from
    843      * which the user can pick.  A ACTION_GET_CONTENT could allow the user to
    844      * create the data as it runs (for example taking a picture or recording a
    845      * sound), let them browser over the web and download the desired data,
    846      * etc.
    847      * <p>
    848      * There are two main ways to use this action: if you want an specific kind
    849      * of data, such as a person contact, you set the MIME type to the kind of
    850      * data you want and launch it with {@link Context#startActivity(Intent)}.
    851      * The system will then launch the best application to select that kind
    852      * of data for you.
    853      * <p>
    854      * You may also be interested in any of a set of types of content the user
    855      * can pick.  For example, an e-mail application that wants to allow the
    856      * user to add an attachment to an e-mail message can use this action to
    857      * bring up a list of all of the types of content the user can attach.
    858      * <p>
    859      * In this case, you should wrap the GET_CONTENT intent with a chooser
    860      * (through {@link #createChooser}), which will give the proper interface
    861      * for the user to pick how to send your data and allow you to specify
    862      * a prompt indicating what they are doing.  You will usually specify a
    863      * broad MIME type (such as image/* or {@literal *}/*), resulting in a
    864      * broad range of content types the user can select from.
    865      * <p>
    866      * When using such a broad GET_CONTENT action, it is often desireable to
    867      * only pick from data that can be represented as a stream.  This is
    868      * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
    869      * <p>
    870      * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
    871      * the launched content chooser only return results representing data that
    872      * is locally available on the device.  For example, if this extra is set
    873      * to true then an image picker should not show any pictures that are available
    874      * from a remote server but not already on the local device (thus requiring
    875      * they be downloaded when opened).
    876      * <p>
    877      * Input: {@link #getType} is the desired MIME type to retrieve.  Note
    878      * that no URI is supplied in the intent, as there are no constraints on
    879      * where the returned data originally comes from.  You may also include the
    880      * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
    881      * opened as a stream.  You may use {@link #EXTRA_LOCAL_ONLY} to limit content
    882      * selection to local data.
    883      * <p>
    884      * Output: The URI of the item that was picked.  This must be a content:
    885      * URI so that any receiver can access it.
    886      */
    887     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    888     public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
    889     /**
    890      * Activity Action: Dial a number as specified by the data.  This shows a
    891      * UI with the number being dialed, allowing the user to explicitly
    892      * initiate the call.
    893      * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
    894      * is URI of a phone number to be dialed or a tel: URI of an explicit phone
    895      * number.
    896      * <p>Output: nothing.
    897      */
    898     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    899     public static final String ACTION_DIAL = "android.intent.action.DIAL";
    900     /**
    901      * Activity Action: Perform a call to someone specified by the data.
    902      * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
    903      * is URI of a phone number to be dialed or a tel: URI of an explicit phone
    904      * number.
    905      * <p>Output: nothing.
    906      *
    907      * <p>Note: there will be restrictions on which applications can initiate a
    908      * call; most applications should use the {@link #ACTION_DIAL}.
    909      * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
    910      * numbers.  Applications can <strong>dial</strong> emergency numbers using
    911      * {@link #ACTION_DIAL}, however.
    912      */
    913     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    914     public static final String ACTION_CALL = "android.intent.action.CALL";
    915     /**
    916      * Activity Action: Perform a call to an emergency number specified by the
    917      * data.
    918      * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
    919      * tel: URI of an explicit phone number.
    920      * <p>Output: nothing.
    921      * @hide
    922      */
    923     public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
    924     /**
    925      * Activity action: Perform a call to any number (emergency or not)
    926      * specified by the data.
    927      * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
    928      * tel: URI of an explicit phone number.
    929      * <p>Output: nothing.
    930      * @hide
    931      */
    932     public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
    933     /**
    934      * Activity Action: Send a message to someone specified by the data.
    935      * <p>Input: {@link #getData} is URI describing the target.
    936      * <p>Output: nothing.
    937      */
    938     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    939     public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
    940     /**
    941      * Activity Action: Deliver some data to someone else.  Who the data is
    942      * being delivered to is not specified; it is up to the receiver of this
    943      * action to ask the user where the data should be sent.
    944      * <p>
    945      * When launching a SEND intent, you should usually wrap it in a chooser
    946      * (through {@link #createChooser}), which will give the proper interface
    947      * for the user to pick how to send your data and allow you to specify
    948      * a prompt indicating what they are doing.
    949      * <p>
    950      * Input: {@link #getType} is the MIME type of the data being sent.
    951      * get*Extra can have either a {@link #EXTRA_TEXT}
    952      * or {@link #EXTRA_STREAM} field, containing the data to be sent.  If
    953      * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
    954      * should be the MIME type of the data in EXTRA_STREAM.  Use {@literal *}/*
    955      * if the MIME type is unknown (this will only allow senders that can
    956      * handle generic data streams).
    957      * <p>
    958      * Optional standard extras, which may be interpreted by some recipients as
    959      * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
    960      * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
    961      * <p>
    962      * Output: nothing.
    963      */
    964     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    965     public static final String ACTION_SEND = "android.intent.action.SEND";
    966     /**
    967      * Activity Action: Deliver multiple data to someone else.
    968      * <p>
    969      * Like ACTION_SEND, except the data is multiple.
    970      * <p>
    971      * Input: {@link #getType} is the MIME type of the data being sent.
    972      * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
    973      * #EXTRA_STREAM} field, containing the data to be sent.
    974      * <p>
    975      * Multiple types are supported, and receivers should handle mixed types
    976      * whenever possible. The right way for the receiver to check them is to
    977      * use the content resolver on each URI. The intent sender should try to
    978      * put the most concrete mime type in the intent type, but it can fall
    979      * back to {@literal <type>/*} or {@literal *}/* as needed.
    980      * <p>
    981      * e.g. if you are sending image/jpg and image/jpg, the intent's type can
    982      * be image/jpg, but if you are sending image/jpg and image/png, then the
    983      * intent's type should be image/*.
    984      * <p>
    985      * Optional standard extras, which may be interpreted by some recipients as
    986      * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
    987      * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
    988      * <p>
    989      * Output: nothing.
    990      */
    991     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    992     public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
    993     /**
    994      * Activity Action: Handle an incoming phone call.
    995      * <p>Input: nothing.
    996      * <p>Output: nothing.
    997      */
    998     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    999     public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
   1000     /**
   1001      * Activity Action: Insert an empty item into the given container.
   1002      * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
   1003      * in which to place the data.
   1004      * <p>Output: URI of the new data that was created.
   1005      */
   1006     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1007     public static final String ACTION_INSERT = "android.intent.action.INSERT";
   1008     /**
   1009      * Activity Action: Create a new item in the given container, initializing it
   1010      * from the current contents of the clipboard.
   1011      * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
   1012      * in which to place the data.
   1013      * <p>Output: URI of the new data that was created.
   1014      */
   1015     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1016     public static final String ACTION_PASTE = "android.intent.action.PASTE";
   1017     /**
   1018      * Activity Action: Delete the given data from its container.
   1019      * <p>Input: {@link #getData} is URI of data to be deleted.
   1020      * <p>Output: nothing.
   1021      */
   1022     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1023     public static final String ACTION_DELETE = "android.intent.action.DELETE";
   1024     /**
   1025      * Activity Action: Run the data, whatever that means.
   1026      * <p>Input: ?  (Note: this is currently specific to the test harness.)
   1027      * <p>Output: nothing.
   1028      */
   1029     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1030     public static final String ACTION_RUN = "android.intent.action.RUN";
   1031     /**
   1032      * Activity Action: Perform a data synchronization.
   1033      * <p>Input: ?
   1034      * <p>Output: ?
   1035      */
   1036     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1037     public static final String ACTION_SYNC = "android.intent.action.SYNC";
   1038     /**
   1039      * Activity Action: Pick an activity given an intent, returning the class
   1040      * selected.
   1041      * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
   1042      * used with {@link PackageManager#queryIntentActivities} to determine the
   1043      * set of activities from which to pick.
   1044      * <p>Output: Class name of the activity that was selected.
   1045      */
   1046     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1047     public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
   1048     /**
   1049      * Activity Action: Perform a search.
   1050      * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
   1051      * is the text to search for.  If empty, simply
   1052      * enter your search results Activity with the search UI activated.
   1053      * <p>Output: nothing.
   1054      */
   1055     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1056     public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
   1057     /**
   1058      * Activity Action: Start the platform-defined tutorial
   1059      * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
   1060      * is the text to search for.  If empty, simply
   1061      * enter your search results Activity with the search UI activated.
   1062      * <p>Output: nothing.
   1063      */
   1064     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1065     public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
   1066     /**
   1067      * Activity Action: Perform a web search.
   1068      * <p>
   1069      * Input: {@link android.app.SearchManager#QUERY
   1070      * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
   1071      * a url starts with http or https, the site will be opened. If it is plain
   1072      * text, Google search will be applied.
   1073      * <p>
   1074      * Output: nothing.
   1075      */
   1076     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1077     public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
   1078     /**
   1079      * Activity Action: List all available applications
   1080      * <p>Input: Nothing.
   1081      * <p>Output: nothing.
   1082      */
   1083     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1084     public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
   1085     /**
   1086      * Activity Action: Show settings for choosing wallpaper
   1087      * <p>Input: Nothing.
   1088      * <p>Output: Nothing.
   1089      */
   1090     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1091     public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
   1092 
   1093     /**
   1094      * Activity Action: Show activity for reporting a bug.
   1095      * <p>Input: Nothing.
   1096      * <p>Output: Nothing.
   1097      */
   1098     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1099     public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
   1100 
   1101     /**
   1102      *  Activity Action: Main entry point for factory tests.  Only used when
   1103      *  the device is booting in factory test node.  The implementing package
   1104      *  must be installed in the system image.
   1105      *  <p>Input: nothing
   1106      *  <p>Output: nothing
   1107      */
   1108     public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
   1109 
   1110     /**
   1111      * Activity Action: The user pressed the "call" button to go to the dialer
   1112      * or other appropriate UI for placing a call.
   1113      * <p>Input: Nothing.
   1114      * <p>Output: Nothing.
   1115      */
   1116     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1117     public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
   1118 
   1119     /**
   1120      * Activity Action: Start Voice Command.
   1121      * <p>Input: Nothing.
   1122      * <p>Output: Nothing.
   1123      */
   1124     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1125     public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
   1126 
   1127     /**
   1128      * Activity Action: Start action associated with long pressing on the
   1129      * search key.
   1130      * <p>Input: Nothing.
   1131      * <p>Output: Nothing.
   1132      */
   1133     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1134     public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
   1135 
   1136     /**
   1137      * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
   1138      * This intent is delivered to the package which installed the application, usually
   1139      * the Market.
   1140      * <p>Input: No data is specified. The bug report is passed in using
   1141      * an {@link #EXTRA_BUG_REPORT} field.
   1142      * <p>Output: Nothing.
   1143      *
   1144      * @see #EXTRA_BUG_REPORT
   1145      */
   1146     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1147     public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
   1148 
   1149     /**
   1150      * Activity Action: Show power usage information to the user.
   1151      * <p>Input: Nothing.
   1152      * <p>Output: Nothing.
   1153      */
   1154     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1155     public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
   1156 
   1157     /**
   1158      * Activity Action: Setup wizard to launch after a platform update.  This
   1159      * activity should have a string meta-data field associated with it,
   1160      * {@link #METADATA_SETUP_VERSION}, which defines the current version of
   1161      * the platform for setup.  The activity will be launched only if
   1162      * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
   1163      * same value.
   1164      * <p>Input: Nothing.
   1165      * <p>Output: Nothing.
   1166      * @hide
   1167      */
   1168     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1169     public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
   1170 
   1171     /**
   1172      * Activity Action: Show settings for managing network data usage of a
   1173      * specific application. Applications should define an activity that offers
   1174      * options to control data usage.
   1175      */
   1176     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1177     public static final String ACTION_MANAGE_NETWORK_USAGE =
   1178             "android.intent.action.MANAGE_NETWORK_USAGE";
   1179 
   1180     /**
   1181      * Activity Action: Launch application installer.
   1182      * <p>
   1183      * Input: The data must be a content: or file: URI at which the application
   1184      * can be retrieved.  You can optionally supply
   1185      * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
   1186      * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
   1187      * <p>
   1188      * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
   1189      * succeeded.
   1190      *
   1191      * @see #EXTRA_INSTALLER_PACKAGE_NAME
   1192      * @see #EXTRA_NOT_UNKNOWN_SOURCE
   1193      * @see #EXTRA_RETURN_RESULT
   1194      */
   1195     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1196     public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
   1197 
   1198     /**
   1199      * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
   1200      * package.  Specifies the installer package name; this package will receive the
   1201      * {@link #ACTION_APP_ERROR} intent.
   1202      */
   1203     public static final String EXTRA_INSTALLER_PACKAGE_NAME
   1204             = "android.intent.extra.INSTALLER_PACKAGE_NAME";
   1205 
   1206     /**
   1207      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
   1208      * package.  Specifies that the application being installed should not be
   1209      * treated as coming from an unknown source, but as coming from the app
   1210      * invoking the Intent.  For this to work you must start the installer with
   1211      * startActivityForResult().
   1212      */
   1213     public static final String EXTRA_NOT_UNKNOWN_SOURCE
   1214             = "android.intent.extra.NOT_UNKNOWN_SOURCE";
   1215 
   1216     /**
   1217      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
   1218      * package.  Tells the installer UI to skip the confirmation with the user
   1219      * if the .apk is replacing an existing one.
   1220      */
   1221     public static final String EXTRA_ALLOW_REPLACE
   1222             = "android.intent.extra.ALLOW_REPLACE";
   1223 
   1224     /**
   1225      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
   1226      * {@link #ACTION_UNINSTALL_PACKAGE}.  Specifies that the installer UI should
   1227      * return to the application the result code of the install/uninstall.  The returned result
   1228      * code will be {@link android.app.Activity#RESULT_OK} on success or
   1229      * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
   1230      */
   1231     public static final String EXTRA_RETURN_RESULT
   1232             = "android.intent.extra.RETURN_RESULT";
   1233 
   1234     /**
   1235      * Package manager install result code.  @hide because result codes are not
   1236      * yet ready to be exposed.
   1237      */
   1238     public static final String EXTRA_INSTALL_RESULT
   1239             = "android.intent.extra.INSTALL_RESULT";
   1240 
   1241     /**
   1242      * Activity Action: Launch application uninstaller.
   1243      * <p>
   1244      * Input: The data must be a package: URI whose scheme specific part is
   1245      * the package name of the current installed package to be uninstalled.
   1246      * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
   1247      * <p>
   1248      * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
   1249      * succeeded.
   1250      */
   1251     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1252     public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
   1253 
   1254     /**
   1255      * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
   1256      * describing the last run version of the platform that was setup.
   1257      * @hide
   1258      */
   1259     public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
   1260 
   1261     // ---------------------------------------------------------------------
   1262     // ---------------------------------------------------------------------
   1263     // Standard intent broadcast actions (see action variable).
   1264 
   1265     /**
   1266      * Broadcast Action: Sent after the screen turns off.
   1267      *
   1268      * <p class="note">This is a protected intent that can only be sent
   1269      * by the system.
   1270      */
   1271     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1272     public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
   1273     /**
   1274      * Broadcast Action: Sent after the screen turns on.
   1275      *
   1276      * <p class="note">This is a protected intent that can only be sent
   1277      * by the system.
   1278      */
   1279     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1280     public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
   1281 
   1282     /**
   1283      * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
   1284      * keyguard is gone).
   1285      *
   1286      * <p class="note">This is a protected intent that can only be sent
   1287      * by the system.
   1288      */
   1289     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1290     public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
   1291 
   1292     /**
   1293      * Broadcast Action: The current time has changed.  Sent every
   1294      * minute.  You can <em>not</em> receive this through components declared
   1295      * in manifests, only by exlicitly registering for it with
   1296      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
   1297      * Context.registerReceiver()}.
   1298      *
   1299      * <p class="note">This is a protected intent that can only be sent
   1300      * by the system.
   1301      */
   1302     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1303     public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
   1304     /**
   1305      * Broadcast Action: The time was set.
   1306      */
   1307     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1308     public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
   1309     /**
   1310      * Broadcast Action: The date has changed.
   1311      */
   1312     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1313     public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
   1314     /**
   1315      * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
   1316      * <ul>
   1317      *   <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
   1318      * </ul>
   1319      *
   1320      * <p class="note">This is a protected intent that can only be sent
   1321      * by the system.
   1322      */
   1323     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1324     public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
   1325     /**
   1326      * Clear DNS Cache Action: This is broadcast when networks have changed and old
   1327      * DNS entries should be tossed.
   1328      * @hide
   1329      */
   1330     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1331     public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
   1332     /**
   1333      * Alarm Changed Action: This is broadcast when the AlarmClock
   1334      * application's alarm is set or unset.  It is used by the
   1335      * AlarmClock application and the StatusBar service.
   1336      * @hide
   1337      */
   1338     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1339     public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
   1340     /**
   1341      * Sync State Changed Action: This is broadcast when the sync starts or stops or when one has
   1342      * been failing for a long time.  It is used by the SyncManager and the StatusBar service.
   1343      * @hide
   1344      */
   1345     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1346     public static final String ACTION_SYNC_STATE_CHANGED
   1347             = "android.intent.action.SYNC_STATE_CHANGED";
   1348     /**
   1349      * Broadcast Action: This is broadcast once, after the system has finished
   1350      * booting.  It can be used to perform application-specific initialization,
   1351      * such as installing alarms.  You must hold the
   1352      * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
   1353      * in order to receive this broadcast.
   1354      *
   1355      * <p class="note">This is a protected intent that can only be sent
   1356      * by the system.
   1357      */
   1358     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1359     public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
   1360     /**
   1361      * Broadcast Action: This is broadcast when a user action should request a
   1362      * temporary system dialog to dismiss.  Some examples of temporary system
   1363      * dialogs are the notification window-shade and the recent tasks dialog.
   1364      */
   1365     public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
   1366     /**
   1367      * Broadcast Action: Trigger the download and eventual installation
   1368      * of a package.
   1369      * <p>Input: {@link #getData} is the URI of the package file to download.
   1370      *
   1371      * <p class="note">This is a protected intent that can only be sent
   1372      * by the system.
   1373      *
   1374      * @deprecated This constant has never been used.
   1375      */
   1376     @Deprecated
   1377     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1378     public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
   1379     /**
   1380      * Broadcast Action: A new application package has been installed on the
   1381      * device. The data contains the name of the package.  Note that the
   1382      * newly installed package does <em>not</em> receive this broadcast.
   1383      * <p>My include the following extras:
   1384      * <ul>
   1385      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
   1386      * <li> {@link #EXTRA_REPLACING} is set to true if this is following
   1387      * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
   1388      * </ul>
   1389      *
   1390      * <p class="note">This is a protected intent that can only be sent
   1391      * by the system.
   1392      */
   1393     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1394     public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
   1395     /**
   1396      * Broadcast Action: A new version of an application package has been
   1397      * installed, replacing an existing version that was previously installed.
   1398      * The data contains the name of the package.
   1399      * <p>My include the following extras:
   1400      * <ul>
   1401      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
   1402      * </ul>
   1403      *
   1404      * <p class="note">This is a protected intent that can only be sent
   1405      * by the system.
   1406      */
   1407     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1408     public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
   1409     /**
   1410      * Broadcast Action: A new version of your application has been installed
   1411      * over an existing one.  This is only sent to the application that was
   1412      * replaced.  It does not contain any additional data; to receive it, just
   1413      * use an intent filter for this action.
   1414      *
   1415      * <p class="note">This is a protected intent that can only be sent
   1416      * by the system.
   1417      */
   1418     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1419     public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
   1420     /**
   1421      * Broadcast Action: An existing application package has been removed from
   1422      * the device.  The data contains the name of the package.  The package
   1423      * that is being installed does <em>not</em> receive this Intent.
   1424      * <ul>
   1425      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
   1426      * to the package.
   1427      * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
   1428      * application -- data and code -- is being removed.
   1429      * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
   1430      * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
   1431      * </ul>
   1432      *
   1433      * <p class="note">This is a protected intent that can only be sent
   1434      * by the system.
   1435      */
   1436     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1437     public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
   1438     /**
   1439      * Broadcast Action: An existing application package has been completely
   1440      * removed from the device.  The data contains the name of the package.
   1441      * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
   1442      * {@link #EXTRA_DATA_REMOVED} is true and
   1443      * {@link #EXTRA_REPLACING} is false of that broadcast.
   1444      *
   1445      * <ul>
   1446      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
   1447      * to the package.
   1448      * </ul>
   1449      *
   1450      * <p class="note">This is a protected intent that can only be sent
   1451      * by the system.
   1452      */
   1453     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1454     public static final String ACTION_PACKAGE_FULLY_REMOVED
   1455             = "android.intent.action.PACKAGE_FULLY_REMOVED";
   1456     /**
   1457      * Broadcast Action: An existing application package has been changed (e.g.
   1458      * a component has been enabled or disabled).  The data contains the name of
   1459      * the package.
   1460      * <ul>
   1461      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
   1462      * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
   1463      * of the changed components.
   1464      * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
   1465      * default action of restarting the application.
   1466      * </ul>
   1467      *
   1468      * <p class="note">This is a protected intent that can only be sent
   1469      * by the system.
   1470      */
   1471     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1472     public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
   1473     /**
   1474      * @hide
   1475      * Broadcast Action: Ask system services if there is any reason to
   1476      * restart the given package.  The data contains the name of the
   1477      * package.
   1478      * <ul>
   1479      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
   1480      * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
   1481      * </ul>
   1482      *
   1483      * <p class="note">This is a protected intent that can only be sent
   1484      * by the system.
   1485      */
   1486     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1487     public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
   1488     /**
   1489      * Broadcast Action: The user has restarted a package, and all of its
   1490      * processes have been killed.  All runtime state
   1491      * associated with it (processes, alarms, notifications, etc) should
   1492      * be removed.  Note that the restarted package does <em>not</em>
   1493      * receive this broadcast.
   1494      * The data contains the name of the package.
   1495      * <ul>
   1496      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
   1497      * </ul>
   1498      *
   1499      * <p class="note">This is a protected intent that can only be sent
   1500      * by the system.
   1501      */
   1502     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1503     public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
   1504     /**
   1505      * Broadcast Action: The user has cleared the data of a package.  This should
   1506      * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
   1507      * its persistent data is erased and this broadcast sent.
   1508      * Note that the cleared package does <em>not</em>
   1509      * receive this broadcast. The data contains the name of the package.
   1510      * <ul>
   1511      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
   1512      * </ul>
   1513      *
   1514      * <p class="note">This is a protected intent that can only be sent
   1515      * by the system.
   1516      */
   1517     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1518     public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
   1519     /**
   1520      * Broadcast Action: A user ID has been removed from the system.  The user
   1521      * ID number is stored in the extra data under {@link #EXTRA_UID}.
   1522      *
   1523      * <p class="note">This is a protected intent that can only be sent
   1524      * by the system.
   1525      */
   1526     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1527     public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
   1528 
   1529     /**
   1530      * Broadcast Action: Sent to the installer package of an application
   1531      * when that application is first launched (that is the first time it
   1532      * is moved out of the stopped state).  The data contains the name of the package.
   1533      *
   1534      * <p class="note">This is a protected intent that can only be sent
   1535      * by the system.
   1536      */
   1537     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1538     public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
   1539 
   1540     /**
   1541      * Broadcast Action: Sent to the system package verifier when a package
   1542      * needs to be verified. The data contains the package URI.
   1543      * <p class="note">
   1544      * This is a protected intent that can only be sent by the system.
   1545      * </p>
   1546      */
   1547     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1548     public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
   1549 
   1550     /**
   1551      * Broadcast Action: Resources for a set of packages (which were
   1552      * previously unavailable) are currently
   1553      * available since the media on which they exist is available.
   1554      * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
   1555      * list of packages whose availability changed.
   1556      * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
   1557      * list of uids of packages whose availability changed.
   1558      * Note that the
   1559      * packages in this list do <em>not</em> receive this broadcast.
   1560      * The specified set of packages are now available on the system.
   1561      * <p>Includes the following extras:
   1562      * <ul>
   1563      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
   1564      * whose resources(were previously unavailable) are currently available.
   1565      * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
   1566      * packages whose resources(were previously unavailable)
   1567      * are  currently available.
   1568      * </ul>
   1569      *
   1570      * <p class="note">This is a protected intent that can only be sent
   1571      * by the system.
   1572      */
   1573     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1574     public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
   1575         "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
   1576 
   1577     /**
   1578      * Broadcast Action: Resources for a set of packages are currently
   1579      * unavailable since the media on which they exist is unavailable.
   1580      * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
   1581      * list of packages whose availability changed.
   1582      * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
   1583      * list of uids of packages whose availability changed.
   1584      * The specified set of packages can no longer be
   1585      * launched and are practically unavailable on the system.
   1586      * <p>Inclues the following extras:
   1587      * <ul>
   1588      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
   1589      * whose resources are no longer available.
   1590      * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
   1591      * whose resources are no longer available.
   1592      * </ul>
   1593      *
   1594      * <p class="note">This is a protected intent that can only be sent
   1595      * by the system.
   1596      */
   1597     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1598     public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
   1599         "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
   1600 
   1601     /**
   1602      * Broadcast Action:  The current system wallpaper has changed.  See
   1603      * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
   1604      */
   1605     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1606     public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
   1607     /**
   1608      * Broadcast Action: The current device {@link android.content.res.Configuration}
   1609      * (orientation, locale, etc) has changed.  When such a change happens, the
   1610      * UIs (view hierarchy) will need to be rebuilt based on this new
   1611      * information; for the most part, applications don't need to worry about
   1612      * this, because the system will take care of stopping and restarting the
   1613      * application to make sure it sees the new changes.  Some system code that
   1614      * can not be restarted will need to watch for this action and handle it
   1615      * appropriately.
   1616      *
   1617      * <p class="note">
   1618      * You can <em>not</em> receive this through components declared
   1619      * in manifests, only by explicitly registering for it with
   1620      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
   1621      * Context.registerReceiver()}.
   1622      *
   1623      * <p class="note">This is a protected intent that can only be sent
   1624      * by the system.
   1625      *
   1626      * @see android.content.res.Configuration
   1627      */
   1628     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1629     public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
   1630     /**
   1631      * Broadcast Action: The current device's locale has changed.
   1632      *
   1633      * <p class="note">This is a protected intent that can only be sent
   1634      * by the system.
   1635      */
   1636     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1637     public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
   1638     /**
   1639      * Broadcast Action:  This is a <em>sticky broadcast</em> containing the
   1640      * charging state, level, and other information about the battery.
   1641      * See {@link android.os.BatteryManager} for documentation on the
   1642      * contents of the Intent.
   1643      *
   1644      * <p class="note">
   1645      * You can <em>not</em> receive this through components declared
   1646      * in manifests, only by explicitly registering for it with
   1647      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
   1648      * Context.registerReceiver()}.  See {@link #ACTION_BATTERY_LOW},
   1649      * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
   1650      * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
   1651      * broadcasts that are sent and can be received through manifest
   1652      * receivers.
   1653      *
   1654      * <p class="note">This is a protected intent that can only be sent
   1655      * by the system.
   1656      */
   1657     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1658     public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
   1659     /**
   1660      * Broadcast Action:  Indicates low battery condition on the device.
   1661      * This broadcast corresponds to the "Low battery warning" system dialog.
   1662      *
   1663      * <p class="note">This is a protected intent that can only be sent
   1664      * by the system.
   1665      */
   1666     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1667     public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
   1668     /**
   1669      * Broadcast Action:  Indicates the battery is now okay after being low.
   1670      * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
   1671      * gone back up to an okay state.
   1672      *
   1673      * <p class="note">This is a protected intent that can only be sent
   1674      * by the system.
   1675      */
   1676     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1677     public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
   1678     /**
   1679      * Broadcast Action:  External power has been connected to the device.
   1680      * This is intended for applications that wish to register specifically to this notification.
   1681      * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
   1682      * stay active to receive this notification.  This action can be used to implement actions
   1683      * that wait until power is available to trigger.
   1684      *
   1685      * <p class="note">This is a protected intent that can only be sent
   1686      * by the system.
   1687      */
   1688     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1689     public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
   1690     /**
   1691      * Broadcast Action:  External power has been removed from the device.
   1692      * This is intended for applications that wish to register specifically to this notification.
   1693      * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
   1694      * stay active to receive this notification.  This action can be used to implement actions
   1695      * that wait until power is available to trigger.
   1696      *
   1697      * <p class="note">This is a protected intent that can only be sent
   1698      * by the system.
   1699      */
   1700     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1701     public static final String ACTION_POWER_DISCONNECTED =
   1702             "android.intent.action.ACTION_POWER_DISCONNECTED";
   1703     /**
   1704      * Broadcast Action:  Device is shutting down.
   1705      * This is broadcast when the device is being shut down (completely turned
   1706      * off, not sleeping).  Once the broadcast is complete, the final shutdown
   1707      * will proceed and all unsaved data lost.  Apps will not normally need
   1708      * to handle this, since the foreground activity will be paused as well.
   1709      *
   1710      * <p class="note">This is a protected intent that can only be sent
   1711      * by the system.
   1712      */
   1713     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1714     public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
   1715     /**
   1716      * Activity Action:  Start this activity to request system shutdown.
   1717      * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
   1718      * to request confirmation from the user before shutting down.
   1719      *
   1720      * <p class="note">This is a protected intent that can only be sent
   1721      * by the system.
   1722      *
   1723      * {@hide}
   1724      */
   1725     public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
   1726     /**
   1727      * Broadcast Action:  A sticky broadcast that indicates low memory
   1728      * condition on the device
   1729      *
   1730      * <p class="note">This is a protected intent that can only be sent
   1731      * by the system.
   1732      */
   1733     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1734     public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
   1735     /**
   1736      * Broadcast Action:  Indicates low memory condition on the device no longer exists
   1737      *
   1738      * <p class="note">This is a protected intent that can only be sent
   1739      * by the system.
   1740      */
   1741     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1742     public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
   1743     /**
   1744      * Broadcast Action:  A sticky broadcast that indicates a memory full
   1745      * condition on the device. This is intended for activities that want
   1746      * to be able to fill the data partition completely, leaving only
   1747      * enough free space to prevent system-wide SQLite failures.
   1748      *
   1749      * <p class="note">This is a protected intent that can only be sent
   1750      * by the system.
   1751      *
   1752      * {@hide}
   1753      */
   1754     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1755     public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
   1756     /**
   1757      * Broadcast Action:  Indicates memory full condition on the device
   1758      * no longer exists.
   1759      *
   1760      * <p class="note">This is a protected intent that can only be sent
   1761      * by the system.
   1762      *
   1763      * {@hide}
   1764      */
   1765     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1766     public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
   1767     /**
   1768      * Broadcast Action:  Indicates low memory condition notification acknowledged by user
   1769      * and package management should be started.
   1770      * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
   1771      * notification.
   1772      */
   1773     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1774     public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
   1775     /**
   1776      * Broadcast Action:  The device has entered USB Mass Storage mode.
   1777      * This is used mainly for the USB Settings panel.
   1778      * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
   1779      * when the SD card file system is mounted or unmounted
   1780      * @deprecated replaced by android.os.storage.StorageEventListener
   1781      */
   1782     @Deprecated
   1783     public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
   1784 
   1785     /**
   1786      * Broadcast Action:  The device has exited USB Mass Storage mode.
   1787      * This is used mainly for the USB Settings panel.
   1788      * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
   1789      * when the SD card file system is mounted or unmounted
   1790      * @deprecated replaced by android.os.storage.StorageEventListener
   1791      */
   1792     @Deprecated
   1793     public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
   1794 
   1795     /**
   1796      * Broadcast Action:  External media has been removed.
   1797      * The path to the mount point for the removed media is contained in the Intent.mData field.
   1798      */
   1799     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1800     public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
   1801 
   1802     /**
   1803      * Broadcast Action:  External media is present, but not mounted at its mount point.
   1804      * The path to the mount point for the removed media is contained in the Intent.mData field.
   1805      */
   1806     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1807     public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
   1808 
   1809     /**
   1810      * Broadcast Action:  External media is present, and being disk-checked
   1811      * The path to the mount point for the checking media is contained in the Intent.mData field.
   1812      */
   1813     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1814     public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
   1815 
   1816     /**
   1817      * Broadcast Action:  External media is present, but is using an incompatible fs (or is blank)
   1818      * The path to the mount point for the checking media is contained in the Intent.mData field.
   1819      */
   1820     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1821     public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
   1822 
   1823     /**
   1824      * Broadcast Action:  External media is present and mounted at its mount point.
   1825      * The path to the mount point for the removed media is contained in the Intent.mData field.
   1826      * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
   1827      * media was mounted read only.
   1828      */
   1829     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1830     public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
   1831 
   1832     /**
   1833      * Broadcast Action:  External media is unmounted because it is being shared via USB mass storage.
   1834      * The path to the mount point for the shared media is contained in the Intent.mData field.
   1835      */
   1836     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1837     public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
   1838 
   1839     /**
   1840      * Broadcast Action:  External media is no longer being shared via USB mass storage.
   1841      * The path to the mount point for the previously shared media is contained in the Intent.mData field.
   1842      *
   1843      * @hide
   1844      */
   1845     public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
   1846 
   1847     /**
   1848      * Broadcast Action:  External media was removed from SD card slot, but mount point was not unmounted.
   1849      * The path to the mount point for the removed media is contained in the Intent.mData field.
   1850      */
   1851     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1852     public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
   1853 
   1854     /**
   1855      * Broadcast Action:  External media is present but cannot be mounted.
   1856      * The path to the mount point for the removed media is contained in the Intent.mData field.
   1857      */
   1858     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1859     public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
   1860 
   1861    /**
   1862      * Broadcast Action:  User has expressed the desire to remove the external storage media.
   1863      * Applications should close all files they have open within the mount point when they receive this intent.
   1864      * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
   1865      */
   1866     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1867     public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
   1868 
   1869     /**
   1870      * Broadcast Action:  The media scanner has started scanning a directory.
   1871      * The path to the directory being scanned is contained in the Intent.mData field.
   1872      */
   1873     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1874     public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
   1875 
   1876    /**
   1877      * Broadcast Action:  The media scanner has finished scanning a directory.
   1878      * The path to the scanned directory is contained in the Intent.mData field.
   1879      */
   1880     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1881     public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
   1882 
   1883    /**
   1884      * Broadcast Action:  Request the media scanner to scan a file and add it to the media database.
   1885      * The path to the file is contained in the Intent.mData field.
   1886      */
   1887     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1888     public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
   1889 
   1890    /**
   1891      * Broadcast Action:  The "Media Button" was pressed.  Includes a single
   1892      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
   1893      * caused the broadcast.
   1894      */
   1895     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1896     public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
   1897 
   1898     /**
   1899      * Broadcast Action:  The "Camera Button" was pressed.  Includes a single
   1900      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
   1901      * caused the broadcast.
   1902      */
   1903     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1904     public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
   1905 
   1906     // *** NOTE: @todo(*) The following really should go into a more domain-specific
   1907     // location; they are not general-purpose actions.
   1908 
   1909     /**
   1910      * Broadcast Action: An GTalk connection has been established.
   1911      */
   1912     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1913     public static final String ACTION_GTALK_SERVICE_CONNECTED =
   1914             "android.intent.action.GTALK_CONNECTED";
   1915 
   1916     /**
   1917      * Broadcast Action: An GTalk connection has been disconnected.
   1918      */
   1919     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1920     public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
   1921             "android.intent.action.GTALK_DISCONNECTED";
   1922 
   1923     /**
   1924      * Broadcast Action: An input method has been changed.
   1925      */
   1926     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1927     public static final String ACTION_INPUT_METHOD_CHANGED =
   1928             "android.intent.action.INPUT_METHOD_CHANGED";
   1929 
   1930     /**
   1931      * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
   1932      * more radios have been turned off or on. The intent will have the following extra value:</p>
   1933      * <ul>
   1934      *   <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
   1935      *   then cell radio and possibly other radios such as bluetooth or WiFi may have also been
   1936      *   turned off</li>
   1937      * </ul>
   1938      *
   1939      * <p class="note">This is a protected intent that can only be sent
   1940      * by the system.
   1941      */
   1942     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1943     public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
   1944 
   1945     /**
   1946      * Broadcast Action: Some content providers have parts of their namespace
   1947      * where they publish new events or items that the user may be especially
   1948      * interested in. For these things, they may broadcast this action when the
   1949      * set of interesting items change.
   1950      *
   1951      * For example, GmailProvider sends this notification when the set of unread
   1952      * mail in the inbox changes.
   1953      *
   1954      * <p>The data of the intent identifies which part of which provider
   1955      * changed. When queried through the content resolver, the data URI will
   1956      * return the data set in question.
   1957      *
   1958      * <p>The intent will have the following extra values:
   1959      * <ul>
   1960      *   <li><em>count</em> - The number of items in the data set. This is the
   1961      *       same as the number of items in the cursor returned by querying the
   1962      *       data URI. </li>
   1963      * </ul>
   1964      *
   1965      * This intent will be sent at boot (if the count is non-zero) and when the
   1966      * data set changes. It is possible for the data set to change without the
   1967      * count changing (for example, if a new unread message arrives in the same
   1968      * sync operation in which a message is archived). The phone should still
   1969      * ring/vibrate/etc as normal in this case.
   1970      */
   1971     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1972     public static final String ACTION_PROVIDER_CHANGED =
   1973             "android.intent.action.PROVIDER_CHANGED";
   1974 
   1975     /**
   1976      * Broadcast Action: Wired Headset plugged in or unplugged.
   1977      *
   1978      * <p>The intent will have the following extra values:
   1979      * <ul>
   1980      *   <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
   1981      *   <li><em>name</em> - Headset type, human readable string </li>
   1982      *   <li><em>microphone</em> - 1 if headset has a microphone, 0 otherwise </li>
   1983      * </ul>
   1984      * </ul>
   1985      */
   1986     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1987     public static final String ACTION_HEADSET_PLUG =
   1988             "android.intent.action.HEADSET_PLUG";
   1989 
   1990     /**
   1991      * Broadcast Action: An analog audio speaker/headset plugged in or unplugged.
   1992      *
   1993      * <p>The intent will have the following extra values:
   1994      * <ul>
   1995      *   <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
   1996      *   <li><em>name</em> - Headset type, human readable string </li>
   1997      * </ul>
   1998      * </ul>
   1999      * @hide
   2000      */
   2001     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2002     public static final String ACTION_USB_ANLG_HEADSET_PLUG =
   2003             "android.intent.action.USB_ANLG_HEADSET_PLUG";
   2004 
   2005     /**
   2006      * Broadcast Action: A digital audio speaker/headset plugged in or unplugged.
   2007      *
   2008      * <p>The intent will have the following extra values:
   2009      * <ul>
   2010      *   <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
   2011      *   <li><em>name</em> - Headset type, human readable string </li>
   2012      * </ul>
   2013      * </ul>
   2014      * @hide
   2015      */
   2016     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2017     public static final String ACTION_USB_DGTL_HEADSET_PLUG =
   2018             "android.intent.action.USB_DGTL_HEADSET_PLUG";
   2019 
   2020     /**
   2021      * Broadcast Action: A HMDI cable was plugged or unplugged
   2022      *
   2023      * <p>The intent will have the following extra values:
   2024      * <ul>
   2025      *   <li><em>state</em> - 0 for unplugged, 1 for plugged. </li>
   2026      *   <li><em>name</em> - HDMI cable, human readable string </li>
   2027      * </ul>
   2028      * </ul>
   2029      * @hide
   2030      */
   2031     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2032     public static final String ACTION_HDMI_AUDIO_PLUG =
   2033             "android.intent.action.HDMI_AUDIO_PLUG";
   2034 
   2035     /**
   2036      * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
   2037      * <ul>
   2038      *   <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
   2039      * </ul>
   2040      *
   2041      * <p class="note">This is a protected intent that can only be sent
   2042      * by the system.
   2043      *
   2044      * @hide
   2045      */
   2046     //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2047     public static final String ACTION_ADVANCED_SETTINGS_CHANGED
   2048             = "android.intent.action.ADVANCED_SETTINGS";
   2049 
   2050     /**
   2051      * Broadcast Action: An outgoing call is about to be placed.
   2052      *
   2053      * <p>The Intent will have the following extra value:
   2054      * <ul>
   2055      *   <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
   2056      *       the phone number originally intended to be dialed.</li>
   2057      * </ul>
   2058      * <p>Once the broadcast is finished, the resultData is used as the actual
   2059      * number to call.  If  <code>null</code>, no call will be placed.</p>
   2060      * <p>It is perfectly acceptable for multiple receivers to process the
   2061      * outgoing call in turn: for example, a parental control application
   2062      * might verify that the user is authorized to place the call at that
   2063      * time, then a number-rewriting application might add an area code if
   2064      * one was not specified.</p>
   2065      * <p>For consistency, any receiver whose purpose is to prohibit phone
   2066      * calls should have a priority of 0, to ensure it will see the final
   2067      * phone number to be dialed.
   2068      * Any receiver whose purpose is to rewrite phone numbers to be called
   2069      * should have a positive priority.
   2070      * Negative priorities are reserved for the system for this broadcast;
   2071      * using them may cause problems.</p>
   2072      * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
   2073      * abort the broadcast.</p>
   2074      * <p>Emergency calls cannot be intercepted using this mechanism, and
   2075      * other calls cannot be modified to call emergency numbers using this
   2076      * mechanism.
   2077      * <p>You must hold the
   2078      * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
   2079      * permission to receive this Intent.</p>
   2080      *
   2081      * <p class="note">This is a protected intent that can only be sent
   2082      * by the system.
   2083      */
   2084     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2085     public static final String ACTION_NEW_OUTGOING_CALL =
   2086             "android.intent.action.NEW_OUTGOING_CALL";
   2087 
   2088     /**
   2089      * Broadcast Action: Have the device reboot.  This is only for use by
   2090      * system code.
   2091      *
   2092      * <p class="note">This is a protected intent that can only be sent
   2093      * by the system.
   2094      */
   2095     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2096     public static final String ACTION_REBOOT =
   2097             "android.intent.action.REBOOT";
   2098 
   2099     /**
   2100      * Broadcast Action:  A sticky broadcast for changes in the physical
   2101      * docking state of the device.
   2102      *
   2103      * <p>The intent will have the following extra values:
   2104      * <ul>
   2105      *   <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
   2106      *       state, indicating which dock the device is physically in.</li>
   2107      * </ul>
   2108      * <p>This is intended for monitoring the current physical dock state.
   2109      * See {@link android.app.UiModeManager} for the normal API dealing with
   2110      * dock mode changes.
   2111      */
   2112     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2113     public static final String ACTION_DOCK_EVENT =
   2114             "android.intent.action.DOCK_EVENT";
   2115 
   2116     /**
   2117      * Broadcast Action: a remote intent is to be broadcasted.
   2118      *
   2119      * A remote intent is used for remote RPC between devices. The remote intent
   2120      * is serialized and sent from one device to another device. The receiving
   2121      * device parses the remote intent and broadcasts it. Note that anyone can
   2122      * broadcast a remote intent. However, if the intent receiver of the remote intent
   2123      * does not trust intent broadcasts from arbitrary intent senders, it should require
   2124      * the sender to hold certain permissions so only trusted sender's broadcast will be
   2125      * let through.
   2126      * @hide
   2127      */
   2128     public static final String ACTION_REMOTE_INTENT =
   2129             "com.google.android.c2dm.intent.RECEIVE";
   2130 
   2131     /**
   2132      * Broadcast Action: hook for permforming cleanup after a system update.
   2133      *
   2134      * The broadcast is sent when the system is booting, before the
   2135      * BOOT_COMPLETED broadcast.  It is only sent to receivers in the system
   2136      * image.  A receiver for this should do its work and then disable itself
   2137      * so that it does not get run again at the next boot.
   2138      * @hide
   2139      */
   2140     public static final String ACTION_PRE_BOOT_COMPLETED =
   2141             "android.intent.action.PRE_BOOT_COMPLETED";
   2142 
   2143     // ---------------------------------------------------------------------
   2144     // ---------------------------------------------------------------------
   2145     // Standard intent categories (see addCategory()).
   2146 
   2147     /**
   2148      * Set if the activity should be an option for the default action
   2149      * (center press) to perform on a piece of data.  Setting this will
   2150      * hide from the user any activities without it set when performing an
   2151      * action on some data.  Note that this is normal -not- set in the
   2152      * Intent when initiating an action -- it is for use in intent filters
   2153      * specified in packages.
   2154      */
   2155     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2156     public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
   2157     /**
   2158      * Activities that can be safely invoked from a browser must support this
   2159      * category.  For example, if the user is viewing a web page or an e-mail
   2160      * and clicks on a link in the text, the Intent generated execute that
   2161      * link will require the BROWSABLE category, so that only activities
   2162      * supporting this category will be considered as possible actions.  By
   2163      * supporting this category, you are promising that there is nothing
   2164      * damaging (without user intervention) that can happen by invoking any
   2165      * matching Intent.
   2166      */
   2167     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2168     public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
   2169     /**
   2170      * Set if the activity should be considered as an alternative action to
   2171      * the data the user is currently viewing.  See also
   2172      * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
   2173      * applies to the selection in a list of items.
   2174      *
   2175      * <p>Supporting this category means that you would like your activity to be
   2176      * displayed in the set of alternative things the user can do, usually as
   2177      * part of the current activity's options menu.  You will usually want to
   2178      * include a specific label in the &lt;intent-filter&gt; of this action
   2179      * describing to the user what it does.
   2180      *
   2181      * <p>The action of IntentFilter with this category is important in that it
   2182      * describes the specific action the target will perform.  This generally
   2183      * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
   2184      * a specific name such as "com.android.camera.action.CROP.  Only one
   2185      * alternative of any particular action will be shown to the user, so using
   2186      * a specific action like this makes sure that your alternative will be
   2187      * displayed while also allowing other applications to provide their own
   2188      * overrides of that particular action.
   2189      */
   2190     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2191     public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
   2192     /**
   2193      * Set if the activity should be considered as an alternative selection
   2194      * action to the data the user has currently selected.  This is like
   2195      * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
   2196      * of items from which the user can select, giving them alternatives to the
   2197      * default action that will be performed on it.
   2198      */
   2199     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2200     public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
   2201     /**
   2202      * Intended to be used as a tab inside of an containing TabActivity.
   2203      */
   2204     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2205     public static final String CATEGORY_TAB = "android.intent.category.TAB";
   2206     /**
   2207      * Should be displayed in the top-level launcher.
   2208      */
   2209     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2210     public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
   2211     /**
   2212      * Provides information about the package it is in; typically used if
   2213      * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
   2214      * a front-door to the user without having to be shown in the all apps list.
   2215      */
   2216     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2217     public static final String CATEGORY_INFO = "android.intent.category.INFO";
   2218     /**
   2219      * This is the home activity, that is the first activity that is displayed
   2220      * when the device boots.
   2221      */
   2222     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2223     public static final String CATEGORY_HOME = "android.intent.category.HOME";
   2224     /**
   2225      * This activity is a preference panel.
   2226      */
   2227     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2228     public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
   2229     /**
   2230      * This activity is a development preference panel.
   2231      */
   2232     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2233     public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
   2234     /**
   2235      * Capable of running inside a parent activity container.
   2236      */
   2237     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2238     public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
   2239     /**
   2240      * This activity allows the user to browse and download new applications.
   2241      */
   2242     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2243     public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
   2244     /**
   2245      * This activity may be exercised by the monkey or other automated test tools.
   2246      */
   2247     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2248     public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
   2249     /**
   2250      * To be used as a test (not part of the normal user experience).
   2251      */
   2252     public static final String CATEGORY_TEST = "android.intent.category.TEST";
   2253     /**
   2254      * To be used as a unit test (run through the Test Harness).
   2255      */
   2256     public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
   2257     /**
   2258      * To be used as an sample code example (not part of the normal user
   2259      * experience).
   2260      */
   2261     public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
   2262     /**
   2263      * Used to indicate that a GET_CONTENT intent only wants URIs that can be opened with
   2264      * ContentResolver.openInputStream. Openable URIs must support the columns in OpenableColumns
   2265      * when queried, though it is allowable for those columns to be blank.
   2266      */
   2267     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2268     public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
   2269 
   2270     /**
   2271      * To be used as code under test for framework instrumentation tests.
   2272      */
   2273     public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
   2274             "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
   2275     /**
   2276      * An activity to run when device is inserted into a car dock.
   2277      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
   2278      * information, see {@link android.app.UiModeManager}.
   2279      */
   2280     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2281     public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
   2282     /**
   2283      * An activity to run when device is inserted into a car dock.
   2284      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
   2285      * information, see {@link android.app.UiModeManager}.
   2286      */
   2287     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2288     public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
   2289     /**
   2290      * An activity to run when device is inserted into a analog (low end) dock.
   2291      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
   2292      * information, see {@link android.app.UiModeManager}.
   2293      */
   2294     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2295     public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
   2296 
   2297     /**
   2298      * An activity to run when device is inserted into a digital (high end) dock.
   2299      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
   2300      * information, see {@link android.app.UiModeManager}.
   2301      */
   2302     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2303     public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
   2304 
   2305     /**
   2306      * Used to indicate that the activity can be used in a car environment.
   2307      */
   2308     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2309     public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
   2310 
   2311     // ---------------------------------------------------------------------
   2312     // ---------------------------------------------------------------------
   2313     // Application launch intent categories (see addCategory()).
   2314 
   2315     /**
   2316      * Used with {@link #ACTION_MAIN} to launch the browser application.
   2317      * The activity should be able to browse the Internet.
   2318      * <p>NOTE: This should not be used as the primary key of an Intent,
   2319      * since it will not result in the app launching with the correct
   2320      * action and category.  Instead, use this with
   2321      * {@link #makeMainSelectorActivity(String, String) to generate a main
   2322      * Intent with this category in the selector.</p>
   2323      */
   2324     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2325     public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
   2326 
   2327     /**
   2328      * Used with {@link #ACTION_MAIN} to launch the calculator application.
   2329      * The activity should be able to perform standard arithmetic operations.
   2330      * <p>NOTE: This should not be used as the primary key of an Intent,
   2331      * since it will not result in the app launching with the correct
   2332      * action and category.  Instead, use this with
   2333      * {@link #makeMainSelectorActivity(String, String) to generate a main
   2334      * Intent with this category in the selector.</p>
   2335      */
   2336     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2337     public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
   2338 
   2339     /**
   2340      * Used with {@link #ACTION_MAIN} to launch the calendar application.
   2341      * The activity should be able to view and manipulate calendar entries.
   2342      * <p>NOTE: This should not be used as the primary key of an Intent,
   2343      * since it will not result in the app launching with the correct
   2344      * action and category.  Instead, use this with
   2345      * {@link #makeMainSelectorActivity(String, String) to generate a main
   2346      * Intent with this category in the selector.</p>
   2347      */
   2348     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2349     public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
   2350 
   2351     /**
   2352      * Used with {@link #ACTION_MAIN} to launch the contacts application.
   2353      * The activity should be able to view and manipulate address book entries.
   2354      * <p>NOTE: This should not be used as the primary key of an Intent,
   2355      * since it will not result in the app launching with the correct
   2356      * action and category.  Instead, use this with
   2357      * {@link #makeMainSelectorActivity(String, String) to generate a main
   2358      * Intent with this category in the selector.</p>
   2359      */
   2360     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2361     public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
   2362 
   2363     /**
   2364      * Used with {@link #ACTION_MAIN} to launch the email application.
   2365      * The activity should be able to send and receive email.
   2366      * <p>NOTE: This should not be used as the primary key of an Intent,
   2367      * since it will not result in the app launching with the correct
   2368      * action and category.  Instead, use this with
   2369      * {@link #makeMainSelectorActivity(String, String) to generate a main
   2370      * Intent with this category in the selector.</p>
   2371      */
   2372     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2373     public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
   2374 
   2375     /**
   2376      * Used with {@link #ACTION_MAIN} to launch the gallery application.
   2377      * The activity should be able to view and manipulate image and video files
   2378      * stored on the device.
   2379      * <p>NOTE: This should not be used as the primary key of an Intent,
   2380      * since it will not result in the app launching with the correct
   2381      * action and category.  Instead, use this with
   2382      * {@link #makeMainSelectorActivity(String, String) to generate a main
   2383      * Intent with this category in the selector.</p>
   2384      */
   2385     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2386     public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
   2387 
   2388     /**
   2389      * Used with {@link #ACTION_MAIN} to launch the maps application.
   2390      * The activity should be able to show the user's current location and surroundings.
   2391      * <p>NOTE: This should not be used as the primary key of an Intent,
   2392      * since it will not result in the app launching with the correct
   2393      * action and category.  Instead, use this with
   2394      * {@link #makeMainSelectorActivity(String, String) to generate a main
   2395      * Intent with this category in the selector.</p>
   2396      */
   2397     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2398     public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
   2399 
   2400     /**
   2401      * Used with {@link #ACTION_MAIN} to launch the messaging application.
   2402      * The activity should be able to send and receive text messages.
   2403      * <p>NOTE: This should not be used as the primary key of an Intent,
   2404      * since it will not result in the app launching with the correct
   2405      * action and category.  Instead, use this with
   2406      * {@link #makeMainSelectorActivity(String, String) to generate a main
   2407      * Intent with this category in the selector.</p>
   2408      */
   2409     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2410     public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
   2411 
   2412     /**
   2413      * Used with {@link #ACTION_MAIN} to launch the music application.
   2414      * The activity should be able to play, browse, or manipulate music files
   2415      * stored on the device.
   2416      * <p>NOTE: This should not be used as the primary key of an Intent,
   2417      * since it will not result in the app launching with the correct
   2418      * action and category.  Instead, use this with
   2419      * {@link #makeMainSelectorActivity(String, String) to generate a main
   2420      * Intent with this category in the selector.</p>
   2421      */
   2422     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   2423     public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
   2424 
   2425     // ---------------------------------------------------------------------
   2426     // ---------------------------------------------------------------------
   2427     // Standard extra data keys.
   2428 
   2429     /**
   2430      * The initial data to place in a newly created record.  Use with
   2431      * {@link #ACTION_INSERT}.  The data here is a Map containing the same
   2432      * fields as would be given to the underlying ContentProvider.insert()
   2433      * call.
   2434      */
   2435     public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
   2436 
   2437     /**
   2438      * A constant CharSequence that is associated with the Intent, used with
   2439      * {@link #ACTION_SEND} to supply the literal data to be sent.  Note that
   2440      * this may be a styled CharSequence, so you must use
   2441      * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
   2442      * retrieve it.
   2443      */
   2444     public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
   2445 
   2446     /**
   2447      * A content: URI holding a stream of data associated with the Intent,
   2448      * used with {@link #ACTION_SEND} to supply the data being sent.
   2449      */
   2450     public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
   2451 
   2452     /**
   2453      * A String[] holding e-mail addresses that should be delivered to.
   2454      */
   2455     public static final String EXTRA_EMAIL       = "android.intent.extra.EMAIL";
   2456 
   2457     /**
   2458      * A String[] holding e-mail addresses that should be carbon copied.
   2459      */
   2460     public static final String EXTRA_CC       = "android.intent.extra.CC";
   2461 
   2462     /**
   2463      * A String[] holding e-mail addresses that should be blind carbon copied.
   2464      */
   2465     public static final String EXTRA_BCC      = "android.intent.extra.BCC";
   2466 
   2467     /**
   2468      * A constant string holding the desired subject line of a message.
   2469      */
   2470     public static final String EXTRA_SUBJECT  = "android.intent.extra.SUBJECT";
   2471 
   2472     /**
   2473      * An Intent describing the choices you would like shown with
   2474      * {@link #ACTION_PICK_ACTIVITY}.
   2475      */
   2476     public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
   2477 
   2478     /**
   2479      * A CharSequence dialog title to provide to the user when used with a
   2480      * {@link #ACTION_CHOOSER}.
   2481      */
   2482     public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
   2483 
   2484     /**
   2485      * A Parcelable[] of {@link Intent} or
   2486      * {@link android.content.pm.LabeledIntent} objects as set with
   2487      * {@link #putExtra(String, Parcelable[])} of additional activities to place
   2488      * a the front of the list of choices, when shown to the user with a
   2489      * {@link #ACTION_CHOOSER}.
   2490      */
   2491     public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
   2492 
   2493     /**
   2494      * A {@link android.view.KeyEvent} object containing the event that
   2495      * triggered the creation of the Intent it is in.
   2496      */
   2497     public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
   2498 
   2499     /**
   2500      * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
   2501      * before shutting down.
   2502      *
   2503      * {@hide}
   2504      */
   2505     public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
   2506 
   2507     /**
   2508      * Used as an boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
   2509      * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
   2510      * of restarting the application.
   2511      */
   2512     public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
   2513 
   2514     /**
   2515      * A String holding the phone number originally entered in
   2516      * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
   2517      * number to call in a {@link android.content.Intent#ACTION_CALL}.
   2518      */
   2519     public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
   2520 
   2521     /**
   2522      * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
   2523      * intents to supply the uid the package had been assigned.  Also an optional
   2524      * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
   2525      * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
   2526      * purpose.
   2527      */
   2528     public static final String EXTRA_UID = "android.intent.extra.UID";
   2529 
   2530     /**
   2531      * @hide String array of package names.
   2532      */
   2533     public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
   2534 
   2535     /**
   2536      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
   2537      * intents to indicate whether this represents a full uninstall (removing
   2538      * both the code and its data) or a partial uninstall (leaving its data,
   2539      * implying that this is an update).
   2540      */
   2541     public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
   2542 
   2543     /**
   2544      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
   2545      * intents to indicate that this is a replacement of the package, so this
   2546      * broadcast will immediately be followed by an add broadcast for a
   2547      * different version of the same package.
   2548      */
   2549     public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
   2550 
   2551     /**
   2552      * Used as an int extra field in {@link android.app.AlarmManager} intents
   2553      * to tell the application being invoked how many pending alarms are being
   2554      * delievered with the intent.  For one-shot alarms this will always be 1.
   2555      * For recurring alarms, this might be greater than 1 if the device was
   2556      * asleep or powered off at the time an earlier alarm would have been
   2557      * delivered.
   2558      */
   2559     public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
   2560 
   2561     /**
   2562      * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
   2563      * intents to request the dock state.  Possible values are
   2564      * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
   2565      * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
   2566      * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
   2567      * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
   2568      * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
   2569      */
   2570     public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
   2571 
   2572     /**
   2573      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
   2574      * to represent that the phone is not in any dock.
   2575      */
   2576     public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
   2577 
   2578     /**
   2579      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
   2580      * to represent that the phone is in a desk dock.
   2581      */
   2582     public static final int EXTRA_DOCK_STATE_DESK = 1;
   2583 
   2584     /**
   2585      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
   2586      * to represent that the phone is in a car dock.
   2587      */
   2588     public static final int EXTRA_DOCK_STATE_CAR = 2;
   2589 
   2590     /**
   2591      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
   2592      * to represent that the phone is in a analog (low end) dock.
   2593      */
   2594     public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
   2595 
   2596     /**
   2597      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
   2598      * to represent that the phone is in a digital (high end) dock.
   2599      */
   2600     public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
   2601 
   2602     /**
   2603      * Boolean that can be supplied as meta-data with a dock activity, to
   2604      * indicate that the dock should take over the home key when it is active.
   2605      */
   2606     public static final String METADATA_DOCK_HOME = "android.dock_home";
   2607 
   2608     /**
   2609      * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
   2610      * the bug report.
   2611      */
   2612     public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
   2613 
   2614     /**
   2615      * Used in the extra field in the remote intent. It's astring token passed with the
   2616      * remote intent.
   2617      */
   2618     public static final String EXTRA_REMOTE_INTENT_TOKEN =
   2619             "android.intent.extra.remote_intent_token";
   2620 
   2621     /**
   2622      * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
   2623      * will contain only the first name in the list.
   2624      */
   2625     @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
   2626             "android.intent.extra.changed_component_name";
   2627 
   2628     /**
   2629      * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
   2630      * and contains a string array of all of the components that have changed.
   2631      */
   2632     public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
   2633             "android.intent.extra.changed_component_name_list";
   2634 
   2635     /**
   2636      * This field is part of
   2637      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
   2638      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
   2639      * and contains a string array of all of the components that have changed.
   2640      */
   2641     public static final String EXTRA_CHANGED_PACKAGE_LIST =
   2642             "android.intent.extra.changed_package_list";
   2643 
   2644     /**
   2645      * This field is part of
   2646      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
   2647      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
   2648      * and contains an integer array of uids of all of the components
   2649      * that have changed.
   2650      */
   2651     public static final String EXTRA_CHANGED_UID_LIST =
   2652             "android.intent.extra.changed_uid_list";
   2653 
   2654     /**
   2655      * @hide
   2656      * Magic extra system code can use when binding, to give a label for
   2657      * who it is that has bound to a service.  This is an integer giving
   2658      * a framework string resource that can be displayed to the user.
   2659      */
   2660     public static final String EXTRA_CLIENT_LABEL =
   2661             "android.intent.extra.client_label";
   2662 
   2663     /**
   2664      * @hide
   2665      * Magic extra system code can use when binding, to give a PendingIntent object
   2666      * that can be launched for the user to disable the system's use of this
   2667      * service.
   2668      */
   2669     public static final String EXTRA_CLIENT_INTENT =
   2670             "android.intent.extra.client_intent";
   2671 
   2672     /**
   2673      * Used to indicate that a {@link #ACTION_GET_CONTENT} intent should only return
   2674      * data that is on the local device.  This is a boolean extra; the default
   2675      * is false.  If true, an implementation of ACTION_GET_CONTENT should only allow
   2676      * the user to select media that is already on the device, not requiring it
   2677      * be downloaded from a remote service when opened.  Another way to look
   2678      * at it is that such content should generally have a "_data" column to the
   2679      * path of the content on local external storage.
   2680      */
   2681     public static final String EXTRA_LOCAL_ONLY =
   2682         "android.intent.extra.LOCAL_ONLY";
   2683 
   2684     // ---------------------------------------------------------------------
   2685     // ---------------------------------------------------------------------
   2686     // Intent flags (see mFlags variable).
   2687 
   2688     /**
   2689      * If set, the recipient of this Intent will be granted permission to
   2690      * perform read operations on the Uri in the Intent's data.
   2691      */
   2692     public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
   2693     /**
   2694      * If set, the recipient of this Intent will be granted permission to
   2695      * perform write operations on the Uri in the Intent's data.
   2696      */
   2697     public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
   2698     /**
   2699      * Can be set by the caller to indicate that this Intent is coming from
   2700      * a background operation, not from direct user interaction.
   2701      */
   2702     public static final int FLAG_FROM_BACKGROUND = 0x00000004;
   2703     /**
   2704      * A flag you can enable for debugging: when set, log messages will be
   2705      * printed during the resolution of this intent to show you what has
   2706      * been found to create the final resolved list.
   2707      */
   2708     public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
   2709     /**
   2710      * If set, this intent will not match any components in packages that
   2711      * are currently stopped.  If this is not set, then the default behavior
   2712      * is to include such applications in the result.
   2713      */
   2714     public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
   2715     /**
   2716      * If set, this intent will always match any components in packages that
   2717      * are currently stopped.  This is the default behavior when
   2718      * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set.  If both of these
   2719      * flags are set, this one wins (it allows overriding of exclude for
   2720      * places where the framework may automatically set the exclude flag).
   2721      */
   2722     public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
   2723 
   2724     /**
   2725      * If set, the new activity is not kept in the history stack.  As soon as
   2726      * the user navigates away from it, the activity is finished.  This may also
   2727      * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
   2728      * noHistory} attribute.
   2729      */
   2730     public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
   2731     /**
   2732      * If set, the activity will not be launched if it is already running
   2733      * at the top of the history stack.
   2734      */
   2735     public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
   2736     /**
   2737      * If set, this activity will become the start of a new task on this
   2738      * history stack.  A task (from the activity that started it to the
   2739      * next task activity) defines an atomic group of activities that the
   2740      * user can move to.  Tasks can be moved to the foreground and background;
   2741      * all of the activities inside of a particular task always remain in
   2742      * the same order.  See
   2743      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
   2744      * Stack</a> for more information about tasks.
   2745      *
   2746      * <p>This flag is generally used by activities that want
   2747      * to present a "launcher" style behavior: they give the user a list of
   2748      * separate things that can be done, which otherwise run completely
   2749      * independently of the activity launching them.
   2750      *
   2751      * <p>When using this flag, if a task is already running for the activity
   2752      * you are now starting, then a new activity will not be started; instead,
   2753      * the current task will simply be brought to the front of the screen with
   2754      * the state it was last in.  See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
   2755      * to disable this behavior.
   2756      *
   2757      * <p>This flag can not be used when the caller is requesting a result from
   2758      * the activity being launched.
   2759      */
   2760     public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
   2761     /**
   2762      * <strong>Do not use this flag unless you are implementing your own
   2763      * top-level application launcher.</strong>  Used in conjunction with
   2764      * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
   2765      * behavior of bringing an existing task to the foreground.  When set,
   2766      * a new task is <em>always</em> started to host the Activity for the
   2767      * Intent, regardless of whether there is already an existing task running
   2768      * the same thing.
   2769      *
   2770      * <p><strong>Because the default system does not include graphical task management,
   2771      * you should not use this flag unless you provide some way for a user to
   2772      * return back to the tasks you have launched.</strong>
   2773      *
   2774      * <p>This flag is ignored if
   2775      * {@link #FLAG_ACTIVITY_NEW_TASK} is not set.
   2776      *
   2777      * <p>See
   2778      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
   2779      * Stack</a> for more information about tasks.
   2780      */
   2781     public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
   2782     /**
   2783      * If set, and the activity being launched is already running in the
   2784      * current task, then instead of launching a new instance of that activity,
   2785      * all of the other activities on top of it will be closed and this Intent
   2786      * will be delivered to the (now on top) old activity as a new Intent.
   2787      *
   2788      * <p>For example, consider a task consisting of the activities: A, B, C, D.
   2789      * If D calls startActivity() with an Intent that resolves to the component
   2790      * of activity B, then C and D will be finished and B receive the given
   2791      * Intent, resulting in the stack now being: A, B.
   2792      *
   2793      * <p>The currently running instance of activity B in the above example will
   2794      * either receive the new intent you are starting here in its
   2795      * onNewIntent() method, or be itself finished and restarted with the
   2796      * new intent.  If it has declared its launch mode to be "multiple" (the
   2797      * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
   2798      * the same intent, then it will be finished and re-created; for all other
   2799      * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
   2800      * Intent will be delivered to the current instance's onNewIntent().
   2801      *
   2802      * <p>This launch mode can also be used to good effect in conjunction with
   2803      * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
   2804      * of a task, it will bring any currently running instance of that task
   2805      * to the foreground, and then clear it to its root state.  This is
   2806      * especially useful, for example, when launching an activity from the
   2807      * notification manager.
   2808      *
   2809      * <p>See
   2810      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
   2811      * Stack</a> for more information about tasks.
   2812      */
   2813     public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
   2814     /**
   2815      * If set and this intent is being used to launch a new activity from an
   2816      * existing one, then the reply target of the existing activity will be
   2817      * transfered to the new activity.  This way the new activity can call
   2818      * {@link android.app.Activity#setResult} and have that result sent back to
   2819      * the reply target of the original activity.
   2820      */
   2821     public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
   2822     /**
   2823      * If set and this intent is being used to launch a new activity from an
   2824      * existing one, the current activity will not be counted as the top
   2825      * activity for deciding whether the new intent should be delivered to
   2826      * the top instead of starting a new one.  The previous activity will
   2827      * be used as the top, with the assumption being that the current activity
   2828      * will finish itself immediately.
   2829      */
   2830     public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
   2831     /**
   2832      * If set, the new activity is not kept in the list of recently launched
   2833      * activities.
   2834      */
   2835     public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
   2836     /**
   2837      * This flag is not normally set by application code, but set for you by
   2838      * the system as described in the
   2839      * {@link android.R.styleable#AndroidManifestActivity_launchMode
   2840      * launchMode} documentation for the singleTask mode.
   2841      */
   2842     public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
   2843     /**
   2844      * If set, and this activity is either being started in a new task or
   2845      * bringing to the top an existing task, then it will be launched as
   2846      * the front door of the task.  This will result in the application of
   2847      * any affinities needed to have that task in the proper state (either
   2848      * moving activities to or from it), or simply resetting that task to
   2849      * its initial state if needed.
   2850      */
   2851     public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
   2852     /**
   2853      * This flag is not normally set by application code, but set for you by
   2854      * the system if this activity is being launched from history
   2855      * (longpress home key).
   2856      */
   2857     public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
   2858     /**
   2859      * If set, this marks a point in the task's activity stack that should
   2860      * be cleared when the task is reset.  That is, the next time the task
   2861      * is brought to the foreground with
   2862      * {@link #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED} (typically as a result of
   2863      * the user re-launching it from home), this activity and all on top of
   2864      * it will be finished so that the user does not return to them, but
   2865      * instead returns to whatever activity preceeded it.
   2866      *
   2867      * <p>This is useful for cases where you have a logical break in your
   2868      * application.  For example, an e-mail application may have a command
   2869      * to view an attachment, which launches an image view activity to
   2870      * display it.  This activity should be part of the e-mail application's
   2871      * task, since it is a part of the task the user is involved in.  However,
   2872      * if the user leaves that task, and later selects the e-mail app from
   2873      * home, we may like them to return to the conversation they were
   2874      * viewing, not the picture attachment, since that is confusing.  By
   2875      * setting this flag when launching the image viewer, that viewer and
   2876      * any activities it starts will be removed the next time the user returns
   2877      * to mail.
   2878      */
   2879     public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
   2880     /**
   2881      * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
   2882      * callback from occurring on the current frontmost activity before it is
   2883      * paused as the newly-started activity is brought to the front.
   2884      *
   2885      * <p>Typically, an activity can rely on that callback to indicate that an
   2886      * explicit user action has caused their activity to be moved out of the
   2887      * foreground. The callback marks an appropriate point in the activity's
   2888      * lifecycle for it to dismiss any notifications that it intends to display
   2889      * "until the user has seen them," such as a blinking LED.
   2890      *
   2891      * <p>If an activity is ever started via any non-user-driven events such as
   2892      * phone-call receipt or an alarm handler, this flag should be passed to {@link
   2893      * Context#startActivity Context.startActivity}, ensuring that the pausing
   2894      * activity does not think the user has acknowledged its notification.
   2895      */
   2896     public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
   2897     /**
   2898      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
   2899      * this flag will cause the launched activity to be brought to the front of its
   2900      * task's history stack if it is already running.
   2901      *
   2902      * <p>For example, consider a task consisting of four activities: A, B, C, D.
   2903      * If D calls startActivity() with an Intent that resolves to the component
   2904      * of activity B, then B will be brought to the front of the history stack,
   2905      * with this resulting order:  A, C, D, B.
   2906      *
   2907      * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
   2908      * specified.
   2909      */
   2910     public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
   2911     /**
   2912      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
   2913      * this flag will prevent the system from applying an activity transition
   2914      * animation to go to the next activity state.  This doesn't mean an
   2915      * animation will never run -- if another activity change happens that doesn't
   2916      * specify this flag before the activity started here is displayed, then
   2917      * that transition will be used.  This flag can be put to good use
   2918      * when you are going to do a series of activity operations but the
   2919      * animation seen by the user shouldn't be driven by the first activity
   2920      * change but rather a later one.
   2921      */
   2922     public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
   2923     /**
   2924      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
   2925      * this flag will cause any existing task that would be associated with the
   2926      * activity to be cleared before the activity is started.  That is, the activity
   2927      * becomes the new root of an otherwise empty task, and any old activities
   2928      * are finished.  This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
   2929      */
   2930     public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
   2931     /**
   2932      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
   2933      * this flag will cause a newly launching task to be placed on top of the current
   2934      * home activity task (if there is one).  That is, pressing back from the task
   2935      * will always return the user to home even if that was not the last activity they
   2936      * saw.   This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
   2937      */
   2938     public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
   2939     /**
   2940      * If set, when sending a broadcast only registered receivers will be
   2941      * called -- no BroadcastReceiver components will be launched.
   2942      */
   2943     public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
   2944     /**
   2945      * If set, when sending a broadcast the new broadcast will replace
   2946      * any existing pending broadcast that matches it.  Matching is defined
   2947      * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
   2948      * true for the intents of the two broadcasts.  When a match is found,
   2949      * the new broadcast (and receivers associated with it) will replace the
   2950      * existing one in the pending broadcast list, remaining at the same
   2951      * position in the list.
   2952      *
   2953      * <p>This flag is most typically used with sticky broadcasts, which
   2954      * only care about delivering the most recent values of the broadcast
   2955      * to their receivers.
   2956      */
   2957     public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
   2958     /**
   2959      * If set, when sending a broadcast <i>before boot has completed</i> only
   2960      * registered receivers will be called -- no BroadcastReceiver components
   2961      * will be launched.  Sticky intent state will be recorded properly even
   2962      * if no receivers wind up being called.  If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
   2963      * is specified in the broadcast intent, this flag is unnecessary.
   2964      *
   2965      * <p>This flag is only for use by system sevices as a convenience to
   2966      * avoid having to implement a more complex mechanism around detection
   2967      * of boot completion.
   2968      *
   2969      * @hide
   2970      */
   2971     public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x10000000;
   2972     /**
   2973      * Set when this broadcast is for a boot upgrade, a special mode that
   2974      * allows the broadcast to be sent before the system is ready and launches
   2975      * the app process with no providers running in it.
   2976      * @hide
   2977      */
   2978     public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x08000000;
   2979 
   2980     /**
   2981      * @hide Flags that can't be changed with PendingIntent.
   2982      */
   2983     public static final int IMMUTABLE_FLAGS =
   2984             FLAG_GRANT_READ_URI_PERMISSION
   2985             | FLAG_GRANT_WRITE_URI_PERMISSION;
   2986 
   2987     // ---------------------------------------------------------------------
   2988     // ---------------------------------------------------------------------
   2989     // toUri() and parseUri() options.
   2990 
   2991     /**
   2992      * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
   2993      * always has the "intent:" scheme.  This syntax can be used when you want
   2994      * to later disambiguate between URIs that are intended to describe an
   2995      * Intent vs. all others that should be treated as raw URIs.  When used
   2996      * with {@link #parseUri}, any other scheme will result in a generic
   2997      * VIEW action for that raw URI.
   2998      */
   2999     public static final int URI_INTENT_SCHEME = 1<<0;
   3000 
   3001     // ---------------------------------------------------------------------
   3002 
   3003     private String mAction;
   3004     private Uri mData;
   3005     private String mType;
   3006     private String mPackage;
   3007     private ComponentName mComponent;
   3008     private int mFlags;
   3009     private HashSet<String> mCategories;
   3010     private Bundle mExtras;
   3011     private Rect mSourceBounds;
   3012     private Intent mSelector;
   3013 
   3014     // ---------------------------------------------------------------------
   3015 
   3016     /**
   3017      * Create an empty intent.
   3018      */
   3019     public Intent() {
   3020     }
   3021 
   3022     /**
   3023      * Copy constructor.
   3024      */
   3025     public Intent(Intent o) {
   3026         this.mAction = o.mAction;
   3027         this.mData = o.mData;
   3028         this.mType = o.mType;
   3029         this.mPackage = o.mPackage;
   3030         this.mComponent = o.mComponent;
   3031         this.mFlags = o.mFlags;
   3032         if (o.mCategories != null) {
   3033             this.mCategories = new HashSet<String>(o.mCategories);
   3034         }
   3035         if (o.mExtras != null) {
   3036             this.mExtras = new Bundle(o.mExtras);
   3037         }
   3038         if (o.mSourceBounds != null) {
   3039             this.mSourceBounds = new Rect(o.mSourceBounds);
   3040         }
   3041         if (o.mSelector != null) {
   3042             this.mSelector = new Intent(o.mSelector);
   3043         }
   3044     }
   3045 
   3046     @Override
   3047     public Object clone() {
   3048         return new Intent(this);
   3049     }
   3050 
   3051     private Intent(Intent o, boolean all) {
   3052         this.mAction = o.mAction;
   3053         this.mData = o.mData;
   3054         this.mType = o.mType;
   3055         this.mPackage = o.mPackage;
   3056         this.mComponent = o.mComponent;
   3057         if (o.mCategories != null) {
   3058             this.mCategories = new HashSet<String>(o.mCategories);
   3059         }
   3060     }
   3061 
   3062     /**
   3063      * Make a clone of only the parts of the Intent that are relevant for
   3064      * filter matching: the action, data, type, component, and categories.
   3065      */
   3066     public Intent cloneFilter() {
   3067         return new Intent(this, false);
   3068     }
   3069 
   3070     /**
   3071      * Create an intent with a given action.  All other fields (data, type,
   3072      * class) are null.  Note that the action <em>must</em> be in a
   3073      * namespace because Intents are used globally in the system -- for
   3074      * example the system VIEW action is android.intent.action.VIEW; an
   3075      * application's custom action would be something like
   3076      * com.google.app.myapp.CUSTOM_ACTION.
   3077      *
   3078      * @param action The Intent action, such as ACTION_VIEW.
   3079      */
   3080     public Intent(String action) {
   3081         setAction(action);
   3082     }
   3083 
   3084     /**
   3085      * Create an intent with a given action and for a given data url.  Note
   3086      * that the action <em>must</em> be in a namespace because Intents are
   3087      * used globally in the system -- for example the system VIEW action is
   3088      * android.intent.action.VIEW; an application's custom action would be
   3089      * something like com.google.app.myapp.CUSTOM_ACTION.
   3090      *
   3091      * <p><em>Note: scheme and host name matching in the Android framework is
   3092      * case-sensitive, unlike the formal RFC.  As a result,
   3093      * you should always ensure that you write your Uri with these elements
   3094      * using lower case letters, and normalize any Uris you receive from
   3095      * outside of Android to ensure the scheme and host is lower case.</em></p>
   3096      *
   3097      * @param action The Intent action, such as ACTION_VIEW.
   3098      * @param uri The Intent data URI.
   3099      */
   3100     public Intent(String action, Uri uri) {
   3101         setAction(action);
   3102         mData = uri;
   3103     }
   3104 
   3105     /**
   3106      * Create an intent for a specific component.  All other fields (action, data,
   3107      * type, class) are null, though they can be modified later with explicit
   3108      * calls.  This provides a convenient way to create an intent that is
   3109      * intended to execute a hard-coded class name, rather than relying on the
   3110      * system to find an appropriate class for you; see {@link #setComponent}
   3111      * for more information on the repercussions of this.
   3112      *
   3113      * @param packageContext A Context of the application package implementing
   3114      * this class.
   3115      * @param cls The component class that is to be used for the intent.
   3116      *
   3117      * @see #setClass
   3118      * @see #setComponent
   3119      * @see #Intent(String, android.net.Uri , Context, Class)
   3120      */
   3121     public Intent(Context packageContext, Class<?> cls) {
   3122         mComponent = new ComponentName(packageContext, cls);
   3123     }
   3124 
   3125     /**
   3126      * Create an intent for a specific component with a specified action and data.
   3127      * This is equivalent using {@link #Intent(String, android.net.Uri)} to
   3128      * construct the Intent and then calling {@link #setClass} to set its
   3129      * class.
   3130      *
   3131      * <p><em>Note: scheme and host name matching in the Android framework is
   3132      * case-sensitive, unlike the formal RFC.  As a result,
   3133      * you should always ensure that you write your Uri with these elements
   3134      * using lower case letters, and normalize any Uris you receive from
   3135      * outside of Android to ensure the scheme and host is lower case.</em></p>
   3136      *
   3137      * @param action The Intent action, such as ACTION_VIEW.
   3138      * @param uri The Intent data URI.
   3139      * @param packageContext A Context of the application package implementing
   3140      * this class.
   3141      * @param cls The component class that is to be used for the intent.
   3142      *
   3143      * @see #Intent(String, android.net.Uri)
   3144      * @see #Intent(Context, Class)
   3145      * @see #setClass
   3146      * @see #setComponent
   3147      */
   3148     public Intent(String action, Uri uri,
   3149             Context packageContext, Class<?> cls) {
   3150         setAction(action);
   3151         mData = uri;
   3152         mComponent = new ComponentName(packageContext, cls);
   3153     }
   3154 
   3155     /**
   3156      * Create an intent to launch the main (root) activity of a task.  This
   3157      * is the Intent that is started when the application's is launched from
   3158      * Home.  For anything else that wants to launch an application in the
   3159      * same way, it is important that they use an Intent structured the same
   3160      * way, and can use this function to ensure this is the case.
   3161      *
   3162      * <p>The returned Intent has the given Activity component as its explicit
   3163      * component, {@link #ACTION_MAIN} as its action, and includes the
   3164      * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
   3165      * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
   3166      * to do that through {@link #addFlags(int)} on the returned Intent.
   3167      *
   3168      * @param mainActivity The main activity component that this Intent will
   3169      * launch.
   3170      * @return Returns a newly created Intent that can be used to launch the
   3171      * activity as a main application entry.
   3172      *
   3173      * @see #setClass
   3174      * @see #setComponent
   3175      */
   3176     public static Intent makeMainActivity(ComponentName mainActivity) {
   3177         Intent intent = new Intent(ACTION_MAIN);
   3178         intent.setComponent(mainActivity);
   3179         intent.addCategory(CATEGORY_LAUNCHER);
   3180         return intent;
   3181     }
   3182 
   3183     /**
   3184      * Make an Intent for the main activity of an application, without
   3185      * specifying a specific activity to run but giving a selector to find
   3186      * the activity.  This results in a final Intent that is structured
   3187      * the same as when the application is launched from
   3188      * Home.  For anything else that wants to launch an application in the
   3189      * same way, it is important that they use an Intent structured the same
   3190      * way, and can use this function to ensure this is the case.
   3191      *
   3192      * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
   3193      * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
   3194      * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
   3195      * to do that through {@link #addFlags(int)} on the returned Intent.
   3196      *
   3197      * @param selectorAction The action name of the Intent's selector.
   3198      * @param selectorCategory The name of a category to add to the Intent's
   3199      * selector.
   3200      * @return Returns a newly created Intent that can be used to launch the
   3201      * activity as a main application entry.
   3202      *
   3203      * @see #setSelector(Intent)
   3204      */
   3205     public static Intent makeMainSelectorActivity(String selectorAction,
   3206             String selectorCategory) {
   3207         Intent intent = new Intent(ACTION_MAIN);
   3208         intent.addCategory(CATEGORY_LAUNCHER);
   3209         Intent selector = new Intent();
   3210         selector.setAction(selectorAction);
   3211         selector.addCategory(selectorCategory);
   3212         intent.setSelector(selector);
   3213         return intent;
   3214     }
   3215 
   3216     /**
   3217      * Make an Intent that can be used to re-launch an application's task
   3218      * in its base state.  This is like {@link #makeMainActivity(ComponentName)},
   3219      * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
   3220      * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
   3221      *
   3222      * @param mainActivity The activity component that is the root of the
   3223      * task; this is the activity that has been published in the application's
   3224      * manifest as the main launcher icon.
   3225      *
   3226      * @return Returns a newly created Intent that can be used to relaunch the
   3227      * activity's task in its root state.
   3228      */
   3229     public static Intent makeRestartActivityTask(ComponentName mainActivity) {
   3230         Intent intent = makeMainActivity(mainActivity);
   3231         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
   3232                 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
   3233         return intent;
   3234     }
   3235 
   3236     /**
   3237      * Call {@link #parseUri} with 0 flags.
   3238      * @deprecated Use {@link #parseUri} instead.
   3239      */
   3240     @Deprecated
   3241     public static Intent getIntent(String uri) throws URISyntaxException {
   3242         return parseUri(uri, 0);
   3243     }
   3244 
   3245     /**
   3246      * Create an intent from a URI.  This URI may encode the action,
   3247      * category, and other intent fields, if it was returned by
   3248      * {@link #toUri}.  If the Intent was not generate by toUri(), its data
   3249      * will be the entire URI and its action will be ACTION_VIEW.
   3250      *
   3251      * <p>The URI given here must not be relative -- that is, it must include
   3252      * the scheme and full path.
   3253      *
   3254      * @param uri The URI to turn into an Intent.
   3255      * @param flags Additional processing flags.  Either 0 or
   3256      * {@link #URI_INTENT_SCHEME}.
   3257      *
   3258      * @return Intent The newly created Intent object.
   3259      *
   3260      * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
   3261      * it bad (as parsed by the Uri class) or the Intent data within the
   3262      * URI is invalid.
   3263      *
   3264      * @see #toUri
   3265      */
   3266     public static Intent parseUri(String uri, int flags) throws URISyntaxException {
   3267         int i = 0;
   3268         try {
   3269             // Validate intent scheme for if requested.
   3270             if ((flags&URI_INTENT_SCHEME) != 0) {
   3271                 if (!uri.startsWith("intent:")) {
   3272                     Intent intent = new Intent(ACTION_VIEW);
   3273                     try {
   3274                         intent.setData(Uri.parse(uri));
   3275                     } catch (IllegalArgumentException e) {
   3276                         throw new URISyntaxException(uri, e.getMessage());
   3277                     }
   3278                     return intent;
   3279                 }
   3280             }
   3281 
   3282             // simple case
   3283             i = uri.lastIndexOf("#");
   3284             if (i == -1) return new Intent(ACTION_VIEW, Uri.parse(uri));
   3285 
   3286             // old format Intent URI
   3287             if (!uri.startsWith("#Intent;", i)) return getIntentOld(uri);
   3288 
   3289             // new format
   3290             Intent intent = new Intent(ACTION_VIEW);
   3291             Intent baseIntent = intent;
   3292 
   3293             // fetch data part, if present
   3294             String data = i >= 0 ? uri.substring(0, i) : null;
   3295             String scheme = null;
   3296             i += "#Intent;".length();
   3297 
   3298             // loop over contents of Intent, all name=value;
   3299             while (!uri.startsWith("end", i)) {
   3300                 int eq = uri.indexOf('=', i);
   3301                 if (eq < 0) eq = i-1;
   3302                 int semi = uri.indexOf(';', i);
   3303                 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
   3304 
   3305                 // action
   3306                 if (uri.startsWith("action=", i)) {
   3307                     intent.setAction(value);
   3308                 }
   3309 
   3310                 // categories
   3311                 else if (uri.startsWith("category=", i)) {
   3312                     intent.addCategory(value);
   3313                 }
   3314 
   3315                 // type
   3316                 else if (uri.startsWith("type=", i)) {
   3317                     intent.mType = value;
   3318                 }
   3319 
   3320                 // launch flags
   3321                 else if (uri.startsWith("launchFlags=", i)) {
   3322                     intent.mFlags = Integer.decode(value).intValue();
   3323                 }
   3324 
   3325                 // package
   3326                 else if (uri.startsWith("package=", i)) {
   3327                     intent.mPackage = value;
   3328                 }
   3329 
   3330                 // component
   3331                 else if (uri.startsWith("component=", i)) {
   3332                     intent.mComponent = ComponentName.unflattenFromString(value);
   3333                 }
   3334 
   3335                 // scheme
   3336                 else if (uri.startsWith("scheme=", i)) {
   3337                     scheme = value;
   3338                 }
   3339 
   3340                 // source bounds
   3341                 else if (uri.startsWith("sourceBounds=", i)) {
   3342                     intent.mSourceBounds = Rect.unflattenFromString(value);
   3343                 }
   3344 
   3345                 // selector
   3346                 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
   3347                     intent = new Intent();
   3348                 }
   3349 
   3350                 // extra
   3351                 else {
   3352                     String key = Uri.decode(uri.substring(i + 2, eq));
   3353                     // create Bundle if it doesn't already exist
   3354                     if (intent.mExtras == null) intent.mExtras = new Bundle();
   3355                     Bundle b = intent.mExtras;
   3356                     // add EXTRA
   3357                     if      (uri.startsWith("S.", i)) b.putString(key, value);
   3358                     else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
   3359                     else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
   3360                     else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
   3361                     else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
   3362                     else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
   3363                     else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
   3364                     else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
   3365                     else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
   3366                     else throw new URISyntaxException(uri, "unknown EXTRA type", i);
   3367                 }
   3368 
   3369                 // move to the next item
   3370                 i = semi + 1;
   3371             }
   3372 
   3373             if (intent != baseIntent) {
   3374                 // The Intent had a selector; fix it up.
   3375                 baseIntent.setSelector(intent);
   3376                 intent = baseIntent;
   3377             }
   3378 
   3379             if (data != null) {
   3380                 if (data.startsWith("intent:")) {
   3381                     data = data.substring(7);
   3382                     if (scheme != null) {
   3383                         data = scheme + ':' + data;
   3384                     }
   3385                 }
   3386 
   3387                 if (data.length() > 0) {
   3388                     try {
   3389                         intent.mData = Uri.parse(data);
   3390                     } catch (IllegalArgumentException e) {
   3391                         throw new URISyntaxException(uri, e.getMessage());
   3392                     }
   3393                 }
   3394             }
   3395 
   3396             return intent;
   3397 
   3398         } catch (IndexOutOfBoundsException e) {
   3399             throw new URISyntaxException(uri, "illegal Intent URI format", i);
   3400         }
   3401     }
   3402 
   3403     public static Intent getIntentOld(String uri) throws URISyntaxException {
   3404         Intent intent;
   3405 
   3406         int i = uri.lastIndexOf('#');
   3407         if (i >= 0) {
   3408             String action = null;
   3409             final int intentFragmentStart = i;
   3410             boolean isIntentFragment = false;
   3411 
   3412             i++;
   3413 
   3414             if (uri.regionMatches(i, "action(", 0, 7)) {
   3415                 isIntentFragment = true;
   3416                 i += 7;
   3417                 int j = uri.indexOf(')', i);
   3418                 action = uri.substring(i, j);
   3419                 i = j + 1;
   3420             }
   3421 
   3422             intent = new Intent(action);
   3423 
   3424             if (uri.regionMatches(i, "categories(", 0, 11)) {
   3425                 isIntentFragment = true;
   3426                 i += 11;
   3427                 int j = uri.indexOf(')', i);
   3428                 while (i < j) {
   3429                     int sep = uri.indexOf('!', i);
   3430                     if (sep < 0) sep = j;
   3431                     if (i < sep) {
   3432                         intent.addCategory(uri.substring(i, sep));
   3433                     }
   3434                     i = sep + 1;
   3435                 }
   3436                 i = j + 1;
   3437             }
   3438 
   3439             if (uri.regionMatches(i, "type(", 0, 5)) {
   3440                 isIntentFragment = true;
   3441                 i += 5;
   3442                 int j = uri.indexOf(')', i);
   3443                 intent.mType = uri.substring(i, j);
   3444                 i = j + 1;
   3445             }
   3446 
   3447             if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
   3448                 isIntentFragment = true;
   3449                 i += 12;
   3450                 int j = uri.indexOf(')', i);
   3451                 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
   3452                 i = j + 1;
   3453             }
   3454 
   3455             if (uri.regionMatches(i, "component(", 0, 10)) {
   3456                 isIntentFragment = true;
   3457                 i += 10;
   3458                 int j = uri.indexOf(')', i);
   3459                 int sep = uri.indexOf('!', i);
   3460                 if (sep >= 0 && sep < j) {
   3461                     String pkg = uri.substring(i, sep);
   3462                     String cls = uri.substring(sep + 1, j);
   3463                     intent.mComponent = new ComponentName(pkg, cls);
   3464                 }
   3465                 i = j + 1;
   3466             }
   3467 
   3468             if (uri.regionMatches(i, "extras(", 0, 7)) {
   3469                 isIntentFragment = true;
   3470                 i += 7;
   3471 
   3472                 final int closeParen = uri.indexOf(')', i);
   3473                 if (closeParen == -1) throw new URISyntaxException(uri,
   3474                         "EXTRA missing trailing ')'", i);
   3475 
   3476                 while (i < closeParen) {
   3477                     // fetch the key value
   3478                     int j = uri.indexOf('=', i);
   3479                     if (j <= i + 1 || i >= closeParen) {
   3480                         throw new URISyntaxException(uri, "EXTRA missing '='", i);
   3481                     }
   3482                     char type = uri.charAt(i);
   3483                     i++;
   3484                     String key = uri.substring(i, j);
   3485                     i = j + 1;
   3486 
   3487                     // get type-value
   3488                     j = uri.indexOf('!', i);
   3489                     if (j == -1 || j >= closeParen) j = closeParen;
   3490                     if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
   3491                     String value = uri.substring(i, j);
   3492                     i = j;
   3493 
   3494                     // create Bundle if it doesn't already exist
   3495                     if (intent.mExtras == null) intent.mExtras = new Bundle();
   3496 
   3497                     // add item to bundle
   3498                     try {
   3499                         switch (type) {
   3500                             case 'S':
   3501                                 intent.mExtras.putString(key, Uri.decode(value));
   3502                                 break;
   3503                             case 'B':
   3504                                 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
   3505                                 break;
   3506                             case 'b':
   3507                                 intent.mExtras.putByte(key, Byte.parseByte(value));
   3508                                 break;
   3509                             case 'c':
   3510                                 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
   3511                                 break;
   3512                             case 'd':
   3513                                 intent.mExtras.putDouble(key, Double.parseDouble(value));
   3514                                 break;
   3515                             case 'f':
   3516                                 intent.mExtras.putFloat(key, Float.parseFloat(value));
   3517                                 break;
   3518                             case 'i':
   3519                                 intent.mExtras.putInt(key, Integer.parseInt(value));
   3520                                 break;
   3521                             case 'l':
   3522                                 intent.mExtras.putLong(key, Long.parseLong(value));
   3523                                 break;
   3524                             case 's':
   3525                                 intent.mExtras.putShort(key, Short.parseShort(value));
   3526                                 break;
   3527                             default:
   3528                                 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
   3529                         }
   3530                     } catch (NumberFormatException e) {
   3531                         throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
   3532                     }
   3533 
   3534                     char ch = uri.charAt(i);
   3535                     if (ch == ')') break;
   3536                     if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
   3537                     i++;
   3538                 }
   3539             }
   3540 
   3541             if (isIntentFragment) {
   3542                 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
   3543             } else {
   3544                 intent.mData = Uri.parse(uri);
   3545             }
   3546 
   3547             if (intent.mAction == null) {
   3548                 // By default, if no action is specified, then use VIEW.
   3549                 intent.mAction = ACTION_VIEW;
   3550             }
   3551 
   3552         } else {
   3553             intent = new Intent(ACTION_VIEW, Uri.parse(uri));
   3554         }
   3555 
   3556         return intent;
   3557     }
   3558 
   3559     /**
   3560      * Retrieve the general action to be performed, such as
   3561      * {@link #ACTION_VIEW}.  The action describes the general way the rest of
   3562      * the information in the intent should be interpreted -- most importantly,
   3563      * what to do with the data returned by {@link #getData}.
   3564      *
   3565      * @return The action of this intent or null if none is specified.
   3566      *
   3567      * @see #setAction
   3568      */
   3569     public String getAction() {
   3570         return mAction;
   3571     }
   3572 
   3573     /**
   3574      * Retrieve data this intent is operating on.  This URI specifies the name
   3575      * of the data; often it uses the content: scheme, specifying data in a
   3576      * content provider.  Other schemes may be handled by specific activities,
   3577      * such as http: by the web browser.
   3578      *
   3579      * @return The URI of the data this intent is targeting or null.
   3580      *
   3581      * @see #getScheme
   3582      * @see #setData
   3583      */
   3584     public Uri getData() {
   3585         return mData;
   3586     }
   3587 
   3588     /**
   3589      * The same as {@link #getData()}, but returns the URI as an encoded
   3590      * String.
   3591      */
   3592     public String getDataString() {
   3593         return mData != null ? mData.toString() : null;
   3594     }
   3595 
   3596     /**
   3597      * Return the scheme portion of the intent's data.  If the data is null or
   3598      * does not include a scheme, null is returned.  Otherwise, the scheme
   3599      * prefix without the final ':' is returned, i.e. "http".
   3600      *
   3601      * <p>This is the same as calling getData().getScheme() (and checking for
   3602      * null data).
   3603      *
   3604      * @return The scheme of this intent.
   3605      *
   3606      * @see #getData
   3607      */
   3608     public String getScheme() {
   3609         return mData != null ? mData.getScheme() : null;
   3610     }
   3611 
   3612     /**
   3613      * Retrieve any explicit MIME type included in the intent.  This is usually
   3614      * null, as the type is determined by the intent data.
   3615      *
   3616      * @return If a type was manually set, it is returned; else null is
   3617      *         returned.
   3618      *
   3619      * @see #resolveType(ContentResolver)
   3620      * @see #setType
   3621      */
   3622     public String getType() {
   3623         return mType;
   3624     }
   3625 
   3626     /**
   3627      * Return the MIME data type of this intent.  If the type field is
   3628      * explicitly set, that is simply returned.  Otherwise, if the data is set,
   3629      * the type of that data is returned.  If neither fields are set, a null is
   3630      * returned.
   3631      *
   3632      * @return The MIME type of this intent.
   3633      *
   3634      * @see #getType
   3635      * @see #resolveType(ContentResolver)
   3636      */
   3637     public String resolveType(Context context) {
   3638         return resolveType(context.getContentResolver());
   3639     }
   3640 
   3641     /**
   3642      * Return the MIME data type of this intent.  If the type field is
   3643      * explicitly set, that is simply returned.  Otherwise, if the data is set,
   3644      * the type of that data is returned.  If neither fields are set, a null is
   3645      * returned.
   3646      *
   3647      * @param resolver A ContentResolver that can be used to determine the MIME
   3648      *                 type of the intent's data.
   3649      *
   3650      * @return The MIME type of this intent.
   3651      *
   3652      * @see #getType
   3653      * @see #resolveType(Context)
   3654      */
   3655     public String resolveType(ContentResolver resolver) {
   3656         if (mType != null) {
   3657             return mType;
   3658         }
   3659         if (mData != null) {
   3660             if ("content".equals(mData.getScheme())) {
   3661                 return resolver.getType(mData);
   3662             }
   3663         }
   3664         return null;
   3665     }
   3666 
   3667     /**
   3668      * Return the MIME data type of this intent, only if it will be needed for
   3669      * intent resolution.  This is not generally useful for application code;
   3670      * it is used by the frameworks for communicating with back-end system
   3671      * services.
   3672      *
   3673      * @param resolver A ContentResolver that can be used to determine the MIME
   3674      *                 type of the intent's data.
   3675      *
   3676      * @return The MIME type of this intent, or null if it is unknown or not
   3677      *         needed.
   3678      */
   3679     public String resolveTypeIfNeeded(ContentResolver resolver) {
   3680         if (mComponent != null) {
   3681             return mType;
   3682         }
   3683         return resolveType(resolver);
   3684     }
   3685 
   3686     /**
   3687      * Check if an category exists in the intent.
   3688      *
   3689      * @param category The category to check.
   3690      *
   3691      * @return boolean True if the intent contains the category, else false.
   3692      *
   3693      * @see #getCategories
   3694      * @see #addCategory
   3695      */
   3696     public boolean hasCategory(String category) {
   3697         return mCategories != null && mCategories.contains(category);
   3698     }
   3699 
   3700     /**
   3701      * Return the set of all categories in the intent.  If there are no categories,
   3702      * returns NULL.
   3703      *
   3704      * @return The set of categories you can examine.  Do not modify!
   3705      *
   3706      * @see #hasCategory
   3707      * @see #addCategory
   3708      */
   3709     public Set<String> getCategories() {
   3710         return mCategories;
   3711     }
   3712 
   3713     /**
   3714      * Return the specific selector associated with this Intent.  If there is
   3715      * none, returns null.  See {@link #setSelector} for more information.
   3716      *
   3717      * @see #setSelector
   3718      */
   3719     public Intent getSelector() {
   3720         return mSelector;
   3721     }
   3722 
   3723     /**
   3724      * Sets the ClassLoader that will be used when unmarshalling
   3725      * any Parcelable values from the extras of this Intent.
   3726      *
   3727      * @param loader a ClassLoader, or null to use the default loader
   3728      * at the time of unmarshalling.
   3729      */
   3730     public void setExtrasClassLoader(ClassLoader loader) {
   3731         if (mExtras != null) {
   3732             mExtras.setClassLoader(loader);
   3733         }
   3734     }
   3735 
   3736     /**
   3737      * Returns true if an extra value is associated with the given name.
   3738      * @param name the extra's name
   3739      * @return true if the given extra is present.
   3740      */
   3741     public boolean hasExtra(String name) {
   3742         return mExtras != null && mExtras.containsKey(name);
   3743     }
   3744 
   3745     /**
   3746      * Returns true if the Intent's extras contain a parcelled file descriptor.
   3747      * @return true if the Intent contains a parcelled file descriptor.
   3748      */
   3749     public boolean hasFileDescriptors() {
   3750         return mExtras != null && mExtras.hasFileDescriptors();
   3751     }
   3752 
   3753     /** @hide */
   3754     public void setAllowFds(boolean allowFds) {
   3755         if (mExtras != null) {
   3756             mExtras.setAllowFds(allowFds);
   3757         }
   3758     }
   3759 
   3760     /**
   3761      * Retrieve extended data from the intent.
   3762      *
   3763      * @param name The name of the desired item.
   3764      *
   3765      * @return the value of an item that previously added with putExtra()
   3766      * or null if none was found.
   3767      *
   3768      * @deprecated
   3769      * @hide
   3770      */
   3771     @Deprecated
   3772     public Object getExtra(String name) {
   3773         return getExtra(name, null);
   3774     }
   3775 
   3776     /**
   3777      * Retrieve extended data from the intent.
   3778      *
   3779      * @param name The name of the desired item.
   3780      * @param defaultValue the value to be returned if no value of the desired
   3781      * type is stored with the given name.
   3782      *
   3783      * @return the value of an item that previously added with putExtra()
   3784      * or the default value if none was found.
   3785      *
   3786      * @see #putExtra(String, boolean)
   3787      */
   3788     public boolean getBooleanExtra(String name, boolean defaultValue) {
   3789         return mExtras == null ? defaultValue :
   3790             mExtras.getBoolean(name, defaultValue);
   3791     }
   3792 
   3793     /**
   3794      * Retrieve extended data from the intent.
   3795      *
   3796      * @param name The name of the desired item.
   3797      * @param defaultValue the value to be returned if no value of the desired
   3798      * type is stored with the given name.
   3799      *
   3800      * @return the value of an item that previously added with putExtra()
   3801      * or the default value if none was found.
   3802      *
   3803      * @see #putExtra(String, byte)
   3804      */
   3805     public byte getByteExtra(String name, byte defaultValue) {
   3806         return mExtras == null ? defaultValue :
   3807             mExtras.getByte(name, defaultValue);
   3808     }
   3809 
   3810     /**
   3811      * Retrieve extended data from the intent.
   3812      *
   3813      * @param name The name of the desired item.
   3814      * @param defaultValue the value to be returned if no value of the desired
   3815      * type is stored with the given name.
   3816      *
   3817      * @return the value of an item that previously added with putExtra()
   3818      * or the default value if none was found.
   3819      *
   3820      * @see #putExtra(String, short)
   3821      */
   3822     public short getShortExtra(String name, short defaultValue) {
   3823         return mExtras == null ? defaultValue :
   3824             mExtras.getShort(name, defaultValue);
   3825     }
   3826 
   3827     /**
   3828      * Retrieve extended data from the intent.
   3829      *
   3830      * @param name The name of the desired item.
   3831      * @param defaultValue the value to be returned if no value of the desired
   3832      * type is stored with the given name.
   3833      *
   3834      * @return the value of an item that previously added with putExtra()
   3835      * or the default value if none was found.
   3836      *
   3837      * @see #putExtra(String, char)
   3838      */
   3839     public char getCharExtra(String name, char defaultValue) {
   3840         return mExtras == null ? defaultValue :
   3841             mExtras.getChar(name, defaultValue);
   3842     }
   3843 
   3844     /**
   3845      * Retrieve extended data from the intent.
   3846      *
   3847      * @param name The name of the desired item.
   3848      * @param defaultValue the value to be returned if no value of the desired
   3849      * type is stored with the given name.
   3850      *
   3851      * @return the value of an item that previously added with putExtra()
   3852      * or the default value if none was found.
   3853      *
   3854      * @see #putExtra(String, int)
   3855      */
   3856     public int getIntExtra(String name, int defaultValue) {
   3857         return mExtras == null ? defaultValue :
   3858             mExtras.getInt(name, defaultValue);
   3859     }
   3860 
   3861     /**
   3862      * Retrieve extended data from the intent.
   3863      *
   3864      * @param name The name of the desired item.
   3865      * @param defaultValue the value to be returned if no value of the desired
   3866      * type is stored with the given name.
   3867      *
   3868      * @return the value of an item that previously added with putExtra()
   3869      * or the default value if none was found.
   3870      *
   3871      * @see #putExtra(String, long)
   3872      */
   3873     public long getLongExtra(String name, long defaultValue) {
   3874         return mExtras == null ? defaultValue :
   3875             mExtras.getLong(name, defaultValue);
   3876     }
   3877 
   3878     /**
   3879      * Retrieve extended data from the intent.
   3880      *
   3881      * @param name The name of the desired item.
   3882      * @param defaultValue the value to be returned if no value of the desired
   3883      * type is stored with the given name.
   3884      *
   3885      * @return the value of an item that previously added with putExtra(),
   3886      * or the default value if no such item is present
   3887      *
   3888      * @see #putExtra(String, float)
   3889      */
   3890     public float getFloatExtra(String name, float defaultValue) {
   3891         return mExtras == null ? defaultValue :
   3892             mExtras.getFloat(name, defaultValue);
   3893     }
   3894 
   3895     /**
   3896      * Retrieve extended data from the intent.
   3897      *
   3898      * @param name The name of the desired item.
   3899      * @param defaultValue the value to be returned if no value of the desired
   3900      * type is stored with the given name.
   3901      *
   3902      * @return the value of an item that previously added with putExtra()
   3903      * or the default value if none was found.
   3904      *
   3905      * @see #putExtra(String, double)
   3906      */
   3907     public double getDoubleExtra(String name, double defaultValue) {
   3908         return mExtras == null ? defaultValue :
   3909             mExtras.getDouble(name, defaultValue);
   3910     }
   3911 
   3912     /**
   3913      * Retrieve extended data from the intent.
   3914      *
   3915      * @param name The name of the desired item.
   3916      *
   3917      * @return the value of an item that previously added with putExtra()
   3918      * or null if no String value was found.
   3919      *
   3920      * @see #putExtra(String, String)
   3921      */
   3922     public String getStringExtra(String name) {
   3923         return mExtras == null ? null : mExtras.getString(name);
   3924     }
   3925 
   3926     /**
   3927      * Retrieve extended data from the intent.
   3928      *
   3929      * @param name The name of the desired item.
   3930      *
   3931      * @return the value of an item that previously added with putExtra()
   3932      * or null if no CharSequence value was found.
   3933      *
   3934      * @see #putExtra(String, CharSequence)
   3935      */
   3936     public CharSequence getCharSequenceExtra(String name) {
   3937         return mExtras == null ? null : mExtras.getCharSequence(name);
   3938     }
   3939 
   3940     /**
   3941      * Retrieve extended data from the intent.
   3942      *
   3943      * @param name The name of the desired item.
   3944      *
   3945      * @return the value of an item that previously added with putExtra()
   3946      * or null if no Parcelable value was found.
   3947      *
   3948      * @see #putExtra(String, Parcelable)
   3949      */
   3950     public <T extends Parcelable> T getParcelableExtra(String name) {
   3951         return mExtras == null ? null : mExtras.<T>getParcelable(name);
   3952     }
   3953 
   3954     /**
   3955      * Retrieve extended data from the intent.
   3956      *
   3957      * @param name The name of the desired item.
   3958      *
   3959      * @return the value of an item that previously added with putExtra()
   3960      * or null if no Parcelable[] value was found.
   3961      *
   3962      * @see #putExtra(String, Parcelable[])
   3963      */
   3964     public Parcelable[] getParcelableArrayExtra(String name) {
   3965         return mExtras == null ? null : mExtras.getParcelableArray(name);
   3966     }
   3967 
   3968     /**
   3969      * Retrieve extended data from the intent.
   3970      *
   3971      * @param name The name of the desired item.
   3972      *
   3973      * @return the value of an item that previously added with putExtra()
   3974      * or null if no ArrayList<Parcelable> value was found.
   3975      *
   3976      * @see #putParcelableArrayListExtra(String, ArrayList)
   3977      */
   3978     public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
   3979         return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
   3980     }
   3981 
   3982     /**
   3983      * Retrieve extended data from the intent.
   3984      *
   3985      * @param name The name of the desired item.
   3986      *
   3987      * @return the value of an item that previously added with putExtra()
   3988      * or null if no Serializable value was found.
   3989      *
   3990      * @see #putExtra(String, Serializable)
   3991      */
   3992     public Serializable getSerializableExtra(String name) {
   3993         return mExtras == null ? null : mExtras.getSerializable(name);
   3994     }
   3995 
   3996     /**
   3997      * Retrieve extended data from the intent.
   3998      *
   3999      * @param name The name of the desired item.
   4000      *
   4001      * @return the value of an item that previously added with putExtra()
   4002      * or null if no ArrayList<Integer> value was found.
   4003      *
   4004      * @see #putIntegerArrayListExtra(String, ArrayList)
   4005      */
   4006     public ArrayList<Integer> getIntegerArrayListExtra(String name) {
   4007         return mExtras == null ? null : mExtras.getIntegerArrayList(name);
   4008     }
   4009 
   4010     /**
   4011      * Retrieve extended data from the intent.
   4012      *
   4013      * @param name The name of the desired item.
   4014      *
   4015      * @return the value of an item that previously added with putExtra()
   4016      * or null if no ArrayList<String> value was found.
   4017      *
   4018      * @see #putStringArrayListExtra(String, ArrayList)
   4019      */
   4020     public ArrayList<String> getStringArrayListExtra(String name) {
   4021         return mExtras == null ? null : mExtras.getStringArrayList(name);
   4022     }
   4023 
   4024     /**
   4025      * Retrieve extended data from the intent.
   4026      *
   4027      * @param name The name of the desired item.
   4028      *
   4029      * @return the value of an item that previously added with putExtra()
   4030      * or null if no ArrayList<CharSequence> value was found.
   4031      *
   4032      * @see #putCharSequenceArrayListExtra(String, ArrayList)
   4033      */
   4034     public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
   4035         return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
   4036     }
   4037 
   4038     /**
   4039      * Retrieve extended data from the intent.
   4040      *
   4041      * @param name The name of the desired item.
   4042      *
   4043      * @return the value of an item that previously added with putExtra()
   4044      * or null if no boolean array value was found.
   4045      *
   4046      * @see #putExtra(String, boolean[])
   4047      */
   4048     public boolean[] getBooleanArrayExtra(String name) {
   4049         return mExtras == null ? null : mExtras.getBooleanArray(name);
   4050     }
   4051 
   4052     /**
   4053      * Retrieve extended data from the intent.
   4054      *
   4055      * @param name The name of the desired item.
   4056      *
   4057      * @return the value of an item that previously added with putExtra()
   4058      * or null if no byte array value was found.
   4059      *
   4060      * @see #putExtra(String, byte[])
   4061      */
   4062     public byte[] getByteArrayExtra(String name) {
   4063         return mExtras == null ? null : mExtras.getByteArray(name);
   4064     }
   4065 
   4066     /**
   4067      * Retrieve extended data from the intent.
   4068      *
   4069      * @param name The name of the desired item.
   4070      *
   4071      * @return the value of an item that previously added with putExtra()
   4072      * or null if no short array value was found.
   4073      *
   4074      * @see #putExtra(String, short[])
   4075      */
   4076     public short[] getShortArrayExtra(String name) {
   4077         return mExtras == null ? null : mExtras.getShortArray(name);
   4078     }
   4079 
   4080     /**
   4081      * Retrieve extended data from the intent.
   4082      *
   4083      * @param name The name of the desired item.
   4084      *
   4085      * @return the value of an item that previously added with putExtra()
   4086      * or null if no char array value was found.
   4087      *
   4088      * @see #putExtra(String, char[])
   4089      */
   4090     public char[] getCharArrayExtra(String name) {
   4091         return mExtras == null ? null : mExtras.getCharArray(name);
   4092     }
   4093 
   4094     /**
   4095      * Retrieve extended data from the intent.
   4096      *
   4097      * @param name The name of the desired item.
   4098      *
   4099      * @return the value of an item that previously added with putExtra()
   4100      * or null if no int array value was found.
   4101      *
   4102      * @see #putExtra(String, int[])
   4103      */
   4104     public int[] getIntArrayExtra(String name) {
   4105         return mExtras == null ? null : mExtras.getIntArray(name);
   4106     }
   4107 
   4108     /**
   4109      * Retrieve extended data from the intent.
   4110      *
   4111      * @param name The name of the desired item.
   4112      *
   4113      * @return the value of an item that previously added with putExtra()
   4114      * or null if no long array value was found.
   4115      *
   4116      * @see #putExtra(String, long[])
   4117      */
   4118     public long[] getLongArrayExtra(String name) {
   4119         return mExtras == null ? null : mExtras.getLongArray(name);
   4120     }
   4121 
   4122     /**
   4123      * Retrieve extended data from the intent.
   4124      *
   4125      * @param name The name of the desired item.
   4126      *
   4127      * @return the value of an item that previously added with putExtra()
   4128      * or null if no float array value was found.
   4129      *
   4130      * @see #putExtra(String, float[])
   4131      */
   4132     public float[] getFloatArrayExtra(String name) {
   4133         return mExtras == null ? null : mExtras.getFloatArray(name);
   4134     }
   4135 
   4136     /**
   4137      * Retrieve extended data from the intent.
   4138      *
   4139      * @param name The name of the desired item.
   4140      *
   4141      * @return the value of an item that previously added with putExtra()
   4142      * or null if no double array value was found.
   4143      *
   4144      * @see #putExtra(String, double[])
   4145      */
   4146     public double[] getDoubleArrayExtra(String name) {
   4147         return mExtras == null ? null : mExtras.getDoubleArray(name);
   4148     }
   4149 
   4150     /**
   4151      * Retrieve extended data from the intent.
   4152      *
   4153      * @param name The name of the desired item.
   4154      *
   4155      * @return the value of an item that previously added with putExtra()
   4156      * or null if no String array value was found.
   4157      *
   4158      * @see #putExtra(String, String[])
   4159      */
   4160     public String[] getStringArrayExtra(String name) {
   4161         return mExtras == null ? null : mExtras.getStringArray(name);
   4162     }
   4163 
   4164     /**
   4165      * Retrieve extended data from the intent.
   4166      *
   4167      * @param name The name of the desired item.
   4168      *
   4169      * @return the value of an item that previously added with putExtra()
   4170      * or null if no CharSequence array value was found.
   4171      *
   4172      * @see #putExtra(String, CharSequence[])
   4173      */
   4174     public CharSequence[] getCharSequenceArrayExtra(String name) {
   4175         return mExtras == null ? null : mExtras.getCharSequenceArray(name);
   4176     }
   4177 
   4178     /**
   4179      * Retrieve extended data from the intent.
   4180      *
   4181      * @param name The name of the desired item.
   4182      *
   4183      * @return the value of an item that previously added with putExtra()
   4184      * or null if no Bundle value was found.
   4185      *
   4186      * @see #putExtra(String, Bundle)
   4187      */
   4188     public Bundle getBundleExtra(String name) {
   4189         return mExtras == null ? null : mExtras.getBundle(name);
   4190     }
   4191 
   4192     /**
   4193      * Retrieve extended data from the intent.
   4194      *
   4195      * @param name The name of the desired item.
   4196      *
   4197      * @return the value of an item that previously added with putExtra()
   4198      * or null if no IBinder value was found.
   4199      *
   4200      * @see #putExtra(String, IBinder)
   4201      *
   4202      * @deprecated
   4203      * @hide
   4204      */
   4205     @Deprecated
   4206     public IBinder getIBinderExtra(String name) {
   4207         return mExtras == null ? null : mExtras.getIBinder(name);
   4208     }
   4209 
   4210     /**
   4211      * Retrieve extended data from the intent.
   4212      *
   4213      * @param name The name of the desired item.
   4214      * @param defaultValue The default value to return in case no item is
   4215      * associated with the key 'name'
   4216      *
   4217      * @return the value of an item that previously added with putExtra()
   4218      * or defaultValue if none was found.
   4219      *
   4220      * @see #putExtra
   4221      *
   4222      * @deprecated
   4223      * @hide
   4224      */
   4225     @Deprecated
   4226     public Object getExtra(String name, Object defaultValue) {
   4227         Object result = defaultValue;
   4228         if (mExtras != null) {
   4229             Object result2 = mExtras.get(name);
   4230             if (result2 != null) {
   4231                 result = result2;
   4232             }
   4233         }
   4234 
   4235         return result;
   4236     }
   4237 
   4238     /**
   4239      * Retrieves a map of extended data from the intent.
   4240      *
   4241      * @return the map of all extras previously added with putExtra(),
   4242      * or null if none have been added.
   4243      */
   4244     public Bundle getExtras() {
   4245         return (mExtras != null)
   4246                 ? new Bundle(mExtras)
   4247                 : null;
   4248     }
   4249 
   4250     /**
   4251      * Retrieve any special flags associated with this intent.  You will
   4252      * normally just set them with {@link #setFlags} and let the system
   4253      * take the appropriate action with them.
   4254      *
   4255      * @return int The currently set flags.
   4256      *
   4257      * @see #setFlags
   4258      */
   4259     public int getFlags() {
   4260         return mFlags;
   4261     }
   4262 
   4263     /** @hide */
   4264     public boolean isExcludingStopped() {
   4265         return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
   4266                 == FLAG_EXCLUDE_STOPPED_PACKAGES;
   4267     }
   4268 
   4269     /**
   4270      * Retrieve the application package name this Intent is limited to.  When
   4271      * resolving an Intent, if non-null this limits the resolution to only
   4272      * components in the given application package.
   4273      *
   4274      * @return The name of the application package for the Intent.
   4275      *
   4276      * @see #resolveActivity
   4277      * @see #setPackage
   4278      */
   4279     public String getPackage() {
   4280         return mPackage;
   4281     }
   4282 
   4283     /**
   4284      * Retrieve the concrete component associated with the intent.  When receiving
   4285      * an intent, this is the component that was found to best handle it (that is,
   4286      * yourself) and will always be non-null; in all other cases it will be
   4287      * null unless explicitly set.
   4288      *
   4289      * @return The name of the application component to handle the intent.
   4290      *
   4291      * @see #resolveActivity
   4292      * @see #setComponent
   4293      */
   4294     public ComponentName getComponent() {
   4295         return mComponent;
   4296     }
   4297 
   4298     /**
   4299      * Get the bounds of the sender of this intent, in screen coordinates.  This can be
   4300      * used as a hint to the receiver for animations and the like.  Null means that there
   4301      * is no source bounds.
   4302      */
   4303     public Rect getSourceBounds() {
   4304         return mSourceBounds;
   4305     }
   4306 
   4307     /**
   4308      * Return the Activity component that should be used to handle this intent.
   4309      * The appropriate component is determined based on the information in the
   4310      * intent, evaluated as follows:
   4311      *
   4312      * <p>If {@link #getComponent} returns an explicit class, that is returned
   4313      * without any further consideration.
   4314      *
   4315      * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
   4316      * category to be considered.
   4317      *
   4318      * <p>If {@link #getAction} is non-NULL, the activity must handle this
   4319      * action.
   4320      *
   4321      * <p>If {@link #resolveType} returns non-NULL, the activity must handle
   4322      * this type.
   4323      *
   4324      * <p>If {@link #addCategory} has added any categories, the activity must
   4325      * handle ALL of the categories specified.
   4326      *
   4327      * <p>If {@link #getPackage} is non-NULL, only activity components in
   4328      * that application package will be considered.
   4329      *
   4330      * <p>If there are no activities that satisfy all of these conditions, a
   4331      * null string is returned.
   4332      *
   4333      * <p>If multiple activities are found to satisfy the intent, the one with
   4334      * the highest priority will be used.  If there are multiple activities
   4335      * with the same priority, the system will either pick the best activity
   4336      * based on user preference, or resolve to a system class that will allow
   4337      * the user to pick an activity and forward from there.
   4338      *
   4339      * <p>This method is implemented simply by calling
   4340      * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
   4341      * true.</p>
   4342      * <p> This API is called for you as part of starting an activity from an
   4343      * intent.  You do not normally need to call it yourself.</p>
   4344      *
   4345      * @param pm The package manager with which to resolve the Intent.
   4346      *
   4347      * @return Name of the component implementing an activity that can
   4348      *         display the intent.
   4349      *
   4350      * @see #setComponent
   4351      * @see #getComponent
   4352      * @see #resolveActivityInfo
   4353      */
   4354     public ComponentName resolveActivity(PackageManager pm) {
   4355         if (mComponent != null) {
   4356             return mComponent;
   4357         }
   4358 
   4359         ResolveInfo info = pm.resolveActivity(
   4360             this, PackageManager.MATCH_DEFAULT_ONLY);
   4361         if (info != null) {
   4362             return new ComponentName(
   4363                     info.activityInfo.applicationInfo.packageName,
   4364                     info.activityInfo.name);
   4365         }
   4366 
   4367         return null;
   4368     }
   4369 
   4370     /**
   4371      * Resolve the Intent into an {@link ActivityInfo}
   4372      * describing the activity that should execute the intent.  Resolution
   4373      * follows the same rules as described for {@link #resolveActivity}, but
   4374      * you get back the completely information about the resolved activity
   4375      * instead of just its class name.
   4376      *
   4377      * @param pm The package manager with which to resolve the Intent.
   4378      * @param flags Addition information to retrieve as per
   4379      * {@link PackageManager#getActivityInfo(ComponentName, int)
   4380      * PackageManager.getActivityInfo()}.
   4381      *
   4382      * @return PackageManager.ActivityInfo
   4383      *
   4384      * @see #resolveActivity
   4385      */
   4386     public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
   4387         ActivityInfo ai = null;
   4388         if (mComponent != null) {
   4389             try {
   4390                 ai = pm.getActivityInfo(mComponent, flags);
   4391             } catch (PackageManager.NameNotFoundException e) {
   4392                 // ignore
   4393             }
   4394         } else {
   4395             ResolveInfo info = pm.resolveActivity(
   4396                 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
   4397             if (info != null) {
   4398                 ai = info.activityInfo;
   4399             }
   4400         }
   4401 
   4402         return ai;
   4403     }
   4404 
   4405     /**
   4406      * Set the general action to be performed.
   4407      *
   4408      * @param action An action name, such as ACTION_VIEW.  Application-specific
   4409      *               actions should be prefixed with the vendor's package name.
   4410      *
   4411      * @return Returns the same Intent object, for chaining multiple calls
   4412      * into a single statement.
   4413      *
   4414      * @see #getAction
   4415      */
   4416     public Intent setAction(String action) {
   4417         mAction = action != null ? action.intern() : null;
   4418         return this;
   4419     }
   4420 
   4421     /**
   4422      * Set the data this intent is operating on.  This method automatically
   4423      * clears any type that was previously set by {@link #setType}.
   4424      *
   4425      * <p><em>Note: scheme and host name matching in the Android framework is
   4426      * case-sensitive, unlike the formal RFC.  As a result,
   4427      * you should always ensure that you write your Uri with these elements
   4428      * using lower case letters, and normalize any Uris you receive from
   4429      * outside of Android to ensure the scheme and host is lower case.</em></p>
   4430      *
   4431      * @param data The URI of the data this intent is now targeting.
   4432      *
   4433      * @return Returns the same Intent object, for chaining multiple calls
   4434      * into a single statement.
   4435      *
   4436      * @see #getData
   4437      * @see #setType
   4438      * @see #setDataAndType
   4439      */
   4440     public Intent setData(Uri data) {
   4441         mData = data;
   4442         mType = null;
   4443         return this;
   4444     }
   4445 
   4446     /**
   4447      * Set an explicit MIME data type.  This is used to create intents that
   4448      * only specify a type and not data, for example to indicate the type of
   4449      * data to return.  This method automatically clears any data that was
   4450      * previously set by {@link #setData}.
   4451      *
   4452      * <p><em>Note: MIME type matching in the Android framework is
   4453      * case-sensitive, unlike formal RFC MIME types.  As a result,
   4454      * you should always write your MIME types with lower case letters,
   4455      * and any MIME types you receive from outside of Android should be
   4456      * converted to lower case before supplying them here.</em></p>
   4457      *
   4458      * @param type The MIME type of the data being handled by this intent.
   4459      *
   4460      * @return Returns the same Intent object, for chaining multiple calls
   4461      * into a single statement.
   4462      *
   4463      * @see #getType
   4464      * @see #setData
   4465      * @see #setDataAndType
   4466      */
   4467     public Intent setType(String type) {
   4468         mData = null;
   4469         mType = type;
   4470         return this;
   4471     }
   4472 
   4473     /**
   4474      * (Usually optional) Set the data for the intent along with an explicit
   4475      * MIME data type.  This method should very rarely be used -- it allows you
   4476      * to override the MIME type that would ordinarily be inferred from the
   4477      * data with your own type given here.
   4478      *
   4479      * <p><em>Note: MIME type, Uri scheme, and host name matching in the
   4480      * Android framework is case-sensitive, unlike the formal RFC definitions.
   4481      * As a result, you should always write these elements with lower case letters,
   4482      * and normalize any MIME types or Uris you receive from
   4483      * outside of Android to ensure these elements are lower case before
   4484      * supplying them here.</em></p>
   4485      *
   4486      * @param data The URI of the data this intent is now targeting.
   4487      * @param type The MIME type of the data being handled by this intent.
   4488      *
   4489      * @return Returns the same Intent object, for chaining multiple calls
   4490      * into a single statement.
   4491      *
   4492      * @see #setData
   4493      * @see #setType
   4494      */
   4495     public Intent setDataAndType(Uri data, String type) {
   4496         mData = data;
   4497         mType = type;
   4498         return this;
   4499     }
   4500 
   4501     /**
   4502      * Add a new category to the intent.  Categories provide additional detail
   4503      * about the action the intent is perform.  When resolving an intent, only
   4504      * activities that provide <em>all</em> of the requested categories will be
   4505      * used.
   4506      *
   4507      * @param category The desired category.  This can be either one of the
   4508      *               predefined Intent categories, or a custom category in your own
   4509      *               namespace.
   4510      *
   4511      * @return Returns the same Intent object, for chaining multiple calls
   4512      * into a single statement.
   4513      *
   4514      * @see #hasCategory
   4515      * @see #removeCategory
   4516      */
   4517     public Intent addCategory(String category) {
   4518         if (mCategories == null) {
   4519             mCategories = new HashSet<String>();
   4520         }
   4521         mCategories.add(category.intern());
   4522         return this;
   4523     }
   4524 
   4525     /**
   4526      * Remove an category from an intent.
   4527      *
   4528      * @param category The category to remove.
   4529      *
   4530      * @see #addCategory
   4531      */
   4532     public void removeCategory(String category) {
   4533         if (mCategories != null) {
   4534             mCategories.remove(category);
   4535             if (mCategories.size() == 0) {
   4536                 mCategories = null;
   4537             }
   4538         }
   4539     }
   4540 
   4541     /**
   4542      * Set a selector for this Intent.  This is a modification to the kinds of
   4543      * things the Intent will match.  If the selector is set, it will be used
   4544      * when trying to find entities that can handle the Intent, instead of the
   4545      * main contents of the Intent.  This allows you build an Intent containing
   4546      * a generic protocol while targeting it more specifically.
   4547      *
   4548      * <p>An example of where this may be used is with things like
   4549      * {@link #CATEGORY_APP_BROWSER}.  This category allows you to build an
   4550      * Intent that will launch the Browser application.  However, the correct
   4551      * main entry point of an application is actually {@link #ACTION_MAIN}
   4552      * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
   4553      * used to specify the actual Activity to launch.  If you launch the browser
   4554      * with something different, undesired behavior may happen if the user has
   4555      * previously or later launches it the normal way, since they do not match.
   4556      * Instead, you can build an Intent with the MAIN action (but no ComponentName
   4557      * yet specified) and set a selector with {@link #ACTION_MAIN} and
   4558      * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
   4559      *
   4560      * <p>Setting a selector does not impact the behavior of
   4561      * {@link #filterEquals(Intent)} and {@link #filterHashCode()}.  This is part of the
   4562      * desired behavior of a selector -- it does not impact the base meaning
   4563      * of the Intent, just what kinds of things will be matched against it
   4564      * when determining who can handle it.</p>
   4565      *
   4566      * <p>You can not use both a selector and {@link #setPackage(String)} on
   4567      * the same base Intent.</p>
   4568      *
   4569      * @param selector The desired selector Intent; set to null to not use
   4570      * a special selector.
   4571      */
   4572     public void setSelector(Intent selector) {
   4573         if (selector == this) {
   4574             throw new IllegalArgumentException(
   4575                     "Intent being set as a selector of itself");
   4576         }
   4577         if (selector != null && mPackage != null) {
   4578             throw new IllegalArgumentException(
   4579                     "Can't set selector when package name is already set");
   4580         }
   4581         mSelector = selector;
   4582     }
   4583 
   4584     /**
   4585      * Add extended data to the intent.  The name must include a package
   4586      * prefix, for example the app com.android.contacts would use names
   4587      * like "com.android.contacts.ShowAll".
   4588      *
   4589      * @param name The name of the extra data, with package prefix.
   4590      * @param value The boolean data value.
   4591      *
   4592      * @return Returns the same Intent object, for chaining multiple calls
   4593      * into a single statement.
   4594      *
   4595      * @see #putExtras
   4596      * @see #removeExtra
   4597      * @see #getBooleanExtra(String, boolean)
   4598      */
   4599     public Intent putExtra(String name, boolean value) {
   4600         if (mExtras == null) {
   4601             mExtras = new Bundle();
   4602         }
   4603         mExtras.putBoolean(name, value);
   4604         return this;
   4605     }
   4606 
   4607     /**
   4608      * Add extended data to the intent.  The name must include a package
   4609      * prefix, for example the app com.android.contacts would use names
   4610      * like "com.android.contacts.ShowAll".
   4611      *
   4612      * @param name The name of the extra data, with package prefix.
   4613      * @param value The byte data value.
   4614      *
   4615      * @return Returns the same Intent object, for chaining multiple calls
   4616      * into a single statement.
   4617      *
   4618      * @see #putExtras
   4619      * @see #removeExtra
   4620      * @see #getByteExtra(String, byte)
   4621      */
   4622     public Intent putExtra(String name, byte value) {
   4623         if (mExtras == null) {
   4624             mExtras = new Bundle();
   4625         }
   4626         mExtras.putByte(name, value);
   4627         return this;
   4628     }
   4629 
   4630     /**
   4631      * Add extended data to the intent.  The name must include a package
   4632      * prefix, for example the app com.android.contacts would use names
   4633      * like "com.android.contacts.ShowAll".
   4634      *
   4635      * @param name The name of the extra data, with package prefix.
   4636      * @param value The char data value.
   4637      *
   4638      * @return Returns the same Intent object, for chaining multiple calls
   4639      * into a single statement.
   4640      *
   4641      * @see #putExtras
   4642      * @see #removeExtra
   4643      * @see #getCharExtra(String, char)
   4644      */
   4645     public Intent putExtra(String name, char value) {
   4646         if (mExtras == null) {
   4647             mExtras = new Bundle();
   4648         }
   4649         mExtras.putChar(name, value);
   4650         return this;
   4651     }
   4652 
   4653     /**
   4654      * Add extended data to the intent.  The name must include a package
   4655      * prefix, for example the app com.android.contacts would use names
   4656      * like "com.android.contacts.ShowAll".
   4657      *
   4658      * @param name The name of the extra data, with package prefix.
   4659      * @param value The short data value.
   4660      *
   4661      * @return Returns the same Intent object, for chaining multiple calls
   4662      * into a single statement.
   4663      *
   4664      * @see #putExtras
   4665      * @see #removeExtra
   4666      * @see #getShortExtra(String, short)
   4667      */
   4668     public Intent putExtra(String name, short value) {
   4669         if (mExtras == null) {
   4670             mExtras = new Bundle();
   4671         }
   4672         mExtras.putShort(name, value);
   4673         return this;
   4674     }
   4675 
   4676     /**
   4677      * Add extended data to the intent.  The name must include a package
   4678      * prefix, for example the app com.android.contacts would use names
   4679      * like "com.android.contacts.ShowAll".
   4680      *
   4681      * @param name The name of the extra data, with package prefix.
   4682      * @param value The integer data value.
   4683      *
   4684      * @return Returns the same Intent object, for chaining multiple calls
   4685      * into a single statement.
   4686      *
   4687      * @see #putExtras
   4688      * @see #removeExtra
   4689      * @see #getIntExtra(String, int)
   4690      */
   4691     public Intent putExtra(String name, int value) {
   4692         if (mExtras == null) {
   4693             mExtras = new Bundle();
   4694         }
   4695         mExtras.putInt(name, value);
   4696         return this;
   4697     }
   4698 
   4699     /**
   4700      * Add extended data to the intent.  The name must include a package
   4701      * prefix, for example the app com.android.contacts would use names
   4702      * like "com.android.contacts.ShowAll".
   4703      *
   4704      * @param name The name of the extra data, with package prefix.
   4705      * @param value The long data value.
   4706      *
   4707      * @return Returns the same Intent object, for chaining multiple calls
   4708      * into a single statement.
   4709      *
   4710      * @see #putExtras
   4711      * @see #removeExtra
   4712      * @see #getLongExtra(String, long)
   4713      */
   4714     public Intent putExtra(String name, long value) {
   4715         if (mExtras == null) {
   4716             mExtras = new Bundle();
   4717         }
   4718         mExtras.putLong(name, value);
   4719         return this;
   4720     }
   4721 
   4722     /**
   4723      * Add extended data to the intent.  The name must include a package
   4724      * prefix, for example the app com.android.contacts would use names
   4725      * like "com.android.contacts.ShowAll".
   4726      *
   4727      * @param name The name of the extra data, with package prefix.
   4728      * @param value The float data value.
   4729      *
   4730      * @return Returns the same Intent object, for chaining multiple calls
   4731      * into a single statement.
   4732      *
   4733      * @see #putExtras
   4734      * @see #removeExtra
   4735      * @see #getFloatExtra(String, float)
   4736      */
   4737     public Intent putExtra(String name, float value) {
   4738         if (mExtras == null) {
   4739             mExtras = new Bundle();
   4740         }
   4741         mExtras.putFloat(name, value);
   4742         return this;
   4743     }
   4744 
   4745     /**
   4746      * Add extended data to the intent.  The name must include a package
   4747      * prefix, for example the app com.android.contacts would use names
   4748      * like "com.android.contacts.ShowAll".
   4749      *
   4750      * @param name The name of the extra data, with package prefix.
   4751      * @param value The double data value.
   4752      *
   4753      * @return Returns the same Intent object, for chaining multiple calls
   4754      * into a single statement.
   4755      *
   4756      * @see #putExtras
   4757      * @see #removeExtra
   4758      * @see #getDoubleExtra(String, double)
   4759      */
   4760     public Intent putExtra(String name, double value) {
   4761         if (mExtras == null) {
   4762             mExtras = new Bundle();
   4763         }
   4764         mExtras.putDouble(name, value);
   4765         return this;
   4766     }
   4767 
   4768     /**
   4769      * Add extended data to the intent.  The name must include a package
   4770      * prefix, for example the app com.android.contacts would use names
   4771      * like "com.android.contacts.ShowAll".
   4772      *
   4773      * @param name The name of the extra data, with package prefix.
   4774      * @param value The String data value.
   4775      *
   4776      * @return Returns the same Intent object, for chaining multiple calls
   4777      * into a single statement.
   4778      *
   4779      * @see #putExtras
   4780      * @see #removeExtra
   4781      * @see #getStringExtra(String)
   4782      */
   4783     public Intent putExtra(String name, String value) {
   4784         if (mExtras == null) {
   4785             mExtras = new Bundle();
   4786         }
   4787         mExtras.putString(name, value);
   4788         return this;
   4789     }
   4790 
   4791     /**
   4792      * Add extended data to the intent.  The name must include a package
   4793      * prefix, for example the app com.android.contacts would use names
   4794      * like "com.android.contacts.ShowAll".
   4795      *
   4796      * @param name The name of the extra data, with package prefix.
   4797      * @param value The CharSequence data value.
   4798      *
   4799      * @return Returns the same Intent object, for chaining multiple calls
   4800      * into a single statement.
   4801      *
   4802      * @see #putExtras
   4803      * @see #removeExtra
   4804      * @see #getCharSequenceExtra(String)
   4805      */
   4806     public Intent putExtra(String name, CharSequence value) {
   4807         if (mExtras == null) {
   4808             mExtras = new Bundle();
   4809         }
   4810         mExtras.putCharSequence(name, value);
   4811         return this;
   4812     }
   4813 
   4814     /**
   4815      * Add extended data to the intent.  The name must include a package
   4816      * prefix, for example the app com.android.contacts would use names
   4817      * like "com.android.contacts.ShowAll".
   4818      *
   4819      * @param name The name of the extra data, with package prefix.
   4820      * @param value The Parcelable data value.
   4821      *
   4822      * @return Returns the same Intent object, for chaining multiple calls
   4823      * into a single statement.
   4824      *
   4825      * @see #putExtras
   4826      * @see #removeExtra
   4827      * @see #getParcelableExtra(String)
   4828      */
   4829     public Intent putExtra(String name, Parcelable value) {
   4830         if (mExtras == null) {
   4831             mExtras = new Bundle();
   4832         }
   4833         mExtras.putParcelable(name, value);
   4834         return this;
   4835     }
   4836 
   4837     /**
   4838      * Add extended data to the intent.  The name must include a package
   4839      * prefix, for example the app com.android.contacts would use names
   4840      * like "com.android.contacts.ShowAll".
   4841      *
   4842      * @param name The name of the extra data, with package prefix.
   4843      * @param value The Parcelable[] data value.
   4844      *
   4845      * @return Returns the same Intent object, for chaining multiple calls
   4846      * into a single statement.
   4847      *
   4848      * @see #putExtras
   4849      * @see #removeExtra
   4850      * @see #getParcelableArrayExtra(String)
   4851      */
   4852     public Intent putExtra(String name, Parcelable[] value) {
   4853         if (mExtras == null) {
   4854             mExtras = new Bundle();
   4855         }
   4856         mExtras.putParcelableArray(name, value);
   4857         return this;
   4858     }
   4859 
   4860     /**
   4861      * Add extended data to the intent.  The name must include a package
   4862      * prefix, for example the app com.android.contacts would use names
   4863      * like "com.android.contacts.ShowAll".
   4864      *
   4865      * @param name The name of the extra data, with package prefix.
   4866      * @param value The ArrayList<Parcelable> data value.
   4867      *
   4868      * @return Returns the same Intent object, for chaining multiple calls
   4869      * into a single statement.
   4870      *
   4871      * @see #putExtras
   4872      * @see #removeExtra
   4873      * @see #getParcelableArrayListExtra(String)
   4874      */
   4875     public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
   4876         if (mExtras == null) {
   4877             mExtras = new Bundle();
   4878         }
   4879         mExtras.putParcelableArrayList(name, value);
   4880         return this;
   4881     }
   4882 
   4883     /**
   4884      * Add extended data to the intent.  The name must include a package
   4885      * prefix, for example the app com.android.contacts would use names
   4886      * like "com.android.contacts.ShowAll".
   4887      *
   4888      * @param name The name of the extra data, with package prefix.
   4889      * @param value The ArrayList<Integer> data value.
   4890      *
   4891      * @return Returns the same Intent object, for chaining multiple calls
   4892      * into a single statement.
   4893      *
   4894      * @see #putExtras
   4895      * @see #removeExtra
   4896      * @see #getIntegerArrayListExtra(String)
   4897      */
   4898     public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
   4899         if (mExtras == null) {
   4900             mExtras = new Bundle();
   4901         }
   4902         mExtras.putIntegerArrayList(name, value);
   4903         return this;
   4904     }
   4905 
   4906     /**
   4907      * Add extended data to the intent.  The name must include a package
   4908      * prefix, for example the app com.android.contacts would use names
   4909      * like "com.android.contacts.ShowAll".
   4910      *
   4911      * @param name The name of the extra data, with package prefix.
   4912      * @param value The ArrayList<String> data value.
   4913      *
   4914      * @return Returns the same Intent object, for chaining multiple calls
   4915      * into a single statement.
   4916      *
   4917      * @see #putExtras
   4918      * @see #removeExtra
   4919      * @see #getStringArrayListExtra(String)
   4920      */
   4921     public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
   4922         if (mExtras == null) {
   4923             mExtras = new Bundle();
   4924         }
   4925         mExtras.putStringArrayList(name, value);
   4926         return this;
   4927     }
   4928 
   4929     /**
   4930      * Add extended data to the intent.  The name must include a package
   4931      * prefix, for example the app com.android.contacts would use names
   4932      * like "com.android.contacts.ShowAll".
   4933      *
   4934      * @param name The name of the extra data, with package prefix.
   4935      * @param value The ArrayList<CharSequence> data value.
   4936      *
   4937      * @return Returns the same Intent object, for chaining multiple calls
   4938      * into a single statement.
   4939      *
   4940      * @see #putExtras
   4941      * @see #removeExtra
   4942      * @see #getCharSequenceArrayListExtra(String)
   4943      */
   4944     public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
   4945         if (mExtras == null) {
   4946             mExtras = new Bundle();
   4947         }
   4948         mExtras.putCharSequenceArrayList(name, value);
   4949         return this;
   4950     }
   4951 
   4952     /**
   4953      * Add extended data to the intent.  The name must include a package
   4954      * prefix, for example the app com.android.contacts would use names
   4955      * like "com.android.contacts.ShowAll".
   4956      *
   4957      * @param name The name of the extra data, with package prefix.
   4958      * @param value The Serializable data value.
   4959      *
   4960      * @return Returns the same Intent object, for chaining multiple calls
   4961      * into a single statement.
   4962      *
   4963      * @see #putExtras
   4964      * @see #removeExtra
   4965      * @see #getSerializableExtra(String)
   4966      */
   4967     public Intent putExtra(String name, Serializable value) {
   4968         if (mExtras == null) {
   4969             mExtras = new Bundle();
   4970         }
   4971         mExtras.putSerializable(name, value);
   4972         return this;
   4973     }
   4974 
   4975     /**
   4976      * Add extended data to the intent.  The name must include a package
   4977      * prefix, for example the app com.android.contacts would use names
   4978      * like "com.android.contacts.ShowAll".
   4979      *
   4980      * @param name The name of the extra data, with package prefix.
   4981      * @param value The boolean array data value.
   4982      *
   4983      * @return Returns the same Intent object, for chaining multiple calls
   4984      * into a single statement.
   4985      *
   4986      * @see #putExtras
   4987      * @see #removeExtra
   4988      * @see #getBooleanArrayExtra(String)
   4989      */
   4990     public Intent putExtra(String name, boolean[] value) {
   4991         if (mExtras == null) {
   4992             mExtras = new Bundle();
   4993         }
   4994         mExtras.putBooleanArray(name, value);
   4995         return this;
   4996     }
   4997 
   4998     /**
   4999      * Add extended data to the intent.  The name must include a package
   5000      * prefix, for example the app com.android.contacts would use names
   5001      * like "com.android.contacts.ShowAll".
   5002      *
   5003      * @param name The name of the extra data, with package prefix.
   5004      * @param value The byte array data value.
   5005      *
   5006      * @return Returns the same Intent object, for chaining multiple calls
   5007      * into a single statement.
   5008      *
   5009      * @see #putExtras
   5010      * @see #removeExtra
   5011      * @see #getByteArrayExtra(String)
   5012      */
   5013     public Intent putExtra(String name, byte[] value) {
   5014         if (mExtras == null) {
   5015             mExtras = new Bundle();
   5016         }
   5017         mExtras.putByteArray(name, value);
   5018         return this;
   5019     }
   5020 
   5021     /**
   5022      * Add extended data to the intent.  The name must include a package
   5023      * prefix, for example the app com.android.contacts would use names
   5024      * like "com.android.contacts.ShowAll".
   5025      *
   5026      * @param name The name of the extra data, with package prefix.
   5027      * @param value The short array data value.
   5028      *
   5029      * @return Returns the same Intent object, for chaining multiple calls
   5030      * into a single statement.
   5031      *
   5032      * @see #putExtras
   5033      * @see #removeExtra
   5034      * @see #getShortArrayExtra(String)
   5035      */
   5036     public Intent putExtra(String name, short[] value) {
   5037         if (mExtras == null) {
   5038             mExtras = new Bundle();
   5039         }
   5040         mExtras.putShortArray(name, value);
   5041         return this;
   5042     }
   5043 
   5044     /**
   5045      * Add extended data to the intent.  The name must include a package
   5046      * prefix, for example the app com.android.contacts would use names
   5047      * like "com.android.contacts.ShowAll".
   5048      *
   5049      * @param name The name of the extra data, with package prefix.
   5050      * @param value The char array data value.
   5051      *
   5052      * @return Returns the same Intent object, for chaining multiple calls
   5053      * into a single statement.
   5054      *
   5055      * @see #putExtras
   5056      * @see #removeExtra
   5057      * @see #getCharArrayExtra(String)
   5058      */
   5059     public Intent putExtra(String name, char[] value) {
   5060         if (mExtras == null) {
   5061             mExtras = new Bundle();
   5062         }
   5063         mExtras.putCharArray(name, value);
   5064         return this;
   5065     }
   5066 
   5067     /**
   5068      * Add extended data to the intent.  The name must include a package
   5069      * prefix, for example the app com.android.contacts would use names
   5070      * like "com.android.contacts.ShowAll".
   5071      *
   5072      * @param name The name of the extra data, with package prefix.
   5073      * @param value The int array data value.
   5074      *
   5075      * @return Returns the same Intent object, for chaining multiple calls
   5076      * into a single statement.
   5077      *
   5078      * @see #putExtras
   5079      * @see #removeExtra
   5080      * @see #getIntArrayExtra(String)
   5081      */
   5082     public Intent putExtra(String name, int[] value) {
   5083         if (mExtras == null) {
   5084             mExtras = new Bundle();
   5085         }
   5086         mExtras.putIntArray(name, value);
   5087         return this;
   5088     }
   5089 
   5090     /**
   5091      * Add extended data to the intent.  The name must include a package
   5092      * prefix, for example the app com.android.contacts would use names
   5093      * like "com.android.contacts.ShowAll".
   5094      *
   5095      * @param name The name of the extra data, with package prefix.
   5096      * @param value The byte array data value.
   5097      *
   5098      * @return Returns the same Intent object, for chaining multiple calls
   5099      * into a single statement.
   5100      *
   5101      * @see #putExtras
   5102      * @see #removeExtra
   5103      * @see #getLongArrayExtra(String)
   5104      */
   5105     public Intent putExtra(String name, long[] value) {
   5106         if (mExtras == null) {
   5107             mExtras = new Bundle();
   5108         }
   5109         mExtras.putLongArray(name, value);
   5110         return this;
   5111     }
   5112 
   5113     /**
   5114      * Add extended data to the intent.  The name must include a package
   5115      * prefix, for example the app com.android.contacts would use names
   5116      * like "com.android.contacts.ShowAll".
   5117      *
   5118      * @param name The name of the extra data, with package prefix.
   5119      * @param value The float array data value.
   5120      *
   5121      * @return Returns the same Intent object, for chaining multiple calls
   5122      * into a single statement.
   5123      *
   5124      * @see #putExtras
   5125      * @see #removeExtra
   5126      * @see #getFloatArrayExtra(String)
   5127      */
   5128     public Intent putExtra(String name, float[] value) {
   5129         if (mExtras == null) {
   5130             mExtras = new Bundle();
   5131         }
   5132         mExtras.putFloatArray(name, value);
   5133         return this;
   5134     }
   5135 
   5136     /**
   5137      * Add extended data to the intent.  The name must include a package
   5138      * prefix, for example the app com.android.contacts would use names
   5139      * like "com.android.contacts.ShowAll".
   5140      *
   5141      * @param name The name of the extra data, with package prefix.
   5142      * @param value The double array data value.
   5143      *
   5144      * @return Returns the same Intent object, for chaining multiple calls
   5145      * into a single statement.
   5146      *
   5147      * @see #putExtras
   5148      * @see #removeExtra
   5149      * @see #getDoubleArrayExtra(String)
   5150      */
   5151     public Intent putExtra(String name, double[] value) {
   5152         if (mExtras == null) {
   5153             mExtras = new Bundle();
   5154         }
   5155         mExtras.putDoubleArray(name, value);
   5156         return this;
   5157     }
   5158 
   5159     /**
   5160      * Add extended data to the intent.  The name must include a package
   5161      * prefix, for example the app com.android.contacts would use names
   5162      * like "com.android.contacts.ShowAll".
   5163      *
   5164      * @param name The name of the extra data, with package prefix.
   5165      * @param value The String array data value.
   5166      *
   5167      * @return Returns the same Intent object, for chaining multiple calls
   5168      * into a single statement.
   5169      *
   5170      * @see #putExtras
   5171      * @see #removeExtra
   5172      * @see #getStringArrayExtra(String)
   5173      */
   5174     public Intent putExtra(String name, String[] value) {
   5175         if (mExtras == null) {
   5176             mExtras = new Bundle();
   5177         }
   5178         mExtras.putStringArray(name, value);
   5179         return this;
   5180     }
   5181 
   5182     /**
   5183      * Add extended data to the intent.  The name must include a package
   5184      * prefix, for example the app com.android.contacts would use names
   5185      * like "com.android.contacts.ShowAll".
   5186      *
   5187      * @param name The name of the extra data, with package prefix.
   5188      * @param value The CharSequence array data value.
   5189      *
   5190      * @return Returns the same Intent object, for chaining multiple calls
   5191      * into a single statement.
   5192      *
   5193      * @see #putExtras
   5194      * @see #removeExtra
   5195      * @see #getCharSequenceArrayExtra(String)
   5196      */
   5197     public Intent putExtra(String name, CharSequence[] value) {
   5198         if (mExtras == null) {
   5199             mExtras = new Bundle();
   5200         }
   5201         mExtras.putCharSequenceArray(name, value);
   5202         return this;
   5203     }
   5204 
   5205     /**
   5206      * Add extended data to the intent.  The name must include a package
   5207      * prefix, for example the app com.android.contacts would use names
   5208      * like "com.android.contacts.ShowAll".
   5209      *
   5210      * @param name The name of the extra data, with package prefix.
   5211      * @param value The Bundle data value.
   5212      *
   5213      * @return Returns the same Intent object, for chaining multiple calls
   5214      * into a single statement.
   5215      *
   5216      * @see #putExtras
   5217      * @see #removeExtra
   5218      * @see #getBundleExtra(String)
   5219      */
   5220     public Intent putExtra(String name, Bundle value) {
   5221         if (mExtras == null) {
   5222             mExtras = new Bundle();
   5223         }
   5224         mExtras.putBundle(name, value);
   5225         return this;
   5226     }
   5227 
   5228     /**
   5229      * Add extended data to the intent.  The name must include a package
   5230      * prefix, for example the app com.android.contacts would use names
   5231      * like "com.android.contacts.ShowAll".
   5232      *
   5233      * @param name The name of the extra data, with package prefix.
   5234      * @param value The IBinder data value.
   5235      *
   5236      * @return Returns the same Intent object, for chaining multiple calls
   5237      * into a single statement.
   5238      *
   5239      * @see #putExtras
   5240      * @see #removeExtra
   5241      * @see #getIBinderExtra(String)
   5242      *
   5243      * @deprecated
   5244      * @hide
   5245      */
   5246     @Deprecated
   5247     public Intent putExtra(String name, IBinder value) {
   5248         if (mExtras == null) {
   5249             mExtras = new Bundle();
   5250         }
   5251         mExtras.putIBinder(name, value);
   5252         return this;
   5253     }
   5254 
   5255     /**
   5256      * Copy all extras in 'src' in to this intent.
   5257      *
   5258      * @param src Contains the extras to copy.
   5259      *
   5260      * @see #putExtra
   5261      */
   5262     public Intent putExtras(Intent src) {
   5263         if (src.mExtras != null) {
   5264             if (mExtras == null) {
   5265                 mExtras = new Bundle(src.mExtras);
   5266             } else {
   5267                 mExtras.putAll(src.mExtras);
   5268             }
   5269         }
   5270         return this;
   5271     }
   5272 
   5273     /**
   5274      * Add a set of extended data to the intent.  The keys must include a package
   5275      * prefix, for example the app com.android.contacts would use names
   5276      * like "com.android.contacts.ShowAll".
   5277      *
   5278      * @param extras The Bundle of extras to add to this intent.
   5279      *
   5280      * @see #putExtra
   5281      * @see #removeExtra
   5282      */
   5283     public Intent putExtras(Bundle extras) {
   5284         if (mExtras == null) {
   5285             mExtras = new Bundle();
   5286         }
   5287         mExtras.putAll(extras);
   5288         return this;
   5289     }
   5290 
   5291     /**
   5292      * Completely replace the extras in the Intent with the extras in the
   5293      * given Intent.
   5294      *
   5295      * @param src The exact extras contained in this Intent are copied
   5296      * into the target intent, replacing any that were previously there.
   5297      */
   5298     public Intent replaceExtras(Intent src) {
   5299         mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
   5300         return this;
   5301     }
   5302 
   5303     /**
   5304      * Completely replace the extras in the Intent with the given Bundle of
   5305      * extras.
   5306      *
   5307      * @param extras The new set of extras in the Intent, or null to erase
   5308      * all extras.
   5309      */
   5310     public Intent replaceExtras(Bundle extras) {
   5311         mExtras = extras != null ? new Bundle(extras) : null;
   5312         return this;
   5313     }
   5314 
   5315     /**
   5316      * Remove extended data from the intent.
   5317      *
   5318      * @see #putExtra
   5319      */
   5320     public void removeExtra(String name) {
   5321         if (mExtras != null) {
   5322             mExtras.remove(name);
   5323             if (mExtras.size() == 0) {
   5324                 mExtras = null;
   5325             }
   5326         }
   5327     }
   5328 
   5329     /**
   5330      * Set special flags controlling how this intent is handled.  Most values
   5331      * here depend on the type of component being executed by the Intent,
   5332      * specifically the FLAG_ACTIVITY_* flags are all for use with
   5333      * {@link Context#startActivity Context.startActivity()} and the
   5334      * FLAG_RECEIVER_* flags are all for use with
   5335      * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
   5336      *
   5337      * <p>See the
   5338      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
   5339      * Stack</a> documentation for important information on how some of these options impact
   5340      * the behavior of your application.
   5341      *
   5342      * @param flags The desired flags.
   5343      *
   5344      * @return Returns the same Intent object, for chaining multiple calls
   5345      * into a single statement.
   5346      *
   5347      * @see #getFlags
   5348      * @see #addFlags
   5349      *
   5350      * @see #FLAG_GRANT_READ_URI_PERMISSION
   5351      * @see #FLAG_GRANT_WRITE_URI_PERMISSION
   5352      * @see #FLAG_DEBUG_LOG_RESOLUTION
   5353      * @see #FLAG_FROM_BACKGROUND
   5354      * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
   5355      * @see #FLAG_ACTIVITY_CLEAR_TASK
   5356      * @see #FLAG_ACTIVITY_CLEAR_TOP
   5357      * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
   5358      * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
   5359      * @see #FLAG_ACTIVITY_FORWARD_RESULT
   5360      * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
   5361      * @see #FLAG_ACTIVITY_MULTIPLE_TASK
   5362      * @see #FLAG_ACTIVITY_NEW_TASK
   5363      * @see #FLAG_ACTIVITY_NO_ANIMATION
   5364      * @see #FLAG_ACTIVITY_NO_HISTORY
   5365      * @see #FLAG_ACTIVITY_NO_USER_ACTION
   5366      * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
   5367      * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
   5368      * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
   5369      * @see #FLAG_ACTIVITY_SINGLE_TOP
   5370      * @see #FLAG_ACTIVITY_TASK_ON_HOME
   5371      * @see #FLAG_RECEIVER_REGISTERED_ONLY
   5372      */
   5373     public Intent setFlags(int flags) {
   5374         mFlags = flags;
   5375         return this;
   5376     }
   5377 
   5378     /**
   5379      * Add additional flags to the intent (or with existing flags
   5380      * value).
   5381      *
   5382      * @param flags The new flags to set.
   5383      *
   5384      * @return Returns the same Intent object, for chaining multiple calls
   5385      * into a single statement.
   5386      *
   5387      * @see #setFlags
   5388      */
   5389     public Intent addFlags(int flags) {
   5390         mFlags |= flags;
   5391         return this;
   5392     }
   5393 
   5394     /**
   5395      * (Usually optional) Set an explicit application package name that limits
   5396      * the components this Intent will resolve to.  If left to the default
   5397      * value of null, all components in all applications will considered.
   5398      * If non-null, the Intent can only match the components in the given
   5399      * application package.
   5400      *
   5401      * @param packageName The name of the application package to handle the
   5402      * intent, or null to allow any application package.
   5403      *
   5404      * @return Returns the same Intent object, for chaining multiple calls
   5405      * into a single statement.
   5406      *
   5407      * @see #getPackage
   5408      * @see #resolveActivity
   5409      */
   5410     public Intent setPackage(String packageName) {
   5411         if (packageName != null && mSelector != null) {
   5412             throw new IllegalArgumentException(
   5413                     "Can't set package name when selector is already set");
   5414         }
   5415         mPackage = packageName;
   5416         return this;
   5417     }
   5418 
   5419     /**
   5420      * (Usually optional) Explicitly set the component to handle the intent.
   5421      * If left with the default value of null, the system will determine the
   5422      * appropriate class to use based on the other fields (action, data,
   5423      * type, categories) in the Intent.  If this class is defined, the
   5424      * specified class will always be used regardless of the other fields.  You
   5425      * should only set this value when you know you absolutely want a specific
   5426      * class to be used; otherwise it is better to let the system find the
   5427      * appropriate class so that you will respect the installed applications
   5428      * and user preferences.
   5429      *
   5430      * @param component The name of the application component to handle the
   5431      * intent, or null to let the system find one for you.
   5432      *
   5433      * @return Returns the same Intent object, for chaining multiple calls
   5434      * into a single statement.
   5435      *
   5436      * @see #setClass
   5437      * @see #setClassName(Context, String)
   5438      * @see #setClassName(String, String)
   5439      * @see #getComponent
   5440      * @see #resolveActivity
   5441      */
   5442     public Intent setComponent(ComponentName component) {
   5443         mComponent = component;
   5444         return this;
   5445     }
   5446 
   5447     /**
   5448      * Convenience for calling {@link #setComponent} with an
   5449      * explicit class name.
   5450      *
   5451      * @param packageContext A Context of the application package implementing
   5452      * this class.
   5453      * @param className The name of a class inside of the application package
   5454      * that will be used as the component for this Intent.
   5455      *
   5456      * @return Returns the same Intent object, for chaining multiple calls
   5457      * into a single statement.
   5458      *
   5459      * @see #setComponent
   5460      * @see #setClass
   5461      */
   5462     public Intent setClassName(Context packageContext, String className) {
   5463         mComponent = new ComponentName(packageContext, className);
   5464         return this;
   5465     }
   5466 
   5467     /**
   5468      * Convenience for calling {@link #setComponent} with an
   5469      * explicit application package name and class name.
   5470      *
   5471      * @param packageName The name of the package implementing the desired
   5472      * component.
   5473      * @param className The name of a class inside of the application package
   5474      * that will be used as the component for this Intent.
   5475      *
   5476      * @return Returns the same Intent object, for chaining multiple calls
   5477      * into a single statement.
   5478      *
   5479      * @see #setComponent
   5480      * @see #setClass
   5481      */
   5482     public Intent setClassName(String packageName, String className) {
   5483         mComponent = new ComponentName(packageName, className);
   5484         return this;
   5485     }
   5486 
   5487     /**
   5488      * Convenience for calling {@link #setComponent(ComponentName)} with the
   5489      * name returned by a {@link Class} object.
   5490      *
   5491      * @param packageContext A Context of the application package implementing
   5492      * this class.
   5493      * @param cls The class name to set, equivalent to
   5494      *            <code>setClassName(context, cls.getName())</code>.
   5495      *
   5496      * @return Returns the same Intent object, for chaining multiple calls
   5497      * into a single statement.
   5498      *
   5499      * @see #setComponent
   5500      */
   5501     public Intent setClass(Context packageContext, Class<?> cls) {
   5502         mComponent = new ComponentName(packageContext, cls);
   5503         return this;
   5504     }
   5505 
   5506     /**
   5507      * Set the bounds of the sender of this intent, in screen coordinates.  This can be
   5508      * used as a hint to the receiver for animations and the like.  Null means that there
   5509      * is no source bounds.
   5510      */
   5511     public void setSourceBounds(Rect r) {
   5512         if (r != null) {
   5513             mSourceBounds = new Rect(r);
   5514         } else {
   5515             mSourceBounds = null;
   5516         }
   5517     }
   5518 
   5519     /**
   5520      * Use with {@link #fillIn} to allow the current action value to be
   5521      * overwritten, even if it is already set.
   5522      */
   5523     public static final int FILL_IN_ACTION = 1<<0;
   5524 
   5525     /**
   5526      * Use with {@link #fillIn} to allow the current data or type value
   5527      * overwritten, even if it is already set.
   5528      */
   5529     public static final int FILL_IN_DATA = 1<<1;
   5530 
   5531     /**
   5532      * Use with {@link #fillIn} to allow the current categories to be
   5533      * overwritten, even if they are already set.
   5534      */
   5535     public static final int FILL_IN_CATEGORIES = 1<<2;
   5536 
   5537     /**
   5538      * Use with {@link #fillIn} to allow the current component value to be
   5539      * overwritten, even if it is already set.
   5540      */
   5541     public static final int FILL_IN_COMPONENT = 1<<3;
   5542 
   5543     /**
   5544      * Use with {@link #fillIn} to allow the current package value to be
   5545      * overwritten, even if it is already set.
   5546      */
   5547     public static final int FILL_IN_PACKAGE = 1<<4;
   5548 
   5549     /**
   5550      * Use with {@link #fillIn} to allow the current bounds rectangle to be
   5551      * overwritten, even if it is already set.
   5552      */
   5553     public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
   5554 
   5555     /**
   5556      * Use with {@link #fillIn} to allow the current selector to be
   5557      * overwritten, even if it is already set.
   5558      */
   5559     public static final int FILL_IN_SELECTOR = 1<<6;
   5560 
   5561     /**
   5562      * Copy the contents of <var>other</var> in to this object, but only
   5563      * where fields are not defined by this object.  For purposes of a field
   5564      * being defined, the following pieces of data in the Intent are
   5565      * considered to be separate fields:
   5566      *
   5567      * <ul>
   5568      * <li> action, as set by {@link #setAction}.
   5569      * <li> data URI and MIME type, as set by {@link #setData(Uri)},
   5570      * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
   5571      * <li> categories, as set by {@link #addCategory}.
   5572      * <li> package, as set by {@link #setPackage}.
   5573      * <li> component, as set by {@link #setComponent(ComponentName)} or
   5574      * related methods.
   5575      * <li> source bounds, as set by {@link #setSourceBounds}
   5576      * <li> each top-level name in the associated extras.
   5577      * </ul>
   5578      *
   5579      * <p>In addition, you can use the {@link #FILL_IN_ACTION},
   5580      * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
   5581      * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, and
   5582      * {@link #FILL_IN_SELECTOR} to override the restriction where the
   5583      * corresponding field will not be replaced if it is already set.
   5584      *
   5585      * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT} is explicitly
   5586      * specified.  The selector will only be copied if {@link #FILL_IN_SELECTOR} is
   5587      * explicitly specified.
   5588      *
   5589      * <p>For example, consider Intent A with {data="foo", categories="bar"}
   5590      * and Intent B with {action="gotit", data-type="some/thing",
   5591      * categories="one","two"}.
   5592      *
   5593      * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
   5594      * containing: {action="gotit", data-type="some/thing",
   5595      * categories="bar"}.
   5596      *
   5597      * @param other Another Intent whose values are to be used to fill in
   5598      * the current one.
   5599      * @param flags Options to control which fields can be filled in.
   5600      *
   5601      * @return Returns a bit mask of {@link #FILL_IN_ACTION},
   5602      * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
   5603      * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS}, and
   5604      * {@link #FILL_IN_SELECTOR} indicating which fields were changed.
   5605      */
   5606     public int fillIn(Intent other, int flags) {
   5607         int changes = 0;
   5608         if (other.mAction != null
   5609                 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
   5610             mAction = other.mAction;
   5611             changes |= FILL_IN_ACTION;
   5612         }
   5613         if ((other.mData != null || other.mType != null)
   5614                 && ((mData == null && mType == null)
   5615                         || (flags&FILL_IN_DATA) != 0)) {
   5616             mData = other.mData;
   5617             mType = other.mType;
   5618             changes |= FILL_IN_DATA;
   5619         }
   5620         if (other.mCategories != null
   5621                 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
   5622             if (other.mCategories != null) {
   5623                 mCategories = new HashSet<String>(other.mCategories);
   5624             }
   5625             changes |= FILL_IN_CATEGORIES;
   5626         }
   5627         if (other.mPackage != null
   5628                 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
   5629             // Only do this if mSelector is not set.
   5630             if (mSelector == null) {
   5631                 mPackage = other.mPackage;
   5632                 changes |= FILL_IN_PACKAGE;
   5633             }
   5634         }
   5635         // Selector is special: it can only be set if explicitly allowed,
   5636         // for the same reason as the component name.
   5637         if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
   5638             if (mPackage == null) {
   5639                 mSelector = new Intent(other.mSelector);
   5640                 mPackage = null;
   5641                 changes |= FILL_IN_SELECTOR;
   5642             }
   5643         }
   5644         // Component is special: it can -only- be set if explicitly allowed,
   5645         // since otherwise the sender could force the intent somewhere the
   5646         // originator didn't intend.
   5647         if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
   5648             mComponent = other.mComponent;
   5649             changes |= FILL_IN_COMPONENT;
   5650         }
   5651         mFlags |= other.mFlags;
   5652         if (other.mSourceBounds != null
   5653                 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
   5654             mSourceBounds = new Rect(other.mSourceBounds);
   5655             changes |= FILL_IN_SOURCE_BOUNDS;
   5656         }
   5657         if (mExtras == null) {
   5658             if (other.mExtras != null) {
   5659                 mExtras = new Bundle(other.mExtras);
   5660             }
   5661         } else if (other.mExtras != null) {
   5662             try {
   5663                 Bundle newb = new Bundle(other.mExtras);
   5664                 newb.putAll(mExtras);
   5665                 mExtras = newb;
   5666             } catch (RuntimeException e) {
   5667                 // Modifying the extras can cause us to unparcel the contents
   5668                 // of the bundle, and if we do this in the system process that
   5669                 // may fail.  We really should handle this (i.e., the Bundle
   5670                 // impl shouldn't be on top of a plain map), but for now just
   5671                 // ignore it and keep the original contents. :(
   5672                 Log.w("Intent", "Failure filling in extras", e);
   5673             }
   5674         }
   5675         return changes;
   5676     }
   5677 
   5678     /**
   5679      * Wrapper class holding an Intent and implementing comparisons on it for
   5680      * the purpose of filtering.  The class implements its
   5681      * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
   5682      * simple calls to {@link Intent#filterEquals(Intent)}  filterEquals()} and
   5683      * {@link android.content.Intent#filterHashCode()}  filterHashCode()}
   5684      * on the wrapped Intent.
   5685      */
   5686     public static final class FilterComparison {
   5687         private final Intent mIntent;
   5688         private final int mHashCode;
   5689 
   5690         public FilterComparison(Intent intent) {
   5691             mIntent = intent;
   5692             mHashCode = intent.filterHashCode();
   5693         }
   5694 
   5695         /**
   5696          * Return the Intent that this FilterComparison represents.
   5697          * @return Returns the Intent held by the FilterComparison.  Do
   5698          * not modify!
   5699          */
   5700         public Intent getIntent() {
   5701             return mIntent;
   5702         }
   5703 
   5704         @Override
   5705         public boolean equals(Object obj) {
   5706             if (obj instanceof FilterComparison) {
   5707                 Intent other = ((FilterComparison)obj).mIntent;
   5708                 return mIntent.filterEquals(other);
   5709             }
   5710             return false;
   5711         }
   5712 
   5713         @Override
   5714         public int hashCode() {
   5715             return mHashCode;
   5716         }
   5717     }
   5718 
   5719     /**
   5720      * Determine if two intents are the same for the purposes of intent
   5721      * resolution (filtering). That is, if their action, data, type,
   5722      * class, and categories are the same.  This does <em>not</em> compare
   5723      * any extra data included in the intents.
   5724      *
   5725      * @param other The other Intent to compare against.
   5726      *
   5727      * @return Returns true if action, data, type, class, and categories
   5728      *         are the same.
   5729      */
   5730     public boolean filterEquals(Intent other) {
   5731         if (other == null) {
   5732             return false;
   5733         }
   5734         if (mAction != other.mAction) {
   5735             if (mAction != null) {
   5736                 if (!mAction.equals(other.mAction)) {
   5737                     return false;
   5738                 }
   5739             } else {
   5740                 if (!other.mAction.equals(mAction)) {
   5741                     return false;
   5742                 }
   5743             }
   5744         }
   5745         if (mData != other.mData) {
   5746             if (mData != null) {
   5747                 if (!mData.equals(other.mData)) {
   5748                     return false;
   5749                 }
   5750             } else {
   5751                 if (!other.mData.equals(mData)) {
   5752                     return false;
   5753                 }
   5754             }
   5755         }
   5756         if (mType != other.mType) {
   5757             if (mType != null) {
   5758                 if (!mType.equals(other.mType)) {
   5759                     return false;
   5760                 }
   5761             } else {
   5762                 if (!other.mType.equals(mType)) {
   5763                     return false;
   5764                 }
   5765             }
   5766         }
   5767         if (mPackage != other.mPackage) {
   5768             if (mPackage != null) {
   5769                 if (!mPackage.equals(other.mPackage)) {
   5770                     return false;
   5771                 }
   5772             } else {
   5773                 if (!other.mPackage.equals(mPackage)) {
   5774                     return false;
   5775                 }
   5776             }
   5777         }
   5778         if (mComponent != other.mComponent) {
   5779             if (mComponent != null) {
   5780                 if (!mComponent.equals(other.mComponent)) {
   5781                     return false;
   5782                 }
   5783             } else {
   5784                 if (!other.mComponent.equals(mComponent)) {
   5785                     return false;
   5786                 }
   5787             }
   5788         }
   5789         if (mCategories != other.mCategories) {
   5790             if (mCategories != null) {
   5791                 if (!mCategories.equals(other.mCategories)) {
   5792                     return false;
   5793                 }
   5794             } else {
   5795                 if (!other.mCategories.equals(mCategories)) {
   5796                     return false;
   5797                 }
   5798             }
   5799         }
   5800 
   5801         return true;
   5802     }
   5803 
   5804     /**
   5805      * Generate hash code that matches semantics of filterEquals().
   5806      *
   5807      * @return Returns the hash value of the action, data, type, class, and
   5808      *         categories.
   5809      *
   5810      * @see #filterEquals
   5811      */
   5812     public int filterHashCode() {
   5813         int code = 0;
   5814         if (mAction != null) {
   5815             code += mAction.hashCode();
   5816         }
   5817         if (mData != null) {
   5818             code += mData.hashCode();
   5819         }
   5820         if (mType != null) {
   5821             code += mType.hashCode();
   5822         }
   5823         if (mPackage != null) {
   5824             code += mPackage.hashCode();
   5825         }
   5826         if (mComponent != null) {
   5827             code += mComponent.hashCode();
   5828         }
   5829         if (mCategories != null) {
   5830             code += mCategories.hashCode();
   5831         }
   5832         return code;
   5833     }
   5834 
   5835     @Override
   5836     public String toString() {
   5837         StringBuilder b = new StringBuilder(128);
   5838 
   5839         b.append("Intent { ");
   5840         toShortString(b, true, true, true);
   5841         b.append(" }");
   5842 
   5843         return b.toString();
   5844     }
   5845 
   5846     /** @hide */
   5847     public String toInsecureString() {
   5848         StringBuilder b = new StringBuilder(128);
   5849 
   5850         b.append("Intent { ");
   5851         toShortString(b, false, true, true);
   5852         b.append(" }");
   5853 
   5854         return b.toString();
   5855     }
   5856 
   5857     /** @hide */
   5858     public String toShortString(boolean secure, boolean comp, boolean extras) {
   5859         StringBuilder b = new StringBuilder(128);
   5860         toShortString(b, secure, comp, extras);
   5861         return b.toString();
   5862     }
   5863 
   5864     /** @hide */
   5865     public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras) {
   5866         boolean first = true;
   5867         if (mAction != null) {
   5868             b.append("act=").append(mAction);
   5869             first = false;
   5870         }
   5871         if (mCategories != null) {
   5872             if (!first) {
   5873                 b.append(' ');
   5874             }
   5875             first = false;
   5876             b.append("cat=[");
   5877             Iterator<String> i = mCategories.iterator();
   5878             boolean didone = false;
   5879             while (i.hasNext()) {
   5880                 if (didone) b.append(",");
   5881                 didone = true;
   5882                 b.append(i.next());
   5883             }
   5884             b.append("]");
   5885         }
   5886         if (mData != null) {
   5887             if (!first) {
   5888                 b.append(' ');
   5889             }
   5890             first = false;
   5891             b.append("dat=");
   5892             if (secure) {
   5893                 b.append(mData.toSafeString());
   5894             } else {
   5895                 b.append(mData);
   5896             }
   5897         }
   5898         if (mType != null) {
   5899             if (!first) {
   5900                 b.append(' ');
   5901             }
   5902             first = false;
   5903             b.append("typ=").append(mType);
   5904         }
   5905         if (mFlags != 0) {
   5906             if (!first) {
   5907                 b.append(' ');
   5908             }
   5909             first = false;
   5910             b.append("flg=0x").append(Integer.toHexString(mFlags));
   5911         }
   5912         if (mPackage != null) {
   5913             if (!first) {
   5914                 b.append(' ');
   5915             }
   5916             first = false;
   5917             b.append("pkg=").append(mPackage);
   5918         }
   5919         if (comp && mComponent != null) {
   5920             if (!first) {
   5921                 b.append(' ');
   5922             }
   5923             first = false;
   5924             b.append("cmp=").append(mComponent.flattenToShortString());
   5925         }
   5926         if (mSourceBounds != null) {
   5927             if (!first) {
   5928                 b.append(' ');
   5929             }
   5930             first = false;
   5931             b.append("bnds=").append(mSourceBounds.toShortString());
   5932         }
   5933         if (extras && mExtras != null) {
   5934             if (!first) {
   5935                 b.append(' ');
   5936             }
   5937             first = false;
   5938             b.append("(has extras)");
   5939         }
   5940         if (mSelector != null) {
   5941             b.append(" sel={");
   5942             mSelector.toShortString(b, secure, comp, extras);
   5943             b.append("}");
   5944         }
   5945     }
   5946 
   5947     /**
   5948      * Call {@link #toUri} with 0 flags.
   5949      * @deprecated Use {@link #toUri} instead.
   5950      */
   5951     @Deprecated
   5952     public String toURI() {
   5953         return toUri(0);
   5954     }
   5955 
   5956     /**
   5957      * Convert this Intent into a String holding a URI representation of it.
   5958      * The returned URI string has been properly URI encoded, so it can be
   5959      * used with {@link Uri#parse Uri.parse(String)}.  The URI contains the
   5960      * Intent's data as the base URI, with an additional fragment describing
   5961      * the action, categories, type, flags, package, component, and extras.
   5962      *
   5963      * <p>You can convert the returned string back to an Intent with
   5964      * {@link #getIntent}.
   5965      *
   5966      * @param flags Additional operating flags.  Either 0 or
   5967      * {@link #URI_INTENT_SCHEME}.
   5968      *
   5969      * @return Returns a URI encoding URI string describing the entire contents
   5970      * of the Intent.
   5971      */
   5972     public String toUri(int flags) {
   5973         StringBuilder uri = new StringBuilder(128);
   5974         String scheme = null;
   5975         if (mData != null) {
   5976             String data = mData.toString();
   5977             if ((flags&URI_INTENT_SCHEME) != 0) {
   5978                 final int N = data.length();
   5979                 for (int i=0; i<N; i++) {
   5980                     char c = data.charAt(i);
   5981                     if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
   5982                             || c == '.' || c == '-') {
   5983                         continue;
   5984                     }
   5985                     if (c == ':' && i > 0) {
   5986                         // Valid scheme.
   5987                         scheme = data.substring(0, i);
   5988                         uri.append("intent:");
   5989                         data = data.substring(i+1);
   5990                         break;
   5991                     }
   5992 
   5993                     // No scheme.
   5994                     break;
   5995                 }
   5996             }
   5997             uri.append(data);
   5998 
   5999         } else if ((flags&URI_INTENT_SCHEME) != 0) {
   6000             uri.append("intent:");
   6001         }
   6002 
   6003         uri.append("#Intent;");
   6004 
   6005         toUriInner(uri, scheme, flags);
   6006         if (mSelector != null) {
   6007             uri.append("SEL;");
   6008             // Note that for now we are not going to try to handle the
   6009             // data part; not clear how to represent this as a URI, and
   6010             // not much utility in it.
   6011             mSelector.toUriInner(uri, null, flags);
   6012         }
   6013 
   6014         uri.append("end");
   6015 
   6016         return uri.toString();
   6017     }
   6018 
   6019     private void toUriInner(StringBuilder uri, String scheme, int flags) {
   6020         if (scheme != null) {
   6021             uri.append("scheme=").append(scheme).append(';');
   6022         }
   6023         if (mAction != null) {
   6024             uri.append("action=").append(Uri.encode(mAction)).append(';');
   6025         }
   6026         if (mCategories != null) {
   6027             for (String category : mCategories) {
   6028                 uri.append("category=").append(Uri.encode(category)).append(';');
   6029             }
   6030         }
   6031         if (mType != null) {
   6032             uri.append("type=").append(Uri.encode(mType, "/")).append(';');
   6033         }
   6034         if (mFlags != 0) {
   6035             uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
   6036         }
   6037         if (mPackage != null) {
   6038             uri.append("package=").append(Uri.encode(mPackage)).append(';');
   6039         }
   6040         if (mComponent != null) {
   6041             uri.append("component=").append(Uri.encode(
   6042                     mComponent.flattenToShortString(), "/")).append(';');
   6043         }
   6044         if (mSourceBounds != null) {
   6045             uri.append("sourceBounds=")
   6046                     .append(Uri.encode(mSourceBounds.flattenToString()))
   6047                     .append(';');
   6048         }
   6049         if (mExtras != null) {
   6050             for (String key : mExtras.keySet()) {
   6051                 final Object value = mExtras.get(key);
   6052                 char entryType =
   6053                         value instanceof String    ? 'S' :
   6054                         value instanceof Boolean   ? 'B' :
   6055                         value instanceof Byte      ? 'b' :
   6056                         value instanceof Character ? 'c' :
   6057                         value instanceof Double    ? 'd' :
   6058                         value instanceof Float     ? 'f' :
   6059                         value instanceof Integer   ? 'i' :
   6060                         value instanceof Long      ? 'l' :
   6061                         value instanceof Short     ? 's' :
   6062                         '\0';
   6063 
   6064                 if (entryType != '\0') {
   6065                     uri.append(entryType);
   6066                     uri.append('.');
   6067                     uri.append(Uri.encode(key));
   6068                     uri.append('=');
   6069                     uri.append(Uri.encode(value.toString()));
   6070                     uri.append(';');
   6071                 }
   6072             }
   6073         }
   6074     }
   6075 
   6076     public int describeContents() {
   6077         return (mExtras != null) ? mExtras.describeContents() : 0;
   6078     }
   6079 
   6080     public void writeToParcel(Parcel out, int flags) {
   6081         out.writeString(mAction);
   6082         Uri.writeToParcel(out, mData);
   6083         out.writeString(mType);
   6084         out.writeInt(mFlags);
   6085         out.writeString(mPackage);
   6086         ComponentName.writeToParcel(mComponent, out);
   6087 
   6088         if (mSourceBounds != null) {
   6089             out.writeInt(1);
   6090             mSourceBounds.writeToParcel(out, flags);
   6091         } else {
   6092             out.writeInt(0);
   6093         }
   6094 
   6095         if (mCategories != null) {
   6096             out.writeInt(mCategories.size());
   6097             for (String category : mCategories) {
   6098                 out.writeString(category);
   6099             }
   6100         } else {
   6101             out.writeInt(0);
   6102         }
   6103 
   6104         if (mSelector != null) {
   6105             out.writeInt(1);
   6106             mSelector.writeToParcel(out, flags);
   6107         } else {
   6108             out.writeInt(0);
   6109         }
   6110 
   6111         out.writeBundle(mExtras);
   6112     }
   6113 
   6114     public static final Parcelable.Creator<Intent> CREATOR
   6115             = new Parcelable.Creator<Intent>() {
   6116         public Intent createFromParcel(Parcel in) {
   6117             return new Intent(in);
   6118         }
   6119         public Intent[] newArray(int size) {
   6120             return new Intent[size];
   6121         }
   6122     };
   6123 
   6124     /** @hide */
   6125     protected Intent(Parcel in) {
   6126         readFromParcel(in);
   6127     }
   6128 
   6129     public void readFromParcel(Parcel in) {
   6130         setAction(in.readString());
   6131         mData = Uri.CREATOR.createFromParcel(in);
   6132         mType = in.readString();
   6133         mFlags = in.readInt();
   6134         mPackage = in.readString();
   6135         mComponent = ComponentName.readFromParcel(in);
   6136 
   6137         if (in.readInt() != 0) {
   6138             mSourceBounds = Rect.CREATOR.createFromParcel(in);
   6139         }
   6140 
   6141         int N = in.readInt();
   6142         if (N > 0) {
   6143             mCategories = new HashSet<String>();
   6144             int i;
   6145             for (i=0; i<N; i++) {
   6146                 mCategories.add(in.readString().intern());
   6147             }
   6148         } else {
   6149             mCategories = null;
   6150         }
   6151 
   6152         if (in.readInt() != 0) {
   6153             mSelector = new Intent(in);
   6154         }
   6155 
   6156         mExtras = in.readBundle();
   6157     }
   6158 
   6159     /**
   6160      * Parses the "intent" element (and its children) from XML and instantiates
   6161      * an Intent object.  The given XML parser should be located at the tag
   6162      * where parsing should start (often named "intent"), from which the
   6163      * basic action, data, type, and package and class name will be
   6164      * retrieved.  The function will then parse in to any child elements,
   6165      * looking for <category android:name="xxx"> tags to add categories and
   6166      * <extra android:name="xxx" android:value="yyy"> to attach extra data
   6167      * to the intent.
   6168      *
   6169      * @param resources The Resources to use when inflating resources.
   6170      * @param parser The XML parser pointing at an "intent" tag.
   6171      * @param attrs The AttributeSet interface for retrieving extended
   6172      * attribute data at the current <var>parser</var> location.
   6173      * @return An Intent object matching the XML data.
   6174      * @throws XmlPullParserException If there was an XML parsing error.
   6175      * @throws IOException If there was an I/O error.
   6176      */
   6177     public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
   6178             throws XmlPullParserException, IOException {
   6179         Intent intent = new Intent();
   6180 
   6181         TypedArray sa = resources.obtainAttributes(attrs,
   6182                 com.android.internal.R.styleable.Intent);
   6183 
   6184         intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
   6185 
   6186         String data = sa.getString(com.android.internal.R.styleable.Intent_data);
   6187         String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
   6188         intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
   6189 
   6190         String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
   6191         String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
   6192         if (packageName != null && className != null) {
   6193             intent.setComponent(new ComponentName(packageName, className));
   6194         }
   6195 
   6196         sa.recycle();
   6197 
   6198         int outerDepth = parser.getDepth();
   6199         int type;
   6200         while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
   6201                && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
   6202             if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
   6203                 continue;
   6204             }
   6205 
   6206             String nodeName = parser.getName();
   6207             if (nodeName.equals("category")) {
   6208                 sa = resources.obtainAttributes(attrs,
   6209                         com.android.internal.R.styleable.IntentCategory);
   6210                 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
   6211                 sa.recycle();
   6212 
   6213                 if (cat != null) {
   6214                     intent.addCategory(cat);
   6215                 }
   6216                 XmlUtils.skipCurrentTag(parser);
   6217 
   6218             } else if (nodeName.equals("extra")) {
   6219                 if (intent.mExtras == null) {
   6220                     intent.mExtras = new Bundle();
   6221                 }
   6222                 resources.parseBundleExtra("extra", attrs, intent.mExtras);
   6223                 XmlUtils.skipCurrentTag(parser);
   6224 
   6225             } else {
   6226                 XmlUtils.skipCurrentTag(parser);
   6227             }
   6228         }
   6229 
   6230         return intent;
   6231     }
   6232 }
   6233