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