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