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 android.content.pm.ApplicationInfo;
     20 import android.os.ResultReceiver;
     21 import android.provider.MediaStore;
     22 import android.util.ArraySet;
     23 
     24 import org.xmlpull.v1.XmlPullParser;
     25 import org.xmlpull.v1.XmlPullParserException;
     26 
     27 import android.annotation.AnyRes;
     28 import android.annotation.IntDef;
     29 import android.annotation.SdkConstant;
     30 import android.annotation.SystemApi;
     31 import android.annotation.SdkConstant.SdkConstantType;
     32 import android.content.pm.ActivityInfo;
     33 
     34 import static android.content.ContentProvider.maybeAddUserId;
     35 
     36 import android.content.pm.PackageManager;
     37 import android.content.pm.ResolveInfo;
     38 import android.content.res.Resources;
     39 import android.content.res.TypedArray;
     40 import android.graphics.Rect;
     41 import android.net.Uri;
     42 import android.os.Bundle;
     43 import android.os.IBinder;
     44 import android.os.Parcel;
     45 import android.os.Parcelable;
     46 import android.os.Process;
     47 import android.os.StrictMode;
     48 import android.os.UserHandle;
     49 import android.provider.DocumentsContract;
     50 import android.provider.DocumentsProvider;
     51 import android.provider.OpenableColumns;
     52 import android.util.AttributeSet;
     53 import android.util.Log;
     54 
     55 import com.android.internal.util.XmlUtils;
     56 
     57 import org.xmlpull.v1.XmlSerializer;
     58 
     59 import java.io.IOException;
     60 import java.io.Serializable;
     61 import java.lang.annotation.Retention;
     62 import java.lang.annotation.RetentionPolicy;
     63 import java.net.URISyntaxException;
     64 import java.util.ArrayList;
     65 import java.util.List;
     66 import java.util.Locale;
     67 import java.util.Objects;
     68 import java.util.Set;
     69 
     70 /**
     71  * An intent is an abstract description of an operation to be performed.  It
     72  * can be used with {@link Context#startActivity(Intent) startActivity} to
     73  * launch an {@link android.app.Activity},
     74  * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
     75  * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
     76  * and {@link android.content.Context#startService} or
     77  * {@link android.content.Context#bindService} to communicate with a
     78  * background {@link android.app.Service}.
     79  *
     80  * <p>An Intent provides a facility for performing late runtime binding between the code in
     81  * different applications. Its most significant use is in the launching of activities, where it
     82  * can be thought of as the glue between activities. It is basically a passive data structure
     83  * holding an abstract description of an action to be performed.</p>
     84  *
     85  * <div class="special reference">
     86  * <h3>Developer Guides</h3>
     87  * <p>For information about how to create and resolve intents, read the
     88  * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
     89  * developer guide.</p>
     90  * </div>
     91  *
     92  * <a name="IntentStructure"></a>
     93  * <h3>Intent Structure</h3>
     94  * <p>The primary pieces of information in an intent are:</p>
     95  *
     96  * <ul>
     97  *   <li> <p><b>action</b> -- The general action to be performed, such as
     98  *     {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
     99  *     etc.</p>
    100  *   </li>
    101  *   <li> <p><b>data</b> -- The data to operate on, such as a person record
    102  *     in the contacts database, expressed as a {@link android.net.Uri}.</p>
    103  *   </li>
    104  * </ul>
    105  *
    106  *
    107  * <p>Some examples of action/data pairs are:</p>
    108  *
    109  * <ul>
    110  *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
    111  *     information about the person whose identifier is "1".</p>
    112  *   </li>
    113  *   <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
    114  *     the phone dialer with the person filled in.</p>
    115  *   </li>
    116  *   <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
    117  *     the phone dialer with the given number filled in.  Note how the
    118  *     VIEW action does what what is considered the most reasonable thing for
    119  *     a particular URI.</p>
    120  *   </li>
    121  *   <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
    122  *     the phone dialer with the given number filled in.</p>
    123  *   </li>
    124  *   <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
    125  *     information about the person whose identifier is "1".</p>
    126  *   </li>
    127  *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
    128  *     a list of people, which the user can browse through.  This example is a
    129  *     typical top-level entry into the Contacts application, showing you the
    130  *     list of people. Selecting a particular person to view would result in a
    131  *     new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/N</i></b> }
    132  *     being used to start an activity to display that person.</p>
    133  *   </li>
    134  * </ul>
    135  *
    136  * <p>In addition to these primary attributes, there are a number of secondary
    137  * attributes that you can also include with an intent:</p>
    138  *
    139  * <ul>
    140  *     <li> <p><b>category</b> -- Gives additional information about the action
    141  *         to execute.  For example, {@link #CATEGORY_LAUNCHER} means it should
    142  *         appear in the Launcher as a top-level application, while
    143  *         {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
    144  *         of alternative actions the user can perform on a piece of data.</p>
    145  *     <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
    146  *         intent data.  Normally the type is inferred from the data itself.
    147  *         By setting this attribute, you disable that evaluation and force
    148  *         an explicit type.</p>
    149  *     <li> <p><b>component</b> -- Specifies an explicit name of a component
    150  *         class to use for the intent.  Normally this is determined by looking
    151  *         at the other information in the intent (the action, data/type, and
    152  *         categories) and matching that with a component that can handle it.
    153  *         If this attribute is set then none of the evaluation is performed,
    154  *         and this component is used exactly as is.  By specifying this attribute,
    155  *         all of the other Intent attributes become optional.</p>
    156  *     <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
    157  *         This can be used to provide extended information to the component.
    158  *         For example, if we have a action to send an e-mail message, we could
    159  *         also include extra pieces of data here to supply a subject, body,
    160  *         etc.</p>
    161  * </ul>
    162  *
    163  * <p>Here are some examples of other operations you can specify as intents
    164  * using these additional parameters:</p>
    165  *
    166  * <ul>
    167  *   <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
    168  *     Launch the home screen.</p>
    169  *   </li>
    170  *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
    171  *     <i>{@link android.provider.Contacts.Phones#CONTENT_URI
    172  *     vnd.android.cursor.item/phone}</i></b>
    173  *     -- Display the list of people's phone numbers, allowing the user to
    174  *     browse through them and pick one and return it to the parent activity.</p>
    175  *   </li>
    176  *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
    177  *     <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
    178  *     -- Display all pickers for data that can be opened with
    179  *     {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
    180  *     allowing the user to pick one of them and then some data inside of it
    181  *     and returning the resulting URI to the caller.  This can be used,
    182  *     for example, in an e-mail application to allow the user to pick some
    183  *     data to include as an attachment.</p>
    184  *   </li>
    185  * </ul>
    186  *
    187  * <p>There are a variety of standard Intent action and category constants
    188  * defined in the Intent class, but applications can also define their own.
    189  * These strings use java style scoping, to ensure they are unique -- for
    190  * example, the standard {@link #ACTION_VIEW} is called
    191  * "android.intent.action.VIEW".</p>
    192  *
    193  * <p>Put together, the set of actions, data types, categories, and extra data
    194  * defines a language for the system allowing for the expression of phrases
    195  * such as "call john smith's cell".  As applications are added to the system,
    196  * they can extend this language by adding new actions, types, and categories, or
    197  * they can modify the behavior of existing phrases by supplying their own
    198  * activities that handle them.</p>
    199  *
    200  * <a name="IntentResolution"></a>
    201  * <h3>Intent Resolution</h3>
    202  *
    203  * <p>There are two primary forms of intents you will use.
    204  *
    205  * <ul>
    206  *     <li> <p><b>Explicit Intents</b> have specified a component (via
    207  *     {@link #setComponent} or {@link #setClass}), which provides the exact
    208  *     class to be run.  Often these will not include any other information,
    209  *     simply being a way for an application to launch various internal
    210  *     activities it has as the user interacts with the application.
    211  *
    212  *     <li> <p><b>Implicit Intents</b> have not specified a component;
    213  *     instead, they must include enough information for the system to
    214  *     determine which of the available components is best to run for that
    215  *     intent.
    216  * </ul>
    217  *
    218  * <p>When using implicit intents, given such an arbitrary intent we need to
    219  * know what to do with it. This is handled by the process of <em>Intent
    220  * resolution</em>, which maps an Intent to an {@link android.app.Activity},
    221  * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
    222  * more activities/receivers) that can handle it.</p>
    223  *
    224  * <p>The intent resolution mechanism basically revolves around matching an
    225  * Intent against all of the &lt;intent-filter&gt; descriptions in the
    226  * installed application packages.  (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
    227  * objects explicitly registered with {@link Context#registerReceiver}.)  More
    228  * details on this can be found in the documentation on the {@link
    229  * IntentFilter} class.</p>
    230  *
    231  * <p>There are three pieces of information in the Intent that are used for
    232  * resolution: the action, type, and category.  Using this information, a query
    233  * is done on the {@link PackageManager} for a component that can handle the
    234  * intent. The appropriate component is determined based on the intent
    235  * information supplied in the <code>AndroidManifest.xml</code> file as
    236  * follows:</p>
    237  *
    238  * <ul>
    239  *     <li> <p>The <b>action</b>, if given, must be listed by the component as
    240  *         one it handles.</p>
    241  *     <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
    242  *         already supplied in the Intent.  Like the action, if a type is
    243  *         included in the intent (either explicitly or implicitly in its
    244  *         data), then this must be listed by the component as one it handles.</p>
    245  *     <li> For data that is not a <code>content:</code> URI and where no explicit
    246  *         type is included in the Intent, instead the <b>scheme</b> of the
    247  *         intent data (such as <code>http:</code> or <code>mailto:</code>) is
    248  *         considered. Again like the action, if we are matching a scheme it
    249  *         must be listed by the component as one it can handle.
    250  *     <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
    251  *         by the activity as categories it handles.  That is, if you include
    252  *         the categories {@link #CATEGORY_LAUNCHER} and
    253  *         {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
    254  *         with an intent that lists <em>both</em> of those categories.
    255  *         Activities will very often need to support the
    256  *         {@link #CATEGORY_DEFAULT} so that they can be found by
    257  *         {@link Context#startActivity Context.startActivity()}.</p>
    258  * </ul>
    259  *
    260  * <p>For example, consider the Note Pad sample application that
    261  * allows user to browse through a list of notes data and view details about
    262  * individual items.  Text in italics indicate places were you would replace a
    263  * name with one specific to your own package.</p>
    264  *
    265  * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    266  *       package="<i>com.android.notepad</i>"&gt;
    267  *     &lt;application android:icon="@drawable/app_notes"
    268  *             android:label="@string/app_name"&gt;
    269  *
    270  *         &lt;provider class=".NotePadProvider"
    271  *                 android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
    272  *
    273  *         &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
    274  *             &lt;intent-filter&gt;
    275  *                 &lt;action android:name="android.intent.action.MAIN" /&gt;
    276  *                 &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
    277  *             &lt;/intent-filter&gt;
    278  *             &lt;intent-filter&gt;
    279  *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
    280  *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
    281  *                 &lt;action android:name="android.intent.action.PICK" /&gt;
    282  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    283  *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
    284  *             &lt;/intent-filter&gt;
    285  *             &lt;intent-filter&gt;
    286  *                 &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
    287  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    288  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    289  *             &lt;/intent-filter&gt;
    290  *         &lt;/activity&gt;
    291  *
    292  *         &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
    293  *             &lt;intent-filter android:label="@string/resolve_edit"&gt;
    294  *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
    295  *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
    296  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    297  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    298  *             &lt;/intent-filter&gt;
    299  *
    300  *             &lt;intent-filter&gt;
    301  *                 &lt;action android:name="android.intent.action.INSERT" /&gt;
    302  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    303  *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
    304  *             &lt;/intent-filter&gt;
    305  *
    306  *         &lt;/activity&gt;
    307  *
    308  *         &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
    309  *                 android:theme="@android:style/Theme.Dialog"&gt;
    310  *             &lt;intent-filter android:label="@string/resolve_title"&gt;
    311  *                 &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
    312  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
    313  *                 &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
    314  *                 &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
    315  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    316  *             &lt;/intent-filter&gt;
    317  *         &lt;/activity&gt;
    318  *
    319  *     &lt;/application&gt;
    320  * &lt;/manifest&gt;</pre>
    321  *
    322  * <p>The first activity,
    323  * <code>com.android.notepad.NotesList</code>, serves as our main
    324  * entry into the app.  It can do three things as described by its three intent
    325  * templates:
    326  * <ol>
    327  * <li><pre>
    328  * &lt;intent-filter&gt;
    329  *     &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
    330  *     &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
    331  * &lt;/intent-filter&gt;</pre>
    332  * <p>This provides a top-level entry into the NotePad application: the standard
    333  * MAIN action is a main entry point (not requiring any other information in
    334  * the Intent), and the LAUNCHER category says that this entry point should be
    335  * listed in the application launcher.</p>
    336  * <li><pre>
    337  * &lt;intent-filter&gt;
    338  *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
    339  *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
    340  *     &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
    341  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
    342  *     &lt;data mimeType:name="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
    343  * &lt;/intent-filter&gt;</pre>
    344  * <p>This declares the things that the activity can do on a directory of
    345  * notes.  The type being supported is given with the &lt;type&gt; tag, where
    346  * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
    347  * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
    348  * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
    349  * The activity allows the user to view or edit the directory of data (via
    350  * the VIEW and EDIT actions), or to pick a particular note and return it
    351  * to the caller (via the PICK action).  Note also the DEFAULT category
    352  * supplied here: this is <em>required</em> for the
    353  * {@link Context#startActivity Context.startActivity} method to resolve your
    354  * activity when its component name is not explicitly specified.</p>
    355  * <li><pre>
    356  * &lt;intent-filter&gt;
    357  *     &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
    358  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
    359  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    360  * &lt;/intent-filter&gt;</pre>
    361  * <p>This filter describes the ability return to the caller a note selected by
    362  * the user without needing to know where it came from.  The data type
    363  * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
    364  * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
    365  * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
    366  * The GET_CONTENT action is similar to the PICK action, where the activity
    367  * will return to its caller a piece of data selected by the user.  Here,
    368  * however, the caller specifies the type of data they desire instead of
    369  * the type of data the user will be picking from.</p>
    370  * </ol>
    371  *
    372  * <p>Given these capabilities, the following intents will resolve to the
    373  * NotesList activity:</p>
    374  *
    375  * <ul>
    376  *     <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
    377  *         activities that can be used as top-level entry points into an
    378  *         application.</p>
    379  *     <li> <p><b>{ action=android.app.action.MAIN,
    380  *         category=android.app.category.LAUNCHER }</b> is the actual intent
    381  *         used by the Launcher to populate its top-level list.</p>
    382  *     <li> <p><b>{ action=android.intent.action.VIEW
    383  *          data=content://com.google.provider.NotePad/notes }</b>
    384  *         displays a list of all the notes under
    385  *         "content://com.google.provider.NotePad/notes", which
    386  *         the user can browse through and see the details on.</p>
    387  *     <li> <p><b>{ action=android.app.action.PICK
    388  *          data=content://com.google.provider.NotePad/notes }</b>
    389  *         provides a list of the notes under
    390  *         "content://com.google.provider.NotePad/notes", from which
    391  *         the user can pick a note whose data URL is returned back to the caller.</p>
    392  *     <li> <p><b>{ action=android.app.action.GET_CONTENT
    393  *          type=vnd.android.cursor.item/vnd.google.note }</b>
    394  *         is similar to the pick action, but allows the caller to specify the
    395  *         kind of data they want back so that the system can find the appropriate
    396  *         activity to pick something of that data type.</p>
    397  * </ul>
    398  *
    399  * <p>The second activity,
    400  * <code>com.android.notepad.NoteEditor</code>, shows the user a single
    401  * note entry and allows them to edit it.  It can do two things as described
    402  * by its two intent templates:
    403  * <ol>
    404  * <li><pre>
    405  * &lt;intent-filter android:label="@string/resolve_edit"&gt;
    406  *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
    407  *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
    408  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
    409  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    410  * &lt;/intent-filter&gt;</pre>
    411  * <p>The first, primary, purpose of this activity is to let the user interact
    412  * with a single note, as decribed by the MIME type
    413  * <code>vnd.android.cursor.item/vnd.google.note</code>.  The activity can
    414  * either VIEW a note or allow the user to EDIT it.  Again we support the
    415  * DEFAULT category to allow the activity to be launched without explicitly
    416  * specifying its component.</p>
    417  * <li><pre>
    418  * &lt;intent-filter&gt;
    419  *     &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
    420  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
    421  *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
    422  * &lt;/intent-filter&gt;</pre>
    423  * <p>The secondary use of this activity is to insert a new note entry into
    424  * an existing directory of notes.  This is used when the user creates a new
    425  * note: the INSERT action is executed on the directory of notes, causing
    426  * this activity to run and have the user create the new note data which
    427  * it then adds to the content provider.</p>
    428  * </ol>
    429  *
    430  * <p>Given these capabilities, the following intents will resolve to the
    431  * NoteEditor activity:</p>
    432  *
    433  * <ul>
    434  *     <li> <p><b>{ action=android.intent.action.VIEW
    435  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
    436  *         shows the user the content of note <var>{ID}</var>.</p>
    437  *     <li> <p><b>{ action=android.app.action.EDIT
    438  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
    439  *         allows the user to edit the content of note <var>{ID}</var>.</p>
    440  *     <li> <p><b>{ action=android.app.action.INSERT
    441  *          data=content://com.google.provider.NotePad/notes }</b>
    442  *         creates a new, empty note in the notes list at
    443  *         "content://com.google.provider.NotePad/notes"
    444  *         and allows the user to edit it.  If they keep their changes, the URI
    445  *         of the newly created note is returned to the caller.</p>
    446  * </ul>
    447  *
    448  * <p>The last activity,
    449  * <code>com.android.notepad.TitleEditor</code>, allows the user to
    450  * edit the title of a note.  This could be implemented as a class that the
    451  * application directly invokes (by explicitly setting its component in
    452  * the Intent), but here we show a way you can publish alternative
    453  * operations on existing data:</p>
    454  *
    455  * <pre>
    456  * &lt;intent-filter android:label="@string/resolve_title"&gt;
    457  *     &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
    458  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
    459  *     &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
    460  *     &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
    461  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
    462  * &lt;/intent-filter&gt;</pre>
    463  *
    464  * <p>In the single intent template here, we
    465  * have created our own private action called
    466  * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
    467  * edit the title of a note.  It must be invoked on a specific note
    468  * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
    469  * view and edit actions, but here displays and edits the title contained
    470  * in the note data.
    471  *
    472  * <p>In addition to supporting the default category as usual, our title editor
    473  * also supports two other standard categories: ALTERNATIVE and
    474  * SELECTED_ALTERNATIVE.  Implementing
    475  * these categories allows others to find the special action it provides
    476  * without directly knowing about it, through the
    477  * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
    478  * more often to build dynamic menu items with
    479  * {@link android.view.Menu#addIntentOptions}.  Note that in the intent
    480  * template here was also supply an explicit name for the template
    481  * (via <code>android:label="@string/resolve_title"</code>) to better control
    482  * what the user sees when presented with this activity as an alternative
    483  * action to the data they are viewing.
    484  *
    485  * <p>Given these capabilities, the following intent will resolve to the
    486  * TitleEditor activity:</p>
    487  *
    488  * <ul>
    489  *     <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
    490  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
    491  *         displays and allows the user to edit the title associated
    492  *         with note <var>{ID}</var>.</p>
    493  * </ul>
    494  *
    495  * <h3>Standard Activity Actions</h3>
    496  *
    497  * <p>These are the current standard actions that Intent defines for launching
    498  * activities (usually through {@link Context#startActivity}.  The most
    499  * important, and by far most frequently used, are {@link #ACTION_MAIN} and
    500  * {@link #ACTION_EDIT}.
    501  *
    502  * <ul>
    503  *     <li> {@link #ACTION_MAIN}
    504  *     <li> {@link #ACTION_VIEW}
    505  *     <li> {@link #ACTION_ATTACH_DATA}
    506  *     <li> {@link #ACTION_EDIT}
    507  *     <li> {@link #ACTION_PICK}
    508  *     <li> {@link #ACTION_CHOOSER}
    509  *     <li> {@link #ACTION_GET_CONTENT}
    510  *     <li> {@link #ACTION_DIAL}
    511  *     <li> {@link #ACTION_CALL}
    512  *     <li> {@link #ACTION_SEND}
    513  *     <li> {@link #ACTION_SENDTO}
    514  *     <li> {@link #ACTION_ANSWER}
    515  *     <li> {@link #ACTION_INSERT}
    516  *     <li> {@link #ACTION_DELETE}
    517  *     <li> {@link #ACTION_RUN}
    518  *     <li> {@link #ACTION_SYNC}
    519  *     <li> {@link #ACTION_PICK_ACTIVITY}
    520  *     <li> {@link #ACTION_SEARCH}
    521  *     <li> {@link #ACTION_WEB_SEARCH}
    522  *     <li> {@link #ACTION_FACTORY_TEST}
    523  * </ul>
    524  *
    525  * <h3>Standard Broadcast Actions</h3>
    526  *
    527  * <p>These are the current standard actions that Intent defines for receiving
    528  * broadcasts (usually through {@link Context#registerReceiver} or a
    529  * &lt;receiver&gt; tag in a manifest).
    530  *
    531  * <ul>
    532  *     <li> {@link #ACTION_TIME_TICK}
    533  *     <li> {@link #ACTION_TIME_CHANGED}
    534  *     <li> {@link #ACTION_TIMEZONE_CHANGED}
    535  *     <li> {@link #ACTION_BOOT_COMPLETED}
    536  *     <li> {@link #ACTION_PACKAGE_ADDED}
    537  *     <li> {@link #ACTION_PACKAGE_CHANGED}
    538  *     <li> {@link #ACTION_PACKAGE_REMOVED}
    539  *     <li> {@link #ACTION_PACKAGE_RESTARTED}
    540  *     <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
    541  *     <li> {@link #ACTION_UID_REMOVED}
    542  *     <li> {@link #ACTION_BATTERY_CHANGED}
    543  *     <li> {@link #ACTION_POWER_CONNECTED}
    544  *     <li> {@link #ACTION_POWER_DISCONNECTED}
    545  *     <li> {@link #ACTION_SHUTDOWN}
    546  * </ul>
    547  *
    548  * <h3>Standard Categories</h3>
    549  *
    550  * <p>These are the current standard categories that can be used to further
    551  * clarify an Intent via {@link #addCategory}.
    552  *
    553  * <ul>
    554  *     <li> {@link #CATEGORY_DEFAULT}
    555  *     <li> {@link #CATEGORY_BROWSABLE}
    556  *     <li> {@link #CATEGORY_TAB}
    557  *     <li> {@link #CATEGORY_ALTERNATIVE}
    558  *     <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
    559  *     <li> {@link #CATEGORY_LAUNCHER}
    560  *     <li> {@link #CATEGORY_INFO}
    561  *     <li> {@link #CATEGORY_HOME}
    562  *     <li> {@link #CATEGORY_PREFERENCE}
    563  *     <li> {@link #CATEGORY_TEST}
    564  *     <li> {@link #CATEGORY_CAR_DOCK}
    565  *     <li> {@link #CATEGORY_DESK_DOCK}
    566  *     <li> {@link #CATEGORY_LE_DESK_DOCK}
    567  *     <li> {@link #CATEGORY_HE_DESK_DOCK}
    568  *     <li> {@link #CATEGORY_CAR_MODE}
    569  *     <li> {@link #CATEGORY_APP_MARKET}
    570  * </ul>
    571  *
    572  * <h3>Standard Extra Data</h3>
    573  *
    574  * <p>These are the current standard fields that can be used as extra data via
    575  * {@link #putExtra}.
    576  *
    577  * <ul>
    578  *     <li> {@link #EXTRA_ALARM_COUNT}
    579  *     <li> {@link #EXTRA_BCC}
    580  *     <li> {@link #EXTRA_CC}
    581  *     <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
    582  *     <li> {@link #EXTRA_DATA_REMOVED}
    583  *     <li> {@link #EXTRA_DOCK_STATE}
    584  *     <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
    585  *     <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
    586  *     <li> {@link #EXTRA_DOCK_STATE_CAR}
    587  *     <li> {@link #EXTRA_DOCK_STATE_DESK}
    588  *     <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
    589  *     <li> {@link #EXTRA_DONT_KILL_APP}
    590  *     <li> {@link #EXTRA_EMAIL}
    591  *     <li> {@link #EXTRA_INITIAL_INTENTS}
    592  *     <li> {@link #EXTRA_INTENT}
    593  *     <li> {@link #EXTRA_KEY_EVENT}
    594  *     <li> {@link #EXTRA_ORIGINATING_URI}
    595  *     <li> {@link #EXTRA_PHONE_NUMBER}
    596  *     <li> {@link #EXTRA_REFERRER}
    597  *     <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
    598  *     <li> {@link #EXTRA_REPLACING}
    599  *     <li> {@link #EXTRA_SHORTCUT_ICON}
    600  *     <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
    601  *     <li> {@link #EXTRA_SHORTCUT_INTENT}
    602  *     <li> {@link #EXTRA_STREAM}
    603  *     <li> {@link #EXTRA_SHORTCUT_NAME}
    604  *     <li> {@link #EXTRA_SUBJECT}
    605  *     <li> {@link #EXTRA_TEMPLATE}
    606  *     <li> {@link #EXTRA_TEXT}
    607  *     <li> {@link #EXTRA_TITLE}
    608  *     <li> {@link #EXTRA_UID}
    609  * </ul>
    610  *
    611  * <h3>Flags</h3>
    612  *
    613  * <p>These are the possible flags that can be used in the Intent via
    614  * {@link #setFlags} and {@link #addFlags}.  See {@link #setFlags} for a list
    615  * of all possible flags.
    616  */
    617 public class Intent implements Parcelable, Cloneable {
    618     private static final String ATTR_ACTION = "action";
    619     private static final String TAG_CATEGORIES = "categories";
    620     private static final String ATTR_CATEGORY = "category";
    621     private static final String TAG_EXTRA = "extra";
    622     private static final String ATTR_TYPE = "type";
    623     private static final String ATTR_COMPONENT = "component";
    624     private static final String ATTR_DATA = "data";
    625     private static final String ATTR_FLAGS = "flags";
    626 
    627     // ---------------------------------------------------------------------
    628     // ---------------------------------------------------------------------
    629     // Standard intent activity actions (see action variable).
    630 
    631     /**
    632      *  Activity Action: Start as a main entry point, does not expect to
    633      *  receive data.
    634      *  <p>Input: nothing
    635      *  <p>Output: nothing
    636      */
    637     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    638     public static final String ACTION_MAIN = "android.intent.action.MAIN";
    639 
    640     /**
    641      * Activity Action: Display the data to the user.  This is the most common
    642      * action performed on data -- it is the generic action you can use on
    643      * a piece of data to get the most reasonable thing to occur.  For example,
    644      * when used on a contacts entry it will view the entry; when used on a
    645      * mailto: URI it will bring up a compose window filled with the information
    646      * supplied by the URI; when used with a tel: URI it will invoke the
    647      * dialer.
    648      * <p>Input: {@link #getData} is URI from which to retrieve data.
    649      * <p>Output: nothing.
    650      */
    651     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    652     public static final String ACTION_VIEW = "android.intent.action.VIEW";
    653 
    654     /**
    655      * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
    656      * performed on a piece of data.
    657      */
    658     public static final String ACTION_DEFAULT = ACTION_VIEW;
    659 
    660     /**
    661      * Used to indicate that some piece of data should be attached to some other
    662      * place.  For example, image data could be attached to a contact.  It is up
    663      * to the recipient to decide where the data should be attached; the intent
    664      * does not specify the ultimate destination.
    665      * <p>Input: {@link #getData} is URI of data to be attached.
    666      * <p>Output: nothing.
    667      */
    668     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    669     public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
    670 
    671     /**
    672      * Activity Action: Provide explicit editable access to the given data.
    673      * <p>Input: {@link #getData} is URI of data to be edited.
    674      * <p>Output: nothing.
    675      */
    676     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    677     public static final String ACTION_EDIT = "android.intent.action.EDIT";
    678 
    679     /**
    680      * Activity Action: Pick an existing item, or insert a new item, and then edit it.
    681      * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
    682      * The extras can contain type specific data to pass through to the editing/creating
    683      * activity.
    684      * <p>Output: The URI of the item that was picked.  This must be a content:
    685      * URI so that any receiver can access it.
    686      */
    687     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    688     public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
    689 
    690     /**
    691      * Activity Action: Pick an item from the data, returning what was selected.
    692      * <p>Input: {@link #getData} is URI containing a directory of data
    693      * (vnd.android.cursor.dir/*) from which to pick an item.
    694      * <p>Output: The URI of the item that was picked.
    695      */
    696     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    697     public static final String ACTION_PICK = "android.intent.action.PICK";
    698 
    699     /**
    700      * Activity Action: Creates a shortcut.
    701      * <p>Input: Nothing.</p>
    702      * <p>Output: An Intent representing the shortcut. The intent must contain three
    703      * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
    704      * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
    705      * (value: ShortcutIconResource).</p>
    706      *
    707      * @see #EXTRA_SHORTCUT_INTENT
    708      * @see #EXTRA_SHORTCUT_NAME
    709      * @see #EXTRA_SHORTCUT_ICON
    710      * @see #EXTRA_SHORTCUT_ICON_RESOURCE
    711      * @see android.content.Intent.ShortcutIconResource
    712      */
    713     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    714     public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
    715 
    716     /**
    717      * The name of the extra used to define the Intent of a shortcut.
    718      *
    719      * @see #ACTION_CREATE_SHORTCUT
    720      */
    721     public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
    722     /**
    723      * The name of the extra used to define the name of a shortcut.
    724      *
    725      * @see #ACTION_CREATE_SHORTCUT
    726      */
    727     public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
    728     /**
    729      * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
    730      *
    731      * @see #ACTION_CREATE_SHORTCUT
    732      */
    733     public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
    734     /**
    735      * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
    736      *
    737      * @see #ACTION_CREATE_SHORTCUT
    738      * @see android.content.Intent.ShortcutIconResource
    739      */
    740     public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
    741             "android.intent.extra.shortcut.ICON_RESOURCE";
    742 
    743     /**
    744      * Represents a shortcut/live folder icon resource.
    745      *
    746      * @see Intent#ACTION_CREATE_SHORTCUT
    747      * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
    748      * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
    749      * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
    750      */
    751     public static class ShortcutIconResource implements Parcelable {
    752         /**
    753          * The package name of the application containing the icon.
    754          */
    755         public String packageName;
    756 
    757         /**
    758          * The resource name of the icon, including package, name and type.
    759          */
    760         public String resourceName;
    761 
    762         /**
    763          * Creates a new ShortcutIconResource for the specified context and resource
    764          * identifier.
    765          *
    766          * @param context The context of the application.
    767          * @param resourceId The resource identifier for the icon.
    768          * @return A new ShortcutIconResource with the specified's context package name
    769          *         and icon resource identifier.``
    770          */
    771         public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
    772             ShortcutIconResource icon = new ShortcutIconResource();
    773             icon.packageName = context.getPackageName();
    774             icon.resourceName = context.getResources().getResourceName(resourceId);
    775             return icon;
    776         }
    777 
    778         /**
    779          * Used to read a ShortcutIconResource from a Parcel.
    780          */
    781         public static final Parcelable.Creator<ShortcutIconResource> CREATOR =
    782             new Parcelable.Creator<ShortcutIconResource>() {
    783 
    784                 public ShortcutIconResource createFromParcel(Parcel source) {
    785                     ShortcutIconResource icon = new ShortcutIconResource();
    786                     icon.packageName = source.readString();
    787                     icon.resourceName = source.readString();
    788                     return icon;
    789                 }
    790 
    791                 public ShortcutIconResource[] newArray(int size) {
    792                     return new ShortcutIconResource[size];
    793                 }
    794             };
    795 
    796         /**
    797          * No special parcel contents.
    798          */
    799         public int describeContents() {
    800             return 0;
    801         }
    802 
    803         public void writeToParcel(Parcel dest, int flags) {
    804             dest.writeString(packageName);
    805             dest.writeString(resourceName);
    806         }
    807 
    808         @Override
    809         public String toString() {
    810             return resourceName;
    811         }
    812     }
    813 
    814     /**
    815      * Activity Action: Display an activity chooser, allowing the user to pick
    816      * what they want to before proceeding.  This can be used as an alternative
    817      * to the standard activity picker that is displayed by the system when
    818      * you try to start an activity with multiple possible matches, with these
    819      * differences in behavior:
    820      * <ul>
    821      * <li>You can specify the title that will appear in the activity chooser.
    822      * <li>The user does not have the option to make one of the matching
    823      * activities a preferred activity, and all possible activities will
    824      * always be shown even if one of them is currently marked as the
    825      * preferred activity.
    826      * </ul>
    827      * <p>
    828      * This action should be used when the user will naturally expect to
    829      * select an activity in order to proceed.  An example if when not to use
    830      * it is when the user clicks on a "mailto:" link.  They would naturally
    831      * expect to go directly to their mail app, so startActivity() should be
    832      * called directly: it will
    833      * either launch the current preferred app, or put up a dialog allowing the
    834      * user to pick an app to use and optionally marking that as preferred.
    835      * <p>
    836      * In contrast, if the user is selecting a menu item to send a picture
    837      * they are viewing to someone else, there are many different things they
    838      * may want to do at this point: send it through e-mail, upload it to a
    839      * web service, etc.  In this case the CHOOSER action should be used, to
    840      * always present to the user a list of the things they can do, with a
    841      * nice title given by the caller such as "Send this photo with:".
    842      * <p>
    843      * If you need to grant URI permissions through a chooser, you must specify
    844      * the permissions to be granted on the ACTION_CHOOSER Intent
    845      * <em>in addition</em> to the EXTRA_INTENT inside.  This means using
    846      * {@link #setClipData} to specify the URIs to be granted as well as
    847      * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
    848      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
    849      * <p>
    850      * As a convenience, an Intent of this form can be created with the
    851      * {@link #createChooser} function.
    852      * <p>
    853      * Input: No data should be specified.  get*Extra must have
    854      * a {@link #EXTRA_INTENT} field containing the Intent being executed,
    855      * and can optionally have a {@link #EXTRA_TITLE} field containing the
    856      * title text to display in the chooser.
    857      * <p>
    858      * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
    859      */
    860     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    861     public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
    862 
    863     /**
    864      * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
    865      *
    866      * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
    867      * target intent, also optionally supplying a title.  If the target
    868      * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
    869      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
    870      * set in the returned chooser intent, with its ClipData set appropriately:
    871      * either a direct reflection of {@link #getClipData()} if that is non-null,
    872      * or a new ClipData built from {@link #getData()}.
    873      *
    874      * @param target The Intent that the user will be selecting an activity
    875      * to perform.
    876      * @param title Optional title that will be displayed in the chooser.
    877      * @return Return a new Intent object that you can hand to
    878      * {@link Context#startActivity(Intent) Context.startActivity()} and
    879      * related methods.
    880      */
    881     public static Intent createChooser(Intent target, CharSequence title) {
    882         return createChooser(target, title, null);
    883     }
    884 
    885     /**
    886      * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
    887      *
    888      * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
    889      * target intent, also optionally supplying a title.  If the target
    890      * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
    891      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
    892      * set in the returned chooser intent, with its ClipData set appropriately:
    893      * either a direct reflection of {@link #getClipData()} if that is non-null,
    894      * or a new ClipData built from {@link #getData()}.</p>
    895      *
    896      * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
    897      * when the user makes a choice. This can be useful if the calling application wants
    898      * to remember the last chosen target and surface it as a more prominent or one-touch
    899      * affordance elsewhere in the UI for next time.</p>
    900      *
    901      * @param target The Intent that the user will be selecting an activity
    902      * to perform.
    903      * @param title Optional title that will be displayed in the chooser.
    904      * @param sender Optional IntentSender to be called when a choice is made.
    905      * @return Return a new Intent object that you can hand to
    906      * {@link Context#startActivity(Intent) Context.startActivity()} and
    907      * related methods.
    908      */
    909     public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
    910         Intent intent = new Intent(ACTION_CHOOSER);
    911         intent.putExtra(EXTRA_INTENT, target);
    912         if (title != null) {
    913             intent.putExtra(EXTRA_TITLE, title);
    914         }
    915 
    916         if (sender != null) {
    917             intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
    918         }
    919 
    920         // Migrate any clip data and flags from target.
    921         int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
    922                 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
    923                 | FLAG_GRANT_PREFIX_URI_PERMISSION);
    924         if (permFlags != 0) {
    925             ClipData targetClipData = target.getClipData();
    926             if (targetClipData == null && target.getData() != null) {
    927                 ClipData.Item item = new ClipData.Item(target.getData());
    928                 String[] mimeTypes;
    929                 if (target.getType() != null) {
    930                     mimeTypes = new String[] { target.getType() };
    931                 } else {
    932                     mimeTypes = new String[] { };
    933                 }
    934                 targetClipData = new ClipData(null, mimeTypes, item);
    935             }
    936             if (targetClipData != null) {
    937                 intent.setClipData(targetClipData);
    938                 intent.addFlags(permFlags);
    939             }
    940         }
    941 
    942         return intent;
    943     }
    944 
    945     /**
    946      * Activity Action: Allow the user to select a particular kind of data and
    947      * return it.  This is different than {@link #ACTION_PICK} in that here we
    948      * just say what kind of data is desired, not a URI of existing data from
    949      * which the user can pick.  An ACTION_GET_CONTENT could allow the user to
    950      * create the data as it runs (for example taking a picture or recording a
    951      * sound), let them browse over the web and download the desired data,
    952      * etc.
    953      * <p>
    954      * There are two main ways to use this action: if you want a specific kind
    955      * of data, such as a person contact, you set the MIME type to the kind of
    956      * data you want and launch it with {@link Context#startActivity(Intent)}.
    957      * The system will then launch the best application to select that kind
    958      * of data for you.
    959      * <p>
    960      * You may also be interested in any of a set of types of content the user
    961      * can pick.  For example, an e-mail application that wants to allow the
    962      * user to add an attachment to an e-mail message can use this action to
    963      * bring up a list of all of the types of content the user can attach.
    964      * <p>
    965      * In this case, you should wrap the GET_CONTENT intent with a chooser
    966      * (through {@link #createChooser}), which will give the proper interface
    967      * for the user to pick how to send your data and allow you to specify
    968      * a prompt indicating what they are doing.  You will usually specify a
    969      * broad MIME type (such as image/* or {@literal *}/*), resulting in a
    970      * broad range of content types the user can select from.
    971      * <p>
    972      * When using such a broad GET_CONTENT action, it is often desirable to
    973      * only pick from data that can be represented as a stream.  This is
    974      * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
    975      * <p>
    976      * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
    977      * the launched content chooser only returns results representing data that
    978      * is locally available on the device.  For example, if this extra is set
    979      * to true then an image picker should not show any pictures that are available
    980      * from a remote server but not already on the local device (thus requiring
    981      * they be downloaded when opened).
    982      * <p>
    983      * If the caller can handle multiple returned items (the user performing
    984      * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
    985      * to indicate this.
    986      * <p>
    987      * Input: {@link #getType} is the desired MIME type to retrieve.  Note
    988      * that no URI is supplied in the intent, as there are no constraints on
    989      * where the returned data originally comes from.  You may also include the
    990      * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
    991      * opened as a stream.  You may use {@link #EXTRA_LOCAL_ONLY} to limit content
    992      * selection to local data.  You may use {@link #EXTRA_ALLOW_MULTIPLE} to
    993      * allow the user to select multiple items.
    994      * <p>
    995      * Output: The URI of the item that was picked.  This must be a content:
    996      * URI so that any receiver can access it.
    997      */
    998     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    999     public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
   1000     /**
   1001      * Activity Action: Dial a number as specified by the data.  This shows a
   1002      * UI with the number being dialed, allowing the user to explicitly
   1003      * initiate the call.
   1004      * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
   1005      * is URI of a phone number to be dialed or a tel: URI of an explicit phone
   1006      * number.
   1007      * <p>Output: nothing.
   1008      */
   1009     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1010     public static final String ACTION_DIAL = "android.intent.action.DIAL";
   1011     /**
   1012      * Activity Action: Perform a call to someone specified by the data.
   1013      * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
   1014      * is URI of a phone number to be dialed or a tel: URI of an explicit phone
   1015      * number.
   1016      * <p>Output: nothing.
   1017      *
   1018      * <p>Note: there will be restrictions on which applications can initiate a
   1019      * call; most applications should use the {@link #ACTION_DIAL}.
   1020      * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
   1021      * numbers.  Applications can <strong>dial</strong> emergency numbers using
   1022      * {@link #ACTION_DIAL}, however.
   1023      *
   1024      * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
   1025      * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
   1026      * permission which is not granted, then attempting to use this action will
   1027      * result in a {@link java.lang.SecurityException}.
   1028      */
   1029     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1030     public static final String ACTION_CALL = "android.intent.action.CALL";
   1031     /**
   1032      * Activity Action: Perform a call to an emergency number specified by the
   1033      * data.
   1034      * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
   1035      * tel: URI of an explicit phone number.
   1036      * <p>Output: nothing.
   1037      * @hide
   1038      */
   1039     public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
   1040     /**
   1041      * Activity action: Perform a call to any number (emergency or not)
   1042      * specified by the data.
   1043      * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
   1044      * tel: URI of an explicit phone number.
   1045      * <p>Output: nothing.
   1046      * @hide
   1047      */
   1048     public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
   1049     /**
   1050      * Activity action: Activate the current SIM card.  If SIM cards do not require activation,
   1051      * sending this intent is a no-op.
   1052      * <p>Input: No data should be specified.  get*Extra may have an optional
   1053      * {@link #EXTRA_SIM_ACTIVATION_RESPONSE} field containing a PendingIntent through which to
   1054      * send the activation result.
   1055      * <p>Output: nothing.
   1056      * @hide
   1057      */
   1058     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1059     public static final String ACTION_SIM_ACTIVATION_REQUEST =
   1060             "android.intent.action.SIM_ACTIVATION_REQUEST";
   1061     /**
   1062      * Activity Action: Send a message to someone specified by the data.
   1063      * <p>Input: {@link #getData} is URI describing the target.
   1064      * <p>Output: nothing.
   1065      */
   1066     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1067     public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
   1068     /**
   1069      * Activity Action: Deliver some data to someone else.  Who the data is
   1070      * being delivered to is not specified; it is up to the receiver of this
   1071      * action to ask the user where the data should be sent.
   1072      * <p>
   1073      * When launching a SEND intent, you should usually wrap it in a chooser
   1074      * (through {@link #createChooser}), which will give the proper interface
   1075      * for the user to pick how to send your data and allow you to specify
   1076      * a prompt indicating what they are doing.
   1077      * <p>
   1078      * Input: {@link #getType} is the MIME type of the data being sent.
   1079      * get*Extra can have either a {@link #EXTRA_TEXT}
   1080      * or {@link #EXTRA_STREAM} field, containing the data to be sent.  If
   1081      * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
   1082      * should be the MIME type of the data in EXTRA_STREAM.  Use {@literal *}/*
   1083      * if the MIME type is unknown (this will only allow senders that can
   1084      * handle generic data streams).  If using {@link #EXTRA_TEXT}, you can
   1085      * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
   1086      * your text with HTML formatting.
   1087      * <p>
   1088      * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
   1089      * being sent can be supplied through {@link #setClipData(ClipData)}.  This
   1090      * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
   1091      * content: URIs and other advanced features of {@link ClipData}.  If
   1092      * using this approach, you still must supply the same data through the
   1093      * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
   1094      * for compatibility with old applications.  If you don't set a ClipData,
   1095      * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
   1096      * <p>
   1097      * Optional standard extras, which may be interpreted by some recipients as
   1098      * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
   1099      * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
   1100      * <p>
   1101      * Output: nothing.
   1102      */
   1103     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1104     public static final String ACTION_SEND = "android.intent.action.SEND";
   1105     /**
   1106      * Activity Action: Deliver multiple data to someone else.
   1107      * <p>
   1108      * Like {@link #ACTION_SEND}, except the data is multiple.
   1109      * <p>
   1110      * Input: {@link #getType} is the MIME type of the data being sent.
   1111      * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
   1112      * #EXTRA_STREAM} field, containing the data to be sent.  If using
   1113      * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
   1114      * for clients to retrieve your text with HTML formatting.
   1115      * <p>
   1116      * Multiple types are supported, and receivers should handle mixed types
   1117      * whenever possible. The right way for the receiver to check them is to
   1118      * use the content resolver on each URI. The intent sender should try to
   1119      * put the most concrete mime type in the intent type, but it can fall
   1120      * back to {@literal <type>/*} or {@literal *}/* as needed.
   1121      * <p>
   1122      * e.g. if you are sending image/jpg and image/jpg, the intent's type can
   1123      * be image/jpg, but if you are sending image/jpg and image/png, then the
   1124      * intent's type should be image/*.
   1125      * <p>
   1126      * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
   1127      * being sent can be supplied through {@link #setClipData(ClipData)}.  This
   1128      * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
   1129      * content: URIs and other advanced features of {@link ClipData}.  If
   1130      * using this approach, you still must supply the same data through the
   1131      * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
   1132      * for compatibility with old applications.  If you don't set a ClipData,
   1133      * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
   1134      * <p>
   1135      * Optional standard extras, which may be interpreted by some recipients as
   1136      * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
   1137      * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
   1138      * <p>
   1139      * Output: nothing.
   1140      */
   1141     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1142     public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
   1143     /**
   1144      * Activity Action: Handle an incoming phone call.
   1145      * <p>Input: nothing.
   1146      * <p>Output: nothing.
   1147      */
   1148     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1149     public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
   1150     /**
   1151      * Activity Action: Insert an empty item into the given container.
   1152      * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
   1153      * in which to place the data.
   1154      * <p>Output: URI of the new data that was created.
   1155      */
   1156     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1157     public static final String ACTION_INSERT = "android.intent.action.INSERT";
   1158     /**
   1159      * Activity Action: Create a new item in the given container, initializing it
   1160      * from the current contents of the clipboard.
   1161      * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
   1162      * in which to place the data.
   1163      * <p>Output: URI of the new data that was created.
   1164      */
   1165     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1166     public static final String ACTION_PASTE = "android.intent.action.PASTE";
   1167     /**
   1168      * Activity Action: Delete the given data from its container.
   1169      * <p>Input: {@link #getData} is URI of data to be deleted.
   1170      * <p>Output: nothing.
   1171      */
   1172     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1173     public static final String ACTION_DELETE = "android.intent.action.DELETE";
   1174     /**
   1175      * Activity Action: Run the data, whatever that means.
   1176      * <p>Input: ?  (Note: this is currently specific to the test harness.)
   1177      * <p>Output: nothing.
   1178      */
   1179     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1180     public static final String ACTION_RUN = "android.intent.action.RUN";
   1181     /**
   1182      * Activity Action: Perform a data synchronization.
   1183      * <p>Input: ?
   1184      * <p>Output: ?
   1185      */
   1186     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1187     public static final String ACTION_SYNC = "android.intent.action.SYNC";
   1188     /**
   1189      * Activity Action: Pick an activity given an intent, returning the class
   1190      * selected.
   1191      * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
   1192      * used with {@link PackageManager#queryIntentActivities} to determine the
   1193      * set of activities from which to pick.
   1194      * <p>Output: Class name of the activity that was selected.
   1195      */
   1196     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1197     public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
   1198     /**
   1199      * Activity Action: Perform a search.
   1200      * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
   1201      * is the text to search for.  If empty, simply
   1202      * enter your search results Activity with the search UI activated.
   1203      * <p>Output: nothing.
   1204      */
   1205     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1206     public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
   1207     /**
   1208      * Activity Action: Start the platform-defined tutorial
   1209      * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
   1210      * is the text to search for.  If empty, simply
   1211      * enter your search results Activity with the search UI activated.
   1212      * <p>Output: nothing.
   1213      */
   1214     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1215     public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
   1216     /**
   1217      * Activity Action: Perform a web search.
   1218      * <p>
   1219      * Input: {@link android.app.SearchManager#QUERY
   1220      * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
   1221      * a url starts with http or https, the site will be opened. If it is plain
   1222      * text, Google search will be applied.
   1223      * <p>
   1224      * Output: nothing.
   1225      */
   1226     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1227     public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
   1228 
   1229     /**
   1230      * Activity Action: Perform assist action.
   1231      * <p>
   1232      * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
   1233      * additional optional contextual information about where the user was when they
   1234      * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
   1235      * information.
   1236      * Output: nothing.
   1237      */
   1238     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1239     public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
   1240 
   1241     /**
   1242      * Activity Action: Perform voice assist action.
   1243      * <p>
   1244      * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
   1245      * additional optional contextual information about where the user was when they
   1246      * requested the voice assist.
   1247      * Output: nothing.
   1248      * @hide
   1249      */
   1250     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1251     public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
   1252 
   1253     /**
   1254      * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
   1255      * application package at the time the assist was invoked.
   1256      */
   1257     public static final String EXTRA_ASSIST_PACKAGE
   1258             = "android.intent.extra.ASSIST_PACKAGE";
   1259 
   1260     /**
   1261      * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
   1262      * application package at the time the assist was invoked.
   1263      */
   1264     public static final String EXTRA_ASSIST_UID
   1265             = "android.intent.extra.ASSIST_UID";
   1266 
   1267     /**
   1268      * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
   1269      * information supplied by the current foreground app at the time of the assist request.
   1270      * This is a {@link Bundle} of additional data.
   1271      */
   1272     public static final String EXTRA_ASSIST_CONTEXT
   1273             = "android.intent.extra.ASSIST_CONTEXT";
   1274 
   1275     /**
   1276      * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
   1277      * keyboard as the primary input device for assistance.
   1278      */
   1279     public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
   1280             "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
   1281 
   1282     /**
   1283      * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
   1284      * that was used to invoke the assist.
   1285      */
   1286     public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
   1287             "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
   1288 
   1289     /**
   1290      * Activity Action: List all available applications
   1291      * <p>Input: Nothing.
   1292      * <p>Output: nothing.
   1293      */
   1294     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1295     public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
   1296     /**
   1297      * Activity Action: Show settings for choosing wallpaper
   1298      * <p>Input: Nothing.
   1299      * <p>Output: Nothing.
   1300      */
   1301     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1302     public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
   1303 
   1304     /**
   1305      * Activity Action: Show activity for reporting a bug.
   1306      * <p>Input: Nothing.
   1307      * <p>Output: Nothing.
   1308      */
   1309     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1310     public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
   1311 
   1312     /**
   1313      *  Activity Action: Main entry point for factory tests.  Only used when
   1314      *  the device is booting in factory test node.  The implementing package
   1315      *  must be installed in the system image.
   1316      *  <p>Input: nothing
   1317      *  <p>Output: nothing
   1318      */
   1319     public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
   1320 
   1321     /**
   1322      * Activity Action: The user pressed the "call" button to go to the dialer
   1323      * or other appropriate UI for placing a call.
   1324      * <p>Input: Nothing.
   1325      * <p>Output: Nothing.
   1326      */
   1327     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1328     public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
   1329 
   1330     /**
   1331      * Activity Action: Start Voice Command.
   1332      * <p>Input: Nothing.
   1333      * <p>Output: Nothing.
   1334      */
   1335     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1336     public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
   1337 
   1338     /**
   1339      * Activity Action: Start action associated with long pressing on the
   1340      * search key.
   1341      * <p>Input: Nothing.
   1342      * <p>Output: Nothing.
   1343      */
   1344     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1345     public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
   1346 
   1347     /**
   1348      * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
   1349      * This intent is delivered to the package which installed the application, usually
   1350      * Google Play.
   1351      * <p>Input: No data is specified. The bug report is passed in using
   1352      * an {@link #EXTRA_BUG_REPORT} field.
   1353      * <p>Output: Nothing.
   1354      *
   1355      * @see #EXTRA_BUG_REPORT
   1356      */
   1357     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1358     public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
   1359 
   1360     /**
   1361      * Activity Action: Show power usage information to the user.
   1362      * <p>Input: Nothing.
   1363      * <p>Output: Nothing.
   1364      */
   1365     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1366     public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
   1367 
   1368     /**
   1369      * Activity Action: Setup wizard to launch after a platform update.  This
   1370      * activity should have a string meta-data field associated with it,
   1371      * {@link #METADATA_SETUP_VERSION}, which defines the current version of
   1372      * the platform for setup.  The activity will be launched only if
   1373      * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
   1374      * same value.
   1375      * <p>Input: Nothing.
   1376      * <p>Output: Nothing.
   1377      * @hide
   1378      */
   1379     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1380     public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
   1381 
   1382     /**
   1383      * Activity Action: Show settings for managing network data usage of a
   1384      * specific application. Applications should define an activity that offers
   1385      * options to control data usage.
   1386      */
   1387     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1388     public static final String ACTION_MANAGE_NETWORK_USAGE =
   1389             "android.intent.action.MANAGE_NETWORK_USAGE";
   1390 
   1391     /**
   1392      * Activity Action: Launch application installer.
   1393      * <p>
   1394      * Input: The data must be a content: or file: URI at which the application
   1395      * can be retrieved.  As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
   1396      * you can also use "package:<package-name>" to install an application for the
   1397      * current user that is already installed for another user. You can optionally supply
   1398      * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
   1399      * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
   1400      * <p>
   1401      * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
   1402      * succeeded.
   1403      * <p>
   1404      * <strong>Note:</strong>If your app is targeting API level higher than 22 you
   1405      * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
   1406      * in order to launch the application installer.
   1407      * </p>
   1408      *
   1409      * @see #EXTRA_INSTALLER_PACKAGE_NAME
   1410      * @see #EXTRA_NOT_UNKNOWN_SOURCE
   1411      * @see #EXTRA_RETURN_RESULT
   1412      */
   1413     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1414     public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
   1415 
   1416     /**
   1417      * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
   1418      * package.  Specifies the installer package name; this package will receive the
   1419      * {@link #ACTION_APP_ERROR} intent.
   1420      */
   1421     public static final String EXTRA_INSTALLER_PACKAGE_NAME
   1422             = "android.intent.extra.INSTALLER_PACKAGE_NAME";
   1423 
   1424     /**
   1425      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
   1426      * package.  Specifies that the application being installed should not be
   1427      * treated as coming from an unknown source, but as coming from the app
   1428      * invoking the Intent.  For this to work you must start the installer with
   1429      * startActivityForResult().
   1430      */
   1431     public static final String EXTRA_NOT_UNKNOWN_SOURCE
   1432             = "android.intent.extra.NOT_UNKNOWN_SOURCE";
   1433 
   1434     /**
   1435      * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
   1436      * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
   1437      * data field originated from.
   1438      */
   1439     public static final String EXTRA_ORIGINATING_URI
   1440             = "android.intent.extra.ORIGINATING_URI";
   1441 
   1442     /**
   1443      * This extra can be used with any Intent used to launch an activity, supplying information
   1444      * about who is launching that activity.  This field contains a {@link android.net.Uri}
   1445      * object, typically an http: or https: URI of the web site that the referral came from;
   1446      * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
   1447      * a native application that it came from.
   1448      *
   1449      * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
   1450      * instead of directly retrieving the extra.  It is also valid for applications to
   1451      * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
   1452      * a string, not a Uri; the field here, if supplied, will always take precedence,
   1453      * however.</p>
   1454      *
   1455      * @see #EXTRA_REFERRER_NAME
   1456      */
   1457     public static final String EXTRA_REFERRER
   1458             = "android.intent.extra.REFERRER";
   1459 
   1460     /**
   1461      * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
   1462      * than a {@link android.net.Uri} object.  Only for use in cases where Uri objects can
   1463      * not be created, in particular when Intent extras are supplied through the
   1464      * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
   1465      * schemes.
   1466      *
   1467      * @see #EXTRA_REFERRER
   1468      */
   1469     public static final String EXTRA_REFERRER_NAME
   1470             = "android.intent.extra.REFERRER_NAME";
   1471 
   1472     /**
   1473      * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
   1474      * {@link} #ACTION_VIEW} to indicate the uid of the package that initiated the install
   1475      * @hide
   1476      */
   1477     public static final String EXTRA_ORIGINATING_UID
   1478             = "android.intent.extra.ORIGINATING_UID";
   1479 
   1480     /**
   1481      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
   1482      * package.  Tells the installer UI to skip the confirmation with the user
   1483      * if the .apk is replacing an existing one.
   1484      * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
   1485      * will no longer show an interstitial message about updating existing
   1486      * applications so this is no longer needed.
   1487      */
   1488     @Deprecated
   1489     public static final String EXTRA_ALLOW_REPLACE
   1490             = "android.intent.extra.ALLOW_REPLACE";
   1491 
   1492     /**
   1493      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
   1494      * {@link #ACTION_UNINSTALL_PACKAGE}.  Specifies that the installer UI should
   1495      * return to the application the result code of the install/uninstall.  The returned result
   1496      * code will be {@link android.app.Activity#RESULT_OK} on success or
   1497      * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
   1498      */
   1499     public static final String EXTRA_RETURN_RESULT
   1500             = "android.intent.extra.RETURN_RESULT";
   1501 
   1502     /**
   1503      * Package manager install result code.  @hide because result codes are not
   1504      * yet ready to be exposed.
   1505      */
   1506     public static final String EXTRA_INSTALL_RESULT
   1507             = "android.intent.extra.INSTALL_RESULT";
   1508 
   1509     /**
   1510      * Activity Action: Launch application uninstaller.
   1511      * <p>
   1512      * Input: The data must be a package: URI whose scheme specific part is
   1513      * the package name of the current installed package to be uninstalled.
   1514      * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
   1515      * <p>
   1516      * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
   1517      * succeeded.
   1518      */
   1519     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1520     public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
   1521 
   1522     /**
   1523      * Specify whether the package should be uninstalled for all users.
   1524      * @hide because these should not be part of normal application flow.
   1525      */
   1526     public static final String EXTRA_UNINSTALL_ALL_USERS
   1527             = "android.intent.extra.UNINSTALL_ALL_USERS";
   1528 
   1529     /**
   1530      * A string associated with a {@link #ACTION_UPGRADE_SETUP} activity
   1531      * describing the last run version of the platform that was setup.
   1532      * @hide
   1533      */
   1534     public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
   1535 
   1536     /**
   1537      * Activity action: Launch UI to manage the permissions of an app.
   1538      * <p>
   1539      * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
   1540      * will be managed by the launched UI.
   1541      * </p>
   1542      * <p>
   1543      * Output: Nothing.
   1544      * </p>
   1545      *
   1546      * @see #EXTRA_PACKAGE_NAME
   1547      *
   1548      * @hide
   1549      */
   1550     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1551     public static final String ACTION_MANAGE_APP_PERMISSIONS =
   1552             "android.intent.action.MANAGE_APP_PERMISSIONS";
   1553 
   1554     /**
   1555      * Activity action: Launch UI to manage permissions.
   1556      * <p>
   1557      * Input: Nothing.
   1558      * </p>
   1559      * <p>
   1560      * Output: Nothing.
   1561      * </p>
   1562      *
   1563      * @hide
   1564      */
   1565     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1566     public static final String ACTION_MANAGE_PERMISSIONS =
   1567             "android.intent.action.MANAGE_PERMISSIONS";
   1568 
   1569     /**
   1570      * Intent extra: An app package name.
   1571      * <p>
   1572      * Type: String
   1573      * </p>
   1574      *
   1575      * @hide
   1576      */
   1577     @SystemApi
   1578     public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
   1579 
   1580     /**
   1581      * Broadcast action that requests current permission granted information.  It will respond
   1582      * to the request by sending a broadcast with action defined by
   1583      * {@link #EXTRA_GET_PERMISSIONS_RESPONSE_INTENT}. The response will contain
   1584      * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}, as well as
   1585      * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}, with contents described below or
   1586      * a null upon failure.
   1587      *
   1588      * <p>If {@link #EXTRA_PACKAGE_NAME} is included then the number of permissions granted, the
   1589      * number of permissions requested and the number of granted additional permissions
   1590      * by that package will be calculated and included as the first
   1591      * and second elements respectively of an int[] in the response as
   1592      * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.  The response will also deliver the list
   1593      * of localized permission group names that are granted in
   1594      * {@link #EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT}.
   1595      *
   1596      * <p>If {@link #EXTRA_PACKAGE_NAME} is not included then the number of apps granted any runtime
   1597      * permissions and the total number of apps requesting runtime permissions will be the first
   1598      * and second elements respectively of an int[] in the response as
   1599      * {@link #EXTRA_GET_PERMISSIONS_COUNT_RESULT}.
   1600      *
   1601      * @hide
   1602      */
   1603     public static final String ACTION_GET_PERMISSIONS_COUNT
   1604             = "android.intent.action.GET_PERMISSIONS_COUNT";
   1605 
   1606     /**
   1607      * Extra included in response to {@link #ACTION_GET_PERMISSIONS_COUNT}.
   1608      * @hide
   1609      */
   1610     public static final String EXTRA_GET_PERMISSIONS_COUNT_RESULT
   1611             = "android.intent.extra.GET_PERMISSIONS_COUNT_RESULT";
   1612 
   1613     /**
   1614      * List of CharSequence of localized permission group labels.
   1615      * @hide
   1616      */
   1617     public static final String EXTRA_GET_PERMISSIONS_GROUP_LIST_RESULT
   1618             = "android.intent.extra.GET_PERMISSIONS_GROUP_LIST_RESULT";
   1619 
   1620     /**
   1621      * Required extra to be sent with {@link #ACTION_GET_PERMISSIONS_COUNT} broadcasts.
   1622      * @hide
   1623      */
   1624     public static final String EXTRA_GET_PERMISSIONS_RESPONSE_INTENT
   1625             = "android.intent.extra.GET_PERMISSIONS_RESONSE_INTENT";
   1626 
   1627     /**
   1628      * Activity action: Launch UI to manage which apps have a given permission.
   1629      * <p>
   1630      * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission access
   1631      * to which will be managed by the launched UI.
   1632      * </p>
   1633      * <p>
   1634      * Output: Nothing.
   1635      * </p>
   1636      *
   1637      * @see #EXTRA_PERMISSION_NAME
   1638      *
   1639      * @hide
   1640      */
   1641     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   1642     public static final String ACTION_MANAGE_PERMISSION_APPS =
   1643             "android.intent.action.MANAGE_PERMISSION_APPS";
   1644 
   1645     /**
   1646      * Intent extra: The name of a permission.
   1647      * <p>
   1648      * Type: String
   1649      * </p>
   1650      *
   1651      * @hide
   1652      */
   1653     @SystemApi
   1654     public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
   1655 
   1656     // ---------------------------------------------------------------------
   1657     // ---------------------------------------------------------------------
   1658     // Standard intent broadcast actions (see action variable).
   1659 
   1660     /**
   1661      * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
   1662      * <p>
   1663      * For historical reasons, the name of this broadcast action refers to the power
   1664      * state of the screen but it is actually sent in response to changes in the
   1665      * overall interactive state of the device.
   1666      * </p><p>
   1667      * This broadcast is sent when the device becomes non-interactive which may have
   1668      * nothing to do with the screen turning off.  To determine the
   1669      * actual state of the screen, use {@link android.view.Display#getState}.
   1670      * </p><p>
   1671      * See {@link android.os.PowerManager#isInteractive} for details.
   1672      * </p>
   1673      * You <em>cannot</em> receive this through components declared in
   1674      * manifests, only by explicitly registering for it with
   1675      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
   1676      * Context.registerReceiver()}.
   1677      *
   1678      * <p class="note">This is a protected intent that can only be sent
   1679      * by the system.
   1680      */
   1681     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1682     public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
   1683 
   1684     /**
   1685      * Broadcast Action: Sent when the device wakes up and becomes interactive.
   1686      * <p>
   1687      * For historical reasons, the name of this broadcast action refers to the power
   1688      * state of the screen but it is actually sent in response to changes in the
   1689      * overall interactive state of the device.
   1690      * </p><p>
   1691      * This broadcast is sent when the device becomes interactive which may have
   1692      * nothing to do with the screen turning on.  To determine the
   1693      * actual state of the screen, use {@link android.view.Display#getState}.
   1694      * </p><p>
   1695      * See {@link android.os.PowerManager#isInteractive} for details.
   1696      * </p>
   1697      * You <em>cannot</em> receive this through components declared in
   1698      * manifests, only by explicitly registering for it with
   1699      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
   1700      * Context.registerReceiver()}.
   1701      *
   1702      * <p class="note">This is a protected intent that can only be sent
   1703      * by the system.
   1704      */
   1705     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1706     public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
   1707 
   1708     /**
   1709      * Broadcast Action: Sent after the system stops dreaming.
   1710      *
   1711      * <p class="note">This is a protected intent that can only be sent by the system.
   1712      * It is only sent to registered receivers.</p>
   1713      */
   1714     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1715     public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
   1716 
   1717     /**
   1718      * Broadcast Action: Sent after the system starts dreaming.
   1719      *
   1720      * <p class="note">This is a protected intent that can only be sent by the system.
   1721      * It is only sent to registered receivers.</p>
   1722      */
   1723     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1724     public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
   1725 
   1726     /**
   1727      * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
   1728      * keyguard is gone).
   1729      *
   1730      * <p class="note">This is a protected intent that can only be sent
   1731      * by the system.
   1732      */
   1733     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1734     public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
   1735 
   1736     /**
   1737      * Broadcast Action: The current time has changed.  Sent every
   1738      * minute.  You <em>cannot</em> receive this through components declared
   1739      * in manifests, only by explicitly registering for it with
   1740      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
   1741      * Context.registerReceiver()}.
   1742      *
   1743      * <p class="note">This is a protected intent that can only be sent
   1744      * by the system.
   1745      */
   1746     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1747     public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
   1748     /**
   1749      * Broadcast Action: The time was set.
   1750      */
   1751     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1752     public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
   1753     /**
   1754      * Broadcast Action: The date has changed.
   1755      */
   1756     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1757     public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
   1758     /**
   1759      * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
   1760      * <ul>
   1761      *   <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
   1762      * </ul>
   1763      *
   1764      * <p class="note">This is a protected intent that can only be sent
   1765      * by the system.
   1766      */
   1767     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1768     public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
   1769     /**
   1770      * Clear DNS Cache Action: This is broadcast when networks have changed and old
   1771      * DNS entries should be tossed.
   1772      * @hide
   1773      */
   1774     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1775     public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
   1776     /**
   1777      * Alarm Changed Action: This is broadcast when the AlarmClock
   1778      * application's alarm is set or unset.  It is used by the
   1779      * AlarmClock application and the StatusBar service.
   1780      * @hide
   1781      */
   1782     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1783     public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
   1784     /**
   1785      * Broadcast Action: This is broadcast once, after the system has finished
   1786      * booting.  It can be used to perform application-specific initialization,
   1787      * such as installing alarms.  You must hold the
   1788      * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission
   1789      * in order to receive this broadcast.
   1790      *
   1791      * <p class="note">This is a protected intent that can only be sent
   1792      * by the system.
   1793      */
   1794     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1795     public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
   1796     /**
   1797      * Broadcast Action: This is broadcast when a user action should request a
   1798      * temporary system dialog to dismiss.  Some examples of temporary system
   1799      * dialogs are the notification window-shade and the recent tasks dialog.
   1800      */
   1801     public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
   1802     /**
   1803      * Broadcast Action: Trigger the download and eventual installation
   1804      * of a package.
   1805      * <p>Input: {@link #getData} is the URI of the package file to download.
   1806      *
   1807      * <p class="note">This is a protected intent that can only be sent
   1808      * by the system.
   1809      *
   1810      * @deprecated This constant has never been used.
   1811      */
   1812     @Deprecated
   1813     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1814     public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
   1815     /**
   1816      * Broadcast Action: A new application package has been installed on the
   1817      * device. The data contains the name of the package.  Note that the
   1818      * newly installed package does <em>not</em> receive this broadcast.
   1819      * <p>May include the following extras:
   1820      * <ul>
   1821      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
   1822      * <li> {@link #EXTRA_REPLACING} is set to true if this is following
   1823      * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
   1824      * </ul>
   1825      *
   1826      * <p class="note">This is a protected intent that can only be sent
   1827      * by the system.
   1828      */
   1829     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1830     public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
   1831     /**
   1832      * Broadcast Action: A new version of an application package has been
   1833      * installed, replacing an existing version that was previously installed.
   1834      * The data contains the name of the package.
   1835      * <p>May include the following extras:
   1836      * <ul>
   1837      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
   1838      * </ul>
   1839      *
   1840      * <p class="note">This is a protected intent that can only be sent
   1841      * by the system.
   1842      */
   1843     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1844     public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
   1845     /**
   1846      * Broadcast Action: A new version of your application has been installed
   1847      * over an existing one.  This is only sent to the application that was
   1848      * replaced.  It does not contain any additional data; to receive it, just
   1849      * use an intent filter for this action.
   1850      *
   1851      * <p class="note">This is a protected intent that can only be sent
   1852      * by the system.
   1853      */
   1854     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1855     public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
   1856     /**
   1857      * Broadcast Action: An existing application package has been removed from
   1858      * the device.  The data contains the name of the package.  The package
   1859      * that is being installed does <em>not</em> receive this Intent.
   1860      * <ul>
   1861      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
   1862      * to the package.
   1863      * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
   1864      * application -- data and code -- is being removed.
   1865      * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
   1866      * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
   1867      * </ul>
   1868      *
   1869      * <p class="note">This is a protected intent that can only be sent
   1870      * by the system.
   1871      */
   1872     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1873     public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
   1874     /**
   1875      * Broadcast Action: An existing application package has been completely
   1876      * removed from the device.  The data contains the name of the package.
   1877      * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
   1878      * {@link #EXTRA_DATA_REMOVED} is true and
   1879      * {@link #EXTRA_REPLACING} is false of that broadcast.
   1880      *
   1881      * <ul>
   1882      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
   1883      * to the package.
   1884      * </ul>
   1885      *
   1886      * <p class="note">This is a protected intent that can only be sent
   1887      * by the system.
   1888      */
   1889     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1890     public static final String ACTION_PACKAGE_FULLY_REMOVED
   1891             = "android.intent.action.PACKAGE_FULLY_REMOVED";
   1892     /**
   1893      * Broadcast Action: An existing application package has been changed (e.g.
   1894      * a component has been enabled or disabled).  The data contains the name of
   1895      * the package.
   1896      * <ul>
   1897      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
   1898      * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
   1899      * of the changed components (or the package name itself).
   1900      * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
   1901      * default action of restarting the application.
   1902      * </ul>
   1903      *
   1904      * <p class="note">This is a protected intent that can only be sent
   1905      * by the system.
   1906      */
   1907     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1908     public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
   1909     /**
   1910      * @hide
   1911      * Broadcast Action: Ask system services if there is any reason to
   1912      * restart the given package.  The data contains the name of the
   1913      * package.
   1914      * <ul>
   1915      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
   1916      * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
   1917      * </ul>
   1918      *
   1919      * <p class="note">This is a protected intent that can only be sent
   1920      * by the system.
   1921      */
   1922     @SystemApi
   1923     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1924     public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
   1925     /**
   1926      * Broadcast Action: The user has restarted a package, and all of its
   1927      * processes have been killed.  All runtime state
   1928      * associated with it (processes, alarms, notifications, etc) should
   1929      * be removed.  Note that the restarted package does <em>not</em>
   1930      * receive this broadcast.
   1931      * The data contains the name of the package.
   1932      * <ul>
   1933      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
   1934      * </ul>
   1935      *
   1936      * <p class="note">This is a protected intent that can only be sent
   1937      * by the system.
   1938      */
   1939     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1940     public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
   1941     /**
   1942      * Broadcast Action: The user has cleared the data of a package.  This should
   1943      * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
   1944      * its persistent data is erased and this broadcast sent.
   1945      * Note that the cleared package does <em>not</em>
   1946      * receive this broadcast. The data contains the name of the package.
   1947      * <ul>
   1948      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
   1949      * </ul>
   1950      *
   1951      * <p class="note">This is a protected intent that can only be sent
   1952      * by the system.
   1953      */
   1954     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1955     public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
   1956     /**
   1957      * Broadcast Action: A user ID has been removed from the system.  The user
   1958      * ID number is stored in the extra data under {@link #EXTRA_UID}.
   1959      *
   1960      * <p class="note">This is a protected intent that can only be sent
   1961      * by the system.
   1962      */
   1963     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1964     public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
   1965 
   1966     /**
   1967      * Broadcast Action: Sent to the installer package of an application
   1968      * when that application is first launched (that is the first time it
   1969      * is moved out of the stopped state).  The data contains the name of the package.
   1970      *
   1971      * <p class="note">This is a protected intent that can only be sent
   1972      * by the system.
   1973      */
   1974     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1975     public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
   1976 
   1977     /**
   1978      * Broadcast Action: Sent to the system package verifier when a package
   1979      * needs to be verified. The data contains the package URI.
   1980      * <p class="note">
   1981      * This is a protected intent that can only be sent by the system.
   1982      * </p>
   1983      */
   1984     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1985     public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
   1986 
   1987     /**
   1988      * Broadcast Action: Sent to the system package verifier when a package is
   1989      * verified. The data contains the package URI.
   1990      * <p class="note">
   1991      * This is a protected intent that can only be sent by the system.
   1992      */
   1993     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   1994     public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
   1995 
   1996     /**
   1997      * Broadcast Action: Sent to the system intent filter verifier when an intent filter
   1998      * needs to be verified. The data contains the filter data hosts to be verified against.
   1999      * <p class="note">
   2000      * This is a protected intent that can only be sent by the system.
   2001      * </p>
   2002      *
   2003      * @hide
   2004      */
   2005     @SystemApi
   2006     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2007     public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
   2008 
   2009     /**
   2010      * Broadcast Action: Resources for a set of packages (which were
   2011      * previously unavailable) are currently
   2012      * available since the media on which they exist is available.
   2013      * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
   2014      * list of packages whose availability changed.
   2015      * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
   2016      * list of uids of packages whose availability changed.
   2017      * Note that the
   2018      * packages in this list do <em>not</em> receive this broadcast.
   2019      * The specified set of packages are now available on the system.
   2020      * <p>Includes the following extras:
   2021      * <ul>
   2022      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
   2023      * whose resources(were previously unavailable) are currently available.
   2024      * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
   2025      * packages whose resources(were previously unavailable)
   2026      * are  currently available.
   2027      * </ul>
   2028      *
   2029      * <p class="note">This is a protected intent that can only be sent
   2030      * by the system.
   2031      */
   2032     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2033     public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
   2034         "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
   2035 
   2036     /**
   2037      * Broadcast Action: Resources for a set of packages are currently
   2038      * unavailable since the media on which they exist is unavailable.
   2039      * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
   2040      * list of packages whose availability changed.
   2041      * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
   2042      * list of uids of packages whose availability changed.
   2043      * The specified set of packages can no longer be
   2044      * launched and are practically unavailable on the system.
   2045      * <p>Inclues the following extras:
   2046      * <ul>
   2047      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
   2048      * whose resources are no longer available.
   2049      * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
   2050      * whose resources are no longer available.
   2051      * </ul>
   2052      *
   2053      * <p class="note">This is a protected intent that can only be sent
   2054      * by the system.
   2055      */
   2056     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2057     public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
   2058         "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
   2059 
   2060     /**
   2061      * Broadcast Action:  The current system wallpaper has changed.  See
   2062      * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
   2063      * This should <em>only</em> be used to determine when the wallpaper
   2064      * has changed to show the new wallpaper to the user.  You should certainly
   2065      * never, in response to this, change the wallpaper or other attributes of
   2066      * it such as the suggested size.  That would be crazy, right?  You'd cause
   2067      * all kinds of loops, especially if other apps are doing similar things,
   2068      * right?  Of course.  So please don't do this.
   2069      *
   2070      * @deprecated Modern applications should use
   2071      * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
   2072      * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
   2073      * shown behind their UI, rather than watching for this broadcast and
   2074      * rendering the wallpaper on their own.
   2075      */
   2076     @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2077     public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
   2078     /**
   2079      * Broadcast Action: The current device {@link android.content.res.Configuration}
   2080      * (orientation, locale, etc) has changed.  When such a change happens, the
   2081      * UIs (view hierarchy) will need to be rebuilt based on this new
   2082      * information; for the most part, applications don't need to worry about
   2083      * this, because the system will take care of stopping and restarting the
   2084      * application to make sure it sees the new changes.  Some system code that
   2085      * can not be restarted will need to watch for this action and handle it
   2086      * appropriately.
   2087      *
   2088      * <p class="note">
   2089      * You <em>cannot</em> receive this through components declared
   2090      * in manifests, only by explicitly registering for it with
   2091      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
   2092      * Context.registerReceiver()}.
   2093      *
   2094      * <p class="note">This is a protected intent that can only be sent
   2095      * by the system.
   2096      *
   2097      * @see android.content.res.Configuration
   2098      */
   2099     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2100     public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
   2101     /**
   2102      * Broadcast Action: The current device's locale has changed.
   2103      *
   2104      * <p class="note">This is a protected intent that can only be sent
   2105      * by the system.
   2106      */
   2107     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2108     public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
   2109     /**
   2110      * Broadcast Action:  This is a <em>sticky broadcast</em> containing the
   2111      * charging state, level, and other information about the battery.
   2112      * See {@link android.os.BatteryManager} for documentation on the
   2113      * contents of the Intent.
   2114      *
   2115      * <p class="note">
   2116      * You <em>cannot</em> receive this through components declared
   2117      * in manifests, only by explicitly registering for it with
   2118      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
   2119      * Context.registerReceiver()}.  See {@link #ACTION_BATTERY_LOW},
   2120      * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
   2121      * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
   2122      * broadcasts that are sent and can be received through manifest
   2123      * receivers.
   2124      *
   2125      * <p class="note">This is a protected intent that can only be sent
   2126      * by the system.
   2127      */
   2128     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2129     public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
   2130     /**
   2131      * Broadcast Action:  Indicates low battery condition on the device.
   2132      * This broadcast corresponds to the "Low battery warning" system dialog.
   2133      *
   2134      * <p class="note">This is a protected intent that can only be sent
   2135      * by the system.
   2136      */
   2137     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2138     public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
   2139     /**
   2140      * Broadcast Action:  Indicates the battery is now okay after being low.
   2141      * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
   2142      * gone back up to an okay state.
   2143      *
   2144      * <p class="note">This is a protected intent that can only be sent
   2145      * by the system.
   2146      */
   2147     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2148     public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
   2149     /**
   2150      * Broadcast Action:  External power has been connected to the device.
   2151      * This is intended for applications that wish to register specifically to this notification.
   2152      * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
   2153      * stay active to receive this notification.  This action can be used to implement actions
   2154      * that wait until power is available to trigger.
   2155      *
   2156      * <p class="note">This is a protected intent that can only be sent
   2157      * by the system.
   2158      */
   2159     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2160     public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
   2161     /**
   2162      * Broadcast Action:  External power has been removed from the device.
   2163      * This is intended for applications that wish to register specifically to this notification.
   2164      * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
   2165      * stay active to receive this notification.  This action can be used to implement actions
   2166      * that wait until power is available to trigger.
   2167      *
   2168      * <p class="note">This is a protected intent that can only be sent
   2169      * by the system.
   2170      */
   2171     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2172     public static final String ACTION_POWER_DISCONNECTED =
   2173             "android.intent.action.ACTION_POWER_DISCONNECTED";
   2174     /**
   2175      * Broadcast Action:  Device is shutting down.
   2176      * This is broadcast when the device is being shut down (completely turned
   2177      * off, not sleeping).  Once the broadcast is complete, the final shutdown
   2178      * will proceed and all unsaved data lost.  Apps will not normally need
   2179      * to handle this, since the foreground activity will be paused as well.
   2180      *
   2181      * <p class="note">This is a protected intent that can only be sent
   2182      * by the system.
   2183      * <p>May include the following extras:
   2184      * <ul>
   2185      * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
   2186      * shutdown is only for userspace processes.  If not set, assumed to be false.
   2187      * </ul>
   2188      */
   2189     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2190     public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
   2191     /**
   2192      * Activity Action:  Start this activity to request system shutdown.
   2193      * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
   2194      * to request confirmation from the user before shutting down.
   2195      *
   2196      * <p class="note">This is a protected intent that can only be sent
   2197      * by the system.
   2198      *
   2199      * {@hide}
   2200      */
   2201     public static final String ACTION_REQUEST_SHUTDOWN = "android.intent.action.ACTION_REQUEST_SHUTDOWN";
   2202     /**
   2203      * Broadcast Action:  A sticky broadcast that indicates low memory
   2204      * condition on the device
   2205      *
   2206      * <p class="note">This is a protected intent that can only be sent
   2207      * by the system.
   2208      */
   2209     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2210     public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
   2211     /**
   2212      * Broadcast Action:  Indicates low memory condition on the device no longer exists
   2213      *
   2214      * <p class="note">This is a protected intent that can only be sent
   2215      * by the system.
   2216      */
   2217     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2218     public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
   2219     /**
   2220      * Broadcast Action:  A sticky broadcast that indicates a memory full
   2221      * condition on the device. This is intended for activities that want
   2222      * to be able to fill the data partition completely, leaving only
   2223      * enough free space to prevent system-wide SQLite failures.
   2224      *
   2225      * <p class="note">This is a protected intent that can only be sent
   2226      * by the system.
   2227      *
   2228      * {@hide}
   2229      */
   2230     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2231     public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
   2232     /**
   2233      * Broadcast Action:  Indicates memory full condition on the device
   2234      * no longer exists.
   2235      *
   2236      * <p class="note">This is a protected intent that can only be sent
   2237      * by the system.
   2238      *
   2239      * {@hide}
   2240      */
   2241     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2242     public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
   2243     /**
   2244      * Broadcast Action:  Indicates low memory condition notification acknowledged by user
   2245      * and package management should be started.
   2246      * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
   2247      * notification.
   2248      */
   2249     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2250     public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
   2251     /**
   2252      * Broadcast Action:  The device has entered USB Mass Storage mode.
   2253      * This is used mainly for the USB Settings panel.
   2254      * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
   2255      * when the SD card file system is mounted or unmounted
   2256      * @deprecated replaced by android.os.storage.StorageEventListener
   2257      */
   2258     @Deprecated
   2259     public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
   2260 
   2261     /**
   2262      * Broadcast Action:  The device has exited USB Mass Storage mode.
   2263      * This is used mainly for the USB Settings panel.
   2264      * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
   2265      * when the SD card file system is mounted or unmounted
   2266      * @deprecated replaced by android.os.storage.StorageEventListener
   2267      */
   2268     @Deprecated
   2269     public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
   2270 
   2271     /**
   2272      * Broadcast Action:  External media has been removed.
   2273      * The path to the mount point for the removed media is contained in the Intent.mData field.
   2274      */
   2275     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2276     public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
   2277 
   2278     /**
   2279      * Broadcast Action:  External media is present, but not mounted at its mount point.
   2280      * The path to the mount point for the unmounted media is contained in the Intent.mData field.
   2281      */
   2282     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2283     public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
   2284 
   2285     /**
   2286      * Broadcast Action:  External media is present, and being disk-checked
   2287      * The path to the mount point for the checking media is contained in the Intent.mData field.
   2288      */
   2289     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2290     public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
   2291 
   2292     /**
   2293      * Broadcast Action:  External media is present, but is using an incompatible fs (or is blank)
   2294      * The path to the mount point for the checking media is contained in the Intent.mData field.
   2295      */
   2296     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2297     public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
   2298 
   2299     /**
   2300      * Broadcast Action:  External media is present and mounted at its mount point.
   2301      * The path to the mount point for the mounted media is contained in the Intent.mData field.
   2302      * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
   2303      * media was mounted read only.
   2304      */
   2305     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2306     public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
   2307 
   2308     /**
   2309      * Broadcast Action:  External media is unmounted because it is being shared via USB mass storage.
   2310      * The path to the mount point for the shared media is contained in the Intent.mData field.
   2311      */
   2312     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2313     public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
   2314 
   2315     /**
   2316      * Broadcast Action:  External media is no longer being shared via USB mass storage.
   2317      * The path to the mount point for the previously shared media is contained in the Intent.mData field.
   2318      *
   2319      * @hide
   2320      */
   2321     public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
   2322 
   2323     /**
   2324      * Broadcast Action:  External media was removed from SD card slot, but mount point was not unmounted.
   2325      * The path to the mount point for the removed media is contained in the Intent.mData field.
   2326      */
   2327     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2328     public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
   2329 
   2330     /**
   2331      * Broadcast Action:  External media is present but cannot be mounted.
   2332      * The path to the mount point for the unmountable media is contained in the Intent.mData field.
   2333      */
   2334     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2335     public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
   2336 
   2337    /**
   2338      * Broadcast Action:  User has expressed the desire to remove the external storage media.
   2339      * Applications should close all files they have open within the mount point when they receive this intent.
   2340      * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
   2341      */
   2342     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2343     public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
   2344 
   2345     /**
   2346      * Broadcast Action:  The media scanner has started scanning a directory.
   2347      * The path to the directory being scanned is contained in the Intent.mData field.
   2348      */
   2349     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2350     public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
   2351 
   2352    /**
   2353      * Broadcast Action:  The media scanner has finished scanning a directory.
   2354      * The path to the scanned directory is contained in the Intent.mData field.
   2355      */
   2356     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2357     public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
   2358 
   2359    /**
   2360      * Broadcast Action:  Request the media scanner to scan a file and add it to the media database.
   2361      * The path to the file is contained in the Intent.mData field.
   2362      */
   2363     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2364     public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
   2365 
   2366    /**
   2367      * Broadcast Action:  The "Media Button" was pressed.  Includes a single
   2368      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
   2369      * caused the broadcast.
   2370      */
   2371     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2372     public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
   2373 
   2374     /**
   2375      * Broadcast Action:  The "Camera Button" was pressed.  Includes a single
   2376      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
   2377      * caused the broadcast.
   2378      */
   2379     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2380     public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
   2381 
   2382     // *** NOTE: @todo(*) The following really should go into a more domain-specific
   2383     // location; they are not general-purpose actions.
   2384 
   2385     /**
   2386      * Broadcast Action: A GTalk connection has been established.
   2387      */
   2388     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2389     public static final String ACTION_GTALK_SERVICE_CONNECTED =
   2390             "android.intent.action.GTALK_CONNECTED";
   2391 
   2392     /**
   2393      * Broadcast Action: A GTalk connection has been disconnected.
   2394      */
   2395     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2396     public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
   2397             "android.intent.action.GTALK_DISCONNECTED";
   2398 
   2399     /**
   2400      * Broadcast Action: An input method has been changed.
   2401      */
   2402     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2403     public static final String ACTION_INPUT_METHOD_CHANGED =
   2404             "android.intent.action.INPUT_METHOD_CHANGED";
   2405 
   2406     /**
   2407      * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
   2408      * more radios have been turned off or on. The intent will have the following extra value:</p>
   2409      * <ul>
   2410      *   <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
   2411      *   then cell radio and possibly other radios such as bluetooth or WiFi may have also been
   2412      *   turned off</li>
   2413      * </ul>
   2414      *
   2415      * <p class="note">This is a protected intent that can only be sent
   2416      * by the system.
   2417      */
   2418     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2419     public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
   2420 
   2421     /**
   2422      * Broadcast Action: Some content providers have parts of their namespace
   2423      * where they publish new events or items that the user may be especially
   2424      * interested in. For these things, they may broadcast this action when the
   2425      * set of interesting items change.
   2426      *
   2427      * For example, GmailProvider sends this notification when the set of unread
   2428      * mail in the inbox changes.
   2429      *
   2430      * <p>The data of the intent identifies which part of which provider
   2431      * changed. When queried through the content resolver, the data URI will
   2432      * return the data set in question.
   2433      *
   2434      * <p>The intent will have the following extra values:
   2435      * <ul>
   2436      *   <li><em>count</em> - The number of items in the data set. This is the
   2437      *       same as the number of items in the cursor returned by querying the
   2438      *       data URI. </li>
   2439      * </ul>
   2440      *
   2441      * This intent will be sent at boot (if the count is non-zero) and when the
   2442      * data set changes. It is possible for the data set to change without the
   2443      * count changing (for example, if a new unread message arrives in the same
   2444      * sync operation in which a message is archived). The phone should still
   2445      * ring/vibrate/etc as normal in this case.
   2446      */
   2447     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2448     public static final String ACTION_PROVIDER_CHANGED =
   2449             "android.intent.action.PROVIDER_CHANGED";
   2450 
   2451     /**
   2452      * Broadcast Action: Wired Headset plugged in or unplugged.
   2453      *
   2454      * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
   2455      *   and documentation.
   2456      * <p>If the minimum SDK version of your application is
   2457      * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
   2458      * to the <code>AudioManager</code> constant in your receiver registration code instead.
   2459      */
   2460     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2461     public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
   2462 
   2463     /**
   2464      * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
   2465      * <ul>
   2466      *   <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
   2467      * </ul>
   2468      *
   2469      * <p class="note">This is a protected intent that can only be sent
   2470      * by the system.
   2471      *
   2472      * @hide
   2473      */
   2474     //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2475     public static final String ACTION_ADVANCED_SETTINGS_CHANGED
   2476             = "android.intent.action.ADVANCED_SETTINGS";
   2477 
   2478     /**
   2479      *  Broadcast Action: Sent after application restrictions are changed.
   2480      *
   2481      * <p class="note">This is a protected intent that can only be sent
   2482      * by the system.</p>
   2483      */
   2484     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2485     public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
   2486             "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
   2487 
   2488     /**
   2489      * Broadcast Action: An outgoing call is about to be placed.
   2490      *
   2491      * <p>The Intent will have the following extra value:</p>
   2492      * <ul>
   2493      *   <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
   2494      *       the phone number originally intended to be dialed.</li>
   2495      * </ul>
   2496      * <p>Once the broadcast is finished, the resultData is used as the actual
   2497      * number to call.  If  <code>null</code>, no call will be placed.</p>
   2498      * <p>It is perfectly acceptable for multiple receivers to process the
   2499      * outgoing call in turn: for example, a parental control application
   2500      * might verify that the user is authorized to place the call at that
   2501      * time, then a number-rewriting application might add an area code if
   2502      * one was not specified.</p>
   2503      * <p>For consistency, any receiver whose purpose is to prohibit phone
   2504      * calls should have a priority of 0, to ensure it will see the final
   2505      * phone number to be dialed.
   2506      * Any receiver whose purpose is to rewrite phone numbers to be called
   2507      * should have a positive priority.
   2508      * Negative priorities are reserved for the system for this broadcast;
   2509      * using them may cause problems.</p>
   2510      * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
   2511      * abort the broadcast.</p>
   2512      * <p>Emergency calls cannot be intercepted using this mechanism, and
   2513      * other calls cannot be modified to call emergency numbers using this
   2514      * mechanism.
   2515      * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
   2516      * call to use their own service instead. Those apps should first prevent
   2517      * the call from being placed by setting resultData to <code>null</code>
   2518      * and then start their own app to make the call.
   2519      * <p>You must hold the
   2520      * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
   2521      * permission to receive this Intent.</p>
   2522      *
   2523      * <p class="note">This is a protected intent that can only be sent
   2524      * by the system.
   2525      */
   2526     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2527     public static final String ACTION_NEW_OUTGOING_CALL =
   2528             "android.intent.action.NEW_OUTGOING_CALL";
   2529 
   2530     /**
   2531      * Broadcast Action: Have the device reboot.  This is only for use by
   2532      * system code.
   2533      *
   2534      * <p class="note">This is a protected intent that can only be sent
   2535      * by the system.
   2536      */
   2537     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2538     public static final String ACTION_REBOOT =
   2539             "android.intent.action.REBOOT";
   2540 
   2541     /**
   2542      * Broadcast Action:  A sticky broadcast for changes in the physical
   2543      * docking state of the device.
   2544      *
   2545      * <p>The intent will have the following extra values:
   2546      * <ul>
   2547      *   <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
   2548      *       state, indicating which dock the device is physically in.</li>
   2549      * </ul>
   2550      * <p>This is intended for monitoring the current physical dock state.
   2551      * See {@link android.app.UiModeManager} for the normal API dealing with
   2552      * dock mode changes.
   2553      */
   2554     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2555     public static final String ACTION_DOCK_EVENT =
   2556             "android.intent.action.DOCK_EVENT";
   2557 
   2558     /**
   2559      * Broadcast Action: A broadcast when idle maintenance can be started.
   2560      * This means that the user is not interacting with the device and is
   2561      * not expected to do so soon. Typical use of the idle maintenance is
   2562      * to perform somehow expensive tasks that can be postponed at a moment
   2563      * when they will not degrade user experience.
   2564      * <p>
   2565      * <p class="note">In order to keep the device responsive in case of an
   2566      * unexpected user interaction, implementations of a maintenance task
   2567      * should be interruptible. In such a scenario a broadcast with action
   2568      * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
   2569      * should not do the maintenance work in
   2570      * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
   2571      * maintenance service by {@link Context#startService(Intent)}. Also
   2572      * you should hold a wake lock while your maintenance service is running
   2573      * to prevent the device going to sleep.
   2574      * </p>
   2575      * <p>
   2576      * <p class="note">This is a protected intent that can only be sent by
   2577      * the system.
   2578      * </p>
   2579      *
   2580      * @see #ACTION_IDLE_MAINTENANCE_END
   2581      *
   2582      * @hide
   2583      */
   2584     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2585     public static final String ACTION_IDLE_MAINTENANCE_START =
   2586             "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
   2587 
   2588     /**
   2589      * Broadcast Action:  A broadcast when idle maintenance should be stopped.
   2590      * This means that the user was not interacting with the device as a result
   2591      * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
   2592      * was sent and now the user started interacting with the device. Typical
   2593      * use of the idle maintenance is to perform somehow expensive tasks that
   2594      * can be postponed at a moment when they will not degrade user experience.
   2595      * <p>
   2596      * <p class="note">In order to keep the device responsive in case of an
   2597      * unexpected user interaction, implementations of a maintenance task
   2598      * should be interruptible. Hence, on receiving a broadcast with this
   2599      * action, the maintenance task should be interrupted as soon as possible.
   2600      * In other words, you should not do the maintenance work in
   2601      * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
   2602      * maintenance service that was started on receiving of
   2603      * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
   2604      * lock you acquired when your maintenance service started.
   2605      * </p>
   2606      * <p class="note">This is a protected intent that can only be sent
   2607      * by the system.
   2608      *
   2609      * @see #ACTION_IDLE_MAINTENANCE_START
   2610      *
   2611      * @hide
   2612      */
   2613     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
   2614     public static final String ACTION_IDLE_MAINTENANCE_END =
   2615             "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
   2616 
   2617     /**
   2618      * Broadcast Action: a remote intent is to be broadcasted.
   2619      *
   2620      * A remote intent is used for remote RPC between devices. The remote intent
   2621      * is serialized and sent from one device to another device. The receiving
   2622      * device parses the remote intent and broadcasts it. Note that anyone can
   2623      * broadcast a remote intent. However, if the intent receiver of the remote intent
   2624      * does not trust intent broadcasts from arbitrary intent senders, it should require
   2625      * the sender to hold certain permissions so only trusted sender's broadcast will be
   2626      * let through.
   2627      * @hide
   2628      */
   2629     public static final String ACTION_REMOTE_INTENT =
   2630             "com.google.android.c2dm.intent.RECEIVE";
   2631 
   2632     /**
   2633      * Broadcast Action: hook for permforming cleanup after a system update.
   2634      *
   2635      * The broadcast is sent when the system is booting, before the
   2636      * BOOT_COMPLETED broadcast.  It is only sent to receivers in the system
   2637      * image.  A receiver for this should do its work and then disable itself
   2638      * so that it does not get run again at the next boot.
   2639      * @hide
   2640      */
   2641     public static final String ACTION_PRE_BOOT_COMPLETED =
   2642             "android.intent.action.PRE_BOOT_COMPLETED";
   2643 
   2644     /**
   2645      * Broadcast to a specific application to query any supported restrictions to impose
   2646      * on restricted users. The broadcast intent contains an extra
   2647      * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
   2648      * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
   2649      * String[] depending on the restriction type.<p/>
   2650      * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
   2651      * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
   2652      * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
   2653      * The activity specified by that intent will be launched for a result which must contain
   2654      * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
   2655      * The keys and values of the returned restrictions will be persisted.
   2656      * @see RestrictionEntry
   2657      */
   2658     public static final String ACTION_GET_RESTRICTION_ENTRIES =
   2659             "android.intent.action.GET_RESTRICTION_ENTRIES";
   2660 
   2661     /**
   2662      * Sent the first time a user is starting, to allow system apps to
   2663      * perform one time initialization.  (This will not be seen by third
   2664      * party applications because a newly initialized user does not have any
   2665      * third party applications installed for it.)  This is sent early in
   2666      * starting the user, around the time the home app is started, before
   2667      * {@link #ACTION_BOOT_COMPLETED} is sent.  This is sent as a foreground
   2668      * broadcast, since it is part of a visible user interaction; be as quick
   2669      * as possible when handling it.
   2670      */
   2671     public static final String ACTION_USER_INITIALIZE =
   2672             "android.intent.action.USER_INITIALIZE";
   2673 
   2674     /**
   2675      * Sent when a user switch is happening, causing the process's user to be
   2676      * brought to the foreground.  This is only sent to receivers registered
   2677      * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
   2678      * Context.registerReceiver}.  It is sent to the user that is going to the
   2679      * foreground.  This is sent as a foreground
   2680      * broadcast, since it is part of a visible user interaction; be as quick
   2681      * as possible when handling it.
   2682      */
   2683     public static final String ACTION_USER_FOREGROUND =
   2684             "android.intent.action.USER_FOREGROUND";
   2685 
   2686     /**
   2687      * Sent when a user switch is happening, causing the process's user to be
   2688      * sent to the background.  This is only sent to receivers registered
   2689      * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
   2690      * Context.registerReceiver}.  It is sent to the user that is going to the
   2691      * background.  This is sent as a foreground
   2692      * broadcast, since it is part of a visible user interaction; be as quick
   2693      * as possible when handling it.
   2694      */
   2695     public static final String ACTION_USER_BACKGROUND =
   2696             "android.intent.action.USER_BACKGROUND";
   2697 
   2698     /**
   2699      * Broadcast sent to the system when a user is added. Carries an extra
   2700      * EXTRA_USER_HANDLE that has the userHandle of the new user.  It is sent to
   2701      * all running users.  You must hold
   2702      * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
   2703      * @hide
   2704      */
   2705     public static final String ACTION_USER_ADDED =
   2706             "android.intent.action.USER_ADDED";
   2707 
   2708     /**
   2709      * Broadcast sent by the system when a user is started. Carries an extra
   2710      * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only sent to
   2711      * registered receivers, not manifest receivers.  It is sent to the user
   2712      * that has been started.  This is sent as a foreground
   2713      * broadcast, since it is part of a visible user interaction; be as quick
   2714      * as possible when handling it.
   2715      * @hide
   2716      */
   2717     public static final String ACTION_USER_STARTED =
   2718             "android.intent.action.USER_STARTED";
   2719 
   2720     /**
   2721      * Broadcast sent when a user is in the process of starting.  Carries an extra
   2722      * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only
   2723      * sent to registered receivers, not manifest receivers.  It is sent to all
   2724      * users (including the one that is being started).  You must hold
   2725      * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
   2726      * this broadcast.  This is sent as a background broadcast, since
   2727      * its result is not part of the primary UX flow; to safely keep track of
   2728      * started/stopped state of a user you can use this in conjunction with
   2729      * {@link #ACTION_USER_STOPPING}.  It is <b>not</b> generally safe to use with
   2730      * other user state broadcasts since those are foreground broadcasts so can
   2731      * execute in a different order.
   2732      * @hide
   2733      */
   2734     public static final String ACTION_USER_STARTING =
   2735             "android.intent.action.USER_STARTING";
   2736 
   2737     /**
   2738      * Broadcast sent when a user is going to be stopped.  Carries an extra
   2739      * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only
   2740      * sent to registered receivers, not manifest receivers.  It is sent to all
   2741      * users (including the one that is being stopped).  You must hold
   2742      * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
   2743      * this broadcast.  The user will not stop until all receivers have
   2744      * handled the broadcast.  This is sent as a background broadcast, since
   2745      * its result is not part of the primary UX flow; to safely keep track of
   2746      * started/stopped state of a user you can use this in conjunction with
   2747      * {@link #ACTION_USER_STARTING}.  It is <b>not</b> generally safe to use with
   2748      * other user state broadcasts since those are foreground broadcasts so can
   2749      * execute in a different order.
   2750      * @hide
   2751      */
   2752     public static final String ACTION_USER_STOPPING =
   2753             "android.intent.action.USER_STOPPING";
   2754 
   2755     /**
   2756      * Broadcast sent to the system when a user is stopped. Carries an extra
   2757      * EXTRA_USER_HANDLE that has the userHandle of the user.  This is similar to
   2758      * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
   2759      * specific package.  This is only sent to registered receivers, not manifest
   2760      * receivers.  It is sent to all running users <em>except</em> the one that
   2761      * has just been stopped (which is no longer running).
   2762      * @hide
   2763      */
   2764     public static final String ACTION_USER_STOPPED =
   2765             "android.intent.action.USER_STOPPED";
   2766 
   2767     /**
   2768      * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
   2769      * the userHandle of the user.  It is sent to all running users except the
   2770      * one that has been removed. The user will not be completely removed until all receivers have
   2771      * handled the broadcast. You must hold
   2772      * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
   2773      * @hide
   2774      */
   2775     public static final String ACTION_USER_REMOVED =
   2776             "android.intent.action.USER_REMOVED";
   2777 
   2778     /**
   2779      * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
   2780      * the userHandle of the user to become the current one. This is only sent to
   2781      * registered receivers, not manifest receivers.  It is sent to all running users.
   2782      * You must hold
   2783      * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
   2784      * @hide
   2785      */
   2786     public static final String ACTION_USER_SWITCHED =
   2787             "android.intent.action.USER_SWITCHED";
   2788 
   2789     /**
   2790      * Broadcast sent to the system when a user's information changes. Carries an extra
   2791      * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
   2792      * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
   2793      * @hide
   2794      */
   2795     public static final String ACTION_USER_INFO_CHANGED =
   2796             "android.intent.action.USER_INFO_CHANGED";
   2797 
   2798     /**
   2799      * Broadcast sent to the primary user when an associated managed profile is added (the profile
   2800      * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
   2801      * the UserHandle of the profile that was added. Only applications (for example Launchers)
   2802      * that need to display merged content across both primary and managed profiles need to
   2803      * worry about this broadcast. This is only sent to registered receivers,
   2804      * not manifest receivers.
   2805      */
   2806     public static final String ACTION_MANAGED_PROFILE_ADDED =
   2807             "android.intent.action.MANAGED_PROFILE_ADDED";
   2808 
   2809     /**
   2810      * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
   2811      * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
   2812      * Only applications (for example Launchers) that need to display merged content across both
   2813      * primary and managed profiles need to worry about this broadcast. This is only sent to
   2814      * registered receivers, not manifest receivers.
   2815      */
   2816     public static final String ACTION_MANAGED_PROFILE_REMOVED =
   2817             "android.intent.action.MANAGED_PROFILE_REMOVED";
   2818 
   2819     /**
   2820      * Sent when the user taps on the clock widget in the system's "quick settings" area.
   2821      */
   2822     public static final String ACTION_QUICK_CLOCK =
   2823             "android.intent.action.QUICK_CLOCK";
   2824 
   2825     /**
   2826      * Activity Action: Shows the brightness setting dialog.
   2827      * @hide
   2828      */
   2829     public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
   2830             "android.intent.action.SHOW_BRIGHTNESS_DIALOG";
   2831 
   2832     /**
   2833      * Broadcast Action:  A global button was pressed.  Includes a single
   2834      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
   2835      * caused the broadcast.
   2836      * @hide
   2837      */
   2838     public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
   2839 
   2840     /**
   2841      * Activity Action: Allow the user to select and return one or more existing
   2842      * documents. When invoked, the system will display the various
   2843      * {@link DocumentsProvider} instances installed on the device, letting the
   2844      * user interactively navigate through them. These documents include local
   2845      * media, such as photos and video, and documents provided by installed
   2846      * cloud storage providers.
   2847      * <p>
   2848      * Each document is represented as a {@code content://} URI backed by a
   2849      * {@link DocumentsProvider}, which can be opened as a stream with
   2850      * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
   2851      * {@link android.provider.DocumentsContract.Document} metadata.
   2852      * <p>
   2853      * All selected documents are returned to the calling application with
   2854      * persistable read and write permission grants. If you want to maintain
   2855      * access to the documents across device reboots, you need to explicitly
   2856      * take the persistable permissions using
   2857      * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
   2858      * <p>
   2859      * Callers must indicate the acceptable document MIME types through
   2860      * {@link #setType(String)}. For example, to select photos, use
   2861      * {@code image/*}. If multiple disjoint MIME types are acceptable, define
   2862      * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
   2863      * {@literal *}/*.
   2864      * <p>
   2865      * If the caller can handle multiple returned items (the user performing
   2866      * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
   2867      * to indicate this.
   2868      * <p>
   2869      * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
   2870      * returned URIs can be opened with
   2871      * {@link ContentResolver#openFileDescriptor(Uri, String)}.
   2872      * <p>
   2873      * Output: The URI of the item that was picked, returned in
   2874      * {@link #getData()}. This must be a {@code content://} URI so that any
   2875      * receiver can access it. If multiple documents were selected, they are
   2876      * returned in {@link #getClipData()}.
   2877      *
   2878      * @see DocumentsContract
   2879      * @see #ACTION_OPEN_DOCUMENT_TREE
   2880      * @see #ACTION_CREATE_DOCUMENT
   2881      * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
   2882      */
   2883     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   2884     public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
   2885 
   2886     /**
   2887      * Activity Action: Allow the user to create a new document. When invoked,
   2888      * the system will display the various {@link DocumentsProvider} instances
   2889      * installed on the device, letting the user navigate through them. The
   2890      * returned document may be a newly created document with no content, or it
   2891      * may be an existing document with the requested MIME type.
   2892      * <p>
   2893      * Each document is represented as a {@code content://} URI backed by a
   2894      * {@link DocumentsProvider}, which can be opened as a stream with
   2895      * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
   2896      * {@link android.provider.DocumentsContract.Document} metadata.
   2897      * <p>
   2898      * Callers must indicate the concrete MIME type of the document being
   2899      * created by setting {@link #setType(String)}. This MIME type cannot be
   2900      * changed after the document is created.
   2901      * <p>
   2902      * Callers can provide an initial display name through {@link #EXTRA_TITLE},
   2903      * but the user may change this value before creating the file.
   2904      * <p>
   2905      * Callers must include {@link #CATEGORY_OPENABLE} in the Intent so that
   2906      * returned URIs can be opened with
   2907      * {@link ContentResolver#openFileDescriptor(Uri, String)}.
   2908      * <p>
   2909      * Output: The URI of the item that was created. This must be a
   2910      * {@code content://} URI so that any receiver can access it.
   2911      *
   2912      * @see DocumentsContract
   2913      * @see #ACTION_OPEN_DOCUMENT
   2914      * @see #ACTION_OPEN_DOCUMENT_TREE
   2915      * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
   2916      */
   2917     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   2918     public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
   2919 
   2920     /**
   2921      * Activity Action: Allow the user to pick a directory subtree. When
   2922      * invoked, the system will display the various {@link DocumentsProvider}
   2923      * instances installed on the device, letting the user navigate through
   2924      * them. Apps can fully manage documents within the returned directory.
   2925      * <p>
   2926      * To gain access to descendant (child, grandchild, etc) documents, use
   2927      * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
   2928      * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
   2929      * with the returned URI.
   2930      * <p>
   2931      * Output: The URI representing the selected directory tree.
   2932      *
   2933      * @see DocumentsContract
   2934      */
   2935     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   2936     public static final String
   2937             ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
   2938 
   2939     /** {@hide} */
   2940     public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
   2941 
   2942     /**
   2943      * Broadcast action: report that a settings element is being restored from backup.  The intent
   2944      * contains three extras: EXTRA_SETTING_NAME is a string naming the restored setting,
   2945      * EXTRA_SETTING_NEW_VALUE is the value being restored, and EXTRA_SETTING_PREVIOUS_VALUE
   2946      * is the value of that settings entry prior to the restore operation.  All of these values are
   2947      * represented as strings.
   2948      *
   2949      * <p>This broadcast is sent only for settings provider entries known to require special handling
   2950      * around restore time.  These entries are found in the BROADCAST_ON_RESTORE table within
   2951      * the provider's backup agent implementation.
   2952      *
   2953      * @see #EXTRA_SETTING_NAME
   2954      * @see #EXTRA_SETTING_PREVIOUS_VALUE
   2955      * @see #EXTRA_SETTING_NEW_VALUE
   2956      * {@hide}
   2957      */
   2958     public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
   2959 
   2960     /** {@hide} */
   2961     public static final String EXTRA_SETTING_NAME = "setting_name";
   2962     /** {@hide} */
   2963     public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
   2964     /** {@hide} */
   2965     public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
   2966 
   2967     /**
   2968      * Activity Action: Process a piece of text.
   2969      * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
   2970      * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
   2971      * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
   2972      */
   2973     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
   2974     public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
   2975     /**
   2976      * The name of the extra used to define the text to be processed, as a
   2977      * CharSequence. Note that this may be a styled CharSequence, so you must use
   2978      * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
   2979      */
   2980     public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
   2981     /**
   2982      * The name of the boolean extra used to define if the processed text will be used as read-only.
   2983      */
   2984     public static final String EXTRA_PROCESS_TEXT_READONLY =
   2985             "android.intent.extra.PROCESS_TEXT_READONLY";
   2986 
   2987     // ---------------------------------------------------------------------
   2988     // ---------------------------------------------------------------------
   2989     // Standard intent categories (see addCategory()).
   2990 
   2991     /**
   2992      * Set if the activity should be an option for the default action
   2993      * (center press) to perform on a piece of data.  Setting this will
   2994      * hide from the user any activities without it set when performing an
   2995      * action on some data.  Note that this is normally -not- set in the
   2996      * Intent when initiating an action -- it is for use in intent filters
   2997      * specified in packages.
   2998      */
   2999     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3000     public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
   3001     /**
   3002      * Activities that can be safely invoked from a browser must support this
   3003      * category.  For example, if the user is viewing a web page or an e-mail
   3004      * and clicks on a link in the text, the Intent generated execute that
   3005      * link will require the BROWSABLE category, so that only activities
   3006      * supporting this category will be considered as possible actions.  By
   3007      * supporting this category, you are promising that there is nothing
   3008      * damaging (without user intervention) that can happen by invoking any
   3009      * matching Intent.
   3010      */
   3011     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3012     public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
   3013     /**
   3014      * Categories for activities that can participate in voice interaction.
   3015      * An activity that supports this category must be prepared to run with
   3016      * no UI shown at all (though in some case it may have a UI shown), and
   3017      * rely on {@link android.app.VoiceInteractor} to interact with the user.
   3018      */
   3019     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3020     public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
   3021     /**
   3022      * Set if the activity should be considered as an alternative action to
   3023      * the data the user is currently viewing.  See also
   3024      * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
   3025      * applies to the selection in a list of items.
   3026      *
   3027      * <p>Supporting this category means that you would like your activity to be
   3028      * displayed in the set of alternative things the user can do, usually as
   3029      * part of the current activity's options menu.  You will usually want to
   3030      * include a specific label in the &lt;intent-filter&gt; of this action
   3031      * describing to the user what it does.
   3032      *
   3033      * <p>The action of IntentFilter with this category is important in that it
   3034      * describes the specific action the target will perform.  This generally
   3035      * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
   3036      * a specific name such as "com.android.camera.action.CROP.  Only one
   3037      * alternative of any particular action will be shown to the user, so using
   3038      * a specific action like this makes sure that your alternative will be
   3039      * displayed while also allowing other applications to provide their own
   3040      * overrides of that particular action.
   3041      */
   3042     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3043     public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
   3044     /**
   3045      * Set if the activity should be considered as an alternative selection
   3046      * action to the data the user has currently selected.  This is like
   3047      * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
   3048      * of items from which the user can select, giving them alternatives to the
   3049      * default action that will be performed on it.
   3050      */
   3051     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3052     public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
   3053     /**
   3054      * Intended to be used as a tab inside of a containing TabActivity.
   3055      */
   3056     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3057     public static final String CATEGORY_TAB = "android.intent.category.TAB";
   3058     /**
   3059      * Should be displayed in the top-level launcher.
   3060      */
   3061     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3062     public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
   3063     /**
   3064      * Indicates an activity optimized for Leanback mode, and that should
   3065      * be displayed in the Leanback launcher.
   3066      */
   3067     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3068     public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
   3069     /**
   3070      * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
   3071      * @hide
   3072      */
   3073     @SystemApi
   3074     public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
   3075     /**
   3076      * Provides information about the package it is in; typically used if
   3077      * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
   3078      * a front-door to the user without having to be shown in the all apps list.
   3079      */
   3080     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3081     public static final String CATEGORY_INFO = "android.intent.category.INFO";
   3082     /**
   3083      * This is the home activity, that is the first activity that is displayed
   3084      * when the device boots.
   3085      */
   3086     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3087     public static final String CATEGORY_HOME = "android.intent.category.HOME";
   3088     /**
   3089      * This is the setup wizard activity, that is the first activity that is displayed
   3090      * when the user sets up the device for the first time.
   3091      * @hide
   3092      */
   3093     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3094     public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
   3095     /**
   3096      * This activity is a preference panel.
   3097      */
   3098     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3099     public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
   3100     /**
   3101      * This activity is a development preference panel.
   3102      */
   3103     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3104     public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
   3105     /**
   3106      * Capable of running inside a parent activity container.
   3107      */
   3108     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3109     public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
   3110     /**
   3111      * This activity allows the user to browse and download new applications.
   3112      */
   3113     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3114     public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
   3115     /**
   3116      * This activity may be exercised by the monkey or other automated test tools.
   3117      */
   3118     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3119     public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
   3120     /**
   3121      * To be used as a test (not part of the normal user experience).
   3122      */
   3123     public static final String CATEGORY_TEST = "android.intent.category.TEST";
   3124     /**
   3125      * To be used as a unit test (run through the Test Harness).
   3126      */
   3127     public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
   3128     /**
   3129      * To be used as a sample code example (not part of the normal user
   3130      * experience).
   3131      */
   3132     public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
   3133 
   3134     /**
   3135      * Used to indicate that an intent only wants URIs that can be opened with
   3136      * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
   3137      * must support at least the columns defined in {@link OpenableColumns} when
   3138      * queried.
   3139      *
   3140      * @see #ACTION_GET_CONTENT
   3141      * @see #ACTION_OPEN_DOCUMENT
   3142      * @see #ACTION_CREATE_DOCUMENT
   3143      */
   3144     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3145     public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
   3146 
   3147     /**
   3148      * To be used as code under test for framework instrumentation tests.
   3149      */
   3150     public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
   3151             "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
   3152     /**
   3153      * An activity to run when device is inserted into a car dock.
   3154      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
   3155      * information, see {@link android.app.UiModeManager}.
   3156      */
   3157     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3158     public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
   3159     /**
   3160      * An activity to run when device is inserted into a car dock.
   3161      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
   3162      * information, see {@link android.app.UiModeManager}.
   3163      */
   3164     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3165     public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
   3166     /**
   3167      * An activity to run when device is inserted into a analog (low end) dock.
   3168      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
   3169      * information, see {@link android.app.UiModeManager}.
   3170      */
   3171     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3172     public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
   3173 
   3174     /**
   3175      * An activity to run when device is inserted into a digital (high end) dock.
   3176      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
   3177      * information, see {@link android.app.UiModeManager}.
   3178      */
   3179     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3180     public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
   3181 
   3182     /**
   3183      * Used to indicate that the activity can be used in a car environment.
   3184      */
   3185     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3186     public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
   3187 
   3188     // ---------------------------------------------------------------------
   3189     // ---------------------------------------------------------------------
   3190     // Application launch intent categories (see addCategory()).
   3191 
   3192     /**
   3193      * Used with {@link #ACTION_MAIN} to launch the browser application.
   3194      * The activity should be able to browse the Internet.
   3195      * <p>NOTE: This should not be used as the primary key of an Intent,
   3196      * since it will not result in the app launching with the correct
   3197      * action and category.  Instead, use this with
   3198      * {@link #makeMainSelectorActivity(String, String)} to generate a main
   3199      * Intent with this category in the selector.</p>
   3200      */
   3201     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3202     public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
   3203 
   3204     /**
   3205      * Used with {@link #ACTION_MAIN} to launch the calculator application.
   3206      * The activity should be able to perform standard arithmetic operations.
   3207      * <p>NOTE: This should not be used as the primary key of an Intent,
   3208      * since it will not result in the app launching with the correct
   3209      * action and category.  Instead, use this with
   3210      * {@link #makeMainSelectorActivity(String, String)} to generate a main
   3211      * Intent with this category in the selector.</p>
   3212      */
   3213     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3214     public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
   3215 
   3216     /**
   3217      * Used with {@link #ACTION_MAIN} to launch the calendar application.
   3218      * The activity should be able to view and manipulate calendar entries.
   3219      * <p>NOTE: This should not be used as the primary key of an Intent,
   3220      * since it will not result in the app launching with the correct
   3221      * action and category.  Instead, use this with
   3222      * {@link #makeMainSelectorActivity(String, String)} to generate a main
   3223      * Intent with this category in the selector.</p>
   3224      */
   3225     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3226     public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
   3227 
   3228     /**
   3229      * Used with {@link #ACTION_MAIN} to launch the contacts application.
   3230      * The activity should be able to view and manipulate address book entries.
   3231      * <p>NOTE: This should not be used as the primary key of an Intent,
   3232      * since it will not result in the app launching with the correct
   3233      * action and category.  Instead, use this with
   3234      * {@link #makeMainSelectorActivity(String, String)} to generate a main
   3235      * Intent with this category in the selector.</p>
   3236      */
   3237     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3238     public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
   3239 
   3240     /**
   3241      * Used with {@link #ACTION_MAIN} to launch the email application.
   3242      * The activity should be able to send and receive email.
   3243      * <p>NOTE: This should not be used as the primary key of an Intent,
   3244      * since it will not result in the app launching with the correct
   3245      * action and category.  Instead, use this with
   3246      * {@link #makeMainSelectorActivity(String, String)} to generate a main
   3247      * Intent with this category in the selector.</p>
   3248      */
   3249     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3250     public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
   3251 
   3252     /**
   3253      * Used with {@link #ACTION_MAIN} to launch the gallery application.
   3254      * The activity should be able to view and manipulate image and video files
   3255      * stored on the device.
   3256      * <p>NOTE: This should not be used as the primary key of an Intent,
   3257      * since it will not result in the app launching with the correct
   3258      * action and category.  Instead, use this with
   3259      * {@link #makeMainSelectorActivity(String, String)} to generate a main
   3260      * Intent with this category in the selector.</p>
   3261      */
   3262     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3263     public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
   3264 
   3265     /**
   3266      * Used with {@link #ACTION_MAIN} to launch the maps application.
   3267      * The activity should be able to show the user's current location and surroundings.
   3268      * <p>NOTE: This should not be used as the primary key of an Intent,
   3269      * since it will not result in the app launching with the correct
   3270      * action and category.  Instead, use this with
   3271      * {@link #makeMainSelectorActivity(String, String)} to generate a main
   3272      * Intent with this category in the selector.</p>
   3273      */
   3274     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3275     public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
   3276 
   3277     /**
   3278      * Used with {@link #ACTION_MAIN} to launch the messaging application.
   3279      * The activity should be able to send and receive text messages.
   3280      * <p>NOTE: This should not be used as the primary key of an Intent,
   3281      * since it will not result in the app launching with the correct
   3282      * action and category.  Instead, use this with
   3283      * {@link #makeMainSelectorActivity(String, String)} to generate a main
   3284      * Intent with this category in the selector.</p>
   3285      */
   3286     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3287     public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
   3288 
   3289     /**
   3290      * Used with {@link #ACTION_MAIN} to launch the music application.
   3291      * The activity should be able to play, browse, or manipulate music files
   3292      * stored on the device.
   3293      * <p>NOTE: This should not be used as the primary key of an Intent,
   3294      * since it will not result in the app launching with the correct
   3295      * action and category.  Instead, use this with
   3296      * {@link #makeMainSelectorActivity(String, String)} to generate a main
   3297      * Intent with this category in the selector.</p>
   3298      */
   3299     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
   3300     public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
   3301 
   3302     // ---------------------------------------------------------------------
   3303     // ---------------------------------------------------------------------
   3304     // Standard extra data keys.
   3305 
   3306     /**
   3307      * The initial data to place in a newly created record.  Use with
   3308      * {@link #ACTION_INSERT}.  The data here is a Map containing the same
   3309      * fields as would be given to the underlying ContentProvider.insert()
   3310      * call.
   3311      */
   3312     public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
   3313 
   3314     /**
   3315      * A constant CharSequence that is associated with the Intent, used with
   3316      * {@link #ACTION_SEND} to supply the literal data to be sent.  Note that
   3317      * this may be a styled CharSequence, so you must use
   3318      * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
   3319      * retrieve it.
   3320      */
   3321     public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
   3322 
   3323     /**
   3324      * A constant String that is associated with the Intent, used with
   3325      * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
   3326      * as HTML formatted text.  Note that you <em>must</em> also supply
   3327      * {@link #EXTRA_TEXT}.
   3328      */
   3329     public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
   3330 
   3331     /**
   3332      * A content: URI holding a stream of data associated with the Intent,
   3333      * used with {@link #ACTION_SEND} to supply the data being sent.
   3334      */
   3335     public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
   3336 
   3337     /**
   3338      * A String[] holding e-mail addresses that should be delivered to.
   3339      */
   3340     public static final String EXTRA_EMAIL       = "android.intent.extra.EMAIL";
   3341 
   3342     /**
   3343      * A String[] holding e-mail addresses that should be carbon copied.
   3344      */
   3345     public static final String EXTRA_CC       = "android.intent.extra.CC";
   3346 
   3347     /**
   3348      * A String[] holding e-mail addresses that should be blind carbon copied.
   3349      */
   3350     public static final String EXTRA_BCC      = "android.intent.extra.BCC";
   3351 
   3352     /**
   3353      * A constant string holding the desired subject line of a message.
   3354      */
   3355     public static final String EXTRA_SUBJECT  = "android.intent.extra.SUBJECT";
   3356 
   3357     /**
   3358      * An Intent describing the choices you would like shown with
   3359      * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
   3360      */
   3361     public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
   3362 
   3363     /**
   3364      * An Intent[] describing additional, alternate choices you would like shown with
   3365      * {@link #ACTION_CHOOSER}.
   3366      *
   3367      * <p>An app may be capable of providing several different payload types to complete a
   3368      * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
   3369      * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
   3370      * several different supported sending mechanisms for sharing, such as the actual "image/*"
   3371      * photo data or a hosted link where the photos can be viewed.</p>
   3372      *
   3373      * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
   3374      * first/primary/preferred intent in the set. Additional intents specified in
   3375      * this extra are ordered; by default intents that appear earlier in the array will be
   3376      * preferred over intents that appear later in the array as matches for the same
   3377      * target component. To alter this preference, a calling app may also supply
   3378      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
   3379      */
   3380     public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
   3381 
   3382     /**
   3383      * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
   3384      * from the chooser activity presented by {@link #ACTION_CHOOSER}.
   3385      *
   3386      * <p>An app preparing an action for another app to complete may wish to allow the user to
   3387      * disambiguate between several options for completing the action based on the chosen target
   3388      * or otherwise refine the action before it is invoked.
   3389      * </p>
   3390      *
   3391      * <p>When sent, this IntentSender may be filled in with the following extras:</p>
   3392      * <ul>
   3393      *     <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
   3394      *     <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
   3395      *     chosen target beyond the first</li>
   3396      *     <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
   3397      *     should fill in and send once the disambiguation is complete</li>
   3398      * </ul>
   3399      */
   3400     public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
   3401             = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
   3402 
   3403     /**
   3404      * A {@link ResultReceiver} used to return data back to the sender.
   3405      *
   3406      * <p>Used to complete an app-specific
   3407      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
   3408      *
   3409      * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
   3410      * used to start a {@link #ACTION_CHOOSER} activity this extra will be
   3411      * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
   3412      * when the user selects a target component from the chooser. It is up to the recipient
   3413      * to send a result to this ResultReceiver to signal that disambiguation is complete
   3414      * and that the chooser should invoke the user's choice.</p>
   3415      *
   3416      * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
   3417      * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
   3418      * to match and fill in the final Intent or ChooserTarget before starting it.
   3419      * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
   3420      * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
   3421      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
   3422      *
   3423      * <p>The result code passed to the ResultReceiver should be
   3424      * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
   3425      * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
   3426      * the chooser should finish without starting a target.</p>
   3427      */
   3428     public static final String EXTRA_RESULT_RECEIVER
   3429             = "android.intent.extra.RESULT_RECEIVER";
   3430 
   3431     /**
   3432      * A CharSequence dialog title to provide to the user when used with a
   3433      * {@link #ACTION_CHOOSER}.
   3434      */
   3435     public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
   3436 
   3437     /**
   3438      * A Parcelable[] of {@link Intent} or
   3439      * {@link android.content.pm.LabeledIntent} objects as set with
   3440      * {@link #putExtra(String, Parcelable[])} of additional activities to place
   3441      * a the front of the list of choices, when shown to the user with a
   3442      * {@link #ACTION_CHOOSER}.
   3443      */
   3444     public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
   3445 
   3446     /**
   3447      * A Bundle forming a mapping of potential target package names to different extras Bundles
   3448      * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
   3449      * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
   3450      * be currently installed on the device.
   3451      *
   3452      * <p>An application may choose to provide alternate extras for the case where a user
   3453      * selects an activity from a predetermined set of target packages. If the activity
   3454      * the user selects from the chooser belongs to a package with its package name as
   3455      * a key in this bundle, the corresponding extras for that package will be merged with
   3456      * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
   3457      * extra has the same key as an extra already present in the intent it will overwrite
   3458      * the extra from the intent.</p>
   3459      *
   3460      * <p><em>Examples:</em>
   3461      * <ul>
   3462      *     <li>An application may offer different {@link #EXTRA_TEXT} to an application
   3463      *     when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
   3464      *     parameters for that target.</li>
   3465      *     <li>An application may offer additional metadata for known targets of a given intent
   3466      *     to pass along information only relevant to that target such as account or content
   3467      *     identifiers already known to that application.</li>
   3468      * </ul></p>
   3469      */
   3470     public static final String EXTRA_REPLACEMENT_EXTRAS =
   3471             "android.intent.extra.REPLACEMENT_EXTRAS";
   3472 
   3473     /**
   3474      * An {@link IntentSender} that will be notified if a user successfully chooses a target
   3475      * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
   3476      * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
   3477      * {@link ComponentName} of the chosen component.
   3478      *
   3479      * <p>In some situations this callback may never come, for example if the user abandons
   3480      * the chooser, switches to another task or any number of other reasons. Apps should not
   3481      * be written assuming that this callback will always occur.</p>
   3482      */
   3483     public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
   3484             "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
   3485 
   3486     /**
   3487      * The {@link ComponentName} chosen by the user to complete an action.
   3488      *
   3489      * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
   3490      */
   3491     public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
   3492 
   3493     /**
   3494      * A {@link android.view.KeyEvent} object containing the event that
   3495      * triggered the creation of the Intent it is in.
   3496      */
   3497     public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
   3498 
   3499     /**
   3500      * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
   3501      * before shutting down.
   3502      *
   3503      * {@hide}
   3504      */
   3505     public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
   3506 
   3507     /**
   3508      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
   3509      * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
   3510      * of restarting the application.
   3511      */
   3512     public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
   3513 
   3514     /**
   3515      * A String holding the phone number originally entered in
   3516      * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
   3517      * number to call in a {@link android.content.Intent#ACTION_CALL}.
   3518      */
   3519     public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
   3520 
   3521     /**
   3522      * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
   3523      * intents to supply the uid the package had been assigned.  Also an optional
   3524      * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
   3525      * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
   3526      * purpose.
   3527      */
   3528     public static final String EXTRA_UID = "android.intent.extra.UID";
   3529 
   3530     /**
   3531      * @hide String array of package names.
   3532      */
   3533     @SystemApi
   3534     public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
   3535 
   3536     /**
   3537      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
   3538      * intents to indicate whether this represents a full uninstall (removing
   3539      * both the code and its data) or a partial uninstall (leaving its data,
   3540      * implying that this is an update).
   3541      */
   3542     public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
   3543 
   3544     /**
   3545      * @hide
   3546      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
   3547      * intents to indicate that at this point the package has been removed for
   3548      * all users on the device.
   3549      */
   3550     public static final String EXTRA_REMOVED_FOR_ALL_USERS
   3551             = "android.intent.extra.REMOVED_FOR_ALL_USERS";
   3552 
   3553     /**
   3554      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
   3555      * intents to indicate that this is a replacement of the package, so this
   3556      * broadcast will immediately be followed by an add broadcast for a
   3557      * different version of the same package.
   3558      */
   3559     public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
   3560 
   3561     /**
   3562      * Used as an int extra field in {@link android.app.AlarmManager} intents
   3563      * to tell the application being invoked how many pending alarms are being
   3564      * delievered with the intent.  For one-shot alarms this will always be 1.
   3565      * For recurring alarms, this might be greater than 1 if the device was
   3566      * asleep or powered off at the time an earlier alarm would have been
   3567      * delivered.
   3568      */
   3569     public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
   3570 
   3571     /**
   3572      * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
   3573      * intents to request the dock state.  Possible values are
   3574      * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
   3575      * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
   3576      * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
   3577      * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
   3578      * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
   3579      */
   3580     public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
   3581 
   3582     /**
   3583      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
   3584      * to represent that the phone is not in any dock.
   3585      */
   3586     public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
   3587 
   3588     /**
   3589      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
   3590      * to represent that the phone is in a desk dock.
   3591      */
   3592     public static final int EXTRA_DOCK_STATE_DESK = 1;
   3593 
   3594     /**
   3595      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
   3596      * to represent that the phone is in a car dock.
   3597      */
   3598     public static final int EXTRA_DOCK_STATE_CAR = 2;
   3599 
   3600     /**
   3601      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
   3602      * to represent that the phone is in a analog (low end) dock.
   3603      */
   3604     public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
   3605 
   3606     /**
   3607      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
   3608      * to represent that the phone is in a digital (high end) dock.
   3609      */
   3610     public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
   3611 
   3612     /**
   3613      * Boolean that can be supplied as meta-data with a dock activity, to
   3614      * indicate that the dock should take over the home key when it is active.
   3615      */
   3616     public static final String METADATA_DOCK_HOME = "android.dock_home";
   3617 
   3618     /**
   3619      * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
   3620      * the bug report.
   3621      */
   3622     public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
   3623 
   3624     /**
   3625      * Used in the extra field in the remote intent. It's astring token passed with the
   3626      * remote intent.
   3627      */
   3628     public static final String EXTRA_REMOTE_INTENT_TOKEN =
   3629             "android.intent.extra.remote_intent_token";
   3630 
   3631     /**
   3632      * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
   3633      * will contain only the first name in the list.
   3634      */
   3635     @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
   3636             "android.intent.extra.changed_component_name";
   3637 
   3638     /**
   3639      * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
   3640      * and contains a string array of all of the components that have changed.  If
   3641      * the state of the overall package has changed, then it will contain an entry
   3642      * with the package name itself.
   3643      */
   3644     public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
   3645             "android.intent.extra.changed_component_name_list";
   3646 
   3647     /**
   3648      * This field is part of
   3649      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
   3650      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
   3651      * and contains a string array of all of the components that have changed.
   3652      */
   3653     public static final String EXTRA_CHANGED_PACKAGE_LIST =
   3654             "android.intent.extra.changed_package_list";
   3655 
   3656     /**
   3657      * This field is part of
   3658      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
   3659      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
   3660      * and contains an integer array of uids of all of the components
   3661      * that have changed.
   3662      */
   3663     public static final String EXTRA_CHANGED_UID_LIST =
   3664             "android.intent.extra.changed_uid_list";
   3665 
   3666     /**
   3667      * @hide
   3668      * Magic extra system code can use when binding, to give a label for
   3669      * who it is that has bound to a service.  This is an integer giving
   3670      * a framework string resource that can be displayed to the user.
   3671      */
   3672     public static final String EXTRA_CLIENT_LABEL =
   3673             "android.intent.extra.client_label";
   3674 
   3675     /**
   3676      * @hide
   3677      * Magic extra system code can use when binding, to give a PendingIntent object
   3678      * that can be launched for the user to disable the system's use of this
   3679      * service.
   3680      */
   3681     public static final String EXTRA_CLIENT_INTENT =
   3682             "android.intent.extra.client_intent";
   3683 
   3684     /**
   3685      * Extra used to indicate that an intent should only return data that is on
   3686      * the local device. This is a boolean extra; the default is false. If true,
   3687      * an implementation should only allow the user to select data that is
   3688      * already on the device, not requiring it be downloaded from a remote
   3689      * service when opened.
   3690      *
   3691      * @see #ACTION_GET_CONTENT
   3692      * @see #ACTION_OPEN_DOCUMENT
   3693      * @see #ACTION_OPEN_DOCUMENT_TREE
   3694      * @see #ACTION_CREATE_DOCUMENT
   3695      */
   3696     public static final String EXTRA_LOCAL_ONLY =
   3697             "android.intent.extra.LOCAL_ONLY";
   3698 
   3699     /**
   3700      * Extra used to indicate that an intent can allow the user to select and
   3701      * return multiple items. This is a boolean extra; the default is false. If
   3702      * true, an implementation is allowed to present the user with a UI where
   3703      * they can pick multiple items that are all returned to the caller. When
   3704      * this happens, they should be returned as the {@link #getClipData()} part
   3705      * of the result Intent.
   3706      *
   3707      * @see #ACTION_GET_CONTENT
   3708      * @see #ACTION_OPEN_DOCUMENT
   3709      */
   3710     public static final String EXTRA_ALLOW_MULTIPLE =
   3711             "android.intent.extra.ALLOW_MULTIPLE";
   3712 
   3713     /**
   3714      * The integer userHandle carried with broadcast intents related to addition, removal and
   3715      * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
   3716      * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
   3717      *
   3718      * @hide
   3719      */
   3720     public static final String EXTRA_USER_HANDLE =
   3721             "android.intent.extra.user_handle";
   3722 
   3723     /**
   3724      * The UserHandle carried with broadcasts intents related to addition and removal of managed
   3725      * profiles - {@link #ACTION_MANAGED_PROFILE_ADDED} and {@link #ACTION_MANAGED_PROFILE_REMOVED}.
   3726      */
   3727     public static final String EXTRA_USER =
   3728             "android.intent.extra.USER";
   3729 
   3730     /**
   3731      * Extra used in the response from a BroadcastReceiver that handles
   3732      * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
   3733      * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
   3734      */
   3735     public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
   3736 
   3737     /**
   3738      * Extra sent in the intent to the BroadcastReceiver that handles
   3739      * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
   3740      * the restrictions as key/value pairs.
   3741      */
   3742     public static final String EXTRA_RESTRICTIONS_BUNDLE =
   3743             "android.intent.extra.restrictions_bundle";
   3744 
   3745     /**
   3746      * Extra used in the response from a BroadcastReceiver that handles
   3747      * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
   3748      */
   3749     public static final String EXTRA_RESTRICTIONS_INTENT =
   3750             "android.intent.extra.restrictions_intent";
   3751 
   3752     /**
   3753      * Extra used to communicate a set of acceptable MIME types. The type of the
   3754      * extra is {@code String[]}. Values may be a combination of concrete MIME
   3755      * types (such as "image/png") and/or partial MIME types (such as
   3756      * "audio/*").
   3757      *
   3758      * @see #ACTION_GET_CONTENT
   3759      * @see #ACTION_OPEN_DOCUMENT
   3760      */
   3761     public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
   3762 
   3763     /**
   3764      * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
   3765      * this shutdown is only for the user space of the system, not a complete shutdown.
   3766      * When this is true, hardware devices can use this information to determine that
   3767      * they shouldn't do a complete shutdown of their device since this is not a
   3768      * complete shutdown down to the kernel, but only user space restarting.
   3769      * The default if not supplied is false.
   3770      */
   3771     public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
   3772             = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
   3773 
   3774     /**
   3775      * Optional boolean extra for {@link #ACTION_TIME_CHANGED} that indicates the
   3776      * user has set their time format preferences to the 24 hour format.
   3777      *
   3778      * @hide for internal use only.
   3779      */
   3780     public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
   3781             "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
   3782 
   3783     /** {@hide} */
   3784     public static final String EXTRA_REASON = "android.intent.extra.REASON";
   3785 
   3786     /** {@hide} */
   3787     public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
   3788 
   3789     /**
   3790      * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
   3791      * activation request.
   3792      * TODO: Add information about the structure and response data used with the pending intent.
   3793      * @hide
   3794      */
   3795     public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
   3796             "android.intent.extra.SIM_ACTIVATION_RESPONSE";
   3797 
   3798     // ---------------------------------------------------------------------
   3799     // ---------------------------------------------------------------------
   3800     // Intent flags (see mFlags variable).
   3801 
   3802     /** @hide */
   3803     @IntDef(flag = true, value = {
   3804             FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
   3805             FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
   3806     @Retention(RetentionPolicy.SOURCE)
   3807     public @interface GrantUriMode {}
   3808 
   3809     /** @hide */
   3810     @IntDef(flag = true, value = {
   3811             FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
   3812     @Retention(RetentionPolicy.SOURCE)
   3813     public @interface AccessUriMode {}
   3814 
   3815     /**
   3816      * Test if given mode flags specify an access mode, which must be at least
   3817      * read and/or write.
   3818      *
   3819      * @hide
   3820      */
   3821     public static boolean isAccessUriMode(int modeFlags) {
   3822         return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
   3823                 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
   3824     }
   3825 
   3826     /**
   3827      * If set, the recipient of this Intent will be granted permission to
   3828      * perform read operations on the URI in the Intent's data and any URIs
   3829      * specified in its ClipData.  When applying to an Intent's ClipData,
   3830      * all URIs as well as recursive traversals through data or other ClipData
   3831      * in Intent items will be granted; only the grant flags of the top-level
   3832      * Intent are used.
   3833      */
   3834     public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
   3835     /**
   3836      * If set, the recipient of this Intent will be granted permission to
   3837      * perform write operations on the URI in the Intent's data and any URIs
   3838      * specified in its ClipData.  When applying to an Intent's ClipData,
   3839      * all URIs as well as recursive traversals through data or other ClipData
   3840      * in Intent items will be granted; only the grant flags of the top-level
   3841      * Intent are used.
   3842      */
   3843     public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
   3844     /**
   3845      * Can be set by the caller to indicate that this Intent is coming from
   3846      * a background operation, not from direct user interaction.
   3847      */
   3848     public static final int FLAG_FROM_BACKGROUND = 0x00000004;
   3849     /**
   3850      * A flag you can enable for debugging: when set, log messages will be
   3851      * printed during the resolution of this intent to show you what has
   3852      * been found to create the final resolved list.
   3853      */
   3854     public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
   3855     /**
   3856      * If set, this intent will not match any components in packages that
   3857      * are currently stopped.  If this is not set, then the default behavior
   3858      * is to include such applications in the result.
   3859      */
   3860     public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
   3861     /**
   3862      * If set, this intent will always match any components in packages that
   3863      * are currently stopped.  This is the default behavior when
   3864      * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set.  If both of these
   3865      * flags are set, this one wins (it allows overriding of exclude for
   3866      * places where the framework may automatically set the exclude flag).
   3867      */
   3868     public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
   3869 
   3870     /**
   3871      * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
   3872      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
   3873      * persisted across device reboots until explicitly revoked with
   3874      * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
   3875      * grant for possible persisting; the receiving application must call
   3876      * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
   3877      * actually persist.
   3878      *
   3879      * @see ContentResolver#takePersistableUriPermission(Uri, int)
   3880      * @see ContentResolver#releasePersistableUriPermission(Uri, int)
   3881      * @see ContentResolver#getPersistedUriPermissions()
   3882      * @see ContentResolver#getOutgoingPersistedUriPermissions()
   3883      */
   3884     public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
   3885 
   3886     /**
   3887      * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
   3888      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
   3889      * applies to any URI that is a prefix match against the original granted
   3890      * URI. (Without this flag, the URI must match exactly for access to be
   3891      * granted.) Another URI is considered a prefix match only when scheme,
   3892      * authority, and all path segments defined by the prefix are an exact
   3893      * match.
   3894      */
   3895     public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
   3896 
   3897     /**
   3898      * If set, the new activity is not kept in the history stack.  As soon as
   3899      * the user navigates away from it, the activity is finished.  This may also
   3900      * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
   3901      * noHistory} attribute.
   3902      *
   3903      * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
   3904      * is never invoked when the current activity starts a new activity which
   3905      * sets a result and finishes.
   3906      */
   3907     public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
   3908     /**
   3909      * If set, the activity will not be launched if it is already running
   3910      * at the top of the history stack.
   3911      */
   3912     public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
   3913     /**
   3914      * If set, this activity will become the start of a new task on this
   3915      * history stack.  A task (from the activity that started it to the
   3916      * next task activity) defines an atomic group of activities that the
   3917      * user can move to.  Tasks can be moved to the foreground and background;
   3918      * all of the activities inside of a particular task always remain in
   3919      * the same order.  See
   3920      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
   3921      * Stack</a> for more information about tasks.
   3922      *
   3923      * <p>This flag is generally used by activities that want
   3924      * to present a "launcher" style behavior: they give the user a list of
   3925      * separate things that can be done, which otherwise run completely
   3926      * independently of the activity launching them.
   3927      *
   3928      * <p>When using this flag, if a task is already running for the activity
   3929      * you are now starting, then a new activity will not be started; instead,
   3930      * the current task will simply be brought to the front of the screen with
   3931      * the state it was last in.  See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
   3932      * to disable this behavior.
   3933      *
   3934      * <p>This flag can not be used when the caller is requesting a result from
   3935      * the activity being launched.
   3936      */
   3937     public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
   3938     /**
   3939      * This flag is used to create a new task and launch an activity into it.
   3940      * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
   3941      * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
   3942      * search through existing tasks for ones matching this Intent. Only if no such
   3943      * task is found would a new task be created. When paired with
   3944      * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
   3945      * the search for a matching task and unconditionally start a new task.
   3946      *
   3947      * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
   3948      * flag unless you are implementing your own
   3949      * top-level application launcher.</strong>  Used in conjunction with
   3950      * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
   3951      * behavior of bringing an existing task to the foreground.  When set,
   3952      * a new task is <em>always</em> started to host the Activity for the
   3953      * Intent, regardless of whether there is already an existing task running
   3954      * the same thing.
   3955      *
   3956      * <p><strong>Because the default system does not include graphical task management,
   3957      * you should not use this flag unless you provide some way for a user to
   3958      * return back to the tasks you have launched.</strong>
   3959      *
   3960      * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
   3961      * creating new document tasks.
   3962      *
   3963      * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
   3964      * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
   3965      *
   3966      * <p>See
   3967      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
   3968      * Stack</a> for more information about tasks.
   3969      *
   3970      * @see #FLAG_ACTIVITY_NEW_DOCUMENT
   3971      * @see #FLAG_ACTIVITY_NEW_TASK
   3972      */
   3973     public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
   3974     /**
   3975      * If set, and the activity being launched is already running in the
   3976      * current task, then instead of launching a new instance of that activity,
   3977      * all of the other activities on top of it will be closed and this Intent
   3978      * will be delivered to the (now on top) old activity as a new Intent.
   3979      *
   3980      * <p>For example, consider a task consisting of the activities: A, B, C, D.
   3981      * If D calls startActivity() with an Intent that resolves to the component
   3982      * of activity B, then C and D will be finished and B receive the given
   3983      * Intent, resulting in the stack now being: A, B.
   3984      *
   3985      * <p>The currently running instance of activity B in the above example will
   3986      * either receive the new intent you are starting here in its
   3987      * onNewIntent() method, or be itself finished and restarted with the
   3988      * new intent.  If it has declared its launch mode to be "multiple" (the
   3989      * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
   3990      * the same intent, then it will be finished and re-created; for all other
   3991      * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
   3992      * Intent will be delivered to the current instance's onNewIntent().
   3993      *
   3994      * <p>This launch mode can also be used to good effect in conjunction with
   3995      * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
   3996      * of a task, it will bring any currently running instance of that task
   3997      * to the foreground, and then clear it to its root state.  This is
   3998      * especially useful, for example, when launching an activity from the
   3999      * notification manager.
   4000      *
   4001      * <p>See
   4002      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
   4003      * Stack</a> for more information about tasks.
   4004      */
   4005     public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
   4006     /**
   4007      * If set and this intent is being used to launch a new activity from an
   4008      * existing one, then the reply target of the existing activity will be
   4009      * transfered to the new activity.  This way the new activity can call
   4010      * {@link android.app.Activity#setResult} and have that result sent back to
   4011      * the reply target of the original activity.
   4012      */
   4013     public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
   4014     /**
   4015      * If set and this intent is being used to launch a new activity from an
   4016      * existing one, the current activity will not be counted as the top
   4017      * activity for deciding whether the new intent should be delivered to
   4018      * the top instead of starting a new one.  The previous activity will
   4019      * be used as the top, with the assumption being that the current activity
   4020      * will finish itself immediately.
   4021      */
   4022     public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
   4023     /**
   4024      * If set, the new activity is not kept in the list of recently launched
   4025      * activities.
   4026      */
   4027     public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
   4028     /**
   4029      * This flag is not normally set by application code, but set for you by
   4030      * the system as described in the
   4031      * {@link android.R.styleable#AndroidManifestActivity_launchMode
   4032      * launchMode} documentation for the singleTask mode.
   4033      */
   4034     public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
   4035     /**
   4036      * If set, and this activity is either being started in a new task or
   4037      * bringing to the top an existing task, then it will be launched as
   4038      * the front door of the task.  This will result in the application of
   4039      * any affinities needed to have that task in the proper state (either
   4040      * moving activities to or from it), or simply resetting that task to
   4041      * its initial state if needed.
   4042      */
   4043     public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
   4044     /**
   4045      * This flag is not normally set by application code, but set for you by
   4046      * the system if this activity is being launched from history
   4047      * (longpress home key).
   4048      */
   4049     public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
   4050     /**
   4051      * @deprecated As of API 21 this performs identically to
   4052      * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
   4053      */
   4054     public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
   4055     /**
   4056      * This flag is used to open a document into a new task rooted at the activity launched
   4057      * by this Intent. Through the use of this flag, or its equivalent attribute,
   4058      * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
   4059      * containing different documents will appear in the recent tasks list.
   4060      *
   4061      * <p>The use of the activity attribute form of this,
   4062      * {@link android.R.attr#documentLaunchMode}, is
   4063      * preferred over the Intent flag described here. The attribute form allows the
   4064      * Activity to specify multiple document behavior for all launchers of the Activity
   4065      * whereas using this flag requires each Intent that launches the Activity to specify it.
   4066      *
   4067      * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
   4068      * it is kept after the activity is finished is different than the use of
   4069      * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
   4070      * this flag is being used to create a new recents entry, then by default that entry
   4071      * will be removed once the activity is finished.  You can modify this behavior with
   4072      * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
   4073      *
   4074      * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
   4075      * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
   4076      * equivalent of the Activity manifest specifying {@link
   4077      * android.R.attr#documentLaunchMode}="intoExisting". When used with
   4078      * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
   4079      * {@link android.R.attr#documentLaunchMode}="always".
   4080      *
   4081      * Refer to {@link android.R.attr#documentLaunchMode} for more information.
   4082      *
   4083      * @see android.R.attr#documentLaunchMode
   4084      * @see #FLAG_ACTIVITY_MULTIPLE_TASK
   4085      */
   4086     public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
   4087     /**
   4088      * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
   4089      * callback from occurring on the current frontmost activity before it is
   4090      * paused as the newly-started activity is brought to the front.
   4091      *
   4092      * <p>Typically, an activity can rely on that callback to indicate that an
   4093      * explicit user action has caused their activity to be moved out of the
   4094      * foreground. The callback marks an appropriate point in the activity's
   4095      * lifecycle for it to dismiss any notifications that it intends to display
   4096      * "until the user has seen them," such as a blinking LED.
   4097      *
   4098      * <p>If an activity is ever started via any non-user-driven events such as
   4099      * phone-call receipt or an alarm handler, this flag should be passed to {@link
   4100      * Context#startActivity Context.startActivity}, ensuring that the pausing
   4101      * activity does not think the user has acknowledged its notification.
   4102      */
   4103     public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
   4104     /**
   4105      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
   4106      * this flag will cause the launched activity to be brought to the front of its
   4107      * task's history stack if it is already running.
   4108      *
   4109      * <p>For example, consider a task consisting of four activities: A, B, C, D.
   4110      * If D calls startActivity() with an Intent that resolves to the component
   4111      * of activity B, then B will be brought to the front of the history stack,
   4112      * with this resulting order:  A, C, D, B.
   4113      *
   4114      * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
   4115      * specified.
   4116      */
   4117     public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
   4118     /**
   4119      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
   4120      * this flag will prevent the system from applying an activity transition
   4121      * animation to go to the next activity state.  This doesn't mean an
   4122      * animation will never run -- if another activity change happens that doesn't
   4123      * specify this flag before the activity started here is displayed, then
   4124      * that transition will be used.  This flag can be put to good use
   4125      * when you are going to do a series of activity operations but the
   4126      * animation seen by the user shouldn't be driven by the first activity
   4127      * change but rather a later one.
   4128      */
   4129     public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
   4130     /**
   4131      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
   4132      * this flag will cause any existing task that would be associated with the
   4133      * activity to be cleared before the activity is started.  That is, the activity
   4134      * becomes the new root of an otherwise empty task, and any old activities
   4135      * are finished.  This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
   4136      */
   4137     public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
   4138     /**
   4139      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
   4140      * this flag will cause a newly launching task to be placed on top of the current
   4141      * home activity task (if there is one).  That is, pressing back from the task
   4142      * will always return the user to home even if that was not the last activity they
   4143      * saw.   This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
   4144      */
   4145     public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
   4146     /**
   4147      * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
   4148      * have its entry in recent tasks removed when the user closes it (with back
   4149      * or however else it may finish()). If you would like to instead allow the
   4150      * document to be kept in recents so that it can be re-launched, you can use
   4151      * this flag. When set and the task's activity is finished, the recents
   4152      * entry will remain in the interface for the user to re-launch it, like a
   4153      * recents entry for a top-level application.
   4154      * <p>
   4155      * The receiving activity can override this request with
   4156      * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
   4157      * {@link android.app.Activity#finishAndRemoveTask()
   4158      * Activity.finishAndRemoveTask()}.
   4159      */
   4160     public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
   4161 
   4162     /**
   4163      * If set, when sending a broadcast only registered receivers will be
   4164      * called -- no BroadcastReceiver components will be launched.
   4165      */
   4166     public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
   4167     /**
   4168      * If set, when sending a broadcast the new broadcast will replace
   4169      * any existing pending broadcast that matches it.  Matching is defined
   4170      * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
   4171      * true for the intents of the two broadcasts.  When a match is found,
   4172      * the new broadcast (and receivers associated with it) will replace the
   4173      * existing one in the pending broadcast list, remaining at the same
   4174      * position in the list.
   4175      *
   4176      * <p>This flag is most typically used with sticky broadcasts, which
   4177      * only care about delivering the most recent values of the broadcast
   4178      * to their receivers.
   4179      */
   4180     public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
   4181     /**
   4182      * If set, when sending a broadcast the recipient is allowed to run at
   4183      * foreground priority, with a shorter timeout interval.  During normal
   4184      * broadcasts the receivers are not automatically hoisted out of the
   4185      * background priority class.
   4186      */
   4187     public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
   4188     /**
   4189      * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
   4190      * They can still propagate results through to later receivers, but they can not prevent
   4191      * later receivers from seeing the broadcast.
   4192      */
   4193     public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
   4194     /**
   4195      * If set, when sending a broadcast <i>before boot has completed</i> only
   4196      * registered receivers will be called -- no BroadcastReceiver components
   4197      * will be launched.  Sticky intent state will be recorded properly even
   4198      * if no receivers wind up being called.  If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
   4199      * is specified in the broadcast intent, this flag is unnecessary.
   4200      *
   4201      * <p>This flag is only for use by system sevices as a convenience to
   4202      * avoid having to implement a more complex mechanism around detection
   4203      * of boot completion.
   4204      *
   4205      * @hide
   4206      */
   4207     public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
   4208     /**
   4209      * Set when this broadcast is for a boot upgrade, a special mode that
   4210      * allows the broadcast to be sent before the system is ready and launches
   4211      * the app process with no providers running in it.
   4212      * @hide
   4213      */
   4214     public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
   4215 
   4216     /**
   4217      * @hide Flags that can't be changed with PendingIntent.
   4218      */
   4219     public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
   4220             | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
   4221             | FLAG_GRANT_PREFIX_URI_PERMISSION;
   4222 
   4223     // ---------------------------------------------------------------------
   4224     // ---------------------------------------------------------------------
   4225     // toUri() and parseUri() options.
   4226 
   4227     /**
   4228      * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
   4229      * always has the "intent:" scheme.  This syntax can be used when you want
   4230      * to later disambiguate between URIs that are intended to describe an
   4231      * Intent vs. all others that should be treated as raw URIs.  When used
   4232      * with {@link #parseUri}, any other scheme will result in a generic
   4233      * VIEW action for that raw URI.
   4234      */
   4235     public static final int URI_INTENT_SCHEME = 1<<0;
   4236 
   4237     /**
   4238      * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
   4239      * always has the "android-app:" scheme.  This is a variation of
   4240      * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
   4241      * http/https URI being delivered to a specific package name.  The format
   4242      * is:
   4243      *
   4244      * <pre class="prettyprint">
   4245      * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
   4246      *
   4247      * <p>In this scheme, only the <code>package_id</code> is required.  If you include a host,
   4248      * you must also include a scheme; including a path also requires both a host and a scheme.
   4249      * The final #Intent; fragment can be used without a scheme, host, or path.
   4250      * Note that this can not be
   4251      * used with intents that have a {@link #setSelector}, since the base intent
   4252      * will always have an explicit package name.</p>
   4253      *
   4254      * <p>Some examples of how this scheme maps to Intent objects:</p>
   4255      * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
   4256      *     <colgroup align="left" />
   4257      *     <colgroup align="left" />
   4258      *     <thead>
   4259      *     <tr><th>URI</th> <th>Intent</th></tr>
   4260      *     </thead>
   4261      *
   4262      *     <tbody>
   4263      *     <tr><td><code>android-app://com.example.app</code></td>
   4264      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
   4265      *             <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
   4266      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
   4267      *         </table></td>
   4268      *     </tr>
   4269      *     <tr><td><code>android-app://com.example.app/http/example.com</code></td>
   4270      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
   4271      *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
   4272      *             <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
   4273      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
   4274      *         </table></td>
   4275      *     </tr>
   4276      *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
   4277      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
   4278      *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
   4279      *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
   4280      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
   4281      *         </table></td>
   4282      *     </tr>
   4283      *     <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
   4284      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
   4285      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
   4286      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
   4287      *         </table></td>
   4288      *     </tr>
   4289      *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
   4290      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
   4291      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
   4292      *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
   4293      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
   4294      *         </table></td>
   4295      *     </tr>
   4296      *     <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;<br />i.some_int=100;S.some_str=hello;end</code></td>
   4297      *         <td><table border="" style="margin:0" >
   4298      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
   4299      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
   4300      *             <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
   4301      *         </table></td>
   4302      *     </tr>
   4303      *     </tbody>
   4304      * </table>
   4305      */
   4306     public static final int URI_ANDROID_APP_SCHEME = 1<<1;
   4307 
   4308     /**
   4309      * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
   4310      * of unsafe information.  In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
   4311      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
   4312      * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
   4313      * generated Intent can not cause unexpected data access to happen.
   4314      *
   4315      * <p>If you do not trust the source of the URI being parsed, you should still do further
   4316      * processing to protect yourself from it.  In particular, when using it to start an
   4317      * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
   4318      * that can handle it.</p>
   4319      */
   4320     public static final int URI_ALLOW_UNSAFE = 1<<2;
   4321 
   4322     // ---------------------------------------------------------------------
   4323 
   4324     private String mAction;
   4325     private Uri mData;
   4326     private String mType;
   4327     private String mPackage;
   4328     private ComponentName mComponent;
   4329     private int mFlags;
   4330     private ArraySet<String> mCategories;
   4331     private Bundle mExtras;
   4332     private Rect mSourceBounds;
   4333     private Intent mSelector;
   4334     private ClipData mClipData;
   4335     private int mContentUserHint = UserHandle.USER_CURRENT;
   4336 
   4337     // ---------------------------------------------------------------------
   4338 
   4339     /**
   4340      * Create an empty intent.
   4341      */
   4342     public Intent() {
   4343     }
   4344 
   4345     /**
   4346      * Copy constructor.
   4347      */
   4348     public Intent(Intent o) {
   4349         this.mAction = o.mAction;
   4350         this.mData = o.mData;
   4351         this.mType = o.mType;
   4352         this.mPackage = o.mPackage;
   4353         this.mComponent = o.mComponent;
   4354         this.mFlags = o.mFlags;
   4355         this.mContentUserHint = o.mContentUserHint;
   4356         if (o.mCategories != null) {
   4357             this.mCategories = new ArraySet<String>(o.mCategories);
   4358         }
   4359         if (o.mExtras != null) {
   4360             this.mExtras = new Bundle(o.mExtras);
   4361         }
   4362         if (o.mSourceBounds != null) {
   4363             this.mSourceBounds = new Rect(o.mSourceBounds);
   4364         }
   4365         if (o.mSelector != null) {
   4366             this.mSelector = new Intent(o.mSelector);
   4367         }
   4368         if (o.mClipData != null) {
   4369             this.mClipData = new ClipData(o.mClipData);
   4370         }
   4371     }
   4372 
   4373     @Override
   4374     public Object clone() {
   4375         return new Intent(this);
   4376     }
   4377 
   4378     private Intent(Intent o, boolean all) {
   4379         this.mAction = o.mAction;
   4380         this.mData = o.mData;
   4381         this.mType = o.mType;
   4382         this.mPackage = o.mPackage;
   4383         this.mComponent = o.mComponent;
   4384         if (o.mCategories != null) {
   4385             this.mCategories = new ArraySet<String>(o.mCategories);
   4386         }
   4387     }
   4388 
   4389     /**
   4390      * Make a clone of only the parts of the Intent that are relevant for
   4391      * filter matching: the action, data, type, component, and categories.
   4392      */
   4393     public Intent cloneFilter() {
   4394         return new Intent(this, false);
   4395     }
   4396 
   4397     /**
   4398      * Create an intent with a given action.  All other fields (data, type,
   4399      * class) are null.  Note that the action <em>must</em> be in a
   4400      * namespace because Intents are used globally in the system -- for
   4401      * example the system VIEW action is android.intent.action.VIEW; an
   4402      * application's custom action would be something like
   4403      * com.google.app.myapp.CUSTOM_ACTION.
   4404      *
   4405      * @param action The Intent action, such as ACTION_VIEW.
   4406      */
   4407     public Intent(String action) {
   4408         setAction(action);
   4409     }
   4410 
   4411     /**
   4412      * Create an intent with a given action and for a given data url.  Note
   4413      * that the action <em>must</em> be in a namespace because Intents are
   4414      * used globally in the system -- for example the system VIEW action is
   4415      * android.intent.action.VIEW; an application's custom action would be
   4416      * something like com.google.app.myapp.CUSTOM_ACTION.
   4417      *
   4418      * <p><em>Note: scheme and host name matching in the Android framework is
   4419      * case-sensitive, unlike the formal RFC.  As a result,
   4420      * you should always ensure that you write your Uri with these elements
   4421      * using lower case letters, and normalize any Uris you receive from
   4422      * outside of Android to ensure the scheme and host is lower case.</em></p>
   4423      *
   4424      * @param action The Intent action, such as ACTION_VIEW.
   4425      * @param uri The Intent data URI.
   4426      */
   4427     public Intent(String action, Uri uri) {
   4428         setAction(action);
   4429         mData = uri;
   4430     }
   4431 
   4432     /**
   4433      * Create an intent for a specific component.  All other fields (action, data,
   4434      * type, class) are null, though they can be modified later with explicit
   4435      * calls.  This provides a convenient way to create an intent that is
   4436      * intended to execute a hard-coded class name, rather than relying on the
   4437      * system to find an appropriate class for you; see {@link #setComponent}
   4438      * for more information on the repercussions of this.
   4439      *
   4440      * @param packageContext A Context of the application package implementing
   4441      * this class.
   4442      * @param cls The component class that is to be used for the intent.
   4443      *
   4444      * @see #setClass
   4445      * @see #setComponent
   4446      * @see #Intent(String, android.net.Uri , Context, Class)
   4447      */
   4448     public Intent(Context packageContext, Class<?> cls) {
   4449         mComponent = new ComponentName(packageContext, cls);
   4450     }
   4451 
   4452     /**
   4453      * Create an intent for a specific component with a specified action and data.
   4454      * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
   4455      * construct the Intent and then calling {@link #setClass} to set its
   4456      * class.
   4457      *
   4458      * <p><em>Note: scheme and host name matching in the Android framework is
   4459      * case-sensitive, unlike the formal RFC.  As a result,
   4460      * you should always ensure that you write your Uri with these elements
   4461      * using lower case letters, and normalize any Uris you receive from
   4462      * outside of Android to ensure the scheme and host is lower case.</em></p>
   4463      *
   4464      * @param action The Intent action, such as ACTION_VIEW.
   4465      * @param uri The Intent data URI.
   4466      * @param packageContext A Context of the application package implementing
   4467      * this class.
   4468      * @param cls The component class that is to be used for the intent.
   4469      *
   4470      * @see #Intent(String, android.net.Uri)
   4471      * @see #Intent(Context, Class)
   4472      * @see #setClass
   4473      * @see #setComponent
   4474      */
   4475     public Intent(String action, Uri uri,
   4476             Context packageContext, Class<?> cls) {
   4477         setAction(action);
   4478         mData = uri;
   4479         mComponent = new ComponentName(packageContext, cls);
   4480     }
   4481 
   4482     /**
   4483      * Create an intent to launch the main (root) activity of a task.  This
   4484      * is the Intent that is started when the application's is launched from
   4485      * Home.  For anything else that wants to launch an application in the
   4486      * same way, it is important that they use an Intent structured the same
   4487      * way, and can use this function to ensure this is the case.
   4488      *
   4489      * <p>The returned Intent has the given Activity component as its explicit
   4490      * component, {@link #ACTION_MAIN} as its action, and includes the
   4491      * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
   4492      * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
   4493      * to do that through {@link #addFlags(int)} on the returned Intent.
   4494      *
   4495      * @param mainActivity The main activity component that this Intent will
   4496      * launch.
   4497      * @return Returns a newly created Intent that can be used to launch the
   4498      * activity as a main application entry.
   4499      *
   4500      * @see #setClass
   4501      * @see #setComponent
   4502      */
   4503     public static Intent makeMainActivity(ComponentName mainActivity) {
   4504         Intent intent = new Intent(ACTION_MAIN);
   4505         intent.setComponent(mainActivity);
   4506         intent.addCategory(CATEGORY_LAUNCHER);
   4507         return intent;
   4508     }
   4509 
   4510     /**
   4511      * Make an Intent for the main activity of an application, without
   4512      * specifying a specific activity to run but giving a selector to find
   4513      * the activity.  This results in a final Intent that is structured
   4514      * the same as when the application is launched from
   4515      * Home.  For anything else that wants to launch an application in the
   4516      * same way, it is important that they use an Intent structured the same
   4517      * way, and can use this function to ensure this is the case.
   4518      *
   4519      * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
   4520      * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
   4521      * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
   4522      * to do that through {@link #addFlags(int)} on the returned Intent.
   4523      *
   4524      * @param selectorAction The action name of the Intent's selector.
   4525      * @param selectorCategory The name of a category to add to the Intent's
   4526      * selector.
   4527      * @return Returns a newly created Intent that can be used to launch the
   4528      * activity as a main application entry.
   4529      *
   4530      * @see #setSelector(Intent)
   4531      */
   4532     public static Intent makeMainSelectorActivity(String selectorAction,
   4533             String selectorCategory) {
   4534         Intent intent = new Intent(ACTION_MAIN);
   4535         intent.addCategory(CATEGORY_LAUNCHER);
   4536         Intent selector = new Intent();
   4537         selector.setAction(selectorAction);
   4538         selector.addCategory(selectorCategory);
   4539         intent.setSelector(selector);
   4540         return intent;
   4541     }
   4542 
   4543     /**
   4544      * Make an Intent that can be used to re-launch an application's task
   4545      * in its base state.  This is like {@link #makeMainActivity(ComponentName)},
   4546      * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
   4547      * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
   4548      *
   4549      * @param mainActivity The activity component that is the root of the
   4550      * task; this is the activity that has been published in the application's
   4551      * manifest as the main launcher icon.
   4552      *
   4553      * @return Returns a newly created Intent that can be used to relaunch the
   4554      * activity's task in its root state.
   4555      */
   4556     public static Intent makeRestartActivityTask(ComponentName mainActivity) {
   4557         Intent intent = makeMainActivity(mainActivity);
   4558         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
   4559                 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
   4560         return intent;
   4561     }
   4562 
   4563     /**
   4564      * Call {@link #parseUri} with 0 flags.
   4565      * @deprecated Use {@link #parseUri} instead.
   4566      */
   4567     @Deprecated
   4568     public static Intent getIntent(String uri) throws URISyntaxException {
   4569         return parseUri(uri, 0);
   4570     }
   4571 
   4572     /**
   4573      * Create an intent from a URI.  This URI may encode the action,
   4574      * category, and other intent fields, if it was returned by
   4575      * {@link #toUri}.  If the Intent was not generate by toUri(), its data
   4576      * will be the entire URI and its action will be ACTION_VIEW.
   4577      *
   4578      * <p>The URI given here must not be relative -- that is, it must include
   4579      * the scheme and full path.
   4580      *
   4581      * @param uri The URI to turn into an Intent.
   4582      * @param flags Additional processing flags.  Either 0,
   4583      * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
   4584      *
   4585      * @return Intent The newly created Intent object.
   4586      *
   4587      * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
   4588      * it bad (as parsed by the Uri class) or the Intent data within the
   4589      * URI is invalid.
   4590      *
   4591      * @see #toUri
   4592      */
   4593     public static Intent parseUri(String uri, int flags) throws URISyntaxException {
   4594         int i = 0;
   4595         try {
   4596             final boolean androidApp = uri.startsWith("android-app:");
   4597 
   4598             // Validate intent scheme if requested.
   4599             if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
   4600                 if (!uri.startsWith("intent:") && !androidApp) {
   4601                     Intent intent = new Intent(ACTION_VIEW);
   4602                     try {
   4603                         intent.setData(Uri.parse(uri));
   4604                     } catch (IllegalArgumentException e) {
   4605                         throw new URISyntaxException(uri, e.getMessage());
   4606                     }
   4607                     return intent;
   4608                 }
   4609             }
   4610 
   4611             i = uri.lastIndexOf("#");
   4612             // simple case
   4613             if (i == -1) {
   4614                 if (!androidApp) {
   4615                     return new Intent(ACTION_VIEW, Uri.parse(uri));
   4616                 }
   4617 
   4618             // old format Intent URI
   4619             } else if (!uri.startsWith("#Intent;", i)) {
   4620                 if (!androidApp) {
   4621                     return getIntentOld(uri, flags);
   4622                 } else {
   4623                     i = -1;
   4624                 }
   4625             }
   4626 
   4627             // new format
   4628             Intent intent = new Intent(ACTION_VIEW);
   4629             Intent baseIntent = intent;
   4630             boolean explicitAction = false;
   4631             boolean inSelector = false;
   4632 
   4633             // fetch data part, if present
   4634             String scheme = null;
   4635             String data;
   4636             if (i >= 0) {
   4637                 data = uri.substring(0, i);
   4638                 i += 8; // length of "#Intent;"
   4639             } else {
   4640                 data = uri;
   4641             }
   4642 
   4643             // loop over contents of Intent, all name=value;
   4644             while (i >= 0 && !uri.startsWith("end", i)) {
   4645                 int eq = uri.indexOf('=', i);
   4646                 if (eq < 0) eq = i-1;
   4647                 int semi = uri.indexOf(';', i);
   4648                 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
   4649 
   4650                 // action
   4651                 if (uri.startsWith("action=", i)) {
   4652                     intent.setAction(value);
   4653                     if (!inSelector) {
   4654                         explicitAction = true;
   4655                     }
   4656                 }
   4657 
   4658                 // categories
   4659                 else if (uri.startsWith("category=", i)) {
   4660                     intent.addCategory(value);
   4661                 }
   4662 
   4663                 // type
   4664                 else if (uri.startsWith("type=", i)) {
   4665                     intent.mType = value;
   4666                 }
   4667 
   4668                 // launch flags
   4669                 else if (uri.startsWith("launchFlags=", i)) {
   4670                     intent.mFlags = Integer.decode(value).intValue();
   4671                     if ((flags& URI_ALLOW_UNSAFE) == 0) {
   4672                         intent.mFlags &= ~IMMUTABLE_FLAGS;
   4673                     }
   4674                 }
   4675 
   4676                 // package
   4677                 else if (uri.startsWith("package=", i)) {
   4678                     intent.mPackage = value;
   4679                 }
   4680 
   4681                 // component
   4682                 else if (uri.startsWith("component=", i)) {
   4683                     intent.mComponent = ComponentName.unflattenFromString(value);
   4684                 }
   4685 
   4686                 // scheme
   4687                 else if (uri.startsWith("scheme=", i)) {
   4688                     if (inSelector) {
   4689                         intent.mData = Uri.parse(value + ":");
   4690                     } else {
   4691                         scheme = value;
   4692                     }
   4693                 }
   4694 
   4695                 // source bounds
   4696                 else if (uri.startsWith("sourceBounds=", i)) {
   4697                     intent.mSourceBounds = Rect.unflattenFromString(value);
   4698                 }
   4699 
   4700                 // selector
   4701                 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
   4702                     intent = new Intent();
   4703                     inSelector = true;
   4704                 }
   4705 
   4706                 // extra
   4707                 else {
   4708                     String key = Uri.decode(uri.substring(i + 2, eq));
   4709                     // create Bundle if it doesn't already exist
   4710                     if (intent.mExtras == null) intent.mExtras = new Bundle();
   4711                     Bundle b = intent.mExtras;
   4712                     // add EXTRA
   4713                     if      (uri.startsWith("S.", i)) b.putString(key, value);
   4714                     else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
   4715                     else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
   4716                     else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
   4717                     else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
   4718                     else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
   4719                     else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
   4720                     else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
   4721                     else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
   4722                     else throw new URISyntaxException(uri, "unknown EXTRA type", i);
   4723                 }
   4724 
   4725                 // move to the next item
   4726                 i = semi + 1;
   4727             }
   4728 
   4729             if (inSelector) {
   4730                 // The Intent had a selector; fix it up.
   4731                 if (baseIntent.mPackage == null) {
   4732                     baseIntent.setSelector(intent);
   4733                 }
   4734                 intent = baseIntent;
   4735             }
   4736 
   4737             if (data != null) {
   4738                 if (data.startsWith("intent:")) {
   4739                     data = data.substring(7);
   4740                     if (scheme != null) {
   4741                         data = scheme + ':' + data;
   4742                     }
   4743                 } else if (data.startsWith("android-app:")) {
   4744                     if (data.charAt(12) == '/' && data.charAt(13) == '/') {
   4745                         // Correctly formed android-app, first part is package name.
   4746                         int end = data.indexOf('/', 14);
   4747                         if (end < 0) {
   4748                             // All we have is a package name.
   4749                             intent.mPackage = data.substring(14);
   4750                             if (!explicitAction) {
   4751                                 intent.setAction(ACTION_MAIN);
   4752                             }
   4753                             data = "";
   4754                         } else {
   4755                             // Target the Intent at the given package name always.
   4756                             String authority = null;
   4757                             intent.mPackage = data.substring(14, end);
   4758                             int newEnd;
   4759                             if ((end+1) < data.length()) {
   4760                                 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
   4761                                     // Found a scheme, remember it.
   4762                                     scheme = data.substring(end+1, newEnd);
   4763                                     end = newEnd;
   4764                                     if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
   4765                                         // Found a authority, remember it.
   4766                                         authority = data.substring(end+1, newEnd);
   4767                                         end = newEnd;
   4768                                     }
   4769                                 } else {
   4770                                     // All we have is a scheme.
   4771                                     scheme = data.substring(end+1);
   4772                                 }
   4773                             }
   4774                             if (scheme == null) {
   4775                                 // If there was no scheme, then this just targets the package.
   4776                                 if (!explicitAction) {
   4777                                     intent.setAction(ACTION_MAIN);
   4778                                 }
   4779                                 data = "";
   4780                             } else if (authority == null) {
   4781                                 data = scheme + ":";
   4782                             } else {
   4783                                 data = scheme + "://" + authority + data.substring(end);
   4784                             }
   4785                         }
   4786                     } else {
   4787                         data = "";
   4788                     }
   4789                 }
   4790 
   4791                 if (data.length() > 0) {
   4792                     try {
   4793                         intent.mData = Uri.parse(data);
   4794                     } catch (IllegalArgumentException e) {
   4795                         throw new URISyntaxException(uri, e.getMessage());
   4796                     }
   4797                 }
   4798             }
   4799 
   4800             return intent;
   4801 
   4802         } catch (IndexOutOfBoundsException e) {
   4803             throw new URISyntaxException(uri, "illegal Intent URI format", i);
   4804         }
   4805     }
   4806 
   4807     public static Intent getIntentOld(String uri) throws URISyntaxException {
   4808         return getIntentOld(uri, 0);
   4809     }
   4810 
   4811     private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
   4812         Intent intent;
   4813 
   4814         int i = uri.lastIndexOf('#');
   4815         if (i >= 0) {
   4816             String action = null;
   4817             final int intentFragmentStart = i;
   4818             boolean isIntentFragment = false;
   4819 
   4820             i++;
   4821 
   4822             if (uri.regionMatches(i, "action(", 0, 7)) {
   4823                 isIntentFragment = true;
   4824                 i += 7;
   4825                 int j = uri.indexOf(')', i);
   4826                 action = uri.substring(i, j);
   4827                 i = j + 1;
   4828             }
   4829 
   4830             intent = new Intent(action);
   4831 
   4832             if (uri.regionMatches(i, "categories(", 0, 11)) {
   4833                 isIntentFragment = true;
   4834                 i += 11;
   4835                 int j = uri.indexOf(')', i);
   4836                 while (i < j) {
   4837                     int sep = uri.indexOf('!', i);
   4838                     if (sep < 0 || sep > j) sep = j;
   4839                     if (i < sep) {
   4840                         intent.addCategory(uri.substring(i, sep));
   4841                     }
   4842                     i = sep + 1;
   4843                 }
   4844                 i = j + 1;
   4845             }
   4846 
   4847             if (uri.regionMatches(i, "type(", 0, 5)) {
   4848                 isIntentFragment = true;
   4849                 i += 5;
   4850                 int j = uri.indexOf(')', i);
   4851                 intent.mType = uri.substring(i, j);
   4852                 i = j + 1;
   4853             }
   4854 
   4855             if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
   4856                 isIntentFragment = true;
   4857                 i += 12;
   4858                 int j = uri.indexOf(')', i);
   4859                 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
   4860                 if ((flags& URI_ALLOW_UNSAFE) == 0) {
   4861                     intent.mFlags &= ~IMMUTABLE_FLAGS;
   4862                 }
   4863                 i = j + 1;
   4864             }
   4865 
   4866             if (uri.regionMatches(i, "component(", 0, 10)) {
   4867                 isIntentFragment = true;
   4868                 i += 10;
   4869                 int j = uri.indexOf(')', i);
   4870                 int sep = uri.indexOf('!', i);
   4871                 if (sep >= 0 && sep < j) {
   4872                     String pkg = uri.substring(i, sep);
   4873                     String cls = uri.substring(sep + 1, j);
   4874                     intent.mComponent = new ComponentName(pkg, cls);
   4875                 }
   4876                 i = j + 1;
   4877             }
   4878 
   4879             if (uri.regionMatches(i, "extras(", 0, 7)) {
   4880                 isIntentFragment = true;
   4881                 i += 7;
   4882 
   4883                 final int closeParen = uri.indexOf(')', i);
   4884                 if (closeParen == -1) throw new URISyntaxException(uri,
   4885                         "EXTRA missing trailing ')'", i);
   4886 
   4887                 while (i < closeParen) {
   4888                     // fetch the key value
   4889                     int j = uri.indexOf('=', i);
   4890                     if (j <= i + 1 || i >= closeParen) {
   4891                         throw new URISyntaxException(uri, "EXTRA missing '='", i);
   4892                     }
   4893                     char type = uri.charAt(i);
   4894                     i++;
   4895                     String key = uri.substring(i, j);
   4896                     i = j + 1;
   4897 
   4898                     // get type-value
   4899                     j = uri.indexOf('!', i);
   4900                     if (j == -1 || j >= closeParen) j = closeParen;
   4901                     if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
   4902                     String value = uri.substring(i, j);
   4903                     i = j;
   4904 
   4905                     // create Bundle if it doesn't already exist
   4906                     if (intent.mExtras == null) intent.mExtras = new Bundle();
   4907 
   4908                     // add item to bundle
   4909                     try {
   4910                         switch (type) {
   4911                             case 'S':
   4912                                 intent.mExtras.putString(key, Uri.decode(value));
   4913                                 break;
   4914                             case 'B':
   4915                                 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
   4916                                 break;
   4917                             case 'b':
   4918                                 intent.mExtras.putByte(key, Byte.parseByte(value));
   4919                                 break;
   4920                             case 'c':
   4921                                 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
   4922                                 break;
   4923                             case 'd':
   4924                                 intent.mExtras.putDouble(key, Double.parseDouble(value));
   4925                                 break;
   4926                             case 'f':
   4927                                 intent.mExtras.putFloat(key, Float.parseFloat(value));
   4928                                 break;
   4929                             case 'i':
   4930                                 intent.mExtras.putInt(key, Integer.parseInt(value));
   4931                                 break;
   4932                             case 'l':
   4933                                 intent.mExtras.putLong(key, Long.parseLong(value));
   4934                                 break;
   4935                             case 's':
   4936                                 intent.mExtras.putShort(key, Short.parseShort(value));
   4937                                 break;
   4938                             default:
   4939                                 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
   4940                         }
   4941                     } catch (NumberFormatException e) {
   4942                         throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
   4943                     }
   4944 
   4945                     char ch = uri.charAt(i);
   4946                     if (ch == ')') break;
   4947                     if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
   4948                     i++;
   4949                 }
   4950             }
   4951 
   4952             if (isIntentFragment) {
   4953                 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
   4954             } else {
   4955                 intent.mData = Uri.parse(uri);
   4956             }
   4957 
   4958             if (intent.mAction == null) {
   4959                 // By default, if no action is specified, then use VIEW.
   4960                 intent.mAction = ACTION_VIEW;
   4961             }
   4962 
   4963         } else {
   4964             intent = new Intent(ACTION_VIEW, Uri.parse(uri));
   4965         }
   4966 
   4967         return intent;
   4968     }
   4969 
   4970     /**
   4971      * Retrieve the general action to be performed, such as
   4972      * {@link #ACTION_VIEW}.  The action describes the general way the rest of
   4973      * the information in the intent should be interpreted -- most importantly,
   4974      * what to do with the data returned by {@link #getData}.
   4975      *
   4976      * @return The action of this intent or null if none is specified.
   4977      *
   4978      * @see #setAction
   4979      */
   4980     public String getAction() {
   4981         return mAction;
   4982     }
   4983 
   4984     /**
   4985      * Retrieve data this intent is operating on.  This URI specifies the name
   4986      * of the data; often it uses the content: scheme, specifying data in a
   4987      * content provider.  Other schemes may be handled by specific activities,
   4988      * such as http: by the web browser.
   4989      *
   4990      * @return The URI of the data this intent is targeting or null.
   4991      *
   4992      * @see #getScheme
   4993      * @see #setData
   4994      */
   4995     public Uri getData() {
   4996         return mData;
   4997     }
   4998 
   4999     /**
   5000      * The same as {@link #getData()}, but returns the URI as an encoded
   5001      * String.
   5002      */
   5003     public String getDataString() {
   5004         return mData != null ? mData.toString() : null;
   5005     }
   5006 
   5007     /**
   5008      * Return the scheme portion of the intent's data.  If the data is null or
   5009      * does not include a scheme, null is returned.  Otherwise, the scheme
   5010      * prefix without the final ':' is returned, i.e. "http".
   5011      *
   5012      * <p>This is the same as calling getData().getScheme() (and checking for
   5013      * null data).
   5014      *
   5015      * @return The scheme of this intent.
   5016      *
   5017      * @see #getData
   5018      */
   5019     public String getScheme() {
   5020         return mData != null ? mData.getScheme() : null;
   5021     }
   5022 
   5023     /**
   5024      * Retrieve any explicit MIME type included in the intent.  This is usually
   5025      * null, as the type is determined by the intent data.
   5026      *
   5027      * @return If a type was manually set, it is returned; else null is
   5028      *         returned.
   5029      *
   5030      * @see #resolveType(ContentResolver)
   5031      * @see #setType
   5032      */
   5033     public String getType() {
   5034         return mType;
   5035     }
   5036 
   5037     /**
   5038      * Return the MIME data type of this intent.  If the type field is
   5039      * explicitly set, that is simply returned.  Otherwise, if the data is set,
   5040      * the type of that data is returned.  If neither fields are set, a null is
   5041      * returned.
   5042      *
   5043      * @return The MIME type of this intent.
   5044      *
   5045      * @see #getType
   5046      * @see #resolveType(ContentResolver)
   5047      */
   5048     public String resolveType(Context context) {
   5049         return resolveType(context.getContentResolver());
   5050     }
   5051 
   5052     /**
   5053      * Return the MIME data type of this intent.  If the type field is
   5054      * explicitly set, that is simply returned.  Otherwise, if the data is set,
   5055      * the type of that data is returned.  If neither fields are set, a null is
   5056      * returned.
   5057      *
   5058      * @param resolver A ContentResolver that can be used to determine the MIME
   5059      *                 type of the intent's data.
   5060      *
   5061      * @return The MIME type of this intent.
   5062      *
   5063      * @see #getType
   5064      * @see #resolveType(Context)
   5065      */
   5066     public String resolveType(ContentResolver resolver) {
   5067         if (mType != null) {
   5068             return mType;
   5069         }
   5070         if (mData != null) {
   5071             if ("content".equals(mData.getScheme())) {
   5072                 return resolver.getType(mData);
   5073             }
   5074         }
   5075         return null;
   5076     }
   5077 
   5078     /**
   5079      * Return the MIME data type of this intent, only if it will be needed for
   5080      * intent resolution.  This is not generally useful for application code;
   5081      * it is used by the frameworks for communicating with back-end system
   5082      * services.
   5083      *
   5084      * @param resolver A ContentResolver that can be used to determine the MIME
   5085      *                 type of the intent's data.
   5086      *
   5087      * @return The MIME type of this intent, or null if it is unknown or not
   5088      *         needed.
   5089      */
   5090     public String resolveTypeIfNeeded(ContentResolver resolver) {
   5091         if (mComponent != null) {
   5092             return mType;
   5093         }
   5094         return resolveType(resolver);
   5095     }
   5096 
   5097     /**
   5098      * Check if a category exists in the intent.
   5099      *
   5100      * @param category The category to check.
   5101      *
   5102      * @return boolean True if the intent contains the category, else false.
   5103      *
   5104      * @see #getCategories
   5105      * @see #addCategory
   5106      */
   5107     public boolean hasCategory(String category) {
   5108         return mCategories != null && mCategories.contains(category);
   5109     }
   5110 
   5111     /**
   5112      * Return the set of all categories in the intent.  If there are no categories,
   5113      * returns NULL.
   5114      *
   5115      * @return The set of categories you can examine.  Do not modify!
   5116      *
   5117      * @see #hasCategory
   5118      * @see #addCategory
   5119      */
   5120     public Set<String> getCategories() {
   5121         return mCategories;
   5122     }
   5123 
   5124     /**
   5125      * Return the specific selector associated with this Intent.  If there is
   5126      * none, returns null.  See {@link #setSelector} for more information.
   5127      *
   5128      * @see #setSelector
   5129      */
   5130     public Intent getSelector() {
   5131         return mSelector;
   5132     }
   5133 
   5134     /**
   5135      * Return the {@link ClipData} associated with this Intent.  If there is
   5136      * none, returns null.  See {@link #setClipData} for more information.
   5137      *
   5138      * @see #setClipData
   5139      */
   5140     public ClipData getClipData() {
   5141         return mClipData;
   5142     }
   5143 
   5144     /** @hide */
   5145     public int getContentUserHint() {
   5146         return mContentUserHint;
   5147     }
   5148 
   5149     /**
   5150      * Sets the ClassLoader that will be used when unmarshalling
   5151      * any Parcelable values from the extras of this Intent.
   5152      *
   5153      * @param loader a ClassLoader, or null to use the default loader
   5154      * at the time of unmarshalling.
   5155      */
   5156     public void setExtrasClassLoader(ClassLoader loader) {
   5157         if (mExtras != null) {
   5158             mExtras.setClassLoader(loader);
   5159         }
   5160     }
   5161 
   5162     /**
   5163      * Returns true if an extra value is associated with the given name.
   5164      * @param name the extra's name
   5165      * @return true if the given extra is present.
   5166      */
   5167     public boolean hasExtra(String name) {
   5168         return mExtras != null && mExtras.containsKey(name);
   5169     }
   5170 
   5171     /**
   5172      * Returns true if the Intent's extras contain a parcelled file descriptor.
   5173      * @return true if the Intent contains a parcelled file descriptor.
   5174      */
   5175     public boolean hasFileDescriptors() {
   5176         return mExtras != null && mExtras.hasFileDescriptors();
   5177     }
   5178 
   5179     /** @hide */
   5180     public void setAllowFds(boolean allowFds) {
   5181         if (mExtras != null) {
   5182             mExtras.setAllowFds(allowFds);
   5183         }
   5184     }
   5185 
   5186     /**
   5187      * Retrieve extended data from the intent.
   5188      *
   5189      * @param name The name of the desired item.
   5190      *
   5191      * @return the value of an item that previously added with putExtra()
   5192      * or null if none was found.
   5193      *
   5194      * @deprecated
   5195      * @hide
   5196      */
   5197     @Deprecated
   5198     public Object getExtra(String name) {
   5199         return getExtra(name, null);
   5200     }
   5201 
   5202     /**
   5203      * Retrieve extended data from the intent.
   5204      *
   5205      * @param name The name of the desired item.
   5206      * @param defaultValue the value to be returned if no value of the desired
   5207      * type is stored with the given name.
   5208      *
   5209      * @return the value of an item that previously added with putExtra()
   5210      * or the default value if none was found.
   5211      *
   5212      * @see #putExtra(String, boolean)
   5213      */
   5214     public boolean getBooleanExtra(String name, boolean defaultValue) {
   5215         return mExtras == null ? defaultValue :
   5216             mExtras.getBoolean(name, defaultValue);
   5217     }
   5218 
   5219     /**
   5220      * Retrieve extended data from the intent.
   5221      *
   5222      * @param name The name of the desired item.
   5223      * @param defaultValue the value to be returned if no value of the desired
   5224      * type is stored with the given name.
   5225      *
   5226      * @return the value of an item that previously added with putExtra()
   5227      * or the default value if none was found.
   5228      *
   5229      * @see #putExtra(String, byte)
   5230      */
   5231     public byte getByteExtra(String name, byte defaultValue) {
   5232         return mExtras == null ? defaultValue :
   5233             mExtras.getByte(name, defaultValue);
   5234     }
   5235 
   5236     /**
   5237      * Retrieve extended data from the intent.
   5238      *
   5239      * @param name The name of the desired item.
   5240      * @param defaultValue the value to be returned if no value of the desired
   5241      * type is stored with the given name.
   5242      *
   5243      * @return the value of an item that previously added with putExtra()
   5244      * or the default value if none was found.
   5245      *
   5246      * @see #putExtra(String, short)
   5247      */
   5248     public short getShortExtra(String name, short defaultValue) {
   5249         return mExtras == null ? defaultValue :
   5250             mExtras.getShort(name, defaultValue);
   5251     }
   5252 
   5253     /**
   5254      * Retrieve extended data from the intent.
   5255      *
   5256      * @param name The name of the desired item.
   5257      * @param defaultValue the value to be returned if no value of the desired
   5258      * type is stored with the given name.
   5259      *
   5260      * @return the value of an item that previously added with putExtra()
   5261      * or the default value if none was found.
   5262      *
   5263      * @see #putExtra(String, char)
   5264      */
   5265     public char getCharExtra(String name, char defaultValue) {
   5266         return mExtras == null ? defaultValue :
   5267             mExtras.getChar(name, defaultValue);
   5268     }
   5269 
   5270     /**
   5271      * Retrieve extended data from the intent.
   5272      *
   5273      * @param name The name of the desired item.
   5274      * @param defaultValue the value to be returned if no value of the desired
   5275      * type is stored with the given name.
   5276      *
   5277      * @return the value of an item that previously added with putExtra()
   5278      * or the default value if none was found.
   5279      *
   5280      * @see #putExtra(String, int)
   5281      */
   5282     public int getIntExtra(String name, int defaultValue) {
   5283         return mExtras == null ? defaultValue :
   5284             mExtras.getInt(name, defaultValue);
   5285     }
   5286 
   5287     /**
   5288      * Retrieve extended data from the intent.
   5289      *
   5290      * @param name The name of the desired item.
   5291      * @param defaultValue the value to be returned if no value of the desired
   5292      * type is stored with the given name.
   5293      *
   5294      * @return the value of an item that previously added with putExtra()
   5295      * or the default value if none was found.
   5296      *
   5297      * @see #putExtra(String, long)
   5298      */
   5299     public long getLongExtra(String name, long defaultValue) {
   5300         return mExtras == null ? defaultValue :
   5301             mExtras.getLong(name, defaultValue);
   5302     }
   5303 
   5304     /**
   5305      * Retrieve extended data from the intent.
   5306      *
   5307      * @param name The name of the desired item.
   5308      * @param defaultValue the value to be returned if no value of the desired
   5309      * type is stored with the given name.
   5310      *
   5311      * @return the value of an item that previously added with putExtra(),
   5312      * or the default value if no such item is present
   5313      *
   5314      * @see #putExtra(String, float)
   5315      */
   5316     public float getFloatExtra(String name, float defaultValue) {
   5317         return mExtras == null ? defaultValue :
   5318             mExtras.getFloat(name, defaultValue);
   5319     }
   5320 
   5321     /**
   5322      * Retrieve extended data from the intent.
   5323      *
   5324      * @param name The name of the desired item.
   5325      * @param defaultValue the value to be returned if no value of the desired
   5326      * type is stored with the given name.
   5327      *
   5328      * @return the value of an item that previously added with putExtra()
   5329      * or the default value if none was found.
   5330      *
   5331      * @see #putExtra(String, double)
   5332      */
   5333     public double getDoubleExtra(String name, double defaultValue) {
   5334         return mExtras == null ? defaultValue :
   5335             mExtras.getDouble(name, defaultValue);
   5336     }
   5337 
   5338     /**
   5339      * Retrieve extended data from the intent.
   5340      *
   5341      * @param name The name of the desired item.
   5342      *
   5343      * @return the value of an item that previously added with putExtra()
   5344      * or null if no String value was found.
   5345      *
   5346      * @see #putExtra(String, String)
   5347      */
   5348     public String getStringExtra(String name) {
   5349         return mExtras == null ? null : mExtras.getString(name);
   5350     }
   5351 
   5352     /**
   5353      * Retrieve extended data from the intent.
   5354      *
   5355      * @param name The name of the desired item.
   5356      *
   5357      * @return the value of an item that previously added with putExtra()
   5358      * or null if no CharSequence value was found.
   5359      *
   5360      * @see #putExtra(String, CharSequence)
   5361      */
   5362     public CharSequence getCharSequenceExtra(String name) {
   5363         return mExtras == null ? null : mExtras.getCharSequence(name);
   5364     }
   5365 
   5366     /**
   5367      * Retrieve extended data from the intent.
   5368      *
   5369      * @param name The name of the desired item.
   5370      *
   5371      * @return the value of an item that previously added with putExtra()
   5372      * or null if no Parcelable value was found.
   5373      *
   5374      * @see #putExtra(String, Parcelable)
   5375      */
   5376     public <T extends Parcelable> T getParcelableExtra(String name) {
   5377         return mExtras == null ? null : mExtras.<T>getParcelable(name);
   5378     }
   5379 
   5380     /**
   5381      * Retrieve extended data from the intent.
   5382      *
   5383      * @param name The name of the desired item.
   5384      *
   5385      * @return the value of an item that previously added with putExtra()
   5386      * or null if no Parcelable[] value was found.
   5387      *
   5388      * @see #putExtra(String, Parcelable[])
   5389      */
   5390     public Parcelable[] getParcelableArrayExtra(String name) {
   5391         return mExtras == null ? null : mExtras.getParcelableArray(name);
   5392     }
   5393 
   5394     /**
   5395      * Retrieve extended data from the intent.
   5396      *
   5397      * @param name The name of the desired item.
   5398      *
   5399      * @return the value of an item that previously added with putExtra()
   5400      * or null if no ArrayList<Parcelable> value was found.
   5401      *
   5402      * @see #putParcelableArrayListExtra(String, ArrayList)
   5403      */
   5404     public <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
   5405         return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
   5406     }
   5407 
   5408     /**
   5409      * Retrieve extended data from the intent.
   5410      *
   5411      * @param name The name of the desired item.
   5412      *
   5413      * @return the value of an item that previously added with putExtra()
   5414      * or null if no Serializable value was found.
   5415      *
   5416      * @see #putExtra(String, Serializable)
   5417      */
   5418     public Serializable getSerializableExtra(String name) {
   5419         return mExtras == null ? null : mExtras.getSerializable(name);
   5420     }
   5421 
   5422     /**
   5423      * Retrieve extended data from the intent.
   5424      *
   5425      * @param name The name of the desired item.
   5426      *
   5427      * @return the value of an item that previously added with putExtra()
   5428      * or null if no ArrayList<Integer> value was found.
   5429      *
   5430      * @see #putIntegerArrayListExtra(String, ArrayList)
   5431      */
   5432     public ArrayList<Integer> getIntegerArrayListExtra(String name) {
   5433         return mExtras == null ? null : mExtras.getIntegerArrayList(name);
   5434     }
   5435 
   5436     /**
   5437      * Retrieve extended data from the intent.
   5438      *
   5439      * @param name The name of the desired item.
   5440      *
   5441      * @return the value of an item that previously added with putExtra()
   5442      * or null if no ArrayList<String> value was found.
   5443      *
   5444      * @see #putStringArrayListExtra(String, ArrayList)
   5445      */
   5446     public ArrayList<String> getStringArrayListExtra(String name) {
   5447         return mExtras == null ? null : mExtras.getStringArrayList(name);
   5448     }
   5449 
   5450     /**
   5451      * Retrieve extended data from the intent.
   5452      *
   5453      * @param name The name of the desired item.
   5454      *
   5455      * @return the value of an item that previously added with putExtra()
   5456      * or null if no ArrayList<CharSequence> value was found.
   5457      *
   5458      * @see #putCharSequenceArrayListExtra(String, ArrayList)
   5459      */
   5460     public ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
   5461         return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
   5462     }
   5463 
   5464     /**
   5465      * Retrieve extended data from the intent.
   5466      *
   5467      * @param name The name of the desired item.
   5468      *
   5469      * @return the value of an item that previously added with putExtra()
   5470      * or null if no boolean array value was found.
   5471      *
   5472      * @see #putExtra(String, boolean[])
   5473      */
   5474     public boolean[] getBooleanArrayExtra(String name) {
   5475         return mExtras == null ? null : mExtras.getBooleanArray(name);
   5476     }
   5477 
   5478     /**
   5479      * Retrieve extended data from the intent.
   5480      *
   5481      * @param name The name of the desired item.
   5482      *
   5483      * @return the value of an item that previously added with putExtra()
   5484      * or null if no byte array value was found.
   5485      *
   5486      * @see #putExtra(String, byte[])
   5487      */
   5488     public byte[] getByteArrayExtra(String name) {
   5489         return mExtras == null ? null : mExtras.getByteArray(name);
   5490     }
   5491 
   5492     /**
   5493      * Retrieve extended data from the intent.
   5494      *
   5495      * @param name The name of the desired item.
   5496      *
   5497      * @return the value of an item that previously added with putExtra()
   5498      * or null if no short array value was found.
   5499      *
   5500      * @see #putExtra(String, short[])
   5501      */
   5502     public short[] getShortArrayExtra(String name) {
   5503         return mExtras == null ? null : mExtras.getShortArray(name);
   5504     }
   5505 
   5506     /**
   5507      * Retrieve extended data from the intent.
   5508      *
   5509      * @param name The name of the desired item.
   5510      *
   5511      * @return the value of an item that previously added with putExtra()
   5512      * or null if no char array value was found.
   5513      *
   5514      * @see #putExtra(String, char[])
   5515      */
   5516     public char[] getCharArrayExtra(String name) {
   5517         return mExtras == null ? null : mExtras.getCharArray(name);
   5518     }
   5519 
   5520     /**
   5521      * Retrieve extended data from the intent.
   5522      *
   5523      * @param name The name of the desired item.
   5524      *
   5525      * @return the value of an item that previously added with putExtra()
   5526      * or null if no int array value was found.
   5527      *
   5528      * @see #putExtra(String, int[])
   5529      */
   5530     public int[] getIntArrayExtra(String name) {
   5531         return mExtras == null ? null : mExtras.getIntArray(name);
   5532     }
   5533 
   5534     /**
   5535      * Retrieve extended data from the intent.
   5536      *
   5537      * @param name The name of the desired item.
   5538      *
   5539      * @return the value of an item that previously added with putExtra()
   5540      * or null if no long array value was found.
   5541      *
   5542      * @see #putExtra(String, long[])
   5543      */
   5544     public long[] getLongArrayExtra(String name) {
   5545         return mExtras == null ? null : mExtras.getLongArray(name);
   5546     }
   5547 
   5548     /**
   5549      * Retrieve extended data from the intent.
   5550      *
   5551      * @param name The name of the desired item.
   5552      *
   5553      * @return the value of an item that previously added with putExtra()
   5554      * or null if no float array value was found.
   5555      *
   5556      * @see #putExtra(String, float[])
   5557      */
   5558     public float[] getFloatArrayExtra(String name) {
   5559         return mExtras == null ? null : mExtras.getFloatArray(name);
   5560     }
   5561 
   5562     /**
   5563      * Retrieve extended data from the intent.
   5564      *
   5565      * @param name The name of the desired item.
   5566      *
   5567      * @return the value of an item that previously added with putExtra()
   5568      * or null if no double array value was found.
   5569      *
   5570      * @see #putExtra(String, double[])
   5571      */
   5572     public double[] getDoubleArrayExtra(String name) {
   5573         return mExtras == null ? null : mExtras.getDoubleArray(name);
   5574     }
   5575 
   5576     /**
   5577      * Retrieve extended data from the intent.
   5578      *
   5579      * @param name The name of the desired item.
   5580      *
   5581      * @return the value of an item that previously added with putExtra()
   5582      * or null if no String array value was found.
   5583      *
   5584      * @see #putExtra(String, String[])
   5585      */
   5586     public String[] getStringArrayExtra(String name) {
   5587         return mExtras == null ? null : mExtras.getStringArray(name);
   5588     }
   5589 
   5590     /**
   5591      * Retrieve extended data from the intent.
   5592      *
   5593      * @param name The name of the desired item.
   5594      *
   5595      * @return the value of an item that previously added with putExtra()
   5596      * or null if no CharSequence array value was found.
   5597      *
   5598      * @see #putExtra(String, CharSequence[])
   5599      */
   5600     public CharSequence[] getCharSequenceArrayExtra(String name) {
   5601         return mExtras == null ? null : mExtras.getCharSequenceArray(name);
   5602     }
   5603 
   5604     /**
   5605      * Retrieve extended data from the intent.
   5606      *
   5607      * @param name The name of the desired item.
   5608      *
   5609      * @return the value of an item that previously added with putExtra()
   5610      * or null if no Bundle value was found.
   5611      *
   5612      * @see #putExtra(String, Bundle)
   5613      */
   5614     public Bundle getBundleExtra(String name) {
   5615         return mExtras == null ? null : mExtras.getBundle(name);
   5616     }
   5617 
   5618     /**
   5619      * Retrieve extended data from the intent.
   5620      *
   5621      * @param name The name of the desired item.
   5622      *
   5623      * @return the value of an item that previously added with putExtra()
   5624      * or null if no IBinder value was found.
   5625      *
   5626      * @see #putExtra(String, IBinder)
   5627      *
   5628      * @deprecated
   5629      * @hide
   5630      */
   5631     @Deprecated
   5632     public IBinder getIBinderExtra(String name) {
   5633         return mExtras == null ? null : mExtras.getIBinder(name);
   5634     }
   5635 
   5636     /**
   5637      * Retrieve extended data from the intent.
   5638      *
   5639      * @param name The name of the desired item.
   5640      * @param defaultValue The default value to return in case no item is
   5641      * associated with the key 'name'
   5642      *
   5643      * @return the value of an item that previously added with putExtra()
   5644      * or defaultValue if none was found.
   5645      *
   5646      * @see #putExtra
   5647      *
   5648      * @deprecated
   5649      * @hide
   5650      */
   5651     @Deprecated
   5652     public Object getExtra(String name, Object defaultValue) {
   5653         Object result = defaultValue;
   5654         if (mExtras != null) {
   5655             Object result2 = mExtras.get(name);
   5656             if (result2 != null) {
   5657                 result = result2;
   5658             }
   5659         }
   5660 
   5661         return result;
   5662     }
   5663 
   5664     /**
   5665      * Retrieves a map of extended data from the intent.
   5666      *
   5667      * @return the map of all extras previously added with putExtra(),
   5668      * or null if none have been added.
   5669      */
   5670     public Bundle getExtras() {
   5671         return (mExtras != null)
   5672                 ? new Bundle(mExtras)
   5673                 : null;
   5674     }
   5675 
   5676     /**
   5677      * Filter extras to only basic types.
   5678      * @hide
   5679      */
   5680     public void removeUnsafeExtras() {
   5681         if (mExtras != null) {
   5682             mExtras.filterValues();
   5683         }
   5684     }
   5685 
   5686     /**
   5687      * Retrieve any special flags associated with this intent.  You will
   5688      * normally just set them with {@link #setFlags} and let the system
   5689      * take the appropriate action with them.
   5690      *
   5691      * @return int The currently set flags.
   5692      *
   5693      * @see #setFlags
   5694      */
   5695     public int getFlags() {
   5696         return mFlags;
   5697     }
   5698 
   5699     /** @hide */
   5700     public boolean isExcludingStopped() {
   5701         return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
   5702                 == FLAG_EXCLUDE_STOPPED_PACKAGES;
   5703     }
   5704 
   5705     /**
   5706      * Retrieve the application package name this Intent is limited to.  When
   5707      * resolving an Intent, if non-null this limits the resolution to only
   5708      * components in the given application package.
   5709      *
   5710      * @return The name of the application package for the Intent.
   5711      *
   5712      * @see #resolveActivity
   5713      * @see #setPackage
   5714      */
   5715     public String getPackage() {
   5716         return mPackage;
   5717     }
   5718 
   5719     /**
   5720      * Retrieve the concrete component associated with the intent.  When receiving
   5721      * an intent, this is the component that was found to best handle it (that is,
   5722      * yourself) and will always be non-null; in all other cases it will be
   5723      * null unless explicitly set.
   5724      *
   5725      * @return The name of the application component to handle the intent.
   5726      *
   5727      * @see #resolveActivity
   5728      * @see #setComponent
   5729      */
   5730     public ComponentName getComponent() {
   5731         return mComponent;
   5732     }
   5733 
   5734     /**
   5735      * Get the bounds of the sender of this intent, in screen coordinates.  This can be
   5736      * used as a hint to the receiver for animations and the like.  Null means that there
   5737      * is no source bounds.
   5738      */
   5739     public Rect getSourceBounds() {
   5740         return mSourceBounds;
   5741     }
   5742 
   5743     /**
   5744      * Return the Activity component that should be used to handle this intent.
   5745      * The appropriate component is determined based on the information in the
   5746      * intent, evaluated as follows:
   5747      *
   5748      * <p>If {@link #getComponent} returns an explicit class, that is returned
   5749      * without any further consideration.
   5750      *
   5751      * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
   5752      * category to be considered.
   5753      *
   5754      * <p>If {@link #getAction} is non-NULL, the activity must handle this
   5755      * action.
   5756      *
   5757      * <p>If {@link #resolveType} returns non-NULL, the activity must handle
   5758      * this type.
   5759      *
   5760      * <p>If {@link #addCategory} has added any categories, the activity must
   5761      * handle ALL of the categories specified.
   5762      *
   5763      * <p>If {@link #getPackage} is non-NULL, only activity components in
   5764      * that application package will be considered.
   5765      *
   5766      * <p>If there are no activities that satisfy all of these conditions, a
   5767      * null string is returned.
   5768      *
   5769      * <p>If multiple activities are found to satisfy the intent, the one with
   5770      * the highest priority will be used.  If there are multiple activities
   5771      * with the same priority, the system will either pick the best activity
   5772      * based on user preference, or resolve to a system class that will allow
   5773      * the user to pick an activity and forward from there.
   5774      *
   5775      * <p>This method is implemented simply by calling
   5776      * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
   5777      * true.</p>
   5778      * <p> This API is called for you as part of starting an activity from an
   5779      * intent.  You do not normally need to call it yourself.</p>
   5780      *
   5781      * @param pm The package manager with which to resolve the Intent.
   5782      *
   5783      * @return Name of the component implementing an activity that can
   5784      *         display the intent.
   5785      *
   5786      * @see #setComponent
   5787      * @see #getComponent
   5788      * @see #resolveActivityInfo
   5789      */
   5790     public ComponentName resolveActivity(PackageManager pm) {
   5791         if (mComponent != null) {
   5792             return mComponent;
   5793         }
   5794 
   5795         ResolveInfo info = pm.resolveActivity(
   5796             this, PackageManager.MATCH_DEFAULT_ONLY);
   5797         if (info != null) {
   5798             return new ComponentName(
   5799                     info.activityInfo.applicationInfo.packageName,
   5800                     info.activityInfo.name);
   5801         }
   5802 
   5803         return null;
   5804     }
   5805 
   5806     /**
   5807      * Resolve the Intent into an {@link ActivityInfo}
   5808      * describing the activity that should execute the intent.  Resolution
   5809      * follows the same rules as described for {@link #resolveActivity}, but
   5810      * you get back the completely information about the resolved activity
   5811      * instead of just its class name.
   5812      *
   5813      * @param pm The package manager with which to resolve the Intent.
   5814      * @param flags Addition information to retrieve as per
   5815      * {@link PackageManager#getActivityInfo(ComponentName, int)
   5816      * PackageManager.getActivityInfo()}.
   5817      *
   5818      * @return PackageManager.ActivityInfo
   5819      *
   5820      * @see #resolveActivity
   5821      */
   5822     public ActivityInfo resolveActivityInfo(PackageManager pm, int flags) {
   5823         ActivityInfo ai = null;
   5824         if (mComponent != null) {
   5825             try {
   5826                 ai = pm.getActivityInfo(mComponent, flags);
   5827             } catch (PackageManager.NameNotFoundException e) {
   5828                 // ignore
   5829             }
   5830         } else {
   5831             ResolveInfo info = pm.resolveActivity(
   5832                 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
   5833             if (info != null) {
   5834                 ai = info.activityInfo;
   5835             }
   5836         }
   5837 
   5838         return ai;
   5839     }
   5840 
   5841     /**
   5842      * Special function for use by the system to resolve service
   5843      * intents to system apps.  Throws an exception if there are
   5844      * multiple potential matches to the Intent.  Returns null if
   5845      * there are no matches.
   5846      * @hide
   5847      */
   5848     public ComponentName resolveSystemService(PackageManager pm, int flags) {
   5849         if (mComponent != null) {
   5850             return mComponent;
   5851         }
   5852 
   5853         List<ResolveInfo> results = pm.queryIntentServices(this, flags);
   5854         if (results == null) {
   5855             return null;
   5856         }
   5857         ComponentName comp = null;
   5858         for (int i=0; i<results.size(); i++) {
   5859             ResolveInfo ri = results.get(i);
   5860             if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
   5861                 continue;
   5862             }
   5863             ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
   5864                     ri.serviceInfo.name);
   5865             if (comp != null) {
   5866                 throw new IllegalStateException("Multiple system services handle " + this
   5867                         + ": " + comp + ", " + foundComp);
   5868             }
   5869             comp = foundComp;
   5870         }
   5871         return comp;
   5872     }
   5873 
   5874     /**
   5875      * Set the general action to be performed.
   5876      *
   5877      * @param action An action name, such as ACTION_VIEW.  Application-specific
   5878      *               actions should be prefixed with the vendor's package name.
   5879      *
   5880      * @return Returns the same Intent object, for chaining multiple calls
   5881      * into a single statement.
   5882      *
   5883      * @see #getAction
   5884      */
   5885     public Intent setAction(String action) {
   5886         mAction = action != null ? action.intern() : null;
   5887         return this;
   5888     }
   5889 
   5890     /**
   5891      * Set the data this intent is operating on.  This method automatically
   5892      * clears any type that was previously set by {@link #setType} or
   5893      * {@link #setTypeAndNormalize}.
   5894      *
   5895      * <p><em>Note: scheme matching in the Android framework is
   5896      * case-sensitive, unlike the formal RFC. As a result,
   5897      * you should always write your Uri with a lower case scheme,
   5898      * or use {@link Uri#normalizeScheme} or
   5899      * {@link #setDataAndNormalize}
   5900      * to ensure that the scheme is converted to lower case.</em>
   5901      *
   5902      * @param data The Uri of the data this intent is now targeting.
   5903      *
   5904      * @return Returns the same Intent object, for chaining multiple calls
   5905      * into a single statement.
   5906      *
   5907      * @see #getData
   5908      * @see #setDataAndNormalize
   5909      * @see android.net.Uri#normalizeScheme()
   5910      */
   5911     public Intent setData(Uri data) {
   5912         mData = data;
   5913         mType = null;
   5914         return this;
   5915     }
   5916 
   5917     /**
   5918      * Normalize and set the data this intent is operating on.
   5919      *
   5920      * <p>This method automatically clears any type that was
   5921      * previously set (for example, by {@link #setType}).
   5922      *
   5923      * <p>The data Uri is normalized using
   5924      * {@link android.net.Uri#normalizeScheme} before it is set,
   5925      * so really this is just a convenience method for
   5926      * <pre>
   5927      * setData(data.normalize())
   5928      * </pre>
   5929      *
   5930      * @param data The Uri of the data this intent is now targeting.
   5931      *
   5932      * @return Returns the same Intent object, for chaining multiple calls
   5933      * into a single statement.
   5934      *
   5935      * @see #getData
   5936      * @see #setType
   5937      * @see android.net.Uri#normalizeScheme
   5938      */
   5939     public Intent setDataAndNormalize(Uri data) {
   5940         return setData(data.normalizeScheme());
   5941     }
   5942 
   5943     /**
   5944      * Set an explicit MIME data type.
   5945      *
   5946      * <p>This is used to create intents that only specify a type and not data,
   5947      * for example to indicate the type of data to return.
   5948      *
   5949      * <p>This method automatically clears any data that was
   5950      * previously set (for example by {@link #setData}).
   5951      *
   5952      * <p><em>Note: MIME type matching in the Android framework is
   5953      * case-sensitive, unlike formal RFC MIME types.  As a result,
   5954      * you should always write your MIME types with lower case letters,
   5955      * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
   5956      * to ensure that it is converted to lower case.</em>
   5957      *
   5958      * @param type The MIME type of the data being handled by this intent.
   5959      *
   5960      * @return Returns the same Intent object, for chaining multiple calls
   5961      * into a single statement.
   5962      *
   5963      * @see #getType
   5964      * @see #setTypeAndNormalize
   5965      * @see #setDataAndType
   5966      * @see #normalizeMimeType
   5967      */
   5968     public Intent setType(String type) {
   5969         mData = null;
   5970         mType = type;
   5971         return this;
   5972     }
   5973 
   5974     /**
   5975      * Normalize and set an explicit MIME data type.
   5976      *
   5977      * <p>This is used to create intents that only specify a type and not data,
   5978      * for example to indicate the type of data to return.
   5979      *
   5980      * <p>This method automatically clears any data that was
   5981      * previously set (for example by {@link #setData}).
   5982      *
   5983      * <p>The MIME type is normalized using
   5984      * {@link #normalizeMimeType} before it is set,
   5985      * so really this is just a convenience method for
   5986      * <pre>
   5987      * setType(Intent.normalizeMimeType(type))
   5988      * </pre>
   5989      *
   5990      * @param type The MIME type of the data being handled by this intent.
   5991      *
   5992      * @return Returns the same Intent object, for chaining multiple calls
   5993      * into a single statement.
   5994      *
   5995      * @see #getType
   5996      * @see #setData
   5997      * @see #normalizeMimeType
   5998      */
   5999     public Intent setTypeAndNormalize(String type) {
   6000         return setType(normalizeMimeType(type));
   6001     }
   6002 
   6003     /**
   6004      * (Usually optional) Set the data for the intent along with an explicit
   6005      * MIME data type.  This method should very rarely be used -- it allows you
   6006      * to override the MIME type that would ordinarily be inferred from the
   6007      * data with your own type given here.
   6008      *
   6009      * <p><em>Note: MIME type and Uri scheme matching in the
   6010      * Android framework is case-sensitive, unlike the formal RFC definitions.
   6011      * As a result, you should always write these elements with lower case letters,
   6012      * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
   6013      * {@link #setDataAndTypeAndNormalize}
   6014      * to ensure that they are converted to lower case.</em>
   6015      *
   6016      * @param data The Uri of the data this intent is now targeting.
   6017      * @param type The MIME type of the data being handled by this intent.
   6018      *
   6019      * @return Returns the same Intent object, for chaining multiple calls
   6020      * into a single statement.
   6021      *
   6022      * @see #setType
   6023      * @see #setData
   6024      * @see #normalizeMimeType
   6025      * @see android.net.Uri#normalizeScheme
   6026      * @see #setDataAndTypeAndNormalize
   6027      */
   6028     public Intent setDataAndType(Uri data, String type) {
   6029         mData = data;
   6030         mType = type;
   6031         return this;
   6032     }
   6033 
   6034     /**
   6035      * (Usually optional) Normalize and set both the data Uri and an explicit
   6036      * MIME data type.  This method should very rarely be used -- it allows you
   6037      * to override the MIME type that would ordinarily be inferred from the
   6038      * data with your own type given here.
   6039      *
   6040      * <p>The data Uri and the MIME type are normalize using
   6041      * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
   6042      * before they are set, so really this is just a convenience method for
   6043      * <pre>
   6044      * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
   6045      * </pre>
   6046      *
   6047      * @param data The Uri of the data this intent is now targeting.
   6048      * @param type The MIME type of the data being handled by this intent.
   6049      *
   6050      * @return Returns the same Intent object, for chaining multiple calls
   6051      * into a single statement.
   6052      *
   6053      * @see #setType
   6054      * @see #setData
   6055      * @see #setDataAndType
   6056      * @see #normalizeMimeType
   6057      * @see android.net.Uri#normalizeScheme
   6058      */
   6059     public Intent setDataAndTypeAndNormalize(Uri data, String type) {
   6060         return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
   6061     }
   6062 
   6063     /**
   6064      * Add a new category to the intent.  Categories provide additional detail
   6065      * about the action the intent performs.  When resolving an intent, only
   6066      * activities that provide <em>all</em> of the requested categories will be
   6067      * used.
   6068      *
   6069      * @param category The desired category.  This can be either one of the
   6070      *               predefined Intent categories, or a custom category in your own
   6071      *               namespace.
   6072      *
   6073      * @return Returns the same Intent object, for chaining multiple calls
   6074      * into a single statement.
   6075      *
   6076      * @see #hasCategory
   6077      * @see #removeCategory
   6078      */
   6079     public Intent addCategory(String category) {
   6080         if (mCategories == null) {
   6081             mCategories = new ArraySet<String>();
   6082         }
   6083         mCategories.add(category.intern());
   6084         return this;
   6085     }
   6086 
   6087     /**
   6088      * Remove a category from an intent.
   6089      *
   6090      * @param category The category to remove.
   6091      *
   6092      * @see #addCategory
   6093      */
   6094     public void removeCategory(String category) {
   6095         if (mCategories != null) {
   6096             mCategories.remove(category);
   6097             if (mCategories.size() == 0) {
   6098                 mCategories = null;
   6099             }
   6100         }
   6101     }
   6102 
   6103     /**
   6104      * Set a selector for this Intent.  This is a modification to the kinds of
   6105      * things the Intent will match.  If the selector is set, it will be used
   6106      * when trying to find entities that can handle the Intent, instead of the
   6107      * main contents of the Intent.  This allows you build an Intent containing
   6108      * a generic protocol while targeting it more specifically.
   6109      *
   6110      * <p>An example of where this may be used is with things like
   6111      * {@link #CATEGORY_APP_BROWSER}.  This category allows you to build an
   6112      * Intent that will launch the Browser application.  However, the correct
   6113      * main entry point of an application is actually {@link #ACTION_MAIN}
   6114      * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
   6115      * used to specify the actual Activity to launch.  If you launch the browser
   6116      * with something different, undesired behavior may happen if the user has
   6117      * previously or later launches it the normal way, since they do not match.
   6118      * Instead, you can build an Intent with the MAIN action (but no ComponentName
   6119      * yet specified) and set a selector with {@link #ACTION_MAIN} and
   6120      * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
   6121      *
   6122      * <p>Setting a selector does not impact the behavior of
   6123      * {@link #filterEquals(Intent)} and {@link #filterHashCode()}.  This is part of the
   6124      * desired behavior of a selector -- it does not impact the base meaning
   6125      * of the Intent, just what kinds of things will be matched against it
   6126      * when determining who can handle it.</p>
   6127      *
   6128      * <p>You can not use both a selector and {@link #setPackage(String)} on
   6129      * the same base Intent.</p>
   6130      *
   6131      * @param selector The desired selector Intent; set to null to not use
   6132      * a special selector.
   6133      */
   6134     public void setSelector(Intent selector) {
   6135         if (selector == this) {
   6136             throw new IllegalArgumentException(
   6137                     "Intent being set as a selector of itself");
   6138         }
   6139         if (selector != null && mPackage != null) {
   6140             throw new IllegalArgumentException(
   6141                     "Can't set selector when package name is already set");
   6142         }
   6143         mSelector = selector;
   6144     }
   6145 
   6146     /**
   6147      * Set a {@link ClipData} associated with this Intent.  This replaces any
   6148      * previously set ClipData.
   6149      *
   6150      * <p>The ClipData in an intent is not used for Intent matching or other
   6151      * such operations.  Semantically it is like extras, used to transmit
   6152      * additional data with the Intent.  The main feature of using this over
   6153      * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
   6154      * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
   6155      * items included in the clip data.  This is useful, in particular, if
   6156      * you want to transmit an Intent containing multiple <code>content:</code>
   6157      * URIs for which the recipient may not have global permission to access the
   6158      * content provider.
   6159      *
   6160      * <p>If the ClipData contains items that are themselves Intents, any
   6161      * grant flags in those Intents will be ignored.  Only the top-level flags
   6162      * of the main Intent are respected, and will be applied to all Uri or
   6163      * Intent items in the clip (or sub-items of the clip).
   6164      *
   6165      * <p>The MIME type, label, and icon in the ClipData object are not
   6166      * directly used by Intent.  Applications should generally rely on the
   6167      * MIME type of the Intent itself, not what it may find in the ClipData.
   6168      * A common practice is to construct a ClipData for use with an Intent
   6169      * with a MIME type of "*&#47;*".
   6170      *
   6171      * @param clip The new clip to set.  May be null to clear the current clip.
   6172      */
   6173     public void setClipData(ClipData clip) {
   6174         mClipData = clip;
   6175     }
   6176 
   6177     /**
   6178      * This is NOT a secure mechanism to identify the user who sent the intent.
   6179      * When the intent is sent to a different user, it is used to fix uris by adding the userId
   6180      * who sent the intent.
   6181      * @hide
   6182      */
   6183     public void prepareToLeaveUser(int userId) {
   6184         // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
   6185         // We want mContentUserHint to refer to the original user, so don't do anything.
   6186         if (mContentUserHint == UserHandle.USER_CURRENT) {
   6187             mContentUserHint = userId;
   6188         }
   6189     }
   6190 
   6191     /**
   6192      * Add extended data to the intent.  The name must include a package
   6193      * prefix, for example the app com.android.contacts would use names
   6194      * like "com.android.contacts.ShowAll".
   6195      *
   6196      * @param name The name of the extra data, with package prefix.
   6197      * @param value The boolean data value.
   6198      *
   6199      * @return Returns the same Intent object, for chaining multiple calls
   6200      * into a single statement.
   6201      *
   6202      * @see #putExtras
   6203      * @see #removeExtra
   6204      * @see #getBooleanExtra(String, boolean)
   6205      */
   6206     public Intent putExtra(String name, boolean value) {
   6207         if (mExtras == null) {
   6208             mExtras = new Bundle();
   6209         }
   6210         mExtras.putBoolean(name, value);
   6211         return this;
   6212     }
   6213 
   6214     /**
   6215      * Add extended data to the intent.  The name must include a package
   6216      * prefix, for example the app com.android.contacts would use names
   6217      * like "com.android.contacts.ShowAll".
   6218      *
   6219      * @param name The name of the extra data, with package prefix.
   6220      * @param value The byte data value.
   6221      *
   6222      * @return Returns the same Intent object, for chaining multiple calls
   6223      * into a single statement.
   6224      *
   6225      * @see #putExtras
   6226      * @see #removeExtra
   6227      * @see #getByteExtra(String, byte)
   6228      */
   6229     public Intent putExtra(String name, byte value) {
   6230         if (mExtras == null) {
   6231             mExtras = new Bundle();
   6232         }
   6233         mExtras.putByte(name, value);
   6234         return this;
   6235     }
   6236 
   6237     /**
   6238      * Add extended data to the intent.  The name must include a package
   6239      * prefix, for example the app com.android.contacts would use names
   6240      * like "com.android.contacts.ShowAll".
   6241      *
   6242      * @param name The name of the extra data, with package prefix.
   6243      * @param value The char data value.
   6244      *
   6245      * @return Returns the same Intent object, for chaining multiple calls
   6246      * into a single statement.
   6247      *
   6248      * @see #putExtras
   6249      * @see #removeExtra
   6250      * @see #getCharExtra(String, char)
   6251      */
   6252     public Intent putExtra(String name, char value) {
   6253         if (mExtras == null) {
   6254             mExtras = new Bundle();
   6255         }
   6256         mExtras.putChar(name, value);
   6257         return this;
   6258     }
   6259 
   6260     /**
   6261      * Add extended data to the intent.  The name must include a package
   6262      * prefix, for example the app com.android.contacts would use names
   6263      * like "com.android.contacts.ShowAll".
   6264      *
   6265      * @param name The name of the extra data, with package prefix.
   6266      * @param value The short data value.
   6267      *
   6268      * @return Returns the same Intent object, for chaining multiple calls
   6269      * into a single statement.
   6270      *
   6271      * @see #putExtras
   6272      * @see #removeExtra
   6273      * @see #getShortExtra(String, short)
   6274      */
   6275     public Intent putExtra(String name, short value) {
   6276         if (mExtras == null) {
   6277             mExtras = new Bundle();
   6278         }
   6279         mExtras.putShort(name, value);
   6280         return this;
   6281     }
   6282 
   6283     /**
   6284      * Add extended data to the intent.  The name must include a package
   6285      * prefix, for example the app com.android.contacts would use names
   6286      * like "com.android.contacts.ShowAll".
   6287      *
   6288      * @param name The name of the extra data, with package prefix.
   6289      * @param value The integer data value.
   6290      *
   6291      * @return Returns the same Intent object, for chaining multiple calls
   6292      * into a single statement.
   6293      *
   6294      * @see #putExtras
   6295      * @see #removeExtra
   6296      * @see #getIntExtra(String, int)
   6297      */
   6298     public Intent putExtra(String name, int value) {
   6299         if (mExtras == null) {
   6300             mExtras = new Bundle();
   6301         }
   6302         mExtras.putInt(name, value);
   6303         return this;
   6304     }
   6305 
   6306     /**
   6307      * Add extended data to the intent.  The name must include a package
   6308      * prefix, for example the app com.android.contacts would use names
   6309      * like "com.android.contacts.ShowAll".
   6310      *
   6311      * @param name The name of the extra data, with package prefix.
   6312      * @param value The long data value.
   6313      *
   6314      * @return Returns the same Intent object, for chaining multiple calls
   6315      * into a single statement.
   6316      *
   6317      * @see #putExtras
   6318      * @see #removeExtra
   6319      * @see #getLongExtra(String, long)
   6320      */
   6321     public Intent putExtra(String name, long value) {
   6322         if (mExtras == null) {
   6323             mExtras = new Bundle();
   6324         }
   6325         mExtras.putLong(name, value);
   6326         return this;
   6327     }
   6328 
   6329     /**
   6330      * Add extended data to the intent.  The name must include a package
   6331      * prefix, for example the app com.android.contacts would use names
   6332      * like "com.android.contacts.ShowAll".
   6333      *
   6334      * @param name The name of the extra data, with package prefix.
   6335      * @param value The float data value.
   6336      *
   6337      * @return Returns the same Intent object, for chaining multiple calls
   6338      * into a single statement.
   6339      *
   6340      * @see #putExtras
   6341      * @see #removeExtra
   6342      * @see #getFloatExtra(String, float)
   6343      */
   6344     public Intent putExtra(String name, float value) {
   6345         if (mExtras == null) {
   6346             mExtras = new Bundle();
   6347         }
   6348         mExtras.putFloat(name, value);
   6349         return this;
   6350     }
   6351 
   6352     /**
   6353      * Add extended data to the intent.  The name must include a package
   6354      * prefix, for example the app com.android.contacts would use names
   6355      * like "com.android.contacts.ShowAll".
   6356      *
   6357      * @param name The name of the extra data, with package prefix.
   6358      * @param value The double data value.
   6359      *
   6360      * @return Returns the same Intent object, for chaining multiple calls
   6361      * into a single statement.
   6362      *
   6363      * @see #putExtras
   6364      * @see #removeExtra
   6365      * @see #getDoubleExtra(String, double)
   6366      */
   6367     public Intent putExtra(String name, double value) {
   6368         if (mExtras == null) {
   6369             mExtras = new Bundle();
   6370         }
   6371         mExtras.putDouble(name, value);
   6372         return this;
   6373     }
   6374 
   6375     /**
   6376      * Add extended data to the intent.  The name must include a package
   6377      * prefix, for example the app com.android.contacts would use names
   6378      * like "com.android.contacts.ShowAll".
   6379      *
   6380      * @param name The name of the extra data, with package prefix.
   6381      * @param value The String data value.
   6382      *
   6383      * @return Returns the same Intent object, for chaining multiple calls
   6384      * into a single statement.
   6385      *
   6386      * @see #putExtras
   6387      * @see #removeExtra
   6388      * @see #getStringExtra(String)
   6389      */
   6390     public Intent putExtra(String name, String value) {
   6391         if (mExtras == null) {
   6392             mExtras = new Bundle();
   6393         }
   6394         mExtras.putString(name, value);
   6395         return this;
   6396     }
   6397 
   6398     /**
   6399      * Add extended data to the intent.  The name must include a package
   6400      * prefix, for example the app com.android.contacts would use names
   6401      * like "com.android.contacts.ShowAll".
   6402      *
   6403      * @param name The name of the extra data, with package prefix.
   6404      * @param value The CharSequence data value.
   6405      *
   6406      * @return Returns the same Intent object, for chaining multiple calls
   6407      * into a single statement.
   6408      *
   6409      * @see #putExtras
   6410      * @see #removeExtra
   6411      * @see #getCharSequenceExtra(String)
   6412      */
   6413     public Intent putExtra(String name, CharSequence value) {
   6414         if (mExtras == null) {
   6415             mExtras = new Bundle();
   6416         }
   6417         mExtras.putCharSequence(name, value);
   6418         return this;
   6419     }
   6420 
   6421     /**
   6422      * Add extended data to the intent.  The name must include a package
   6423      * prefix, for example the app com.android.contacts would use names
   6424      * like "com.android.contacts.ShowAll".
   6425      *
   6426      * @param name The name of the extra data, with package prefix.
   6427      * @param value The Parcelable data value.
   6428      *
   6429      * @return Returns the same Intent object, for chaining multiple calls
   6430      * into a single statement.
   6431      *
   6432      * @see #putExtras
   6433      * @see #removeExtra
   6434      * @see #getParcelableExtra(String)
   6435      */
   6436     public Intent putExtra(String name, Parcelable value) {
   6437         if (mExtras == null) {
   6438             mExtras = new Bundle();
   6439         }
   6440         mExtras.putParcelable(name, value);
   6441         return this;
   6442     }
   6443 
   6444     /**
   6445      * Add extended data to the intent.  The name must include a package
   6446      * prefix, for example the app com.android.contacts would use names
   6447      * like "com.android.contacts.ShowAll".
   6448      *
   6449      * @param name The name of the extra data, with package prefix.
   6450      * @param value The Parcelable[] data value.
   6451      *
   6452      * @return Returns the same Intent object, for chaining multiple calls
   6453      * into a single statement.
   6454      *
   6455      * @see #putExtras
   6456      * @see #removeExtra
   6457      * @see #getParcelableArrayExtra(String)
   6458      */
   6459     public Intent putExtra(String name, Parcelable[] value) {
   6460         if (mExtras == null) {
   6461             mExtras = new Bundle();
   6462         }
   6463         mExtras.putParcelableArray(name, value);
   6464         return this;
   6465     }
   6466 
   6467     /**
   6468      * Add extended data to the intent.  The name must include a package
   6469      * prefix, for example the app com.android.contacts would use names
   6470      * like "com.android.contacts.ShowAll".
   6471      *
   6472      * @param name The name of the extra data, with package prefix.
   6473      * @param value The ArrayList<Parcelable> data value.
   6474      *
   6475      * @return Returns the same Intent object, for chaining multiple calls
   6476      * into a single statement.
   6477      *
   6478      * @see #putExtras
   6479      * @see #removeExtra
   6480      * @see #getParcelableArrayListExtra(String)
   6481      */
   6482     public Intent putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value) {
   6483         if (mExtras == null) {
   6484             mExtras = new Bundle();
   6485         }
   6486         mExtras.putParcelableArrayList(name, value);
   6487         return this;
   6488     }
   6489 
   6490     /**
   6491      * Add extended data to the intent.  The name must include a package
   6492      * prefix, for example the app com.android.contacts would use names
   6493      * like "com.android.contacts.ShowAll".
   6494      *
   6495      * @param name The name of the extra data, with package prefix.
   6496      * @param value The ArrayList<Integer> data value.
   6497      *
   6498      * @return Returns the same Intent object, for chaining multiple calls
   6499      * into a single statement.
   6500      *
   6501      * @see #putExtras
   6502      * @see #removeExtra
   6503      * @see #getIntegerArrayListExtra(String)
   6504      */
   6505     public Intent putIntegerArrayListExtra(String name, ArrayList<Integer> value) {
   6506         if (mExtras == null) {
   6507             mExtras = new Bundle();
   6508         }
   6509         mExtras.putIntegerArrayList(name, value);
   6510         return this;
   6511     }
   6512 
   6513     /**
   6514      * Add extended data to the intent.  The name must include a package
   6515      * prefix, for example the app com.android.contacts would use names
   6516      * like "com.android.contacts.ShowAll".
   6517      *
   6518      * @param name The name of the extra data, with package prefix.
   6519      * @param value The ArrayList<String> data value.
   6520      *
   6521      * @return Returns the same Intent object, for chaining multiple calls
   6522      * into a single statement.
   6523      *
   6524      * @see #putExtras
   6525      * @see #removeExtra
   6526      * @see #getStringArrayListExtra(String)
   6527      */
   6528     public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
   6529         if (mExtras == null) {
   6530             mExtras = new Bundle();
   6531         }
   6532         mExtras.putStringArrayList(name, value);
   6533         return this;
   6534     }
   6535 
   6536     /**
   6537      * Add extended data to the intent.  The name must include a package
   6538      * prefix, for example the app com.android.contacts would use names
   6539      * like "com.android.contacts.ShowAll".
   6540      *
   6541      * @param name The name of the extra data, with package prefix.
   6542      * @param value The ArrayList<CharSequence> data value.
   6543      *
   6544      * @return Returns the same Intent object, for chaining multiple calls
   6545      * into a single statement.
   6546      *
   6547      * @see #putExtras
   6548      * @see #removeExtra
   6549      * @see #getCharSequenceArrayListExtra(String)
   6550      */
   6551     public Intent putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value) {
   6552         if (mExtras == null) {
   6553             mExtras = new Bundle();
   6554         }
   6555         mExtras.putCharSequenceArrayList(name, value);
   6556         return this;
   6557     }
   6558 
   6559     /**
   6560      * Add extended data to the intent.  The name must include a package
   6561      * prefix, for example the app com.android.contacts would use names
   6562      * like "com.android.contacts.ShowAll".
   6563      *
   6564      * @param name The name of the extra data, with package prefix.
   6565      * @param value The Serializable data value.
   6566      *
   6567      * @return Returns the same Intent object, for chaining multiple calls
   6568      * into a single statement.
   6569      *
   6570      * @see #putExtras
   6571      * @see #removeExtra
   6572      * @see #getSerializableExtra(String)
   6573      */
   6574     public Intent putExtra(String name, Serializable value) {
   6575         if (mExtras == null) {
   6576             mExtras = new Bundle();
   6577         }
   6578         mExtras.putSerializable(name, value);
   6579         return this;
   6580     }
   6581 
   6582     /**
   6583      * Add extended data to the intent.  The name must include a package
   6584      * prefix, for example the app com.android.contacts would use names
   6585      * like "com.android.contacts.ShowAll".
   6586      *
   6587      * @param name The name of the extra data, with package prefix.
   6588      * @param value The boolean array data value.
   6589      *
   6590      * @return Returns the same Intent object, for chaining multiple calls
   6591      * into a single statement.
   6592      *
   6593      * @see #putExtras
   6594      * @see #removeExtra
   6595      * @see #getBooleanArrayExtra(String)
   6596      */
   6597     public Intent putExtra(String name, boolean[] value) {
   6598         if (mExtras == null) {
   6599             mExtras = new Bundle();
   6600         }
   6601         mExtras.putBooleanArray(name, value);
   6602         return this;
   6603     }
   6604 
   6605     /**
   6606      * Add extended data to the intent.  The name must include a package
   6607      * prefix, for example the app com.android.contacts would use names
   6608      * like "com.android.contacts.ShowAll".
   6609      *
   6610      * @param name The name of the extra data, with package prefix.
   6611      * @param value The byte array data value.
   6612      *
   6613      * @return Returns the same Intent object, for chaining multiple calls
   6614      * into a single statement.
   6615      *
   6616      * @see #putExtras
   6617      * @see #removeExtra
   6618      * @see #getByteArrayExtra(String)
   6619      */
   6620     public Intent putExtra(String name, byte[] value) {
   6621         if (mExtras == null) {
   6622             mExtras = new Bundle();
   6623         }
   6624         mExtras.putByteArray(name, value);
   6625         return this;
   6626     }
   6627 
   6628     /**
   6629      * Add extended data to the intent.  The name must include a package
   6630      * prefix, for example the app com.android.contacts would use names
   6631      * like "com.android.contacts.ShowAll".
   6632      *
   6633      * @param name The name of the extra data, with package prefix.
   6634      * @param value The short array data value.
   6635      *
   6636      * @return Returns the same Intent object, for chaining multiple calls
   6637      * into a single statement.
   6638      *
   6639      * @see #putExtras
   6640      * @see #removeExtra
   6641      * @see #getShortArrayExtra(String)
   6642      */
   6643     public Intent putExtra(String name, short[] value) {
   6644         if (mExtras == null) {
   6645             mExtras = new Bundle();
   6646         }
   6647         mExtras.putShortArray(name, value);
   6648         return this;
   6649     }
   6650 
   6651     /**
   6652      * Add extended data to the intent.  The name must include a package
   6653      * prefix, for example the app com.android.contacts would use names
   6654      * like "com.android.contacts.ShowAll".
   6655      *
   6656      * @param name The name of the extra data, with package prefix.
   6657      * @param value The char array data value.
   6658      *
   6659      * @return Returns the same Intent object, for chaining multiple calls
   6660      * into a single statement.
   6661      *
   6662      * @see #putExtras
   6663      * @see #removeExtra
   6664      * @see #getCharArrayExtra(String)
   6665      */
   6666     public Intent putExtra(String name, char[] value) {
   6667         if (mExtras == null) {
   6668             mExtras = new Bundle();
   6669         }
   6670         mExtras.putCharArray(name, value);
   6671         return this;
   6672     }
   6673 
   6674     /**
   6675      * Add extended data to the intent.  The name must include a package
   6676      * prefix, for example the app com.android.contacts would use names
   6677      * like "com.android.contacts.ShowAll".
   6678      *
   6679      * @param name The name of the extra data, with package prefix.
   6680      * @param value The int array data value.
   6681      *
   6682      * @return Returns the same Intent object, for chaining multiple calls
   6683      * into a single statement.
   6684      *
   6685      * @see #putExtras
   6686      * @see #removeExtra
   6687      * @see #getIntArrayExtra(String)
   6688      */
   6689     public Intent putExtra(String name, int[] value) {
   6690         if (mExtras == null) {
   6691             mExtras = new Bundle();
   6692         }
   6693         mExtras.putIntArray(name, value);
   6694         return this;
   6695     }
   6696 
   6697     /**
   6698      * Add extended data to the intent.  The name must include a package
   6699      * prefix, for example the app com.android.contacts would use names
   6700      * like "com.android.contacts.ShowAll".
   6701      *
   6702      * @param name The name of the extra data, with package prefix.
   6703      * @param value The byte array data value.
   6704      *
   6705      * @return Returns the same Intent object, for chaining multiple calls
   6706      * into a single statement.
   6707      *
   6708      * @see #putExtras
   6709      * @see #removeExtra
   6710      * @see #getLongArrayExtra(String)
   6711      */
   6712     public Intent putExtra(String name, long[] value) {
   6713         if (mExtras == null) {
   6714             mExtras = new Bundle();
   6715         }
   6716         mExtras.putLongArray(name, value);
   6717         return this;
   6718     }
   6719 
   6720     /**
   6721      * Add extended data to the intent.  The name must include a package
   6722      * prefix, for example the app com.android.contacts would use names
   6723      * like "com.android.contacts.ShowAll".
   6724      *
   6725      * @param name The name of the extra data, with package prefix.
   6726      * @param value The float array data value.
   6727      *
   6728      * @return Returns the same Intent object, for chaining multiple calls
   6729      * into a single statement.
   6730      *
   6731      * @see #putExtras
   6732      * @see #removeExtra
   6733      * @see #getFloatArrayExtra(String)
   6734      */
   6735     public Intent putExtra(String name, float[] value) {
   6736         if (mExtras == null) {
   6737             mExtras = new Bundle();
   6738         }
   6739         mExtras.putFloatArray(name, value);
   6740         return this;
   6741     }
   6742 
   6743     /**
   6744      * Add extended data to the intent.  The name must include a package
   6745      * prefix, for example the app com.android.contacts would use names
   6746      * like "com.android.contacts.ShowAll".
   6747      *
   6748      * @param name The name of the extra data, with package prefix.
   6749      * @param value The double array data value.
   6750      *
   6751      * @return Returns the same Intent object, for chaining multiple calls
   6752      * into a single statement.
   6753      *
   6754      * @see #putExtras
   6755      * @see #removeExtra
   6756      * @see #getDoubleArrayExtra(String)
   6757      */
   6758     public Intent putExtra(String name, double[] value) {
   6759         if (mExtras == null) {
   6760             mExtras = new Bundle();
   6761         }
   6762         mExtras.putDoubleArray(name, value);
   6763         return this;
   6764     }
   6765 
   6766     /**
   6767      * Add extended data to the intent.  The name must include a package
   6768      * prefix, for example the app com.android.contacts would use names
   6769      * like "com.android.contacts.ShowAll".
   6770      *
   6771      * @param name The name of the extra data, with package prefix.
   6772      * @param value The String array data value.
   6773      *
   6774      * @return Returns the same Intent object, for chaining multiple calls
   6775      * into a single statement.
   6776      *
   6777      * @see #putExtras
   6778      * @see #removeExtra
   6779      * @see #getStringArrayExtra(String)
   6780      */
   6781     public Intent putExtra(String name, String[] value) {
   6782         if (mExtras == null) {
   6783             mExtras = new Bundle();
   6784         }
   6785         mExtras.putStringArray(name, value);
   6786         return this;
   6787     }
   6788 
   6789     /**
   6790      * Add extended data to the intent.  The name must include a package
   6791      * prefix, for example the app com.android.contacts would use names
   6792      * like "com.android.contacts.ShowAll".
   6793      *
   6794      * @param name The name of the extra data, with package prefix.
   6795      * @param value The CharSequence array data value.
   6796      *
   6797      * @return Returns the same Intent object, for chaining multiple calls
   6798      * into a single statement.
   6799      *
   6800      * @see #putExtras
   6801      * @see #removeExtra
   6802      * @see #getCharSequenceArrayExtra(String)
   6803      */
   6804     public Intent putExtra(String name, CharSequence[] value) {
   6805         if (mExtras == null) {
   6806             mExtras = new Bundle();
   6807         }
   6808         mExtras.putCharSequenceArray(name, value);
   6809         return this;
   6810     }
   6811 
   6812     /**
   6813      * Add extended data to the intent.  The name must include a package
   6814      * prefix, for example the app com.android.contacts would use names
   6815      * like "com.android.contacts.ShowAll".
   6816      *
   6817      * @param name The name of the extra data, with package prefix.
   6818      * @param value The Bundle data value.
   6819      *
   6820      * @return Returns the same Intent object, for chaining multiple calls
   6821      * into a single statement.
   6822      *
   6823      * @see #putExtras
   6824      * @see #removeExtra
   6825      * @see #getBundleExtra(String)
   6826      */
   6827     public Intent putExtra(String name, Bundle value) {
   6828         if (mExtras == null) {
   6829             mExtras = new Bundle();
   6830         }
   6831         mExtras.putBundle(name, value);
   6832         return this;
   6833     }
   6834 
   6835     /**
   6836      * Add extended data to the intent.  The name must include a package
   6837      * prefix, for example the app com.android.contacts would use names
   6838      * like "com.android.contacts.ShowAll".
   6839      *
   6840      * @param name The name of the extra data, with package prefix.
   6841      * @param value The IBinder data value.
   6842      *
   6843      * @return Returns the same Intent object, for chaining multiple calls
   6844      * into a single statement.
   6845      *
   6846      * @see #putExtras
   6847      * @see #removeExtra
   6848      * @see #getIBinderExtra(String)
   6849      *
   6850      * @deprecated
   6851      * @hide
   6852      */
   6853     @Deprecated
   6854     public Intent putExtra(String name, IBinder value) {
   6855         if (mExtras == null) {
   6856             mExtras = new Bundle();
   6857         }
   6858         mExtras.putIBinder(name, value);
   6859         return this;
   6860     }
   6861 
   6862     /**
   6863      * Copy all extras in 'src' in to this intent.
   6864      *
   6865      * @param src Contains the extras to copy.
   6866      *
   6867      * @see #putExtra
   6868      */
   6869     public Intent putExtras(Intent src) {
   6870         if (src.mExtras != null) {
   6871             if (mExtras == null) {
   6872                 mExtras = new Bundle(src.mExtras);
   6873             } else {
   6874                 mExtras.putAll(src.mExtras);
   6875             }
   6876         }
   6877         return this;
   6878     }
   6879 
   6880     /**
   6881      * Add a set of extended data to the intent.  The keys must include a package
   6882      * prefix, for example the app com.android.contacts would use names
   6883      * like "com.android.contacts.ShowAll".
   6884      *
   6885      * @param extras The Bundle of extras to add to this intent.
   6886      *
   6887      * @see #putExtra
   6888      * @see #removeExtra
   6889      */
   6890     public Intent putExtras(Bundle extras) {
   6891         if (mExtras == null) {
   6892             mExtras = new Bundle();
   6893         }
   6894         mExtras.putAll(extras);
   6895         return this;
   6896     }
   6897 
   6898     /**
   6899      * Completely replace the extras in the Intent with the extras in the
   6900      * given Intent.
   6901      *
   6902      * @param src The exact extras contained in this Intent are copied
   6903      * into the target intent, replacing any that were previously there.
   6904      */
   6905     public Intent replaceExtras(Intent src) {
   6906         mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
   6907         return this;
   6908     }
   6909 
   6910     /**
   6911      * Completely replace the extras in the Intent with the given Bundle of
   6912      * extras.
   6913      *
   6914      * @param extras The new set of extras in the Intent, or null to erase
   6915      * all extras.
   6916      */
   6917     public Intent replaceExtras(Bundle extras) {
   6918         mExtras = extras != null ? new Bundle(extras) : null;
   6919         return this;
   6920     }
   6921 
   6922     /**
   6923      * Remove extended data from the intent.
   6924      *
   6925      * @see #putExtra
   6926      */
   6927     public void removeExtra(String name) {
   6928         if (mExtras != null) {
   6929             mExtras.remove(name);
   6930             if (mExtras.size() == 0) {
   6931                 mExtras = null;
   6932             }
   6933         }
   6934     }
   6935 
   6936     /**
   6937      * Set special flags controlling how this intent is handled.  Most values
   6938      * here depend on the type of component being executed by the Intent,
   6939      * specifically the FLAG_ACTIVITY_* flags are all for use with
   6940      * {@link Context#startActivity Context.startActivity()} and the
   6941      * FLAG_RECEIVER_* flags are all for use with
   6942      * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
   6943      *
   6944      * <p>See the
   6945      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
   6946      * Stack</a> documentation for important information on how some of these options impact
   6947      * the behavior of your application.
   6948      *
   6949      * @param flags The desired flags.
   6950      *
   6951      * @return Returns the same Intent object, for chaining multiple calls
   6952      * into a single statement.
   6953      *
   6954      * @see #getFlags
   6955      * @see #addFlags
   6956      *
   6957      * @see #FLAG_GRANT_READ_URI_PERMISSION
   6958      * @see #FLAG_GRANT_WRITE_URI_PERMISSION
   6959      * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
   6960      * @see #FLAG_GRANT_PREFIX_URI_PERMISSION
   6961      * @see #FLAG_DEBUG_LOG_RESOLUTION
   6962      * @see #FLAG_FROM_BACKGROUND
   6963      * @see #FLAG_ACTIVITY_BROUGHT_TO_FRONT
   6964      * @see #FLAG_ACTIVITY_CLEAR_TASK
   6965      * @see #FLAG_ACTIVITY_CLEAR_TOP
   6966      * @see #FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
   6967      * @see #FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS
   6968      * @see #FLAG_ACTIVITY_FORWARD_RESULT
   6969      * @see #FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
   6970      * @see #FLAG_ACTIVITY_MULTIPLE_TASK
   6971      * @see #FLAG_ACTIVITY_NEW_DOCUMENT
   6972      * @see #FLAG_ACTIVITY_NEW_TASK
   6973      * @see #FLAG_ACTIVITY_NO_ANIMATION
   6974      * @see #FLAG_ACTIVITY_NO_HISTORY
   6975      * @see #FLAG_ACTIVITY_NO_USER_ACTION
   6976      * @see #FLAG_ACTIVITY_PREVIOUS_IS_TOP
   6977      * @see #FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
   6978      * @see #FLAG_ACTIVITY_REORDER_TO_FRONT
   6979      * @see #FLAG_ACTIVITY_SINGLE_TOP
   6980      * @see #FLAG_ACTIVITY_TASK_ON_HOME
   6981      * @see #FLAG_RECEIVER_REGISTERED_ONLY
   6982      */
   6983     public Intent setFlags(int flags) {
   6984         mFlags = flags;
   6985         return this;
   6986     }
   6987 
   6988     /**
   6989      * Add additional flags to the intent (or with existing flags
   6990      * value).
   6991      *
   6992      * @param flags The new flags to set.
   6993      *
   6994      * @return Returns the same Intent object, for chaining multiple calls
   6995      * into a single statement.
   6996      *
   6997      * @see #setFlags
   6998      */
   6999     public Intent addFlags(int flags) {
   7000         mFlags |= flags;
   7001         return this;
   7002     }
   7003 
   7004     /**
   7005      * (Usually optional) Set an explicit application package name that limits
   7006      * the components this Intent will resolve to.  If left to the default
   7007      * value of null, all components in all applications will considered.
   7008      * If non-null, the Intent can only match the components in the given
   7009      * application package.
   7010      *
   7011      * @param packageName The name of the application package to handle the
   7012      * intent, or null to allow any application package.
   7013      *
   7014      * @return Returns the same Intent object, for chaining multiple calls
   7015      * into a single statement.
   7016      *
   7017      * @see #getPackage
   7018      * @see #resolveActivity
   7019      */
   7020     public Intent setPackage(String packageName) {
   7021         if (packageName != null && mSelector != null) {
   7022             throw new IllegalArgumentException(
   7023                     "Can't set package name when selector is already set");
   7024         }
   7025         mPackage = packageName;
   7026         return this;
   7027     }
   7028 
   7029     /**
   7030      * (Usually optional) Explicitly set the component to handle the intent.
   7031      * If left with the default value of null, the system will determine the
   7032      * appropriate class to use based on the other fields (action, data,
   7033      * type, categories) in the Intent.  If this class is defined, the
   7034      * specified class will always be used regardless of the other fields.  You
   7035      * should only set this value when you know you absolutely want a specific
   7036      * class to be used; otherwise it is better to let the system find the
   7037      * appropriate class so that you will respect the installed applications
   7038      * and user preferences.
   7039      *
   7040      * @param component The name of the application component to handle the
   7041      * intent, or null to let the system find one for you.
   7042      *
   7043      * @return Returns the same Intent object, for chaining multiple calls
   7044      * into a single statement.
   7045      *
   7046      * @see #setClass
   7047      * @see #setClassName(Context, String)
   7048      * @see #setClassName(String, String)
   7049      * @see #getComponent
   7050      * @see #resolveActivity
   7051      */
   7052     public Intent setComponent(ComponentName component) {
   7053         mComponent = component;
   7054         return this;
   7055     }
   7056 
   7057     /**
   7058      * Convenience for calling {@link #setComponent} with an
   7059      * explicit class name.
   7060      *
   7061      * @param packageContext A Context of the application package implementing
   7062      * this class.
   7063      * @param className The name of a class inside of the application package
   7064      * that will be used as the component for this Intent.
   7065      *
   7066      * @return Returns the same Intent object, for chaining multiple calls
   7067      * into a single statement.
   7068      *
   7069      * @see #setComponent
   7070      * @see #setClass
   7071      */
   7072     public Intent setClassName(Context packageContext, String className) {
   7073         mComponent = new ComponentName(packageContext, className);
   7074         return this;
   7075     }
   7076 
   7077     /**
   7078      * Convenience for calling {@link #setComponent} with an
   7079      * explicit application package name and class name.
   7080      *
   7081      * @param packageName The name of the package implementing the desired
   7082      * component.
   7083      * @param className The name of a class inside of the application package
   7084      * that will be used as the component for this Intent.
   7085      *
   7086      * @return Returns the same Intent object, for chaining multiple calls
   7087      * into a single statement.
   7088      *
   7089      * @see #setComponent
   7090      * @see #setClass
   7091      */
   7092     public Intent setClassName(String packageName, String className) {
   7093         mComponent = new ComponentName(packageName, className);
   7094         return this;
   7095     }
   7096 
   7097     /**
   7098      * Convenience for calling {@link #setComponent(ComponentName)} with the
   7099      * name returned by a {@link Class} object.
   7100      *
   7101      * @param packageContext A Context of the application package implementing
   7102      * this class.
   7103      * @param cls The class name to set, equivalent to
   7104      *            <code>setClassName(context, cls.getName())</code>.
   7105      *
   7106      * @return Returns the same Intent object, for chaining multiple calls
   7107      * into a single statement.
   7108      *
   7109      * @see #setComponent
   7110      */
   7111     public Intent setClass(Context packageContext, Class<?> cls) {
   7112         mComponent = new ComponentName(packageContext, cls);
   7113         return this;
   7114     }
   7115 
   7116     /**
   7117      * Set the bounds of the sender of this intent, in screen coordinates.  This can be
   7118      * used as a hint to the receiver for animations and the like.  Null means that there
   7119      * is no source bounds.
   7120      */
   7121     public void setSourceBounds(Rect r) {
   7122         if (r != null) {
   7123             mSourceBounds = new Rect(r);
   7124         } else {
   7125             mSourceBounds = null;
   7126         }
   7127     }
   7128 
   7129     /** @hide */
   7130     @IntDef(flag = true,
   7131             value = {
   7132                     FILL_IN_ACTION,
   7133                     FILL_IN_DATA,
   7134                     FILL_IN_CATEGORIES,
   7135                     FILL_IN_COMPONENT,
   7136                     FILL_IN_PACKAGE,
   7137                     FILL_IN_SOURCE_BOUNDS,
   7138                     FILL_IN_SELECTOR,
   7139                     FILL_IN_CLIP_DATA
   7140             })
   7141     @Retention(RetentionPolicy.SOURCE)
   7142     public @interface FillInFlags {}
   7143 
   7144     /**
   7145      * Use with {@link #fillIn} to allow the current action value to be
   7146      * overwritten, even if it is already set.
   7147      */
   7148     public static final int FILL_IN_ACTION = 1<<0;
   7149 
   7150     /**
   7151      * Use with {@link #fillIn} to allow the current data or type value
   7152      * overwritten, even if it is already set.
   7153      */
   7154     public static final int FILL_IN_DATA = 1<<1;
   7155 
   7156     /**
   7157      * Use with {@link #fillIn} to allow the current categories to be
   7158      * overwritten, even if they are already set.
   7159      */
   7160     public static final int FILL_IN_CATEGORIES = 1<<2;
   7161 
   7162     /**
   7163      * Use with {@link #fillIn} to allow the current component value to be
   7164      * overwritten, even if it is already set.
   7165      */
   7166     public static final int FILL_IN_COMPONENT = 1<<3;
   7167 
   7168     /**
   7169      * Use with {@link #fillIn} to allow the current package value to be
   7170      * overwritten, even if it is already set.
   7171      */
   7172     public static final int FILL_IN_PACKAGE = 1<<4;
   7173 
   7174     /**
   7175      * Use with {@link #fillIn} to allow the current bounds rectangle to be
   7176      * overwritten, even if it is already set.
   7177      */
   7178     public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
   7179 
   7180     /**
   7181      * Use with {@link #fillIn} to allow the current selector to be
   7182      * overwritten, even if it is already set.
   7183      */
   7184     public static final int FILL_IN_SELECTOR = 1<<6;
   7185 
   7186     /**
   7187      * Use with {@link #fillIn} to allow the current ClipData to be
   7188      * overwritten, even if it is already set.
   7189      */
   7190     public static final int FILL_IN_CLIP_DATA = 1<<7;
   7191 
   7192     /**
   7193      * Copy the contents of <var>other</var> in to this object, but only
   7194      * where fields are not defined by this object.  For purposes of a field
   7195      * being defined, the following pieces of data in the Intent are
   7196      * considered to be separate fields:
   7197      *
   7198      * <ul>
   7199      * <li> action, as set by {@link #setAction}.
   7200      * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
   7201      * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
   7202      * <li> categories, as set by {@link #addCategory}.
   7203      * <li> package, as set by {@link #setPackage}.
   7204      * <li> component, as set by {@link #setComponent(ComponentName)} or
   7205      * related methods.
   7206      * <li> source bounds, as set by {@link #setSourceBounds}.
   7207      * <li> selector, as set by {@link #setSelector(Intent)}.
   7208      * <li> clip data, as set by {@link #setClipData(ClipData)}.
   7209      * <li> each top-level name in the associated extras.
   7210      * </ul>
   7211      *
   7212      * <p>In addition, you can use the {@link #FILL_IN_ACTION},
   7213      * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
   7214      * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
   7215      * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
   7216      * the restriction where the corresponding field will not be replaced if
   7217      * it is already set.
   7218      *
   7219      * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
   7220      * is explicitly specified.  The selector will only be copied if
   7221      * {@link #FILL_IN_SELECTOR} is explicitly specified.
   7222      *
   7223      * <p>For example, consider Intent A with {data="foo", categories="bar"}
   7224      * and Intent B with {action="gotit", data-type="some/thing",
   7225      * categories="one","two"}.
   7226      *
   7227      * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
   7228      * containing: {action="gotit", data-type="some/thing",
   7229      * categories="bar"}.
   7230      *
   7231      * @param other Another Intent whose values are to be used to fill in
   7232      * the current one.
   7233      * @param flags Options to control which fields can be filled in.
   7234      *
   7235      * @return Returns a bit mask of {@link #FILL_IN_ACTION},
   7236      * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
   7237      * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
   7238      * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA indicating which fields were
   7239      * changed.
   7240      */
   7241     @FillInFlags
   7242     public int fillIn(Intent other, @FillInFlags int flags) {
   7243         int changes = 0;
   7244         boolean mayHaveCopiedUris = false;
   7245         if (other.mAction != null
   7246                 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
   7247             mAction = other.mAction;
   7248             changes |= FILL_IN_ACTION;
   7249         }
   7250         if ((other.mData != null || other.mType != null)
   7251                 && ((mData == null && mType == null)
   7252                         || (flags&FILL_IN_DATA) != 0)) {
   7253             mData = other.mData;
   7254             mType = other.mType;
   7255             changes |= FILL_IN_DATA;
   7256             mayHaveCopiedUris = true;
   7257         }
   7258         if (other.mCategories != null
   7259                 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
   7260             if (other.mCategories != null) {
   7261                 mCategories = new ArraySet<String>(other.mCategories);
   7262             }
   7263             changes |= FILL_IN_CATEGORIES;
   7264         }
   7265         if (other.mPackage != null
   7266                 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
   7267             // Only do this if mSelector is not set.
   7268             if (mSelector == null) {
   7269                 mPackage = other.mPackage;
   7270                 changes |= FILL_IN_PACKAGE;
   7271             }
   7272         }
   7273         // Selector is special: it can only be set if explicitly allowed,
   7274         // for the same reason as the component name.
   7275         if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
   7276             if (mPackage == null) {
   7277                 mSelector = new Intent(other.mSelector);
   7278                 mPackage = null;
   7279                 changes |= FILL_IN_SELECTOR;
   7280             }
   7281         }
   7282         if (other.mClipData != null
   7283                 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
   7284             mClipData = other.mClipData;
   7285             changes |= FILL_IN_CLIP_DATA;
   7286             mayHaveCopiedUris = true;
   7287         }
   7288         // Component is special: it can -only- be set if explicitly allowed,
   7289         // since otherwise the sender could force the intent somewhere the
   7290         // originator didn't intend.
   7291         if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
   7292             mComponent = other.mComponent;
   7293             changes |= FILL_IN_COMPONENT;
   7294         }
   7295         mFlags |= other.mFlags;
   7296         if (other.mSourceBounds != null
   7297                 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
   7298             mSourceBounds = new Rect(other.mSourceBounds);
   7299             changes |= FILL_IN_SOURCE_BOUNDS;
   7300         }
   7301         if (mExtras == null) {
   7302             if (other.mExtras != null) {
   7303                 mExtras = new Bundle(other.mExtras);
   7304                 mayHaveCopiedUris = true;
   7305             }
   7306         } else if (other.mExtras != null) {
   7307             try {
   7308                 Bundle newb = new Bundle(other.mExtras);
   7309                 newb.putAll(mExtras);
   7310                 mExtras = newb;
   7311                 mayHaveCopiedUris = true;
   7312             } catch (RuntimeException e) {
   7313                 // Modifying the extras can cause us to unparcel the contents
   7314                 // of the bundle, and if we do this in the system process that
   7315                 // may fail.  We really should handle this (i.e., the Bundle
   7316                 // impl shouldn't be on top of a plain map), but for now just
   7317                 // ignore it and keep the original contents. :(
   7318                 Log.w("Intent", "Failure filling in extras", e);
   7319             }
   7320         }
   7321         if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
   7322                 && other.mContentUserHint != UserHandle.USER_CURRENT) {
   7323             mContentUserHint = other.mContentUserHint;
   7324         }
   7325         return changes;
   7326     }
   7327 
   7328     /**
   7329      * Wrapper class holding an Intent and implementing comparisons on it for
   7330      * the purpose of filtering.  The class implements its
   7331      * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
   7332      * simple calls to {@link Intent#filterEquals(Intent)}  filterEquals()} and
   7333      * {@link android.content.Intent#filterHashCode()}  filterHashCode()}
   7334      * on the wrapped Intent.
   7335      */
   7336     public static final class FilterComparison {
   7337         private final Intent mIntent;
   7338         private final int mHashCode;
   7339 
   7340         public FilterComparison(Intent intent) {
   7341             mIntent = intent;
   7342             mHashCode = intent.filterHashCode();
   7343         }
   7344 
   7345         /**
   7346          * Return the Intent that this FilterComparison represents.
   7347          * @return Returns the Intent held by the FilterComparison.  Do
   7348          * not modify!
   7349          */
   7350         public Intent getIntent() {
   7351             return mIntent;
   7352         }
   7353 
   7354         @Override
   7355         public boolean equals(Object obj) {
   7356             if (obj instanceof FilterComparison) {
   7357                 Intent other = ((FilterComparison)obj).mIntent;
   7358                 return mIntent.filterEquals(other);
   7359             }
   7360             return false;
   7361         }
   7362 
   7363         @Override
   7364         public int hashCode() {
   7365             return mHashCode;
   7366         }
   7367     }
   7368 
   7369     /**
   7370      * Determine if two intents are the same for the purposes of intent
   7371      * resolution (filtering). That is, if their action, data, type,
   7372      * class, and categories are the same.  This does <em>not</em> compare
   7373      * any extra data included in the intents.
   7374      *
   7375      * @param other The other Intent to compare against.
   7376      *
   7377      * @return Returns true if action, data, type, class, and categories
   7378      *         are the same.
   7379      */
   7380     public boolean filterEquals(Intent other) {
   7381         if (other == null) {
   7382             return false;
   7383         }
   7384         if (!Objects.equals(this.mAction, other.mAction)) return false;
   7385         if (!Objects.equals(this.mData, other.mData)) return false;
   7386         if (!Objects.equals(this.mType, other.mType)) return false;
   7387         if (!Objects.equals(this.mPackage, other.mPackage)) return false;
   7388         if (!Objects.equals(this.mComponent, other.mComponent)) return false;
   7389         if (!Objects.equals(this.mCategories, other.mCategories)) return false;
   7390 
   7391         return true;
   7392     }
   7393 
   7394     /**
   7395      * Generate hash code that matches semantics of filterEquals().
   7396      *
   7397      * @return Returns the hash value of the action, data, type, class, and
   7398      *         categories.
   7399      *
   7400      * @see #filterEquals
   7401      */
   7402     public int filterHashCode() {
   7403         int code = 0;
   7404         if (mAction != null) {
   7405             code += mAction.hashCode();
   7406         }
   7407         if (mData != null) {
   7408             code += mData.hashCode();
   7409         }
   7410         if (mType != null) {
   7411             code += mType.hashCode();
   7412         }
   7413         if (mPackage != null) {
   7414             code += mPackage.hashCode();
   7415         }
   7416         if (mComponent != null) {
   7417             code += mComponent.hashCode();
   7418         }
   7419         if (mCategories != null) {
   7420             code += mCategories.hashCode();
   7421         }
   7422         return code;
   7423     }
   7424 
   7425     @Override
   7426     public String toString() {
   7427         StringBuilder b = new StringBuilder(128);
   7428 
   7429         b.append("Intent { ");
   7430         toShortString(b, true, true, true, false);
   7431         b.append(" }");
   7432 
   7433         return b.toString();
   7434     }
   7435 
   7436     /** @hide */
   7437     public String toInsecureString() {
   7438         StringBuilder b = new StringBuilder(128);
   7439 
   7440         b.append("Intent { ");
   7441         toShortString(b, false, true, true, false);
   7442         b.append(" }");
   7443 
   7444         return b.toString();
   7445     }
   7446 
   7447     /** @hide */
   7448     public String toInsecureStringWithClip() {
   7449         StringBuilder b = new StringBuilder(128);
   7450 
   7451         b.append("Intent { ");
   7452         toShortString(b, false, true, true, true);
   7453         b.append(" }");
   7454 
   7455         return b.toString();
   7456     }
   7457 
   7458     /** @hide */
   7459     public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
   7460         StringBuilder b = new StringBuilder(128);
   7461         toShortString(b, secure, comp, extras, clip);
   7462         return b.toString();
   7463     }
   7464 
   7465     /** @hide */
   7466     public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
   7467             boolean clip) {
   7468         boolean first = true;
   7469         if (mAction != null) {
   7470             b.append("act=").append(mAction);
   7471             first = false;
   7472         }
   7473         if (mCategories != null) {
   7474             if (!first) {
   7475                 b.append(' ');
   7476             }
   7477             first = false;
   7478             b.append("cat=[");
   7479             for (int i=0; i<mCategories.size(); i++) {
   7480                 if (i > 0) b.append(',');
   7481                 b.append(mCategories.valueAt(i));
   7482             }
   7483             b.append("]");
   7484         }
   7485         if (mData != null) {
   7486             if (!first) {
   7487                 b.append(' ');
   7488             }
   7489             first = false;
   7490             b.append("dat=");
   7491             if (secure) {
   7492                 b.append(mData.toSafeString());
   7493             } else {
   7494                 b.append(mData);
   7495             }
   7496         }
   7497         if (mType != null) {
   7498             if (!first) {
   7499                 b.append(' ');
   7500             }
   7501             first = false;
   7502             b.append("typ=").append(mType);
   7503         }
   7504         if (mFlags != 0) {
   7505             if (!first) {
   7506                 b.append(' ');
   7507             }
   7508             first = false;
   7509             b.append("flg=0x").append(Integer.toHexString(mFlags));
   7510         }
   7511         if (mPackage != null) {
   7512             if (!first) {
   7513                 b.append(' ');
   7514             }
   7515             first = false;
   7516             b.append("pkg=").append(mPackage);
   7517         }
   7518         if (comp && mComponent != null) {
   7519             if (!first) {
   7520                 b.append(' ');
   7521             }
   7522             first = false;
   7523             b.append("cmp=").append(mComponent.flattenToShortString());
   7524         }
   7525         if (mSourceBounds != null) {
   7526             if (!first) {
   7527                 b.append(' ');
   7528             }
   7529             first = false;
   7530             b.append("bnds=").append(mSourceBounds.toShortString());
   7531         }
   7532         if (mClipData != null) {
   7533             if (!first) {
   7534                 b.append(' ');
   7535             }
   7536             b.append("clip={");
   7537             if (clip) {
   7538                 mClipData.toShortString(b);
   7539             } else {
   7540                 if (mClipData.getDescription() != null) {
   7541                     first = !mClipData.getDescription().toShortStringTypesOnly(b);
   7542                 } else {
   7543                     first = true;
   7544                 }
   7545                 mClipData.toShortStringShortItems(b, first);
   7546             }
   7547             first = false;
   7548             b.append('}');
   7549         }
   7550         if (extras && mExtras != null) {
   7551             if (!first) {
   7552                 b.append(' ');
   7553             }
   7554             first = false;
   7555             b.append("(has extras)");
   7556         }
   7557         if (mContentUserHint != UserHandle.USER_CURRENT) {
   7558             if (!first) {
   7559                 b.append(' ');
   7560             }
   7561             first = false;
   7562             b.append("u=").append(mContentUserHint);
   7563         }
   7564         if (mSelector != null) {
   7565             b.append(" sel=");
   7566             mSelector.toShortString(b, secure, comp, extras, clip);
   7567             b.append("}");
   7568         }
   7569     }
   7570 
   7571     /**
   7572      * Call {@link #toUri} with 0 flags.
   7573      * @deprecated Use {@link #toUri} instead.
   7574      */
   7575     @Deprecated
   7576     public String toURI() {
   7577         return toUri(0);
   7578     }
   7579 
   7580     /**
   7581      * Convert this Intent into a String holding a URI representation of it.
   7582      * The returned URI string has been properly URI encoded, so it can be
   7583      * used with {@link Uri#parse Uri.parse(String)}.  The URI contains the
   7584      * Intent's data as the base URI, with an additional fragment describing
   7585      * the action, categories, type, flags, package, component, and extras.
   7586      *
   7587      * <p>You can convert the returned string back to an Intent with
   7588      * {@link #getIntent}.
   7589      *
   7590      * @param flags Additional operating flags.  Either 0,
   7591      * {@link #URI_INTENT_SCHEME}, or {@link #URI_ANDROID_APP_SCHEME}.
   7592      *
   7593      * @return Returns a URI encoding URI string describing the entire contents
   7594      * of the Intent.
   7595      */
   7596     public String toUri(int flags) {
   7597         StringBuilder uri = new StringBuilder(128);
   7598         if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
   7599             if (mPackage == null) {
   7600                 throw new IllegalArgumentException(
   7601                         "Intent must include an explicit package name to build an android-app: "
   7602                         + this);
   7603             }
   7604             uri.append("android-app://");
   7605             uri.append(mPackage);
   7606             String scheme = null;
   7607             if (mData != null) {
   7608                 scheme = mData.getScheme();
   7609                 if (scheme != null) {
   7610                     uri.append('/');
   7611                     uri.append(scheme);
   7612                     String authority = mData.getEncodedAuthority();
   7613                     if (authority != null) {
   7614                         uri.append('/');
   7615                         uri.append(authority);
   7616                         String path = mData.getEncodedPath();
   7617                         if (path != null) {
   7618                             uri.append(path);
   7619                         }
   7620                         String queryParams = mData.getEncodedQuery();
   7621                         if (queryParams != null) {
   7622                             uri.append('?');
   7623                             uri.append(queryParams);
   7624                         }
   7625                         String fragment = mData.getEncodedFragment();
   7626                         if (fragment != null) {
   7627                             uri.append('#');
   7628                             uri.append(fragment);
   7629                         }
   7630                     }
   7631                 }
   7632             }
   7633             toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
   7634                     mPackage, flags);
   7635             return uri.toString();
   7636         }
   7637         String scheme = null;
   7638         if (mData != null) {
   7639             String data = mData.toString();
   7640             if ((flags&URI_INTENT_SCHEME) != 0) {
   7641                 final int N = data.length();
   7642                 for (int i=0; i<N; i++) {
   7643                     char c = data.charAt(i);
   7644                     if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
   7645                             || c == '.' || c == '-') {
   7646                         continue;
   7647                     }
   7648                     if (c == ':' && i > 0) {
   7649                         // Valid scheme.
   7650                         scheme = data.substring(0, i);
   7651                         uri.append("intent:");
   7652                         data = data.substring(i+1);
   7653                         break;
   7654                     }
   7655 
   7656                     // No scheme.
   7657                     break;
   7658                 }
   7659             }
   7660             uri.append(data);
   7661 
   7662         } else if ((flags&URI_INTENT_SCHEME) != 0) {
   7663             uri.append("intent:");
   7664         }
   7665 
   7666         toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
   7667 
   7668         return uri.toString();
   7669     }
   7670 
   7671     private void toUriFragment(StringBuilder uri, String scheme, String defAction,
   7672             String defPackage, int flags) {
   7673         StringBuilder frag = new StringBuilder(128);
   7674 
   7675         toUriInner(frag, scheme, defAction, defPackage, flags);
   7676         if (mSelector != null) {
   7677             frag.append("SEL;");
   7678             // Note that for now we are not going to try to handle the
   7679             // data part; not clear how to represent this as a URI, and
   7680             // not much utility in it.
   7681             mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
   7682                     null, null, flags);
   7683         }
   7684 
   7685         if (frag.length() > 0) {
   7686             uri.append("#Intent;");
   7687             uri.append(frag);
   7688             uri.append("end");
   7689         }
   7690     }
   7691 
   7692     private void toUriInner(StringBuilder uri, String scheme, String defAction,
   7693             String defPackage, int flags) {
   7694         if (scheme != null) {
   7695             uri.append("scheme=").append(scheme).append(';');
   7696         }
   7697         if (mAction != null && !mAction.equals(defAction)) {
   7698             uri.append("action=").append(Uri.encode(mAction)).append(';');
   7699         }
   7700         if (mCategories != null) {
   7701             for (int i=0; i<mCategories.size(); i++) {
   7702                 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
   7703             }
   7704         }
   7705         if (mType != null) {
   7706             uri.append("type=").append(Uri.encode(mType, "/")).append(';');
   7707         }
   7708         if (mFlags != 0) {
   7709             uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
   7710         }
   7711         if (mPackage != null && !mPackage.equals(defPackage)) {
   7712             uri.append("package=").append(Uri.encode(mPackage)).append(';');
   7713         }
   7714         if (mComponent != null) {
   7715             uri.append("component=").append(Uri.encode(
   7716                     mComponent.flattenToShortString(), "/")).append(';');
   7717         }
   7718         if (mSourceBounds != null) {
   7719             uri.append("sourceBounds=")
   7720                     .append(Uri.encode(mSourceBounds.flattenToString()))
   7721                     .append(';');
   7722         }
   7723         if (mExtras != null) {
   7724             for (String key : mExtras.keySet()) {
   7725                 final Object value = mExtras.get(key);
   7726                 char entryType =
   7727                         value instanceof String    ? 'S' :
   7728                         value instanceof Boolean   ? 'B' :
   7729                         value instanceof Byte      ? 'b' :
   7730                         value instanceof Character ? 'c' :
   7731                         value instanceof Double    ? 'd' :
   7732                         value instanceof Float     ? 'f' :
   7733                         value instanceof Integer   ? 'i' :
   7734                         value instanceof Long      ? 'l' :
   7735                         value instanceof Short     ? 's' :
   7736                         '\0';
   7737 
   7738                 if (entryType != '\0') {
   7739                     uri.append(entryType);
   7740                     uri.append('.');
   7741                     uri.append(Uri.encode(key));
   7742                     uri.append('=');
   7743                     uri.append(Uri.encode(value.toString()));
   7744                     uri.append(';');
   7745                 }
   7746             }
   7747         }
   7748     }
   7749 
   7750     public int describeContents() {
   7751         return (mExtras != null) ? mExtras.describeContents() : 0;
   7752     }
   7753 
   7754     public void writeToParcel(Parcel out, int flags) {
   7755         out.writeString(mAction);
   7756         Uri.writeToParcel(out, mData);
   7757         out.writeString(mType);
   7758         out.writeInt(mFlags);
   7759         out.writeString(mPackage);
   7760         ComponentName.writeToParcel(mComponent, out);
   7761 
   7762         if (mSourceBounds != null) {
   7763             out.writeInt(1);
   7764             mSourceBounds.writeToParcel(out, flags);
   7765         } else {
   7766             out.writeInt(0);
   7767         }
   7768 
   7769         if (mCategories != null) {
   7770             final int N = mCategories.size();
   7771             out.writeInt(N);
   7772             for (int i=0; i<N; i++) {
   7773                 out.writeString(mCategories.valueAt(i));
   7774             }
   7775         } else {
   7776             out.writeInt(0);
   7777         }
   7778 
   7779         if (mSelector != null) {
   7780             out.writeInt(1);
   7781             mSelector.writeToParcel(out, flags);
   7782         } else {
   7783             out.writeInt(0);
   7784         }
   7785 
   7786         if (mClipData != null) {
   7787             out.writeInt(1);
   7788             mClipData.writeToParcel(out, flags);
   7789         } else {
   7790             out.writeInt(0);
   7791         }
   7792         out.writeInt(mContentUserHint);
   7793         out.writeBundle(mExtras);
   7794     }
   7795 
   7796     public static final Parcelable.Creator<Intent> CREATOR
   7797             = new Parcelable.Creator<Intent>() {
   7798         public Intent createFromParcel(Parcel in) {
   7799             return new Intent(in);
   7800         }
   7801         public Intent[] newArray(int size) {
   7802             return new Intent[size];
   7803         }
   7804     };
   7805 
   7806     /** @hide */
   7807     protected Intent(Parcel in) {
   7808         readFromParcel(in);
   7809     }
   7810 
   7811     public void readFromParcel(Parcel in) {
   7812         setAction(in.readString());
   7813         mData = Uri.CREATOR.createFromParcel(in);
   7814         mType = in.readString();
   7815         mFlags = in.readInt();
   7816         mPackage = in.readString();
   7817         mComponent = ComponentName.readFromParcel(in);
   7818 
   7819         if (in.readInt() != 0) {
   7820             mSourceBounds = Rect.CREATOR.createFromParcel(in);
   7821         }
   7822 
   7823         int N = in.readInt();
   7824         if (N > 0) {
   7825             mCategories = new ArraySet<String>();
   7826             int i;
   7827             for (i=0; i<N; i++) {
   7828                 mCategories.add(in.readString().intern());
   7829             }
   7830         } else {
   7831             mCategories = null;
   7832         }
   7833 
   7834         if (in.readInt() != 0) {
   7835             mSelector = new Intent(in);
   7836         }
   7837 
   7838         if (in.readInt() != 0) {
   7839             mClipData = new ClipData(in);
   7840         }
   7841         mContentUserHint = in.readInt();
   7842         mExtras = in.readBundle();
   7843     }
   7844 
   7845     /**
   7846      * Parses the "intent" element (and its children) from XML and instantiates
   7847      * an Intent object.  The given XML parser should be located at the tag
   7848      * where parsing should start (often named "intent"), from which the
   7849      * basic action, data, type, and package and class name will be
   7850      * retrieved.  The function will then parse in to any child elements,
   7851      * looking for <category android:name="xxx"> tags to add categories and
   7852      * <extra android:name="xxx" android:value="yyy"> to attach extra data
   7853      * to the intent.
   7854      *
   7855      * @param resources The Resources to use when inflating resources.
   7856      * @param parser The XML parser pointing at an "intent" tag.
   7857      * @param attrs The AttributeSet interface for retrieving extended
   7858      * attribute data at the current <var>parser</var> location.
   7859      * @return An Intent object matching the XML data.
   7860      * @throws XmlPullParserException If there was an XML parsing error.
   7861      * @throws IOException If there was an I/O error.
   7862      */
   7863     public static Intent parseIntent(Resources resources, XmlPullParser parser, AttributeSet attrs)
   7864             throws XmlPullParserException, IOException {
   7865         Intent intent = new Intent();
   7866 
   7867         TypedArray sa = resources.obtainAttributes(attrs,
   7868                 com.android.internal.R.styleable.Intent);
   7869 
   7870         intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
   7871 
   7872         String data = sa.getString(com.android.internal.R.styleable.Intent_data);
   7873         String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
   7874         intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
   7875 
   7876         String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
   7877         String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
   7878         if (packageName != null && className != null) {
   7879             intent.setComponent(new ComponentName(packageName, className));
   7880         }
   7881 
   7882         sa.recycle();
   7883 
   7884         int outerDepth = parser.getDepth();
   7885         int type;
   7886         while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
   7887                && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
   7888             if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
   7889                 continue;
   7890             }
   7891 
   7892             String nodeName = parser.getName();
   7893             if (nodeName.equals(TAG_CATEGORIES)) {
   7894                 sa = resources.obtainAttributes(attrs,
   7895                         com.android.internal.R.styleable.IntentCategory);
   7896                 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
   7897                 sa.recycle();
   7898 
   7899                 if (cat != null) {
   7900                     intent.addCategory(cat);
   7901                 }
   7902                 XmlUtils.skipCurrentTag(parser);
   7903 
   7904             } else if (nodeName.equals(TAG_EXTRA)) {
   7905                 if (intent.mExtras == null) {
   7906                     intent.mExtras = new Bundle();
   7907                 }
   7908                 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
   7909                 XmlUtils.skipCurrentTag(parser);
   7910 
   7911             } else {
   7912                 XmlUtils.skipCurrentTag(parser);
   7913             }
   7914         }
   7915 
   7916         return intent;
   7917     }
   7918 
   7919     /** @hide */
   7920     public void saveToXml(XmlSerializer out) throws IOException {
   7921         if (mAction != null) {
   7922             out.attribute(null, ATTR_ACTION, mAction);
   7923         }
   7924         if (mData != null) {
   7925             out.attribute(null, ATTR_DATA, mData.toString());
   7926         }
   7927         if (mType != null) {
   7928             out.attribute(null, ATTR_TYPE, mType);
   7929         }
   7930         if (mComponent != null) {
   7931             out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
   7932         }
   7933         out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
   7934 
   7935         if (mCategories != null) {
   7936             out.startTag(null, TAG_CATEGORIES);
   7937             for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
   7938                 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
   7939             }
   7940             out.endTag(null, TAG_CATEGORIES);
   7941         }
   7942     }
   7943 
   7944     /** @hide */
   7945     public static Intent restoreFromXml(XmlPullParser in) throws IOException,
   7946             XmlPullParserException {
   7947         Intent intent = new Intent();
   7948         final int outerDepth = in.getDepth();
   7949 
   7950         int attrCount = in.getAttributeCount();
   7951         for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
   7952             final String attrName = in.getAttributeName(attrNdx);
   7953             final String attrValue = in.getAttributeValue(attrNdx);
   7954             if (ATTR_ACTION.equals(attrName)) {
   7955                 intent.setAction(attrValue);
   7956             } else if (ATTR_DATA.equals(attrName)) {
   7957                 intent.setData(Uri.parse(attrValue));
   7958             } else if (ATTR_TYPE.equals(attrName)) {
   7959                 intent.setType(attrValue);
   7960             } else if (ATTR_COMPONENT.equals(attrName)) {
   7961                 intent.setComponent(ComponentName.unflattenFromString(attrValue));
   7962             } else if (ATTR_FLAGS.equals(attrName)) {
   7963                 intent.setFlags(Integer.valueOf(attrValue, 16));
   7964             } else {
   7965                 Log.e("Intent", "restoreFromXml: unknown attribute=" + attrName);
   7966             }
   7967         }
   7968 
   7969         int event;
   7970         String name;
   7971         while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
   7972                 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
   7973             if (event == XmlPullParser.START_TAG) {
   7974                 name = in.getName();
   7975                 if (TAG_CATEGORIES.equals(name)) {
   7976                     attrCount = in.getAttributeCount();
   7977                     for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
   7978                         intent.addCategory(in.getAttributeValue(attrNdx));
   7979                     }
   7980                 } else {
   7981                     Log.w("Intent", "restoreFromXml: unknown name=" + name);
   7982                     XmlUtils.skipCurrentTag(in);
   7983                 }
   7984             }
   7985         }
   7986 
   7987         return intent;
   7988     }
   7989 
   7990     /**
   7991      * Normalize a MIME data type.
   7992      *
   7993      * <p>A normalized MIME type has white-space trimmed,
   7994      * content-type parameters removed, and is lower-case.
   7995      * This aligns the type with Android best practices for
   7996      * intent filtering.
   7997      *
   7998      * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
   7999      * "text/x-vCard" becomes "text/x-vcard".
   8000      *
   8001      * <p>All MIME types received from outside Android (such as user input,
   8002      * or external sources like Bluetooth, NFC, or the Internet) should
   8003      * be normalized before they are used to create an Intent.
   8004      *
   8005      * @param type MIME data type to normalize
   8006      * @return normalized MIME data type, or null if the input was null
   8007      * @see #setType
   8008      * @see #setTypeAndNormalize
   8009      */
   8010     public static String normalizeMimeType(String type) {
   8011         if (type == null) {
   8012             return null;
   8013         }
   8014 
   8015         type = type.trim().toLowerCase(Locale.ROOT);
   8016 
   8017         final int semicolonIndex = type.indexOf(';');
   8018         if (semicolonIndex != -1) {
   8019             type = type.substring(0, semicolonIndex);
   8020         }
   8021         return type;
   8022     }
   8023 
   8024     /**
   8025      * Prepare this {@link Intent} to leave an app process.
   8026      *
   8027      * @hide
   8028      */
   8029     public void prepareToLeaveProcess() {
   8030         setAllowFds(false);
   8031 
   8032         if (mSelector != null) {
   8033             mSelector.prepareToLeaveProcess();
   8034         }
   8035         if (mClipData != null) {
   8036             mClipData.prepareToLeaveProcess();
   8037         }
   8038 
   8039         if (mData != null && StrictMode.vmFileUriExposureEnabled()) {
   8040             // There are several ACTION_MEDIA_* broadcasts that send file://
   8041             // Uris, so only check common actions.
   8042             if (ACTION_VIEW.equals(mAction) ||
   8043                     ACTION_EDIT.equals(mAction) ||
   8044                     ACTION_ATTACH_DATA.equals(mAction)) {
   8045                 mData.checkFileUriExposed("Intent.getData()");
   8046             }
   8047         }
   8048     }
   8049 
   8050     /**
   8051      * @hide
   8052      */
   8053     public void prepareToEnterProcess() {
   8054         if (mContentUserHint != UserHandle.USER_CURRENT) {
   8055             if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
   8056                 fixUris(mContentUserHint);
   8057                 mContentUserHint = UserHandle.USER_CURRENT;
   8058             }
   8059         }
   8060     }
   8061 
   8062     /**
   8063      * @hide
   8064      */
   8065      public void fixUris(int contentUserHint) {
   8066         Uri data = getData();
   8067         if (data != null) {
   8068             mData = maybeAddUserId(data, contentUserHint);
   8069         }
   8070         if (mClipData != null) {
   8071             mClipData.fixUris(contentUserHint);
   8072         }
   8073         String action = getAction();
   8074         if (ACTION_SEND.equals(action)) {
   8075             final Uri stream = getParcelableExtra(EXTRA_STREAM);
   8076             if (stream != null) {
   8077                 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
   8078             }
   8079         } else if (ACTION_SEND_MULTIPLE.equals(action)) {
   8080             final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
   8081             if (streams != null) {
   8082                 ArrayList<Uri> newStreams = new ArrayList<Uri>();
   8083                 for (int i = 0; i < streams.size(); i++) {
   8084                     newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
   8085                 }
   8086                 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
   8087             }
   8088         } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
   8089                 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
   8090                 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
   8091             final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
   8092             if (output != null) {
   8093                 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
   8094             }
   8095         }
   8096      }
   8097 
   8098     /**
   8099      * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
   8100      * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
   8101      * intents in {@link #ACTION_CHOOSER}.
   8102      *
   8103      * @return Whether any contents were migrated.
   8104      * @hide
   8105      */
   8106     public boolean migrateExtraStreamToClipData() {
   8107         // Refuse to touch if extras already parcelled
   8108         if (mExtras != null && mExtras.isParcelled()) return false;
   8109 
   8110         // Bail when someone already gave us ClipData
   8111         if (getClipData() != null) return false;
   8112 
   8113         final String action = getAction();
   8114         if (ACTION_CHOOSER.equals(action)) {
   8115             // Inspect contained intents to see if we need to migrate extras. We
   8116             // don't promote ClipData to the parent, since ChooserActivity will
   8117             // already start the picked item as the caller, and we can't combine
   8118             // the flags in a safe way.
   8119 
   8120             boolean migrated = false;
   8121             try {
   8122                 final Intent intent = getParcelableExtra(EXTRA_INTENT);
   8123                 if (intent != null) {
   8124                     migrated |= intent.migrateExtraStreamToClipData();
   8125                 }
   8126             } catch (ClassCastException e) {
   8127             }
   8128             try {
   8129                 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
   8130                 if (intents != null) {
   8131                     for (int i = 0; i < intents.length; i++) {
   8132                         final Intent intent = (Intent) intents[i];
   8133                         if (intent != null) {
   8134                             migrated |= intent.migrateExtraStreamToClipData();
   8135                         }
   8136                     }
   8137                 }
   8138             } catch (ClassCastException e) {
   8139             }
   8140             return migrated;
   8141 
   8142         } else if (ACTION_SEND.equals(action)) {
   8143             try {
   8144                 final Uri stream = getParcelableExtra(EXTRA_STREAM);
   8145                 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
   8146                 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
   8147                 if (stream != null || text != null || htmlText != null) {
   8148                     final ClipData clipData = new ClipData(
   8149                             null, new String[] { getType() },
   8150                             new ClipData.Item(text, htmlText, null, stream));
   8151                     setClipData(clipData);
   8152                     addFlags(FLAG_GRANT_READ_URI_PERMISSION);
   8153                     return true;
   8154                 }
   8155             } catch (ClassCastException e) {
   8156             }
   8157 
   8158         } else if (ACTION_SEND_MULTIPLE.equals(action)) {
   8159             try {
   8160                 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
   8161                 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
   8162                 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
   8163                 int num = -1;
   8164                 if (streams != null) {
   8165                     num = streams.size();
   8166                 }
   8167                 if (texts != null) {
   8168                     if (num >= 0 && num != texts.size()) {
   8169                         // Wha...!  F- you.
   8170                         return false;
   8171                     }
   8172                     num = texts.size();
   8173                 }
   8174                 if (htmlTexts != null) {
   8175                     if (num >= 0 && num != htmlTexts.size()) {
   8176                         // Wha...!  F- you.
   8177                         return false;
   8178                     }
   8179                     num = htmlTexts.size();
   8180                 }
   8181                 if (num > 0) {
   8182                     final ClipData clipData = new ClipData(
   8183                             null, new String[] { getType() },
   8184                             makeClipItem(streams, texts, htmlTexts, 0));
   8185 
   8186                     for (int i = 1; i < num; i++) {
   8187                         clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
   8188                     }
   8189 
   8190                     setClipData(clipData);
   8191                     addFlags(FLAG_GRANT_READ_URI_PERMISSION);
   8192                     return true;
   8193                 }
   8194             } catch (ClassCastException e) {
   8195             }
   8196         } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
   8197                 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
   8198                 || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
   8199             final Uri output;
   8200             try {
   8201                 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
   8202             } catch (ClassCastException e) {
   8203                 return false;
   8204             }
   8205             if (output != null) {
   8206                 setClipData(ClipData.newRawUri("", output));
   8207                 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
   8208                 return true;
   8209             }
   8210         }
   8211 
   8212         return false;
   8213     }
   8214 
   8215     private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
   8216             ArrayList<String> htmlTexts, int which) {
   8217         Uri uri = streams != null ? streams.get(which) : null;
   8218         CharSequence text = texts != null ? texts.get(which) : null;
   8219         String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
   8220         return new ClipData.Item(text, htmlText, null, uri);
   8221     }
   8222 
   8223     /** @hide */
   8224     public boolean isDocument() {
   8225         return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
   8226     }
   8227 }
   8228