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 static android.content.ContentProvider.maybeAddUserId;
20 
21 import android.annotation.AnyRes;
22 import android.annotation.BroadcastBehavior;
23 import android.annotation.IntDef;
24 import android.annotation.NonNull;
25 import android.annotation.Nullable;
26 import android.annotation.RequiresPermission;
27 import android.annotation.SdkConstant;
28 import android.annotation.SdkConstant.SdkConstantType;
29 import android.annotation.SuppressLint;
30 import android.annotation.SystemApi;
31 import android.annotation.TestApi;
32 import android.app.AppGlobals;
33 import android.compat.annotation.UnsupportedAppUsage;
34 import android.content.pm.ActivityInfo;
35 import android.content.pm.ApplicationInfo;
36 import android.content.pm.ComponentInfo;
37 import android.content.pm.PackageManager;
38 import android.content.pm.ResolveInfo;
39 import android.content.pm.ShortcutInfo;
40 import android.content.pm.SuspendDialogInfo;
41 import android.content.res.Resources;
42 import android.content.res.TypedArray;
43 import android.graphics.Rect;
44 import android.net.Uri;
45 import android.os.Build;
46 import android.os.Bundle;
47 import android.os.IBinder;
48 import android.os.IncidentManager;
49 import android.os.Parcel;
50 import android.os.Parcelable;
51 import android.os.PersistableBundle;
52 import android.os.Process;
53 import android.os.ResultReceiver;
54 import android.os.ShellCommand;
55 import android.os.StrictMode;
56 import android.os.UserHandle;
57 import android.os.storage.StorageManager;
58 import android.provider.ContactsContract.QuickContact;
59 import android.provider.DocumentsContract;
60 import android.provider.DocumentsProvider;
61 import android.provider.MediaStore;
62 import android.provider.OpenableColumns;
63 import android.telecom.PhoneAccount;
64 import android.telecom.TelecomManager;
65 import android.text.TextUtils;
66 import android.util.ArraySet;
67 import android.util.AttributeSet;
68 import android.util.Log;
69 import android.util.proto.ProtoOutputStream;
70 
71 import com.android.internal.util.XmlUtils;
72 
73 import org.xmlpull.v1.XmlPullParser;
74 import org.xmlpull.v1.XmlPullParserException;
75 import org.xmlpull.v1.XmlSerializer;
76 
77 import java.io.File;
78 import java.io.IOException;
79 import java.io.PrintWriter;
80 import java.io.Serializable;
81 import java.lang.annotation.Retention;
82 import java.lang.annotation.RetentionPolicy;
83 import java.net.URISyntaxException;
84 import java.util.ArrayList;
85 import java.util.HashSet;
86 import java.util.List;
87 import java.util.Locale;
88 import java.util.Objects;
89 import java.util.Set;
90 import java.util.TimeZone;
91 
92 /**
93  * An intent is an abstract description of an operation to be performed.  It
94  * can be used with {@link Context#startActivity(Intent) startActivity} to
95  * launch an {@link android.app.Activity},
96  * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
97  * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
98  * and {@link android.content.Context#startService} or
99  * {@link android.content.Context#bindService} to communicate with a
100  * background {@link android.app.Service}.
101  *
102  * <p>An Intent provides a facility for performing late runtime binding between the code in
103  * different applications. Its most significant use is in the launching of activities, where it
104  * can be thought of as the glue between activities. It is basically a passive data structure
105  * holding an abstract description of an action to be performed.</p>
106  *
107  * <div class="special reference">
108  * <h3>Developer Guides</h3>
109  * <p>For information about how to create and resolve intents, read the
110  * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
111  * developer guide.</p>
112  * </div>
113  *
114  * <a name="IntentStructure"></a>
115  * <h3>Intent Structure</h3>
116  * <p>The primary pieces of information in an intent are:</p>
117  *
118  * <ul>
119  *   <li> <p><b>action</b> -- The general action to be performed, such as
120  *     {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
121  *     etc.</p>
122  *   </li>
123  *   <li> <p><b>data</b> -- The data to operate on, such as a person record
124  *     in the contacts database, expressed as a {@link android.net.Uri}.</p>
125  *   </li>
126  * </ul>
127  *
128  *
129  * <p>Some examples of action/data pairs are:</p>
130  *
131  * <ul>
132  *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
133  *     information about the person whose identifier is "1".</p>
134  *   </li>
135  *   <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
136  *     the phone dialer with the person filled in.</p>
137  *   </li>
138  *   <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
139  *     the phone dialer with the given number filled in.  Note how the
140  *     VIEW action does what is considered the most reasonable thing for
141  *     a particular URI.</p>
142  *   </li>
143  *   <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
144  *     the phone dialer with the given number filled in.</p>
145  *   </li>
146  *   <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
147  *     information about the person whose identifier is "1".</p>
148  *   </li>
149  *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
150  *     a list of people, which the user can browse through.  This example is a
151  *     typical top-level entry into the Contacts application, showing you the
152  *     list of people. Selecting a particular person to view would result in a
153  *     new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
154  *     being used to start an activity to display that person.</p>
155  *   </li>
156  * </ul>
157  *
158  * <p>In addition to these primary attributes, there are a number of secondary
159  * attributes that you can also include with an intent:</p>
160  *
161  * <ul>
162  *     <li> <p><b>category</b> -- Gives additional information about the action
163  *         to execute.  For example, {@link #CATEGORY_LAUNCHER} means it should
164  *         appear in the Launcher as a top-level application, while
165  *         {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
166  *         of alternative actions the user can perform on a piece of data.</p>
167  *     <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
168  *         intent data.  Normally the type is inferred from the data itself.
169  *         By setting this attribute, you disable that evaluation and force
170  *         an explicit type.</p>
171  *     <li> <p><b>component</b> -- Specifies an explicit name of a component
172  *         class to use for the intent.  Normally this is determined by looking
173  *         at the other information in the intent (the action, data/type, and
174  *         categories) and matching that with a component that can handle it.
175  *         If this attribute is set then none of the evaluation is performed,
176  *         and this component is used exactly as is.  By specifying this attribute,
177  *         all of the other Intent attributes become optional.</p>
178  *     <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
179  *         This can be used to provide extended information to the component.
180  *         For example, if we have a action to send an e-mail message, we could
181  *         also include extra pieces of data here to supply a subject, body,
182  *         etc.</p>
183  * </ul>
184  *
185  * <p>Here are some examples of other operations you can specify as intents
186  * using these additional parameters:</p>
187  *
188  * <ul>
189  *   <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
190  *     Launch the home screen.</p>
191  *   </li>
192  *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
193  *     <i>{@link android.provider.Contacts.Phones#CONTENT_URI
194  *     vnd.android.cursor.item/phone}</i></b>
195  *     -- Display the list of people's phone numbers, allowing the user to
196  *     browse through them and pick one and return it to the parent activity.</p>
197  *   </li>
198  *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
199  *     <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
200  *     -- Display all pickers for data that can be opened with
201  *     {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
202  *     allowing the user to pick one of them and then some data inside of it
203  *     and returning the resulting URI to the caller.  This can be used,
204  *     for example, in an e-mail application to allow the user to pick some
205  *     data to include as an attachment.</p>
206  *   </li>
207  * </ul>
208  *
209  * <p>There are a variety of standard Intent action and category constants
210  * defined in the Intent class, but applications can also define their own.
211  * These strings use Java-style scoping, to ensure they are unique -- for
212  * example, the standard {@link #ACTION_VIEW} is called
213  * "android.intent.action.VIEW".</p>
214  *
215  * <p>Put together, the set of actions, data types, categories, and extra data
216  * defines a language for the system allowing for the expression of phrases
217  * such as "call john smith's cell".  As applications are added to the system,
218  * they can extend this language by adding new actions, types, and categories, or
219  * they can modify the behavior of existing phrases by supplying their own
220  * activities that handle them.</p>
221  *
222  * <a name="IntentResolution"></a>
223  * <h3>Intent Resolution</h3>
224  *
225  * <p>There are two primary forms of intents you will use.
226  *
227  * <ul>
228  *     <li> <p><b>Explicit Intents</b> have specified a component (via
229  *     {@link #setComponent} or {@link #setClass}), which provides the exact
230  *     class to be run.  Often these will not include any other information,
231  *     simply being a way for an application to launch various internal
232  *     activities it has as the user interacts with the application.
233  *
234  *     <li> <p><b>Implicit Intents</b> have not specified a component;
235  *     instead, they must include enough information for the system to
236  *     determine which of the available components is best to run for that
237  *     intent.
238  * </ul>
239  *
240  * <p>When using implicit intents, given such an arbitrary intent we need to
241  * know what to do with it. This is handled by the process of <em>Intent
242  * resolution</em>, which maps an Intent to an {@link android.app.Activity},
243  * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
244  * more activities/receivers) that can handle it.</p>
245  *
246  * <p>The intent resolution mechanism basically revolves around matching an
247  * Intent against all of the &lt;intent-filter&gt; descriptions in the
248  * installed application packages.  (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
249  * objects explicitly registered with {@link Context#registerReceiver}.)  More
250  * details on this can be found in the documentation on the {@link
251  * IntentFilter} class.</p>
252  *
253  * <p>There are three pieces of information in the Intent that are used for
254  * resolution: the action, type, and category.  Using this information, a query
255  * is done on the {@link PackageManager} for a component that can handle the
256  * intent. The appropriate component is determined based on the intent
257  * information supplied in the <code>AndroidManifest.xml</code> file as
258  * follows:</p>
259  *
260  * <ul>
261  *     <li> <p>The <b>action</b>, if given, must be listed by the component as
262  *         one it handles.</p>
263  *     <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
264  *         already supplied in the Intent.  Like the action, if a type is
265  *         included in the intent (either explicitly or implicitly in its
266  *         data), then this must be listed by the component as one it handles.</p>
267  *     <li> For data that is not a <code>content:</code> URI and where no explicit
268  *         type is included in the Intent, instead the <b>scheme</b> of the
269  *         intent data (such as <code>http:</code> or <code>mailto:</code>) is
270  *         considered. Again like the action, if we are matching a scheme it
271  *         must be listed by the component as one it can handle.
272  *     <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
273  *         by the activity as categories it handles.  That is, if you include
274  *         the categories {@link #CATEGORY_LAUNCHER} and
275  *         {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
276  *         with an intent that lists <em>both</em> of those categories.
277  *         Activities will very often need to support the
278  *         {@link #CATEGORY_DEFAULT} so that they can be found by
279  *         {@link Context#startActivity Context.startActivity()}.</p>
280  * </ul>
281  *
282  * <p>For example, consider the Note Pad sample application that
283  * allows a user to browse through a list of notes data and view details about
284  * individual items.  Text in italics indicates places where you would replace a
285  * name with one specific to your own package.</p>
286  *
287  * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
288  *       package="<i>com.android.notepad</i>"&gt;
289  *     &lt;application android:icon="@drawable/app_notes"
290  *             android:label="@string/app_name"&gt;
291  *
292  *         &lt;provider class=".NotePadProvider"
293  *                 android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
294  *
295  *         &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
296  *             &lt;intent-filter&gt;
297  *                 &lt;action android:name="android.intent.action.MAIN" /&gt;
298  *                 &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
299  *             &lt;/intent-filter&gt;
300  *             &lt;intent-filter&gt;
301  *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
302  *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
303  *                 &lt;action android:name="android.intent.action.PICK" /&gt;
304  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
305  *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
306  *             &lt;/intent-filter&gt;
307  *             &lt;intent-filter&gt;
308  *                 &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
309  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
310  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
311  *             &lt;/intent-filter&gt;
312  *         &lt;/activity&gt;
313  *
314  *         &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
315  *             &lt;intent-filter android:label="@string/resolve_edit"&gt;
316  *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
317  *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
318  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
319  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
320  *             &lt;/intent-filter&gt;
321  *
322  *             &lt;intent-filter&gt;
323  *                 &lt;action android:name="android.intent.action.INSERT" /&gt;
324  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
325  *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
326  *             &lt;/intent-filter&gt;
327  *
328  *         &lt;/activity&gt;
329  *
330  *         &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
331  *                 android:theme="@android:style/Theme.Dialog"&gt;
332  *             &lt;intent-filter android:label="@string/resolve_title"&gt;
333  *                 &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
334  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
335  *                 &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
336  *                 &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
337  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
338  *             &lt;/intent-filter&gt;
339  *         &lt;/activity&gt;
340  *
341  *     &lt;/application&gt;
342  * &lt;/manifest&gt;</pre>
343  *
344  * <p>The first activity,
345  * <code>com.android.notepad.NotesList</code>, serves as our main
346  * entry into the app.  It can do three things as described by its three intent
347  * templates:
348  * <ol>
349  * <li><pre>
350  * &lt;intent-filter&gt;
351  *     &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
352  *     &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
353  * &lt;/intent-filter&gt;</pre>
354  * <p>This provides a top-level entry into the NotePad application: the standard
355  * MAIN action is a main entry point (not requiring any other information in
356  * the Intent), and the LAUNCHER category says that this entry point should be
357  * listed in the application launcher.</p>
358  * <li><pre>
359  * &lt;intent-filter&gt;
360  *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
361  *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
362  *     &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
363  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
364  *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
365  * &lt;/intent-filter&gt;</pre>
366  * <p>This declares the things that the activity can do on a directory of
367  * notes.  The type being supported is given with the &lt;type&gt; tag, where
368  * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
369  * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
370  * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
371  * The activity allows the user to view or edit the directory of data (via
372  * the VIEW and EDIT actions), or to pick a particular note and return it
373  * to the caller (via the PICK action).  Note also the DEFAULT category
374  * supplied here: this is <em>required</em> for the
375  * {@link Context#startActivity Context.startActivity} method to resolve your
376  * activity when its component name is not explicitly specified.</p>
377  * <li><pre>
378  * &lt;intent-filter&gt;
379  *     &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
380  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
381  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
382  * &lt;/intent-filter&gt;</pre>
383  * <p>This filter describes the ability to return to the caller a note selected by
384  * the user without needing to know where it came from.  The data type
385  * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
386  * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
387  * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
388  * The GET_CONTENT action is similar to the PICK action, where the activity
389  * will return to its caller a piece of data selected by the user.  Here,
390  * however, the caller specifies the type of data they desire instead of
391  * the type of data the user will be picking from.</p>
392  * </ol>
393  *
394  * <p>Given these capabilities, the following intents will resolve to the
395  * NotesList activity:</p>
396  *
397  * <ul>
398  *     <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
399  *         activities that can be used as top-level entry points into an
400  *         application.</p>
401  *     <li> <p><b>{ action=android.app.action.MAIN,
402  *         category=android.app.category.LAUNCHER }</b> is the actual intent
403  *         used by the Launcher to populate its top-level list.</p>
404  *     <li> <p><b>{ action=android.intent.action.VIEW
405  *          data=content://com.google.provider.NotePad/notes }</b>
406  *         displays a list of all the notes under
407  *         "content://com.google.provider.NotePad/notes", which
408  *         the user can browse through and see the details on.</p>
409  *     <li> <p><b>{ action=android.app.action.PICK
410  *          data=content://com.google.provider.NotePad/notes }</b>
411  *         provides a list of the notes under
412  *         "content://com.google.provider.NotePad/notes", from which
413  *         the user can pick a note whose data URL is returned back to the caller.</p>
414  *     <li> <p><b>{ action=android.app.action.GET_CONTENT
415  *          type=vnd.android.cursor.item/vnd.google.note }</b>
416  *         is similar to the pick action, but allows the caller to specify the
417  *         kind of data they want back so that the system can find the appropriate
418  *         activity to pick something of that data type.</p>
419  * </ul>
420  *
421  * <p>The second activity,
422  * <code>com.android.notepad.NoteEditor</code>, shows the user a single
423  * note entry and allows them to edit it.  It can do two things as described
424  * by its two intent templates:
425  * <ol>
426  * <li><pre>
427  * &lt;intent-filter android:label="@string/resolve_edit"&gt;
428  *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
429  *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
430  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
431  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
432  * &lt;/intent-filter&gt;</pre>
433  * <p>The first, primary, purpose of this activity is to let the user interact
434  * with a single note, as decribed by the MIME type
435  * <code>vnd.android.cursor.item/vnd.google.note</code>.  The activity can
436  * either VIEW a note or allow the user to EDIT it.  Again we support the
437  * DEFAULT category to allow the activity to be launched without explicitly
438  * specifying its component.</p>
439  * <li><pre>
440  * &lt;intent-filter&gt;
441  *     &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
442  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
443  *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
444  * &lt;/intent-filter&gt;</pre>
445  * <p>The secondary use of this activity is to insert a new note entry into
446  * an existing directory of notes.  This is used when the user creates a new
447  * note: the INSERT action is executed on the directory of notes, causing
448  * this activity to run and have the user create the new note data which
449  * it then adds to the content provider.</p>
450  * </ol>
451  *
452  * <p>Given these capabilities, the following intents will resolve to the
453  * NoteEditor activity:</p>
454  *
455  * <ul>
456  *     <li> <p><b>{ action=android.intent.action.VIEW
457  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
458  *         shows the user the content of note <var>{ID}</var>.</p>
459  *     <li> <p><b>{ action=android.app.action.EDIT
460  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
461  *         allows the user to edit the content of note <var>{ID}</var>.</p>
462  *     <li> <p><b>{ action=android.app.action.INSERT
463  *          data=content://com.google.provider.NotePad/notes }</b>
464  *         creates a new, empty note in the notes list at
465  *         "content://com.google.provider.NotePad/notes"
466  *         and allows the user to edit it.  If they keep their changes, the URI
467  *         of the newly created note is returned to the caller.</p>
468  * </ul>
469  *
470  * <p>The last activity,
471  * <code>com.android.notepad.TitleEditor</code>, allows the user to
472  * edit the title of a note.  This could be implemented as a class that the
473  * application directly invokes (by explicitly setting its component in
474  * the Intent), but here we show a way you can publish alternative
475  * operations on existing data:</p>
476  *
477  * <pre>
478  * &lt;intent-filter android:label="@string/resolve_title"&gt;
479  *     &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
480  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
481  *     &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
482  *     &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
483  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
484  * &lt;/intent-filter&gt;</pre>
485  *
486  * <p>In the single intent template here, we
487  * have created our own private action called
488  * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
489  * edit the title of a note.  It must be invoked on a specific note
490  * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
491  * view and edit actions, but here displays and edits the title contained
492  * in the note data.
493  *
494  * <p>In addition to supporting the default category as usual, our title editor
495  * also supports two other standard categories: ALTERNATIVE and
496  * SELECTED_ALTERNATIVE.  Implementing
497  * these categories allows others to find the special action it provides
498  * without directly knowing about it, through the
499  * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
500  * more often to build dynamic menu items with
501  * {@link android.view.Menu#addIntentOptions}.  Note that in the intent
502  * template here was also supply an explicit name for the template
503  * (via <code>android:label="@string/resolve_title"</code>) to better control
504  * what the user sees when presented with this activity as an alternative
505  * action to the data they are viewing.
506  *
507  * <p>Given these capabilities, the following intent will resolve to the
508  * TitleEditor activity:</p>
509  *
510  * <ul>
511  *     <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
512  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
513  *         displays and allows the user to edit the title associated
514  *         with note <var>{ID}</var>.</p>
515  * </ul>
516  *
517  * <h3>Standard Activity Actions</h3>
518  *
519  * <p>These are the current standard actions that Intent defines for launching
520  * activities (usually through {@link Context#startActivity}.  The most
521  * important, and by far most frequently used, are {@link #ACTION_MAIN} and
522  * {@link #ACTION_EDIT}.
523  *
524  * <ul>
525  *     <li> {@link #ACTION_MAIN}
526  *     <li> {@link #ACTION_VIEW}
527  *     <li> {@link #ACTION_ATTACH_DATA}
528  *     <li> {@link #ACTION_EDIT}
529  *     <li> {@link #ACTION_PICK}
530  *     <li> {@link #ACTION_CHOOSER}
531  *     <li> {@link #ACTION_GET_CONTENT}
532  *     <li> {@link #ACTION_DIAL}
533  *     <li> {@link #ACTION_CALL}
534  *     <li> {@link #ACTION_SEND}
535  *     <li> {@link #ACTION_SENDTO}
536  *     <li> {@link #ACTION_ANSWER}
537  *     <li> {@link #ACTION_INSERT}
538  *     <li> {@link #ACTION_DELETE}
539  *     <li> {@link #ACTION_RUN}
540  *     <li> {@link #ACTION_SYNC}
541  *     <li> {@link #ACTION_PICK_ACTIVITY}
542  *     <li> {@link #ACTION_SEARCH}
543  *     <li> {@link #ACTION_WEB_SEARCH}
544  *     <li> {@link #ACTION_FACTORY_TEST}
545  * </ul>
546  *
547  * <h3>Standard Broadcast Actions</h3>
548  *
549  * <p>These are the current standard actions that Intent defines for receiving
550  * broadcasts (usually through {@link Context#registerReceiver} or a
551  * &lt;receiver&gt; tag in a manifest).
552  *
553  * <ul>
554  *     <li> {@link #ACTION_TIME_TICK}
555  *     <li> {@link #ACTION_TIME_CHANGED}
556  *     <li> {@link #ACTION_TIMEZONE_CHANGED}
557  *     <li> {@link #ACTION_BOOT_COMPLETED}
558  *     <li> {@link #ACTION_PACKAGE_ADDED}
559  *     <li> {@link #ACTION_PACKAGE_CHANGED}
560  *     <li> {@link #ACTION_PACKAGE_REMOVED}
561  *     <li> {@link #ACTION_PACKAGE_RESTARTED}
562  *     <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
563  *     <li> {@link #ACTION_PACKAGES_SUSPENDED}
564  *     <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
565  *     <li> {@link #ACTION_UID_REMOVED}
566  *     <li> {@link #ACTION_BATTERY_CHANGED}
567  *     <li> {@link #ACTION_POWER_CONNECTED}
568  *     <li> {@link #ACTION_POWER_DISCONNECTED}
569  *     <li> {@link #ACTION_SHUTDOWN}
570  * </ul>
571  *
572  * <h3>Standard Categories</h3>
573  *
574  * <p>These are the current standard categories that can be used to further
575  * clarify an Intent via {@link #addCategory}.
576  *
577  * <ul>
578  *     <li> {@link #CATEGORY_DEFAULT}
579  *     <li> {@link #CATEGORY_BROWSABLE}
580  *     <li> {@link #CATEGORY_TAB}
581  *     <li> {@link #CATEGORY_ALTERNATIVE}
582  *     <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
583  *     <li> {@link #CATEGORY_LAUNCHER}
584  *     <li> {@link #CATEGORY_INFO}
585  *     <li> {@link #CATEGORY_HOME}
586  *     <li> {@link #CATEGORY_PREFERENCE}
587  *     <li> {@link #CATEGORY_TEST}
588  *     <li> {@link #CATEGORY_CAR_DOCK}
589  *     <li> {@link #CATEGORY_DESK_DOCK}
590  *     <li> {@link #CATEGORY_LE_DESK_DOCK}
591  *     <li> {@link #CATEGORY_HE_DESK_DOCK}
592  *     <li> {@link #CATEGORY_CAR_MODE}
593  *     <li> {@link #CATEGORY_APP_MARKET}
594  *     <li> {@link #CATEGORY_VR_HOME}
595  * </ul>
596  *
597  * <h3>Standard Extra Data</h3>
598  *
599  * <p>These are the current standard fields that can be used as extra data via
600  * {@link #putExtra}.
601  *
602  * <ul>
603  *     <li> {@link #EXTRA_ALARM_COUNT}
604  *     <li> {@link #EXTRA_BCC}
605  *     <li> {@link #EXTRA_CC}
606  *     <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
607  *     <li> {@link #EXTRA_DATA_REMOVED}
608  *     <li> {@link #EXTRA_DOCK_STATE}
609  *     <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
610  *     <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
611  *     <li> {@link #EXTRA_DOCK_STATE_CAR}
612  *     <li> {@link #EXTRA_DOCK_STATE_DESK}
613  *     <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
614  *     <li> {@link #EXTRA_DONT_KILL_APP}
615  *     <li> {@link #EXTRA_EMAIL}
616  *     <li> {@link #EXTRA_INITIAL_INTENTS}
617  *     <li> {@link #EXTRA_INTENT}
618  *     <li> {@link #EXTRA_KEY_EVENT}
619  *     <li> {@link #EXTRA_ORIGINATING_URI}
620  *     <li> {@link #EXTRA_PHONE_NUMBER}
621  *     <li> {@link #EXTRA_REFERRER}
622  *     <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
623  *     <li> {@link #EXTRA_REPLACING}
624  *     <li> {@link #EXTRA_SHORTCUT_ICON}
625  *     <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
626  *     <li> {@link #EXTRA_SHORTCUT_INTENT}
627  *     <li> {@link #EXTRA_STREAM}
628  *     <li> {@link #EXTRA_SHORTCUT_NAME}
629  *     <li> {@link #EXTRA_SUBJECT}
630  *     <li> {@link #EXTRA_TEMPLATE}
631  *     <li> {@link #EXTRA_TEXT}
632  *     <li> {@link #EXTRA_TITLE}
633  *     <li> {@link #EXTRA_UID}
634  * </ul>
635  *
636  * <h3>Flags</h3>
637  *
638  * <p>These are the possible flags that can be used in the Intent via
639  * {@link #setFlags} and {@link #addFlags}.  See {@link #setFlags} for a list
640  * of all possible flags.
641  */
642 public class Intent implements Parcelable, Cloneable {
643     private static final String TAG = "Intent";
644 
645     private static final String ATTR_ACTION = "action";
646     private static final String TAG_CATEGORIES = "categories";
647     private static final String ATTR_CATEGORY = "category";
648     private static final String TAG_EXTRA = "extra";
649     private static final String ATTR_TYPE = "type";
650     private static final String ATTR_IDENTIFIER = "ident";
651     private static final String ATTR_COMPONENT = "component";
652     private static final String ATTR_DATA = "data";
653     private static final String ATTR_FLAGS = "flags";
654 
655     // ---------------------------------------------------------------------
656     // ---------------------------------------------------------------------
657     // Standard intent activity actions (see action variable).
658 
659     /**
660      *  Activity Action: Start as a main entry point, does not expect to
661      *  receive data.
662      *  <p>Input: nothing
663      *  <p>Output: nothing
664      */
665     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
666     public static final String ACTION_MAIN = "android.intent.action.MAIN";
667 
668     /**
669      * Activity Action: Display the data to the user.  This is the most common
670      * action performed on data -- it is the generic action you can use on
671      * a piece of data to get the most reasonable thing to occur.  For example,
672      * when used on a contacts entry it will view the entry; when used on a
673      * mailto: URI it will bring up a compose window filled with the information
674      * supplied by the URI; when used with a tel: URI it will invoke the
675      * dialer.
676      * <p>Input: {@link #getData} is URI from which to retrieve data.
677      * <p>Output: nothing.
678      */
679     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
680     public static final String ACTION_VIEW = "android.intent.action.VIEW";
681 
682     /**
683      * Extra that can be included on activity intents coming from the storage UI
684      * when it launches sub-activities to manage various types of storage.  For example,
685      * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
686      * the images on the device, and in that case also include this extra to tell the
687      * app it is coming from the storage UI so should help the user manage storage of
688      * this type.
689      */
690     public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
691 
692     /**
693      * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
694      * performed on a piece of data.
695      */
696     public static final String ACTION_DEFAULT = ACTION_VIEW;
697 
698     /**
699      * Activity Action: Quick view the data. Launches a quick viewer for
700      * a URI or a list of URIs.
701      * <p>Activities handling this intent action should handle the vast majority of
702      * MIME types rather than only specific ones.
703      * <p>Quick viewers must render the quick view image locally, and must not send
704      * file content outside current device.
705      * <p>Input: {@link #getData} is a mandatory content URI of the item to
706      * preview. {@link #getClipData} contains an optional list of content URIs
707      * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
708      * optional index of the URI in the clip data to show first.
709      * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
710      * that can be shown in the quick view UI.
711      * <p>Output: nothing.
712      * @see #EXTRA_INDEX
713      * @see #EXTRA_QUICK_VIEW_FEATURES
714      */
715     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
716     public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
717 
718     /**
719      * Used to indicate that some piece of data should be attached to some other
720      * place.  For example, image data could be attached to a contact.  It is up
721      * to the recipient to decide where the data should be attached; the intent
722      * does not specify the ultimate destination.
723      * <p>Input: {@link #getData} is URI of data to be attached.
724      * <p>Output: nothing.
725      */
726     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
727     public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
728 
729     /**
730      * Activity Action: Provide explicit editable access to the given data.
731      * <p>Input: {@link #getData} is URI of data to be edited.
732      * <p>Output: nothing.
733      */
734     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
735     public static final String ACTION_EDIT = "android.intent.action.EDIT";
736 
737     /**
738      * Activity Action: Pick an existing item, or insert a new item, and then edit it.
739      * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
740      * The extras can contain type specific data to pass through to the editing/creating
741      * activity.
742      * <p>Output: The URI of the item that was picked.  This must be a content:
743      * URI so that any receiver can access it.
744      */
745     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
746     public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
747 
748     /**
749      * Activity Action: Pick an item from the data, returning what was selected.
750      * <p>Input: {@link #getData} is URI containing a directory of data
751      * (vnd.android.cursor.dir/*) from which to pick an item.
752      * <p>Output: The URI of the item that was picked.
753      */
754     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
755     public static final String ACTION_PICK = "android.intent.action.PICK";
756 
757     /**
758      * Activity Action: Creates a reminder.
759      * <p>Input: {@link #EXTRA_TITLE} The title of the reminder that will be shown to the user.
760      * {@link #EXTRA_TEXT} The reminder text that will be shown to the user. The intent should at
761      * least specify a title or a text. {@link #EXTRA_TIME} The time when the reminder will be shown
762      * to the user. The time is specified in milliseconds since the Epoch (optional).
763      * </p>
764      * <p>Output: Nothing.</p>
765      *
766      * @see #EXTRA_TITLE
767      * @see #EXTRA_TEXT
768      * @see #EXTRA_TIME
769      */
770     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
771     public static final String ACTION_CREATE_REMINDER = "android.intent.action.CREATE_REMINDER";
772 
773     /**
774      * Activity Action: Creates a shortcut.
775      * <p>Input: Nothing.</p>
776      * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
777      * <p>For compatibility with older versions of android the intent may also contain three
778      * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
779      * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
780      * (value: ShortcutIconResource).</p>
781      *
782      * @see android.content.pm.ShortcutManager#createShortcutResultIntent
783      * @see #EXTRA_SHORTCUT_INTENT
784      * @see #EXTRA_SHORTCUT_NAME
785      * @see #EXTRA_SHORTCUT_ICON
786      * @see #EXTRA_SHORTCUT_ICON_RESOURCE
787      * @see android.content.Intent.ShortcutIconResource
788      */
789     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
790     public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
791 
792     /**
793      * The name of the extra used to define the Intent of a shortcut.
794      *
795      * @see #ACTION_CREATE_SHORTCUT
796      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
797      */
798     @Deprecated
799     public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
800     /**
801      * The name of the extra used to define the name of a shortcut.
802      *
803      * @see #ACTION_CREATE_SHORTCUT
804      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
805      */
806     @Deprecated
807     public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
808     /**
809      * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
810      *
811      * @see #ACTION_CREATE_SHORTCUT
812      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
813      */
814     @Deprecated
815     public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
816     /**
817      * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
818      *
819      * @see #ACTION_CREATE_SHORTCUT
820      * @see android.content.Intent.ShortcutIconResource
821      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
822      */
823     @Deprecated
824     public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
825             "android.intent.extra.shortcut.ICON_RESOURCE";
826 
827     /**
828      * An activity that provides a user interface for adjusting application preferences.
829      * Optional but recommended settings for all applications which have settings.
830      */
831     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
832     public static final String ACTION_APPLICATION_PREFERENCES
833             = "android.intent.action.APPLICATION_PREFERENCES";
834 
835     /**
836      * Activity Action: Launch an activity showing the app information.
837      * For applications which install other applications (such as app stores), it is recommended
838      * to handle this action for providing the app information to the user.
839      *
840      * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
841      * to be displayed.
842      * <p>Output: Nothing.
843      */
844     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
845     public static final String ACTION_SHOW_APP_INFO
846             = "android.intent.action.SHOW_APP_INFO";
847 
848     /**
849      * Represents a shortcut/live folder icon resource.
850      *
851      * @see Intent#ACTION_CREATE_SHORTCUT
852      * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
853      * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
854      * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
855      */
856     public static class ShortcutIconResource implements Parcelable {
857         /**
858          * The package name of the application containing the icon.
859          */
860         public String packageName;
861 
862         /**
863          * The resource name of the icon, including package, name and type.
864          */
865         public String resourceName;
866 
867         /**
868          * Creates a new ShortcutIconResource for the specified context and resource
869          * identifier.
870          *
871          * @param context The context of the application.
872          * @param resourceId The resource identifier for the icon.
873          * @return A new ShortcutIconResource with the specified's context package name
874          *         and icon resource identifier.``
875          */
fromContext(Context context, @AnyRes int resourceId)876         public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
877             ShortcutIconResource icon = new ShortcutIconResource();
878             icon.packageName = context.getPackageName();
879             icon.resourceName = context.getResources().getResourceName(resourceId);
880             return icon;
881         }
882 
883         /**
884          * Used to read a ShortcutIconResource from a Parcel.
885          */
886         public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR =
887             new Parcelable.Creator<ShortcutIconResource>() {
888 
889                 public ShortcutIconResource createFromParcel(Parcel source) {
890                     ShortcutIconResource icon = new ShortcutIconResource();
891                     icon.packageName = source.readString8();
892                     icon.resourceName = source.readString8();
893                     return icon;
894                 }
895 
896                 public ShortcutIconResource[] newArray(int size) {
897                     return new ShortcutIconResource[size];
898                 }
899             };
900 
901         /**
902          * No special parcel contents.
903          */
describeContents()904         public int describeContents() {
905             return 0;
906         }
907 
writeToParcel(Parcel dest, int flags)908         public void writeToParcel(Parcel dest, int flags) {
909             dest.writeString8(packageName);
910             dest.writeString8(resourceName);
911         }
912 
913         @Override
toString()914         public String toString() {
915             return resourceName;
916         }
917     }
918 
919     /**
920      * Activity Action: Display an activity chooser, allowing the user to pick
921      * what they want to before proceeding.  This can be used as an alternative
922      * to the standard activity picker that is displayed by the system when
923      * you try to start an activity with multiple possible matches, with these
924      * differences in behavior:
925      * <ul>
926      * <li>You can specify the title that will appear in the activity chooser.
927      * <li>The user does not have the option to make one of the matching
928      * activities a preferred activity, and all possible activities will
929      * always be shown even if one of them is currently marked as the
930      * preferred activity.
931      * </ul>
932      * <p>
933      * This action should be used when the user will naturally expect to
934      * select an activity in order to proceed.  An example if when not to use
935      * it is when the user clicks on a "mailto:" link.  They would naturally
936      * expect to go directly to their mail app, so startActivity() should be
937      * called directly: it will
938      * either launch the current preferred app, or put up a dialog allowing the
939      * user to pick an app to use and optionally marking that as preferred.
940      * <p>
941      * In contrast, if the user is selecting a menu item to send a picture
942      * they are viewing to someone else, there are many different things they
943      * may want to do at this point: send it through e-mail, upload it to a
944      * web service, etc.  In this case the CHOOSER action should be used, to
945      * always present to the user a list of the things they can do, with a
946      * nice title given by the caller such as "Send this photo with:".
947      * <p>
948      * If you need to grant URI permissions through a chooser, you must specify
949      * the permissions to be granted on the ACTION_CHOOSER Intent
950      * <em>in addition</em> to the EXTRA_INTENT inside.  This means using
951      * {@link #setClipData} to specify the URIs to be granted as well as
952      * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
953      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
954      * <p>
955      * As a convenience, an Intent of this form can be created with the
956      * {@link #createChooser} function.
957      * <p>
958      * Input: No data should be specified.  get*Extra must have
959      * a {@link #EXTRA_INTENT} field containing the Intent being executed,
960      * and can optionally have a {@link #EXTRA_TITLE} field containing the
961      * title text to display in the chooser.
962      * <p>
963      * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
964      */
965     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
966     public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
967 
968     /**
969      * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
970      *
971      * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
972      * target intent, also optionally supplying a title.  If the target
973      * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
974      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
975      * set in the returned chooser intent, with its ClipData set appropriately:
976      * either a direct reflection of {@link #getClipData()} if that is non-null,
977      * or a new ClipData built from {@link #getData()}.
978      *
979      * @param target The Intent that the user will be selecting an activity
980      * to perform.
981      * @param title Optional title that will be displayed in the chooser,
982      * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
983      * @return Return a new Intent object that you can hand to
984      * {@link Context#startActivity(Intent) Context.startActivity()} and
985      * related methods.
986      */
createChooser(Intent target, CharSequence title)987     public static Intent createChooser(Intent target, CharSequence title) {
988         return createChooser(target, title, null);
989     }
990 
991     /**
992      * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
993      *
994      * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
995      * target intent, also optionally supplying a title.  If the target
996      * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
997      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
998      * set in the returned chooser intent, with its ClipData set appropriately:
999      * either a direct reflection of {@link #getClipData()} if that is non-null,
1000      * or a new ClipData built from {@link #getData()}.</p>
1001      *
1002      * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
1003      * when the user makes a choice. This can be useful if the calling application wants
1004      * to remember the last chosen target and surface it as a more prominent or one-touch
1005      * affordance elsewhere in the UI for next time.</p>
1006      *
1007      * @param target The Intent that the user will be selecting an activity
1008      * to perform.
1009      * @param title Optional title that will be displayed in the chooser,
1010      * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
1011      * @param sender Optional IntentSender to be called when a choice is made.
1012      * @return Return a new Intent object that you can hand to
1013      * {@link Context#startActivity(Intent) Context.startActivity()} and
1014      * related methods.
1015      */
createChooser(Intent target, CharSequence title, IntentSender sender)1016     public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
1017         Intent intent = new Intent(ACTION_CHOOSER);
1018         intent.putExtra(EXTRA_INTENT, target);
1019         if (title != null) {
1020             intent.putExtra(EXTRA_TITLE, title);
1021         }
1022 
1023         if (sender != null) {
1024             intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
1025         }
1026 
1027         // Migrate any clip data and flags from target.
1028         int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
1029                 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
1030                 | FLAG_GRANT_PREFIX_URI_PERMISSION);
1031         if (permFlags != 0) {
1032             ClipData targetClipData = target.getClipData();
1033             if (targetClipData == null && target.getData() != null) {
1034                 ClipData.Item item = new ClipData.Item(target.getData());
1035                 String[] mimeTypes;
1036                 if (target.getType() != null) {
1037                     mimeTypes = new String[] { target.getType() };
1038                 } else {
1039                     mimeTypes = new String[] { };
1040                 }
1041                 targetClipData = new ClipData(null, mimeTypes, item);
1042             }
1043             if (targetClipData != null) {
1044                 intent.setClipData(targetClipData);
1045                 intent.addFlags(permFlags);
1046             }
1047         }
1048 
1049         return intent;
1050     }
1051 
1052     /**
1053      * Activity Action: Allow the user to select a particular kind of data and
1054      * return it.  This is different than {@link #ACTION_PICK} in that here we
1055      * just say what kind of data is desired, not a URI of existing data from
1056      * which the user can pick.  An ACTION_GET_CONTENT could allow the user to
1057      * create the data as it runs (for example taking a picture or recording a
1058      * sound), let them browse over the web and download the desired data,
1059      * etc.
1060      * <p>
1061      * There are two main ways to use this action: if you want a specific kind
1062      * of data, such as a person contact, you set the MIME type to the kind of
1063      * data you want and launch it with {@link Context#startActivity(Intent)}.
1064      * The system will then launch the best application to select that kind
1065      * of data for you.
1066      * <p>
1067      * You may also be interested in any of a set of types of content the user
1068      * can pick.  For example, an e-mail application that wants to allow the
1069      * user to add an attachment to an e-mail message can use this action to
1070      * bring up a list of all of the types of content the user can attach.
1071      * <p>
1072      * In this case, you should wrap the GET_CONTENT intent with a chooser
1073      * (through {@link #createChooser}), which will give the proper interface
1074      * for the user to pick how to send your data and allow you to specify
1075      * a prompt indicating what they are doing.  You will usually specify a
1076      * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1077      * broad range of content types the user can select from.
1078      * <p>
1079      * When using such a broad GET_CONTENT action, it is often desirable to
1080      * only pick from data that can be represented as a stream.  This is
1081      * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1082      * <p>
1083      * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
1084      * the launched content chooser only returns results representing data that
1085      * is locally available on the device.  For example, if this extra is set
1086      * to true then an image picker should not show any pictures that are available
1087      * from a remote server but not already on the local device (thus requiring
1088      * they be downloaded when opened).
1089      * <p>
1090      * If the caller can handle multiple returned items (the user performing
1091      * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1092      * to indicate this.
1093      * <p>
1094      * Input: {@link #getType} is the desired MIME type to retrieve.  Note
1095      * that no URI is supplied in the intent, as there are no constraints on
1096      * where the returned data originally comes from.  You may also include the
1097      * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
1098      * opened as a stream.  You may use {@link #EXTRA_LOCAL_ONLY} to limit content
1099      * selection to local data.  You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1100      * allow the user to select multiple items.
1101      * <p>
1102      * Output: The URI of the item that was picked.  This must be a content:
1103      * URI so that any receiver can access it.
1104      */
1105     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1106     public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1107     /**
1108      * Activity Action: Dial a number as specified by the data.  This shows a
1109      * UI with the number being dialed, allowing the user to explicitly
1110      * initiate the call.
1111      * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1112      * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1113      * number.
1114      * <p>Output: nothing.
1115      */
1116     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1117     public static final String ACTION_DIAL = "android.intent.action.DIAL";
1118     /**
1119      * Activity Action: Perform a call to someone specified by the data.
1120      * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1121      * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1122      * number.
1123      * <p>Output: nothing.
1124      *
1125      * <p>Note: there will be restrictions on which applications can initiate a
1126      * call; most applications should use the {@link #ACTION_DIAL}.
1127      * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1128      * numbers.  Applications can <strong>dial</strong> emergency numbers using
1129      * {@link #ACTION_DIAL}, however.
1130      *
1131      * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
1132      * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
1133      * permission which is not granted, then attempting to use this action will
1134      * result in a {@link java.lang.SecurityException}.
1135      */
1136     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1137     public static final String ACTION_CALL = "android.intent.action.CALL";
1138     /**
1139      * Activity Action: Perform a call to an emergency number specified by the
1140      * data.
1141      * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1142      * tel: URI of an explicit phone number.
1143      * <p>Output: nothing.
1144      *
1145      * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on
1146      * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE}
1147      * extra (if specified) and may be placed on another {@link PhoneAccount} with the
1148      * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external
1149      * factors, such as network conditions and Modem/SIM status.
1150      * @hide
1151      */
1152     @SystemApi
1153     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1154     public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1155     /**
1156      * Activity Action: Dial a emergency number specified by the data.  This shows a
1157      * UI with the number being dialed, allowing the user to explicitly
1158      * initiate the call.
1159      * <p>Input: If nothing, an empty emergency dialer is started; else {@link #getData}
1160      * is a tel: URI of an explicit emergency phone number.
1161      * <p>Output: nothing.
1162      * @hide
1163      */
1164     @SystemApi
1165     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1166     public static final String ACTION_DIAL_EMERGENCY = "android.intent.action.DIAL_EMERGENCY";
1167     /**
1168      * Activity action: Perform a call to any number (emergency or not)
1169      * specified by the data.
1170      * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1171      * tel: URI of an explicit phone number.
1172      * <p>Output: nothing.
1173      * @hide
1174      */
1175     @SystemApi
1176     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1177     public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1178 
1179     /**
1180      * Activity Action: Main entry point for carrier setup apps.
1181      * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1182      * carrier service and typically require
1183      * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1184      * fulfill their duties.
1185      */
1186     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1187     public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1188     /**
1189      * Activity Action: Send a message to someone specified by the data.
1190      * <p>Input: {@link #getData} is URI describing the target.
1191      * <p>Output: nothing.
1192      */
1193     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1194     public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1195     /**
1196      * Activity Action: Deliver some data to someone else.  Who the data is
1197      * being delivered to is not specified; it is up to the receiver of this
1198      * action to ask the user where the data should be sent.
1199      * <p>
1200      * When launching a SEND intent, you should usually wrap it in a chooser
1201      * (through {@link #createChooser}), which will give the proper interface
1202      * for the user to pick how to send your data and allow you to specify
1203      * a prompt indicating what they are doing.
1204      * <p>
1205      * Input: {@link #getType} is the MIME type of the data being sent.
1206      * get*Extra can have either a {@link #EXTRA_TEXT}
1207      * or {@link #EXTRA_STREAM} field, containing the data to be sent.  If
1208      * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1209      * should be the MIME type of the data in EXTRA_STREAM.  Use {@literal *}/*
1210      * if the MIME type is unknown (this will only allow senders that can
1211      * handle generic data streams).  If using {@link #EXTRA_TEXT}, you can
1212      * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1213      * your text with HTML formatting.
1214      * <p>
1215      * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1216      * being sent can be supplied through {@link #setClipData(ClipData)}.  This
1217      * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1218      * content: URIs and other advanced features of {@link ClipData}.  If
1219      * using this approach, you still must supply the same data through the
1220      * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1221      * for compatibility with old applications.  If you don't set a ClipData,
1222      * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1223      * <p>
1224      * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1225      * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1226      * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1227      * be openable only as asset typed files using
1228      * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1229      * <p>
1230      * Optional standard extras, which may be interpreted by some recipients as
1231      * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1232      * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1233      * <p>
1234      * Output: nothing.
1235      */
1236     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1237     public static final String ACTION_SEND = "android.intent.action.SEND";
1238     /**
1239      * Activity Action: Deliver multiple data to someone else.
1240      * <p>
1241      * Like {@link #ACTION_SEND}, except the data is multiple.
1242      * <p>
1243      * Input: {@link #getType} is the MIME type of the data being sent.
1244      * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
1245      * #EXTRA_STREAM} field, containing the data to be sent.  If using
1246      * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1247      * for clients to retrieve your text with HTML formatting.
1248      * <p>
1249      * Multiple types are supported, and receivers should handle mixed types
1250      * whenever possible. The right way for the receiver to check them is to
1251      * use the content resolver on each URI. The intent sender should try to
1252      * put the most concrete mime type in the intent type, but it can fall
1253      * back to {@literal <type>/*} or {@literal *}/* as needed.
1254      * <p>
1255      * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1256      * be image/jpg, but if you are sending image/jpg and image/png, then the
1257      * intent's type should be image/*.
1258      * <p>
1259      * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1260      * being sent can be supplied through {@link #setClipData(ClipData)}.  This
1261      * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1262      * content: URIs and other advanced features of {@link ClipData}.  If
1263      * using this approach, you still must supply the same data through the
1264      * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1265      * for compatibility with old applications.  If you don't set a ClipData,
1266      * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1267      * <p>
1268      * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1269      * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1270      * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1271      * be openable only as asset typed files using
1272      * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1273      * <p>
1274      * Optional standard extras, which may be interpreted by some recipients as
1275      * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1276      * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1277      * <p>
1278      * Output: nothing.
1279      */
1280     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1281     public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1282     /**
1283      * Activity Action: Handle an incoming phone call.
1284      * <p>Input: nothing.
1285      * <p>Output: nothing.
1286      */
1287     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1288     public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1289     /**
1290      * Activity Action: Insert an empty item into the given container.
1291      * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1292      * in which to place the data.
1293      * <p>Output: URI of the new data that was created.
1294      */
1295     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1296     public static final String ACTION_INSERT = "android.intent.action.INSERT";
1297     /**
1298      * Activity Action: Create a new item in the given container, initializing it
1299      * from the current contents of the clipboard.
1300      * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1301      * in which to place the data.
1302      * <p>Output: URI of the new data that was created.
1303      */
1304     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1305     public static final String ACTION_PASTE = "android.intent.action.PASTE";
1306     /**
1307      * Activity Action: Delete the given data from its container.
1308      * <p>Input: {@link #getData} is URI of data to be deleted.
1309      * <p>Output: nothing.
1310      */
1311     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1312     public static final String ACTION_DELETE = "android.intent.action.DELETE";
1313     /**
1314      * Activity Action: Run the data, whatever that means.
1315      * <p>Input: ?  (Note: this is currently specific to the test harness.)
1316      * <p>Output: nothing.
1317      */
1318     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1319     public static final String ACTION_RUN = "android.intent.action.RUN";
1320     /**
1321      * Activity Action: Perform a data synchronization.
1322      * <p>Input: ?
1323      * <p>Output: ?
1324      */
1325     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1326     public static final String ACTION_SYNC = "android.intent.action.SYNC";
1327     /**
1328      * Activity Action: Pick an activity given an intent, returning the class
1329      * selected.
1330      * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1331      * used with {@link PackageManager#queryIntentActivities} to determine the
1332      * set of activities from which to pick.
1333      * <p>Output: Class name of the activity that was selected.
1334      */
1335     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1336     public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1337     /**
1338      * Activity Action: Perform a search.
1339      * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1340      * is the text to search for.  If empty, simply
1341      * enter your search results Activity with the search UI activated.
1342      * <p>Output: nothing.
1343      */
1344     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1345     public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1346     /**
1347      * Activity Action: Start the platform-defined tutorial
1348      * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1349      * is the text to search for.  If empty, simply
1350      * enter your search results Activity with the search UI activated.
1351      * <p>Output: nothing.
1352      */
1353     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1354     public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1355     /**
1356      * Activity Action: Perform a web search.
1357      * <p>
1358      * Input: {@link android.app.SearchManager#QUERY
1359      * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1360      * a url starts with http or https, the site will be opened. If it is plain
1361      * text, Google search will be applied.
1362      * <p>
1363      * Output: nothing.
1364      */
1365     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1366     public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1367 
1368     /**
1369      * Activity Action: Perform assist action.
1370      * <p>
1371      * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1372      * additional optional contextual information about where the user was when they
1373      * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1374      * information.
1375      * Output: nothing.
1376      */
1377     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1378     public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
1379 
1380     /**
1381      * Activity Action: Perform voice assist action.
1382      * <p>
1383      * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1384      * additional optional contextual information about where the user was when they
1385      * requested the voice assist.
1386      * Output: nothing.
1387      * @hide
1388      */
1389     @SystemApi
1390     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1391     public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1392 
1393     /**
1394      * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1395      * application package at the time the assist was invoked.
1396      */
1397     public static final String EXTRA_ASSIST_PACKAGE
1398             = "android.intent.extra.ASSIST_PACKAGE";
1399 
1400     /**
1401      * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1402      * application package at the time the assist was invoked.
1403      */
1404     public static final String EXTRA_ASSIST_UID
1405             = "android.intent.extra.ASSIST_UID";
1406 
1407     /**
1408      * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1409      * information supplied by the current foreground app at the time of the assist request.
1410      * This is a {@link Bundle} of additional data.
1411      */
1412     public static final String EXTRA_ASSIST_CONTEXT
1413             = "android.intent.extra.ASSIST_CONTEXT";
1414 
1415     /**
1416      * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1417      * keyboard as the primary input device for assistance.
1418      */
1419     public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1420             "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1421 
1422     /**
1423      * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1424      * that was used to invoke the assist.
1425      */
1426     public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1427             "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1428 
1429     /**
1430      * Activity Action: List all available applications.
1431      * <p>Input: Nothing.
1432      * <p>Output: nothing.
1433      */
1434     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1435     public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1436     /**
1437      * Activity Action: Show settings for choosing wallpaper.
1438      * <p>Input: Nothing.
1439      * <p>Output: Nothing.
1440      */
1441     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1442     public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1443 
1444     /**
1445      * Activity Action: Show activity for reporting a bug.
1446      * <p>Input: Nothing.
1447      * <p>Output: Nothing.
1448      */
1449     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1450     public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1451 
1452     /**
1453      *  Activity Action: Main entry point for factory tests.  Only used when
1454      *  the device is booting in factory test node.  The implementing package
1455      *  must be installed in the system image.
1456      *  <p>Input: nothing
1457      *  <p>Output: nothing
1458      */
1459     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1460     public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1461 
1462     /**
1463      * Activity Action: The user pressed the "call" button to go to the dialer
1464      * or other appropriate UI for placing a call.
1465      * <p>Input: Nothing.
1466      * <p>Output: Nothing.
1467      */
1468     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1469     public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1470 
1471     /**
1472      * Activity Action: Start Voice Command.
1473      * <p>Input: Nothing.
1474      * <p>Output: Nothing.
1475      * <p class="note">
1476      * In some cases, a matching Activity may not exist, so ensure you
1477      * safeguard against this.
1478      */
1479     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1480     public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
1481 
1482     /**
1483      * Activity Action: Start action associated with long pressing on the
1484      * search key.
1485      * <p>Input: Nothing.
1486      * <p>Output: Nothing.
1487      */
1488     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1489     public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
1490 
1491     /**
1492      * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1493      * This intent is delivered to the package which installed the application, usually
1494      * Google Play.
1495      * <p>Input: No data is specified. The bug report is passed in using
1496      * an {@link #EXTRA_BUG_REPORT} field.
1497      * <p>Output: Nothing.
1498      *
1499      * @see #EXTRA_BUG_REPORT
1500      */
1501     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1502     public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
1503 
1504     /**
1505      * An incident or bug report has been taken, and a system app has requested it to be shared,
1506      * so trigger the confirmation screen.
1507      *
1508      * This will be sent directly to the registered receiver with the
1509      * android.permission.APPROVE_INCIDENT_REPORTS permission.
1510      * @hide
1511      */
1512     @SystemApi
1513     public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED =
1514             "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED";
1515 
1516     /**
1517      * An incident report has been taken, and the user has approved it for sharing.
1518      * <p>
1519      * This will be sent directly to the registered receiver, which must have
1520      * both the DUMP and USAGE_STATS permissions.
1521      * <p>
1522      * After receiving this, the application should wait until a suitable time
1523      * (e.g. network available), get the list of available reports with
1524      * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)}
1525      * and then when the reports have been successfully uploaded, call
1526      * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}.
1527      *
1528      * @hide
1529      */
1530     @SystemApi
1531     public static final String ACTION_INCIDENT_REPORT_READY =
1532             "android.intent.action.INCIDENT_REPORT_READY";
1533 
1534     /**
1535      * Activity Action: Show power usage information to the user.
1536      * <p>Input: Nothing.
1537      * <p>Output: Nothing.
1538      */
1539     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1540     public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
1541 
1542     /**
1543      * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1544      * to run.
1545      * <p>Input: Nothing.
1546      * <p>Output: Nothing.
1547      * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1548      * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1549      * @hide
1550      * @removed
1551      */
1552     @Deprecated
1553     @SystemApi
1554     public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1555             "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1556 
1557     /**
1558      * Activity Action: Setup wizard to launch after a platform update.  This
1559      * activity should have a string meta-data field associated with it,
1560      * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1561      * the platform for setup.  The activity will be launched only if
1562      * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1563      * same value.
1564      * <p>Input: Nothing.
1565      * <p>Output: Nothing.
1566      * @hide
1567      */
1568     @SystemApi
1569     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1570     public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
1571 
1572     /**
1573      * Activity Action: Start the Keyboard Shortcuts Helper screen.
1574      * <p>Input: Nothing.
1575      * <p>Output: Nothing.
1576      * @hide
1577      */
1578     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1579     public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
1580             "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
1581 
1582     /**
1583      * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1584      * <p>Input: Nothing.
1585      * <p>Output: Nothing.
1586      * @hide
1587      */
1588     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1589     public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
1590             "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
1591 
1592     /**
1593      * Activity Action: Show settings for managing network data usage of a
1594      * specific application. Applications should define an activity that offers
1595      * options to control data usage.
1596      */
1597     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1598     public static final String ACTION_MANAGE_NETWORK_USAGE =
1599             "android.intent.action.MANAGE_NETWORK_USAGE";
1600 
1601     /**
1602      * Activity Action: Launch application installer.
1603      * <p>
1604      * Input: The data must be a content: URI at which the application
1605      * can be retrieved.  As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1606      * you can also use "package:<package-name>" to install an application for the
1607      * current user that is already installed for another user. You can optionally supply
1608      * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1609      * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1610      * <p>
1611      * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1612      * succeeded.
1613      * <p>
1614      * <strong>Note:</strong>If your app is targeting API level higher than 25 you
1615      * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1616      * in order to launch the application installer.
1617      * </p>
1618      *
1619      * @see #EXTRA_INSTALLER_PACKAGE_NAME
1620      * @see #EXTRA_NOT_UNKNOWN_SOURCE
1621      * @see #EXTRA_RETURN_RESULT
1622      *
1623      * @deprecated use {@link android.content.pm.PackageInstaller} instead
1624      */
1625     @Deprecated
1626     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1627     public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1628 
1629     /**
1630      * Activity Action: Activity to handle split installation failures.
1631      * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1632      * but the split that contains the application isn't installed. When a split is
1633      * installed in this manner, the containing package usually doesn't know this is
1634      * happening. However, if an error occurs during installation, the containing
1635      * package can define a single activity handling this action to deal with such
1636      * failures.
1637      * <p>The activity handling this action must be in the base package.
1638      * <p>
1639      * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1640      * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1641      */
1642     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1643     public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1644 
1645     /**
1646      * Activity Action: Launch instant application installer.
1647      * <p class="note">
1648      * This is a protected intent that can only be sent by the system.
1649      * </p>
1650      *
1651      * @hide
1652      */
1653     @SystemApi
1654     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1655     public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1656             = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
1657 
1658     /**
1659      * Service Action: Resolve instant application.
1660      * <p>
1661      * The system will have a persistent connection to this service.
1662      * This is a protected intent that can only be sent by the system.
1663      * </p>
1664      *
1665      * @hide
1666      */
1667     @SystemApi
1668     @SdkConstant(SdkConstantType.SERVICE_ACTION)
1669     public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1670             = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
1671 
1672     /**
1673      * Activity Action: Launch instant app settings.
1674      *
1675      * <p class="note">
1676      * This is a protected intent that can only be sent by the system.
1677      * </p>
1678      *
1679      * @hide
1680      */
1681     @SystemApi
1682     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1683     public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1684             = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
1685 
1686     /**
1687      * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1688      * package.  Specifies the installer package name; this package will receive the
1689      * {@link #ACTION_APP_ERROR} intent.
1690      */
1691     public static final String EXTRA_INSTALLER_PACKAGE_NAME
1692             = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1693 
1694     /**
1695      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1696      * package.  Specifies that the application being installed should not be
1697      * treated as coming from an unknown source, but as coming from the app
1698      * invoking the Intent.  For this to work you must start the installer with
1699      * startActivityForResult().
1700      */
1701     public static final String EXTRA_NOT_UNKNOWN_SOURCE
1702             = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1703 
1704     /**
1705      * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1706      * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
1707      * data field originated from.
1708      */
1709     public static final String EXTRA_ORIGINATING_URI
1710             = "android.intent.extra.ORIGINATING_URI";
1711 
1712     /**
1713      * This extra can be used with any Intent used to launch an activity, supplying information
1714      * about who is launching that activity.  This field contains a {@link android.net.Uri}
1715      * object, typically an http: or https: URI of the web site that the referral came from;
1716      * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1717      * a native application that it came from.
1718      *
1719      * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1720      * instead of directly retrieving the extra.  It is also valid for applications to
1721      * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1722      * a string, not a Uri; the field here, if supplied, will always take precedence,
1723      * however.</p>
1724      *
1725      * @see #EXTRA_REFERRER_NAME
1726      */
1727     public static final String EXTRA_REFERRER
1728             = "android.intent.extra.REFERRER";
1729 
1730     /**
1731      * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1732      * than a {@link android.net.Uri} object.  Only for use in cases where Uri objects can
1733      * not be created, in particular when Intent extras are supplied through the
1734      * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1735      * schemes.
1736      *
1737      * @see #EXTRA_REFERRER
1738      */
1739     public static final String EXTRA_REFERRER_NAME
1740             = "android.intent.extra.REFERRER_NAME";
1741 
1742     /**
1743      * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1744      * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
1745      * Currently only a system app that hosts the provider authority "downloads" or holds the
1746      * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
1747      * @hide
1748      */
1749     @SystemApi
1750     @TestApi
1751     public static final String EXTRA_ORIGINATING_UID
1752             = "android.intent.extra.ORIGINATING_UID";
1753 
1754     /**
1755      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1756      * package.  Tells the installer UI to skip the confirmation with the user
1757      * if the .apk is replacing an existing one.
1758      * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1759      * will no longer show an interstitial message about updating existing
1760      * applications so this is no longer needed.
1761      */
1762     @Deprecated
1763     public static final String EXTRA_ALLOW_REPLACE
1764             = "android.intent.extra.ALLOW_REPLACE";
1765 
1766     /**
1767      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1768      * {@link #ACTION_UNINSTALL_PACKAGE}.  Specifies that the installer UI should
1769      * return to the application the result code of the install/uninstall.  The returned result
1770      * code will be {@link android.app.Activity#RESULT_OK} on success or
1771      * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1772      */
1773     public static final String EXTRA_RETURN_RESULT
1774             = "android.intent.extra.RETURN_RESULT";
1775 
1776     /**
1777      * Package manager install result code.  @hide because result codes are not
1778      * yet ready to be exposed.
1779      */
1780     public static final String EXTRA_INSTALL_RESULT
1781             = "android.intent.extra.INSTALL_RESULT";
1782 
1783     /**
1784      * Activity Action: Launch application uninstaller.
1785      * <p>
1786      * Input: The data must be a package: URI whose scheme specific part is
1787      * the package name of the current installed package to be uninstalled.
1788      * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1789      * <p>
1790      * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1791      * succeeded.
1792      * <p>
1793      * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1794      * since {@link Build.VERSION_CODES#P}.
1795      *
1796      * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1797      *             instead
1798      */
1799     @Deprecated
1800     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1801     public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1802 
1803     /**
1804      * Specify whether the package should be uninstalled for all users.
1805      * @hide because these should not be part of normal application flow.
1806      */
1807     public static final String EXTRA_UNINSTALL_ALL_USERS
1808             = "android.intent.extra.UNINSTALL_ALL_USERS";
1809 
1810     /**
1811      * A string that associates with a metadata entry, indicating the last run version of the
1812      * platform that was setup.
1813      *
1814      * @see #ACTION_UPGRADE_SETUP
1815      *
1816      * @hide
1817      */
1818     @SystemApi
1819     public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1820 
1821     /**
1822      * Activity action: Launch UI to manage the permissions of an app.
1823      * <p>
1824      * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1825      * will be managed by the launched UI.
1826      * </p>
1827      * <p>
1828      * Output: Nothing.
1829      * </p>
1830      *
1831      * @see #EXTRA_PACKAGE_NAME
1832      *
1833      * @hide
1834      */
1835     @SystemApi
1836     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1837     public static final String ACTION_MANAGE_APP_PERMISSIONS =
1838             "android.intent.action.MANAGE_APP_PERMISSIONS";
1839 
1840     /**
1841      * Activity action: Launch UI to manage a specific permissions of an app.
1842      * <p>
1843      * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission
1844      * will be managed by the launched UI.
1845      * </p>
1846      * <p>
1847      * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission
1848      * that should be managed by the launched UI.
1849      * </p>
1850      * <p>
1851      * <li> {@link #EXTRA_USER} specifies the UserHandle of the user that owns the app.
1852      * </p>
1853      * <p>
1854      * Output: Nothing.
1855      * </p>
1856      *
1857      * @see #EXTRA_PACKAGE_NAME
1858      * @see #EXTRA_PERMISSION_NAME
1859      * @see #EXTRA_USER
1860      *
1861      * @hide
1862      */
1863     @SystemApi
1864     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
1865     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1866     public static final String ACTION_MANAGE_APP_PERMISSION =
1867             "android.intent.action.MANAGE_APP_PERMISSION";
1868 
1869     /**
1870      * Activity action: Launch UI to manage permissions.
1871      * <p>
1872      * Input: Nothing.
1873      * </p>
1874      * <p>
1875      * Output: Nothing.
1876      * </p>
1877      *
1878      * @hide
1879      */
1880     @SystemApi
1881     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1882     public static final String ACTION_MANAGE_PERMISSIONS =
1883             "android.intent.action.MANAGE_PERMISSIONS";
1884 
1885     /**
1886      * Activity action: Launch UI to manage auto-revoke state.
1887      *
1888      * This is equivalent to Intent#ACTION_APPLICATION_DETAILS_SETTINGS
1889      *
1890      * <p>
1891      * Input: {@link Intent#setData data} should be a {@code package}-scheme {@link Uri} with
1892      * a package name, whose auto-revoke state will be reviewed (mandatory).
1893      * E.g. {@code Uri.fromParts("package", packageName, null) }
1894      * </p>
1895      * <p>
1896      * Output: Nothing.
1897      * </p>
1898      */
1899     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1900     public static final String ACTION_AUTO_REVOKE_PERMISSIONS =
1901             "android.intent.action.AUTO_REVOKE_PERMISSIONS";
1902 
1903     /**
1904      * Activity action: Launch UI to review permissions for an app.
1905      * The system uses this intent if permission review for apps not
1906      * supporting the new runtime permissions model is enabled. In
1907      * this mode a permission review is required before any of the
1908      * app components can run.
1909      * <p>
1910      * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1911      * permissions will be reviewed (mandatory).
1912      * </p>
1913      * <p>
1914      * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1915      * be fired after the permission review (optional).
1916      * </p>
1917      * <p>
1918      * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1919      * be invoked after the permission review (optional).
1920      * </p>
1921      * <p>
1922      * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1923      * passed via {@link #EXTRA_INTENT} needs a result (optional).
1924      * </p>
1925      * <p>
1926      * Output: Nothing.
1927      * </p>
1928      *
1929      * @see #EXTRA_PACKAGE_NAME
1930      * @see #EXTRA_INTENT
1931      * @see #EXTRA_REMOTE_CALLBACK
1932      * @see #EXTRA_RESULT_NEEDED
1933      *
1934      * @hide
1935      */
1936     @SystemApi
1937     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1938     public static final String ACTION_REVIEW_PERMISSIONS =
1939             "android.intent.action.REVIEW_PERMISSIONS";
1940 
1941     /**
1942      * Activity action: Launch UI to show information about the usage
1943      * of a given permission. This action would be handled by apps that
1944      * want to show details about how and why given permission is being
1945      * used.
1946      * <p>
1947      * <strong>Important:</strong>You must protect the activity that handles
1948      * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE
1949      *  START_VIEW_PERMISSION_USAGE} permission to ensure that only the
1950      * system can launch this activity. The system will not launch
1951      * activities that are not properly protected.
1952      *
1953      * <p>
1954      * Input: {@code android.intent.extra.PERMISSION_NAME} specifies the permission
1955      * for which the launched UI would be targeted.
1956      * </p>
1957      * <p>
1958      * Output: Nothing.
1959      * </p>
1960      */
1961     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1962     @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
1963     public static final String ACTION_VIEW_PERMISSION_USAGE =
1964             "android.intent.action.VIEW_PERMISSION_USAGE";
1965 
1966     /**
1967      * Activity action: Launch UI to manage a default app.
1968      * <p>
1969      * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed
1970      * by the launched UI.
1971      * </p>
1972      * <p>
1973      * Output: Nothing.
1974      * </p>
1975      *
1976      * @hide
1977      */
1978     @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
1979     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1980     @SystemApi
1981     @TestApi
1982     public static final String ACTION_MANAGE_DEFAULT_APP =
1983             "android.intent.action.MANAGE_DEFAULT_APP";
1984 
1985     /**
1986      * Intent extra: A role name.
1987      * <p>
1988      * Type: String
1989      * </p>
1990      *
1991      * @see android.app.role.RoleManager
1992      *
1993      * @hide
1994      */
1995     @SystemApi
1996     @TestApi
1997     public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME";
1998 
1999     /**
2000      * Activity action: Launch UI to manage special app accesses.
2001      * <p>
2002      * Input: Nothing.
2003      * </p>
2004      * <p>
2005      * Output: Nothing.
2006      * </p>
2007      *
2008      * @hide
2009      */
2010     @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
2011     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2012     @SystemApi
2013     public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES =
2014             "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES";
2015 
2016     /**
2017      * Intent extra: A callback for reporting remote result as a bundle.
2018      * <p>
2019      * Type: IRemoteCallback
2020      * </p>
2021      *
2022      * @hide
2023      */
2024     @SystemApi
2025     public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
2026 
2027     /**
2028      * Intent extra: An app package name.
2029      * <p>
2030      * Type: String
2031      * </p>
2032      *
2033      */
2034     public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
2035 
2036     /**
2037      * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
2038      * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
2039      *
2040      * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
2041      * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
2042      * This is meant to enable the suspended app to better handle the state of being suspended.
2043      *
2044      * @see #ACTION_MY_PACKAGE_SUSPENDED
2045      * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2046      * @see PackageManager#isPackageSuspended()
2047      * @see PackageManager#getSuspendedPackageAppExtras()
2048      */
2049     public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
2050 
2051     /**
2052      * Intent extra: An app split name.
2053      * <p>
2054      * Type: String
2055      * </p>
2056      */
2057     public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
2058 
2059     /**
2060      * Intent extra: A {@link ComponentName} value.
2061      * <p>
2062      * Type: String
2063      * </p>
2064      */
2065     public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
2066 
2067     /**
2068      * Intent extra: An extra for specifying whether a result is needed.
2069      * <p>
2070      * Type: boolean
2071      * </p>
2072      *
2073      * @hide
2074      */
2075     @SystemApi
2076     public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
2077 
2078     /**
2079      * Intent extra: ID of the shortcut used to send the share intent. Will be sent with
2080      * {@link #ACTION_SEND}.
2081      *
2082      * @see ShortcutInfo#getId()
2083      *
2084      * <p>
2085      * Type: String
2086      * </p>
2087      */
2088     public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID";
2089 
2090     /**
2091      * Activity action: Launch UI to manage which apps have a given permission.
2092      * <p>
2093      * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission group
2094      * which will be managed by the launched UI.
2095      * </p>
2096      * <p>
2097      * Output: Nothing.
2098      * </p>
2099      *
2100      * @see #EXTRA_PERMISSION_NAME
2101      *
2102      * @hide
2103      */
2104     @SystemApi
2105     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2106     public static final String ACTION_MANAGE_PERMISSION_APPS =
2107             "android.intent.action.MANAGE_PERMISSION_APPS";
2108 
2109     /**
2110      * Intent extra: The name of a permission.
2111      * <p>
2112      * Type: String
2113      * </p>
2114      *
2115      * @hide
2116      */
2117     @SystemApi
2118     public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
2119 
2120     /**
2121      * Intent extra: The name of a permission group.
2122      * <p>
2123      * Type: String
2124      * </p>
2125      *
2126      * @hide
2127      */
2128     @SystemApi
2129     public static final String EXTRA_PERMISSION_GROUP_NAME =
2130             "android.intent.extra.PERMISSION_GROUP_NAME";
2131 
2132     /**
2133      * Intent extra: The number of milliseconds.
2134      * <p>
2135      * Type: long
2136      * </p>
2137      */
2138     public static final String EXTRA_DURATION_MILLIS =
2139             "android.intent.extra.DURATION_MILLIS";
2140 
2141     /**
2142      * Activity action: Launch UI to review app uses of permissions.
2143      * <p>
2144      * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name
2145      * that will be displayed by the launched UI.  Do not pass both this and
2146      * {@link #EXTRA_PERMISSION_GROUP_NAME} .
2147      * </p>
2148      * <p>
2149      * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2150      * that will be displayed by the launched UI.  Do not pass both this and
2151      * {@link #EXTRA_PERMISSION_NAME}.
2152      * </p>
2153      * <p>
2154      * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2155      * activity to show (optional).  Must be non-negative.
2156      * </p>
2157      * <p>
2158      * Output: Nothing.
2159      * </p>
2160      * <p class="note">
2161      * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2162      * </p>
2163      *
2164      * @see #EXTRA_PERMISSION_NAME
2165      * @see #EXTRA_PERMISSION_GROUP_NAME
2166      * @see #EXTRA_DURATION_MILLIS
2167      *
2168      * @hide
2169      */
2170     @SystemApi
2171     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2172     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2173     public static final String ACTION_REVIEW_PERMISSION_USAGE =
2174             "android.intent.action.REVIEW_PERMISSION_USAGE";
2175 
2176     /**
2177      * Activity action: Launch UI to review ongoing app uses of permissions.
2178      * <p>
2179      * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2180      * activity to show (optional).  Must be non-negative.
2181      * </p>
2182      * <p>
2183      * Output: Nothing.
2184      * </p>
2185      * <p class="note">
2186      * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2187      * </p>
2188      *
2189      * @see #EXTRA_DURATION_MILLIS
2190      *
2191      * @hide
2192      */
2193     @SystemApi
2194     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2195     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2196     public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE =
2197             "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE";
2198 
2199     /**
2200      * Activity action: Launch UI to review running accessibility services.
2201      * <p>
2202      * Input: Nothing.
2203      * </p>
2204      * <p>
2205      * Output: Nothing.
2206      * </p>
2207      *
2208      * @hide
2209      */
2210     @SystemApi
2211     @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES)
2212     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2213     public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES =
2214             "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES";
2215 
2216     // ---------------------------------------------------------------------
2217     // ---------------------------------------------------------------------
2218     // Standard intent broadcast actions (see action variable).
2219 
2220     /**
2221      * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
2222      * <p>
2223      * For historical reasons, the name of this broadcast action refers to the power
2224      * state of the screen but it is actually sent in response to changes in the
2225      * overall interactive state of the device.
2226      * </p><p>
2227      * This broadcast is sent when the device becomes non-interactive which may have
2228      * nothing to do with the screen turning off.  To determine the
2229      * actual state of the screen, use {@link android.view.Display#getState}.
2230      * </p><p>
2231      * See {@link android.os.PowerManager#isInteractive} for details.
2232      * </p>
2233      * You <em>cannot</em> receive this through components declared in
2234      * manifests, only by explicitly registering for it with
2235      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2236      * Context.registerReceiver()}.
2237      *
2238      * <p class="note">This is a protected intent that can only be sent
2239      * by the system.
2240      */
2241     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2242     public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
2243 
2244     /**
2245      * Broadcast Action: Sent when the device wakes up and becomes interactive.
2246      * <p>
2247      * For historical reasons, the name of this broadcast action refers to the power
2248      * state of the screen but it is actually sent in response to changes in the
2249      * overall interactive state of the device.
2250      * </p><p>
2251      * This broadcast is sent when the device becomes interactive which may have
2252      * nothing to do with the screen turning on.  To determine the
2253      * actual state of the screen, use {@link android.view.Display#getState}.
2254      * </p><p>
2255      * See {@link android.os.PowerManager#isInteractive} for details.
2256      * </p>
2257      * You <em>cannot</em> receive this through components declared in
2258      * manifests, only by explicitly registering for it with
2259      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2260      * Context.registerReceiver()}.
2261      *
2262      * <p class="note">This is a protected intent that can only be sent
2263      * by the system.
2264      */
2265     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2266     public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
2267 
2268     /**
2269      * Broadcast Action: Sent after the system stops dreaming.
2270      *
2271      * <p class="note">This is a protected intent that can only be sent by the system.
2272      * It is only sent to registered receivers.</p>
2273      */
2274     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2275     public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
2276 
2277     /**
2278      * Broadcast Action: Sent after the system starts dreaming.
2279      *
2280      * <p class="note">This is a protected intent that can only be sent by the system.
2281      * It is only sent to registered receivers.</p>
2282      */
2283     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2284     public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
2285 
2286     /**
2287      * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
2288      * keyguard is gone).
2289      *
2290      * <p class="note">This is a protected intent that can only be sent
2291      * by the system.
2292      */
2293     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2294     public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
2295 
2296     /**
2297      * Broadcast Action: The current time has changed.  Sent every
2298      * minute.  You <em>cannot</em> receive this through components declared
2299      * in manifests, only by explicitly registering for it with
2300      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2301      * Context.registerReceiver()}.
2302      *
2303      * <p class="note">This is a protected intent that can only be sent
2304      * by the system.
2305      */
2306     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2307     public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2308     /**
2309      * Broadcast Action: The time was set.
2310      */
2311     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2312     public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2313     /**
2314      * Broadcast Action: The date has changed.
2315      */
2316     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2317     public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2318     /**
2319      * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2320      * <ul>
2321      *   <li>{@link #EXTRA_TIMEZONE} - The java.util.TimeZone.getID() value identifying the new
2322      *   time zone.</li>
2323      * </ul>
2324      *
2325      * <p class="note">This is a protected intent that can only be sent
2326      * by the system.
2327      */
2328     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2329     public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2330     /**
2331      * Clear DNS Cache Action: This is broadcast when networks have changed and old
2332      * DNS entries should be tossed.
2333      * @hide
2334      */
2335     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2336     public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2337     /**
2338      * Alarm Changed Action: This is broadcast when the AlarmClock
2339      * application's alarm is set or unset.  It is used by the
2340      * AlarmClock application and the StatusBar service.
2341      * @hide
2342      */
2343     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2344     @UnsupportedAppUsage
2345     public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
2346 
2347     /**
2348      * Broadcast Action: This is broadcast once, after the user has finished
2349      * booting, but while still in the "locked" state. It can be used to perform
2350      * application-specific initialization, such as installing alarms. You must
2351      * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2352      * permission in order to receive this broadcast.
2353      * <p>
2354      * This broadcast is sent immediately at boot by all devices (regardless of
2355      * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2356      * higher. Upon receipt of this broadcast, the user is still locked and only
2357      * device-protected storage can be accessed safely. If you want to access
2358      * credential-protected storage, you need to wait for the user to be
2359      * unlocked (typically by entering their lock pattern or PIN for the first
2360      * time), after which the {@link #ACTION_USER_UNLOCKED} and
2361      * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2362      * <p>
2363      * To receive this broadcast, your receiver component must be marked as
2364      * being {@link ComponentInfo#directBootAware}.
2365      * <p class="note">
2366      * This is a protected intent that can only be sent by the system.
2367      *
2368      * @see Context#createDeviceProtectedStorageContext()
2369      */
2370     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2371     public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2372 
2373     /**
2374      * Broadcast Action: This is broadcast once, after the user has finished
2375      * booting. It can be used to perform application-specific initialization,
2376      * such as installing alarms. You must hold the
2377      * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2378      * order to receive this broadcast.
2379      * <p>
2380      * This broadcast is sent at boot by all devices (both with and without
2381      * direct boot support). Upon receipt of this broadcast, the user is
2382      * unlocked and both device-protected and credential-protected storage can
2383      * accessed safely.
2384      * <p>
2385      * If you need to run while the user is still locked (before they've entered
2386      * their lock pattern or PIN for the first time), you can listen for the
2387      * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2388      * <p class="note">
2389      * This is a protected intent that can only be sent by the system.
2390      */
2391     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2392     @BroadcastBehavior(includeBackground = true)
2393     public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
2394 
2395     /**
2396      * Broadcast Action: This is broadcast when a user action should request a
2397      * temporary system dialog to dismiss.  Some examples of temporary system
2398      * dialogs are the notification window-shade and the recent tasks dialog.
2399      */
2400     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2401     public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2402     /**
2403      * Broadcast Action: Trigger the download and eventual installation
2404      * of a package.
2405      * <p>Input: {@link #getData} is the URI of the package file to download.
2406      *
2407      * <p class="note">This is a protected intent that can only be sent
2408      * by the system.
2409      *
2410      * @deprecated This constant has never been used.
2411      */
2412     @Deprecated
2413     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2414     public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2415     /**
2416      * Broadcast Action: A new application package has been installed on the
2417      * device. The data contains the name of the package.  Note that the
2418      * newly installed package does <em>not</em> receive this broadcast.
2419      * <p>May include the following extras:
2420      * <ul>
2421      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2422      * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2423      * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2424      * </ul>
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_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2431     /**
2432      * Broadcast Action: A new version of an application package has been
2433      * installed, replacing an existing version that was previously installed.
2434      * The data contains the name of the package.
2435      * <p>May include the following extras:
2436      * <ul>
2437      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2438      * </ul>
2439      *
2440      * <p class="note">This is a protected intent that can only be sent
2441      * by the system.
2442      */
2443     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2444     public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2445     /**
2446      * Broadcast Action: A new version of your application has been installed
2447      * over an existing one.  This is only sent to the application that was
2448      * replaced.  It does not contain any additional data; to receive it, just
2449      * use an intent filter for this action.
2450      *
2451      * <p class="note">This is a protected intent that can only be sent
2452      * by the system.
2453      */
2454     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2455     public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2456     /**
2457      * Broadcast Action: An existing application package has been removed from
2458      * the device.  The data contains the name of the package.  The package
2459      * that is being removed does <em>not</em> receive this Intent.
2460      * <ul>
2461      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2462      * to the package.
2463      * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2464      * application -- data and code -- is being removed.
2465      * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2466      * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2467      * </ul>
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_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2474     /**
2475      * Broadcast Action: An existing application package has been completely
2476      * removed from the device.  The data contains the name of the package.
2477      * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2478      * {@link #EXTRA_DATA_REMOVED} is true and
2479      * {@link #EXTRA_REPLACING} is false of that broadcast.
2480      *
2481      * <ul>
2482      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2483      * to the package.
2484      * </ul>
2485      *
2486      * <p class="note">This is a protected intent that can only be sent
2487      * by the system.
2488      */
2489     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2490     public static final String ACTION_PACKAGE_FULLY_REMOVED
2491             = "android.intent.action.PACKAGE_FULLY_REMOVED";
2492     /**
2493      * Broadcast Action: An existing application package has been changed (for
2494      * example, a component has been enabled or disabled).  The data contains
2495      * the name of the package.
2496      * <ul>
2497      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2498      * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
2499      * of the changed components (or the package name itself).
2500      * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2501      * default action of restarting the application.
2502      * </ul>
2503      *
2504      * <p class="note">This is a protected intent that can only be sent
2505      * by the system.
2506      */
2507     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2508     public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2509     /**
2510      * Broadcast Action: Sent to the system rollback manager when a package
2511      * needs to have rollback enabled.
2512      * <p class="note">
2513      * This is a protected intent that can only be sent by the system.
2514      * </p>
2515      *
2516      * @hide This broadcast is used internally by the system.
2517      */
2518     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2519     public static final String ACTION_PACKAGE_ENABLE_ROLLBACK =
2520             "android.intent.action.PACKAGE_ENABLE_ROLLBACK";
2521     /**
2522      * Broadcast Action: Sent to the system rollback manager when the rollback for a certain
2523      * package needs to be cancelled.
2524      *
2525      * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager
2526      * that enabling a specific rollback has timed out.
2527      *
2528      * @hide
2529      */
2530     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2531     public static final String ACTION_CANCEL_ENABLE_ROLLBACK =
2532             "android.intent.action.CANCEL_ENABLE_ROLLBACK";
2533     /**
2534      * Broadcast Action: A rollback has been committed.
2535      *
2536      * <p class="note">This is a protected intent that can only be sent
2537      * by the system. The receiver must hold MANAGE_ROLLBACK permission.
2538      *
2539      * @hide
2540      */
2541     @SystemApi @TestApi
2542     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2543     public static final String ACTION_ROLLBACK_COMMITTED =
2544             "android.intent.action.ROLLBACK_COMMITTED";
2545     /**
2546      * @hide
2547      * Broadcast Action: Ask system services if there is any reason to
2548      * restart the given package.  The data contains the name of the
2549      * package.
2550      * <ul>
2551      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2552      * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2553      * </ul>
2554      *
2555      * <p class="note">This is a protected intent that can only be sent
2556      * by the system.
2557      */
2558     @SystemApi
2559     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2560     public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2561     /**
2562      * Broadcast Action: The user has restarted a package, and all of its
2563      * processes have been killed.  All runtime state
2564      * associated with it (processes, alarms, notifications, etc) should
2565      * be removed.  Note that the restarted package does <em>not</em>
2566      * receive this broadcast.
2567      * The data contains the name of the package.
2568      * <ul>
2569      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2570      * </ul>
2571      *
2572      * <p class="note">This is a protected intent that can only be sent
2573      * by the system.
2574      */
2575     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2576     public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2577     /**
2578      * Broadcast Action: The user has cleared the data of a package.  This should
2579      * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
2580      * its persistent data is erased and this broadcast sent.
2581      * Note that the cleared package does <em>not</em>
2582      * receive this broadcast. The data contains the name of the package.
2583      * <ul>
2584      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2585      *      package whose data was cleared is an uninstalled instant app, then the UID
2586      *      will be -1. The platform keeps some meta-data associated with instant apps
2587      *      after they are uninstalled.
2588      * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2589      *      data was for an instant app.
2590      * </ul>
2591      *
2592      * <p class="note">This is a protected intent that can only be sent
2593      * by the system.
2594      */
2595     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2596     public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2597     /**
2598      * Broadcast Action: Packages have been suspended.
2599      * <p>Includes the following extras:
2600      * <ul>
2601      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2602      * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
2603      * </ul>
2604      *
2605      * <p class="note">This is a protected intent that can only be sent
2606      * by the system. It is only sent to registered receivers.
2607      */
2608     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2609     public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2610     /**
2611      * Broadcast Action: Packages have been unsuspended.
2612      * <p>Includes the following extras:
2613      * <ul>
2614      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2615      * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
2616      * </ul>
2617      *
2618      * <p class="note">This is a protected intent that can only be sent
2619      * by the system. It is only sent to registered receivers.
2620      */
2621     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2622     public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2623 
2624     /**
2625      * Broadcast Action: Distracting packages have been changed.
2626      * <p>Includes the following extras:
2627      * <ul>
2628      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed.
2629      * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed.
2630      * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages.
2631      * </ul>
2632      *
2633      * <p class="note">This is a protected intent that can only be sent
2634      * by the system. It is only sent to registered receivers.
2635      *
2636      * @see PackageManager#setDistractingPackageRestrictions(String[], int)
2637      * @hide
2638      */
2639     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2640     public static final String ACTION_DISTRACTING_PACKAGES_CHANGED =
2641             "android.intent.action.DISTRACTING_PACKAGES_CHANGED";
2642 
2643     /**
2644      * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
2645      * whenever a package is put into a suspended state or any of its app extras change while in the
2646      * suspended state.
2647      * <p> Optionally includes the following extras:
2648      * <ul>
2649      *     <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2650      *     useful information for the app being suspended.
2651      * </ul>
2652      * <p class="note">This is a protected intent that can only be sent
2653      * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2654      * the manifest.</em>
2655      *
2656      * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2657      * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2658      * @see PackageManager#isPackageSuspended()
2659      * @see PackageManager#getSuspendedPackageAppExtras()
2660      */
2661     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2662     public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2663 
2664     /**
2665      * Activity Action: Started to show more details about why an application was suspended.
2666      *
2667      * <p>Whenever the system detects an activity launch for a suspended app, this action can
2668      * be used to show more details about the reason for suspension.
2669      *
2670      * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2671      * handling this intent and protect it with
2672      * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2673      *
2674      * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2675      *
2676      * <p class="note">This is a protected intent that can only be sent
2677      * by the system.
2678      *
2679      * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2680      * PersistableBundle, String)
2681      * @see PackageManager#isPackageSuspended()
2682      * @see #ACTION_PACKAGES_SUSPENDED
2683      *
2684      * @hide
2685      */
2686     @SystemApi
2687     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2688     public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2689             "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2690 
2691     /**
2692      * Broadcast Action: Sent to indicate that the user unsuspended a package.
2693      *
2694      * <p>This can happen when the user taps on the neutral button of the
2695      * {@linkplain SuspendDialogInfo suspend-dialog} which was created by using
2696      * {@link SuspendDialogInfo#BUTTON_ACTION_UNSUSPEND}. This broadcast is only sent to the
2697      * suspending app that originally specified this dialog while calling
2698      * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2699      * PersistableBundle, SuspendDialogInfo)}.
2700      *
2701      * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the package that just
2702      * got unsuspended.
2703      *
2704      * <p class="note">This is a protected intent that can only be sent
2705      * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2706      * the manifest.</em>
2707      *
2708      * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2709      * PersistableBundle, SuspendDialogInfo)
2710      * @see PackageManager#isPackageSuspended()
2711      * @see SuspendDialogInfo#BUTTON_ACTION_MORE_DETAILS
2712      * @hide
2713      */
2714     @SystemApi
2715     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2716     public static final String ACTION_PACKAGE_UNSUSPENDED_MANUALLY =
2717             "android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY";
2718 
2719     /**
2720      * Broadcast Action: Sent to a package that has been unsuspended.
2721      *
2722      * <p class="note">This is a protected intent that can only be sent
2723      * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2724      * the manifest.</em>
2725      *
2726      * @see #ACTION_MY_PACKAGE_SUSPENDED
2727      * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2728      * @see PackageManager#isPackageSuspended()
2729      * @see PackageManager#getSuspendedPackageAppExtras()
2730      */
2731     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2732     public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2733 
2734     /**
2735      * Broadcast Action: A user ID has been removed from the system.  The user
2736      * ID number is stored in the extra data under {@link #EXTRA_UID}.
2737      *
2738      * <p class="note">This is a protected intent that can only be sent
2739      * by the system.
2740      */
2741     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2742     public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
2743 
2744     /**
2745      * Broadcast Action: Sent to the installer package of an application when
2746      * that application is first launched (that is the first time it is moved
2747      * out of the stopped state).  The data contains the name of the package.
2748      *
2749      * <p>When the application is first launched, the application itself doesn't receive this
2750      * broadcast.</p>
2751      *
2752      * <p class="note">This is a protected intent that can only be sent
2753      * by the system.
2754      */
2755     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2756     public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2757 
2758     /**
2759      * Broadcast Action: Sent to the system package verifier when a package
2760      * needs to be verified. The data contains the package URI.
2761      * <p class="note">
2762      * This is a protected intent that can only be sent by the system.
2763      * </p>
2764      */
2765     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2766     public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2767 
2768     /**
2769      * Broadcast Action: Sent to the system package verifier when a package is
2770      * verified. The data contains the package URI.
2771      * <p class="note">
2772      * This is a protected intent that can only be sent by the system.
2773      */
2774     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2775     public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2776 
2777     /**
2778      * Broadcast Action: Sent to the system intent filter verifier when an
2779      * intent filter needs to be verified. The data contains the filter data
2780      * hosts to be verified against.
2781      * <p class="note">
2782      * This is a protected intent that can only be sent by the system.
2783      * </p>
2784      *
2785      * @hide
2786      */
2787     @SystemApi
2788     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2789     public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2790 
2791     /**
2792      * Broadcast Action: Resources for a set of packages (which were
2793      * previously unavailable) are currently
2794      * available since the media on which they exist is available.
2795      * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2796      * list of packages whose availability changed.
2797      * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2798      * list of uids of packages whose availability changed.
2799      * Note that the
2800      * packages in this list do <em>not</em> receive this broadcast.
2801      * The specified set of packages are now available on the system.
2802      * <p>Includes the following extras:
2803      * <ul>
2804      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2805      * whose resources(were previously unavailable) are currently available.
2806      * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2807      * packages whose resources(were previously unavailable)
2808      * are  currently available.
2809      * </ul>
2810      *
2811      * <p class="note">This is a protected intent that can only be sent
2812      * by the system.
2813      */
2814     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2815     public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2816         "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
2817 
2818     /**
2819      * Broadcast Action: Resources for a set of packages are currently
2820      * unavailable since the media on which they exist is unavailable.
2821      * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2822      * list of packages whose availability changed.
2823      * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2824      * list of uids of packages whose availability changed.
2825      * The specified set of packages can no longer be
2826      * launched and are practically unavailable on the system.
2827      * <p>Inclues the following extras:
2828      * <ul>
2829      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2830      * whose resources are no longer available.
2831      * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2832      * whose resources are no longer available.
2833      * </ul>
2834      *
2835      * <p class="note">This is a protected intent that can only be sent
2836      * by the system.
2837      */
2838     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2839     public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
2840         "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
2841 
2842     /**
2843      * Broadcast Action: preferred activities have changed *explicitly*.
2844      *
2845      * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2846      * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2847      * be sent.
2848      *
2849      * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2850      *
2851      * @hide
2852      */
2853     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2854     public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2855             "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2856 
2857 
2858     /**
2859      * Broadcast Action:  The current system wallpaper has changed.  See
2860      * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
2861      * This should <em>only</em> be used to determine when the wallpaper
2862      * has changed to show the new wallpaper to the user.  You should certainly
2863      * never, in response to this, change the wallpaper or other attributes of
2864      * it such as the suggested size.  That would be crazy, right?  You'd cause
2865      * all kinds of loops, especially if other apps are doing similar things,
2866      * right?  Of course.  So please don't do this.
2867      *
2868      * @deprecated Modern applications should use
2869      * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2870      * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2871      * shown behind their UI, rather than watching for this broadcast and
2872      * rendering the wallpaper on their own.
2873      */
2874     @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2875     public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2876     /**
2877      * Broadcast Action: The current device {@link android.content.res.Configuration}
2878      * (orientation, locale, etc) has changed.  When such a change happens, the
2879      * UIs (view hierarchy) will need to be rebuilt based on this new
2880      * information; for the most part, applications don't need to worry about
2881      * this, because the system will take care of stopping and restarting the
2882      * application to make sure it sees the new changes.  Some system code that
2883      * can not be restarted will need to watch for this action and handle it
2884      * appropriately.
2885      *
2886      * <p class="note">
2887      * You <em>cannot</em> receive this through components declared
2888      * in manifests, only by explicitly registering for it with
2889      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2890      * Context.registerReceiver()}.
2891      *
2892      * <p class="note">This is a protected intent that can only be sent
2893      * by the system.
2894      *
2895      * @see android.content.res.Configuration
2896      */
2897     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2898     public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2899 
2900     /**
2901      * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2902      * such that the device may be eligible for the installation of additional configuration splits.
2903      * Configuration properties that can trigger this broadcast include locale and display density.
2904      *
2905      * <p class="note">
2906      * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2907      * components declared in manifests. However, the receiver <em>must</em> hold the
2908      * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2909      *
2910      * <p class="note">
2911      * This is a protected intent that can only be sent by the system.
2912      *
2913      * @hide
2914      */
2915     @SystemApi
2916     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2917     public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2918             "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
2919     /**
2920      * Broadcast Action: The current device's locale has changed.
2921      *
2922      * <p class="note">This is a protected intent that can only be sent
2923      * by the system.
2924      */
2925     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2926     public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2927     /**
2928      * Broadcast Action:  This is a <em>sticky broadcast</em> containing the
2929      * charging state, level, and other information about the battery.
2930      * See {@link android.os.BatteryManager} for documentation on the
2931      * contents of the Intent.
2932      *
2933      * <p class="note">
2934      * You <em>cannot</em> receive this through components declared
2935      * in manifests, only by explicitly registering for it with
2936      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2937      * Context.registerReceiver()}.  See {@link #ACTION_BATTERY_LOW},
2938      * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2939      * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2940      * broadcasts that are sent and can be received through manifest
2941      * receivers.
2942      *
2943      * <p class="note">This is a protected intent that can only be sent
2944      * by the system.
2945      */
2946     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2947     public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2948 
2949 
2950     /**
2951      * Broadcast Action: Sent when the current battery level changes.
2952      *
2953      * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2954      * instances representing individual battery level changes with associated
2955      * extras from {@link #ACTION_BATTERY_CHANGED}.
2956      *
2957      * <p class="note">
2958      * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2959      *
2960      * @hide
2961      */
2962     @SystemApi
2963     public static final String ACTION_BATTERY_LEVEL_CHANGED =
2964             "android.intent.action.BATTERY_LEVEL_CHANGED";
2965     /**
2966      * Broadcast Action:  Indicates low battery condition on the device.
2967      * This broadcast corresponds to the "Low battery warning" system dialog.
2968      *
2969      * <p class="note">This is a protected intent that can only be sent
2970      * by the system.
2971      */
2972     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2973     public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2974     /**
2975      * Broadcast Action:  Indicates the battery is now okay after being low.
2976      * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2977      * gone back up to an okay state.
2978      *
2979      * <p class="note">This is a protected intent that can only be sent
2980      * by the system.
2981      */
2982     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2983     public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2984     /**
2985      * Broadcast Action:  External power has been connected to the device.
2986      * This is intended for applications that wish to register specifically to this notification.
2987      * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2988      * stay active to receive this notification.  This action can be used to implement actions
2989      * that wait until power is available to trigger.
2990      *
2991      * <p class="note">This is a protected intent that can only be sent
2992      * by the system.
2993      */
2994     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2995     public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
2996     /**
2997      * Broadcast Action:  External power has been removed from the device.
2998      * This is intended for applications that wish to register specifically to this notification.
2999      * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
3000      * stay active to receive this notification.  This action can be used to implement actions
3001      * that wait until power is available to trigger.
3002      *
3003      * <p class="note">This is a protected intent that can only be sent
3004      * by the system.
3005      */
3006     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3007     public static final String ACTION_POWER_DISCONNECTED =
3008             "android.intent.action.ACTION_POWER_DISCONNECTED";
3009     /**
3010      * Broadcast Action:  Device is shutting down.
3011      * This is broadcast when the device is being shut down (completely turned
3012      * off, not sleeping).  Once the broadcast is complete, the final shutdown
3013      * will proceed and all unsaved data lost.  Apps will not normally need
3014      * to handle this, since the foreground activity will be paused as well.
3015      * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
3016      * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3017      * Context.registerReceiver}.
3018      *
3019      * <p class="note">This is a protected intent that can only be sent
3020      * by the system.
3021      * <p>May include the following extras:
3022      * <ul>
3023      * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
3024      * shutdown is only for userspace processes.  If not set, assumed to be false.
3025      * </ul>
3026      */
3027     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3028     public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
3029     /**
3030      * Activity Action:  Start this activity to request system shutdown.
3031      * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
3032      * to request confirmation from the user before shutting down. The optional boolean
3033      * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
3034      * indicate that the shutdown is requested by the user.
3035      *
3036      * <p class="note">This is a protected intent that can only be sent
3037      * by the system.
3038      *
3039      * {@hide}
3040      */
3041     public static final String ACTION_REQUEST_SHUTDOWN
3042             = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
3043     /**
3044      * Broadcast Action: A sticky broadcast that indicates low storage space
3045      * condition on the device
3046      * <p class="note">
3047      * This is a protected intent that can only be sent by the system.
3048      *
3049      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3050      *             or above, this broadcast will no longer be delivered to any
3051      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3052      *             apps are strongly encouraged to use the improved
3053      *             {@link Context#getCacheDir()} behavior so the system can
3054      *             automatically free up storage when needed.
3055      */
3056     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3057     @Deprecated
3058     public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
3059     /**
3060      * Broadcast Action: Indicates low storage space condition on the device no
3061      * longer exists
3062      * <p class="note">
3063      * This is a protected intent that can only be sent by the system.
3064      *
3065      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3066      *             or above, this broadcast will no longer be delivered to any
3067      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3068      *             apps are strongly encouraged to use the improved
3069      *             {@link Context#getCacheDir()} behavior so the system can
3070      *             automatically free up storage when needed.
3071      */
3072     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3073     @Deprecated
3074     public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
3075     /**
3076      * Broadcast Action: A sticky broadcast that indicates a storage space full
3077      * condition on the device. This is intended for activities that want to be
3078      * able to fill the data partition completely, leaving only enough free
3079      * space to prevent system-wide SQLite failures.
3080      * <p class="note">
3081      * This is a protected intent that can only be sent by the system.
3082      *
3083      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3084      *             or above, this broadcast will no longer be delivered to any
3085      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3086      *             apps are strongly encouraged to use the improved
3087      *             {@link Context#getCacheDir()} behavior so the system can
3088      *             automatically free up storage when needed.
3089      * @hide
3090      */
3091     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3092     @Deprecated
3093     public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
3094     /**
3095      * Broadcast Action: Indicates storage space full condition on the device no
3096      * longer exists.
3097      * <p class="note">
3098      * This is a protected intent that can only be sent by the system.
3099      *
3100      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3101      *             or above, this broadcast will no longer be delivered to any
3102      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3103      *             apps are strongly encouraged to use the improved
3104      *             {@link Context#getCacheDir()} behavior so the system can
3105      *             automatically free up storage when needed.
3106      * @hide
3107      */
3108     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3109     @Deprecated
3110     public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
3111     /**
3112      * Broadcast Action:  Indicates low memory condition notification acknowledged by user
3113      * and package management should be started.
3114      * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
3115      * notification.
3116      */
3117     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3118     public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
3119     /**
3120      * Broadcast Action:  The device has entered USB Mass Storage mode.
3121      * This is used mainly for the USB Settings panel.
3122      * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3123      * when the SD card file system is mounted or unmounted
3124      * @deprecated replaced by android.os.storage.StorageEventListener
3125      */
3126     @Deprecated
3127     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3128     public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
3129 
3130     /**
3131      * Broadcast Action:  The device has exited USB Mass Storage mode.
3132      * This is used mainly for the USB Settings panel.
3133      * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3134      * when the SD card file system is mounted or unmounted
3135      * @deprecated replaced by android.os.storage.StorageEventListener
3136      */
3137     @Deprecated
3138     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3139     public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
3140 
3141     /**
3142      * Broadcast Action:  External media has been removed.
3143      * The path to the mount point for the removed media is contained in the Intent.mData field.
3144      */
3145     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3146     public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
3147 
3148     /**
3149      * Broadcast Action:  External media is present, but not mounted at its mount point.
3150      * The path to the mount point for the unmounted media is contained in the Intent.mData field.
3151      */
3152     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3153     public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
3154 
3155     /**
3156      * Broadcast Action:  External media is present, and being disk-checked
3157      * The path to the mount point for the checking media is contained in the Intent.mData field.
3158      */
3159     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3160     public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
3161 
3162     /**
3163      * Broadcast Action:  External media is present, but is using an incompatible fs (or is blank)
3164      * The path to the mount point for the checking media is contained in the Intent.mData field.
3165      */
3166     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3167     public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
3168 
3169     /**
3170      * Broadcast Action:  External media is present and mounted at its mount point.
3171      * The path to the mount point for the mounted media is contained in the Intent.mData field.
3172      * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
3173      * media was mounted read only.
3174      */
3175     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3176     public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
3177 
3178     /**
3179      * Broadcast Action:  External media is unmounted because it is being shared via USB mass storage.
3180      * The path to the mount point for the shared media is contained in the Intent.mData field.
3181      */
3182     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3183     public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
3184 
3185     /**
3186      * Broadcast Action:  External media is no longer being shared via USB mass storage.
3187      * The path to the mount point for the previously shared media is contained in the Intent.mData field.
3188      *
3189      * @hide
3190      */
3191     public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
3192 
3193     /**
3194      * Broadcast Action:  External media was removed from SD card slot, but mount point was not unmounted.
3195      * The path to the mount point for the removed media is contained in the Intent.mData field.
3196      */
3197     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3198     public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
3199 
3200     /**
3201      * Broadcast Action:  External media is present but cannot be mounted.
3202      * The path to the mount point for the unmountable media is contained in the Intent.mData field.
3203      */
3204     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3205     public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
3206 
3207    /**
3208      * Broadcast Action:  User has expressed the desire to remove the external storage media.
3209      * Applications should close all files they have open within the mount point when they receive this intent.
3210      * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
3211      */
3212     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3213     public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
3214 
3215     /**
3216      * Broadcast Action:  The media scanner has started scanning a directory.
3217      * The path to the directory being scanned is contained in the Intent.mData field.
3218      */
3219     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3220     public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
3221 
3222    /**
3223      * Broadcast Action:  The media scanner has finished scanning a directory.
3224      * The path to the scanned directory is contained in the Intent.mData field.
3225      */
3226     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3227     public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
3228 
3229     /**
3230      * Broadcast Action: Request the media scanner to scan a file and add it to
3231      * the media database.
3232      * <p>
3233      * The path to the file is contained in {@link Intent#getData()}.
3234      *
3235      * @deprecated Callers should migrate to inserting items directly into
3236      *             {@link MediaStore}, where they will be automatically scanned
3237      *             after each mutation.
3238      */
3239     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3240     @Deprecated
3241     public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
3242 
3243    /**
3244      * Broadcast Action:  The "Media Button" was pressed.  Includes a single
3245      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3246      * caused the broadcast.
3247      */
3248     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3249     public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
3250 
3251     /**
3252      * Broadcast Action:  The "Camera Button" was pressed.  Includes a single
3253      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3254      * caused the broadcast.
3255      */
3256     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3257     public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
3258 
3259     // *** NOTE: @todo(*) The following really should go into a more domain-specific
3260     // location; they are not general-purpose actions.
3261 
3262     /**
3263      * Broadcast Action: A GTalk connection has been established.
3264      */
3265     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3266     public static final String ACTION_GTALK_SERVICE_CONNECTED =
3267             "android.intent.action.GTALK_CONNECTED";
3268 
3269     /**
3270      * Broadcast Action: A GTalk connection has been disconnected.
3271      */
3272     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3273     public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
3274             "android.intent.action.GTALK_DISCONNECTED";
3275 
3276     /**
3277      * Broadcast Action: An input method has been changed.
3278      */
3279     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3280     public static final String ACTION_INPUT_METHOD_CHANGED =
3281             "android.intent.action.INPUT_METHOD_CHANGED";
3282 
3283     /**
3284      * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
3285      * more radios have been turned off or on. The intent will have the following extra value:</p>
3286      * <ul>
3287      *   <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
3288      *   then cell radio and possibly other radios such as bluetooth or WiFi may have also been
3289      *   turned off</li>
3290      * </ul>
3291      *
3292      * <p class="note">This is a protected intent that can only be sent by the system.</p>
3293      */
3294     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3295     public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
3296 
3297     /**
3298      * Broadcast Action: Some content providers have parts of their namespace
3299      * where they publish new events or items that the user may be especially
3300      * interested in. For these things, they may broadcast this action when the
3301      * set of interesting items change.
3302      *
3303      * For example, GmailProvider sends this notification when the set of unread
3304      * mail in the inbox changes.
3305      *
3306      * <p>The data of the intent identifies which part of which provider
3307      * changed. When queried through the content resolver, the data URI will
3308      * return the data set in question.
3309      *
3310      * <p>The intent will have the following extra values:
3311      * <ul>
3312      *   <li><em>count</em> - The number of items in the data set. This is the
3313      *       same as the number of items in the cursor returned by querying the
3314      *       data URI. </li>
3315      * </ul>
3316      *
3317      * This intent will be sent at boot (if the count is non-zero) and when the
3318      * data set changes. It is possible for the data set to change without the
3319      * count changing (for example, if a new unread message arrives in the same
3320      * sync operation in which a message is archived). The phone should still
3321      * ring/vibrate/etc as normal in this case.
3322      */
3323     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3324     public static final String ACTION_PROVIDER_CHANGED =
3325             "android.intent.action.PROVIDER_CHANGED";
3326 
3327     /**
3328      * Broadcast Action: Wired Headset plugged in or unplugged.
3329      *
3330      * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
3331      *   and documentation.
3332      * <p>If the minimum SDK version of your application is
3333      * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
3334      * to the <code>AudioManager</code> constant in your receiver registration code instead.
3335      */
3336     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3337     public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
3338 
3339     /**
3340      * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
3341      * <ul>
3342      *   <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
3343      * </ul>
3344      *
3345      * <p class="note">This is a protected intent that can only be sent
3346      * by the system.
3347      *
3348      * @hide
3349      */
3350     //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3351     public static final String ACTION_ADVANCED_SETTINGS_CHANGED
3352             = "android.intent.action.ADVANCED_SETTINGS";
3353 
3354     /**
3355      *  Broadcast Action: Sent after application restrictions are changed.
3356      *
3357      * <p class="note">This is a protected intent that can only be sent
3358      * by the system.</p>
3359      */
3360     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3361     public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
3362             "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
3363 
3364     /**
3365      * Broadcast Action: An outgoing call is about to be placed.
3366      *
3367      * <p>The Intent will have the following extra value:</p>
3368      * <ul>
3369      *   <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
3370      *       the phone number originally intended to be dialed.</li>
3371      * </ul>
3372      * <p>Once the broadcast is finished, the resultData is used as the actual
3373      * number to call.  If  <code>null</code>, no call will be placed.</p>
3374      * <p>It is perfectly acceptable for multiple receivers to process the
3375      * outgoing call in turn: for example, a parental control application
3376      * might verify that the user is authorized to place the call at that
3377      * time, then a number-rewriting application might add an area code if
3378      * one was not specified.</p>
3379      * <p>For consistency, any receiver whose purpose is to prohibit phone
3380      * calls should have a priority of 0, to ensure it will see the final
3381      * phone number to be dialed.
3382      * Any receiver whose purpose is to rewrite phone numbers to be called
3383      * should have a positive priority.
3384      * Negative priorities are reserved for the system for this broadcast;
3385      * using them may cause problems.</p>
3386      * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3387      * abort the broadcast.</p>
3388      * <p>Emergency calls cannot be intercepted using this mechanism, and
3389      * other calls cannot be modified to call emergency numbers using this
3390      * mechanism.
3391      * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3392      * call to use their own service instead. Those apps should first prevent
3393      * the call from being placed by setting resultData to <code>null</code>
3394      * and then start their own app to make the call.
3395      * <p>You must hold the
3396      * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3397      * permission to receive this Intent.</p>
3398      *
3399      * <p class="note">This is a protected intent that can only be sent
3400      * by the system.
3401      *
3402      * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to
3403      * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast.
3404      * This means that attempts to re-write the outgoing call by other apps using this intent will
3405      * be ignored.
3406      * </p>
3407      *
3408      * @deprecated Apps that redirect outgoing calls should use the
3409      * {@link android.telecom.CallRedirectionService} API.  Apps that perform call screening
3410      * should use the {@link android.telecom.CallScreeningService} API.  Apps which need to be
3411      * notified of basic call state should use
3412      * {@link android.telephony.PhoneStateListener#onCallStateChanged(int, String)} to determine
3413      * when a new outgoing call is placed.
3414      */
3415     @Deprecated
3416     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3417     public static final String ACTION_NEW_OUTGOING_CALL =
3418             "android.intent.action.NEW_OUTGOING_CALL";
3419 
3420     /**
3421      * Broadcast Action: Have the device reboot.  This is only for use by
3422      * system code.
3423      *
3424      * <p class="note">This is a protected intent that can only be sent
3425      * by the system.
3426      */
3427     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3428     public static final String ACTION_REBOOT =
3429             "android.intent.action.REBOOT";
3430 
3431     /**
3432      * Broadcast Action:  A sticky broadcast for changes in the physical
3433      * docking state of the device.
3434      *
3435      * <p>The intent will have the following extra values:
3436      * <ul>
3437      *   <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
3438      *       state, indicating which dock the device is physically in.</li>
3439      * </ul>
3440      * <p>This is intended for monitoring the current physical dock state.
3441      * See {@link android.app.UiModeManager} for the normal API dealing with
3442      * dock mode changes.
3443      */
3444     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3445     public static final String ACTION_DOCK_EVENT =
3446             "android.intent.action.DOCK_EVENT";
3447 
3448     /**
3449      * Broadcast Action: A broadcast when idle maintenance can be started.
3450      * This means that the user is not interacting with the device and is
3451      * not expected to do so soon. Typical use of the idle maintenance is
3452      * to perform somehow expensive tasks that can be postponed at a moment
3453      * when they will not degrade user experience.
3454      * <p>
3455      * <p class="note">In order to keep the device responsive in case of an
3456      * unexpected user interaction, implementations of a maintenance task
3457      * should be interruptible. In such a scenario a broadcast with action
3458      * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3459      * should not do the maintenance work in
3460      * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3461      * maintenance service by {@link Context#startService(Intent)}. Also
3462      * you should hold a wake lock while your maintenance service is running
3463      * to prevent the device going to sleep.
3464      * </p>
3465      * <p>
3466      * <p class="note">This is a protected intent that can only be sent by
3467      * the system.
3468      * </p>
3469      *
3470      * @see #ACTION_IDLE_MAINTENANCE_END
3471      *
3472      * @hide
3473      */
3474     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3475     public static final String ACTION_IDLE_MAINTENANCE_START =
3476             "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3477 
3478     /**
3479      * Broadcast Action:  A broadcast when idle maintenance should be stopped.
3480      * This means that the user was not interacting with the device as a result
3481      * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3482      * was sent and now the user started interacting with the device. Typical
3483      * use of the idle maintenance is to perform somehow expensive tasks that
3484      * can be postponed at a moment when they will not degrade user experience.
3485      * <p>
3486      * <p class="note">In order to keep the device responsive in case of an
3487      * unexpected user interaction, implementations of a maintenance task
3488      * should be interruptible. Hence, on receiving a broadcast with this
3489      * action, the maintenance task should be interrupted as soon as possible.
3490      * In other words, you should not do the maintenance work in
3491      * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3492      * maintenance service that was started on receiving of
3493      * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3494      * lock you acquired when your maintenance service started.
3495      * </p>
3496      * <p class="note">This is a protected intent that can only be sent
3497      * by the system.
3498      *
3499      * @see #ACTION_IDLE_MAINTENANCE_START
3500      *
3501      * @hide
3502      */
3503     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3504     public static final String ACTION_IDLE_MAINTENANCE_END =
3505             "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3506 
3507     /**
3508      * Broadcast Action: a remote intent is to be broadcasted.
3509      *
3510      * A remote intent is used for remote RPC between devices. The remote intent
3511      * is serialized and sent from one device to another device. The receiving
3512      * device parses the remote intent and broadcasts it. Note that anyone can
3513      * broadcast a remote intent. However, if the intent receiver of the remote intent
3514      * does not trust intent broadcasts from arbitrary intent senders, it should require
3515      * the sender to hold certain permissions so only trusted sender's broadcast will be
3516      * let through.
3517      * @hide
3518      */
3519     public static final String ACTION_REMOTE_INTENT =
3520             "com.google.android.c2dm.intent.RECEIVE";
3521 
3522     /**
3523      * Broadcast Action: This is broadcast once when the user is booting after a
3524      * system update. It can be used to perform cleanup or upgrades after a
3525      * system update.
3526      * <p>
3527      * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3528      * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3529      * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3530      * sent to receivers in the system image.
3531      *
3532      * @hide
3533      */
3534     @SystemApi
3535     public static final String ACTION_PRE_BOOT_COMPLETED =
3536             "android.intent.action.PRE_BOOT_COMPLETED";
3537 
3538     /**
3539      * Broadcast to a specific application to query any supported restrictions to impose
3540      * on restricted users. The broadcast intent contains an extra
3541      * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3542      * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3543      * String[] depending on the restriction type.<p/>
3544      * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
3545      * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3546      * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3547      * The activity specified by that intent will be launched for a result which must contain
3548      * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3549      * The keys and values of the returned restrictions will be persisted.
3550      * @see RestrictionEntry
3551      */
3552     public static final String ACTION_GET_RESTRICTION_ENTRIES =
3553             "android.intent.action.GET_RESTRICTION_ENTRIES";
3554 
3555     /**
3556      * Sent the first time a user is starting, to allow system apps to
3557      * perform one time initialization.  (This will not be seen by third
3558      * party applications because a newly initialized user does not have any
3559      * third party applications installed for it.)  This is sent early in
3560      * starting the user, around the time the home app is started, before
3561      * {@link #ACTION_BOOT_COMPLETED} is sent.  This is sent as a foreground
3562      * broadcast, since it is part of a visible user interaction; be as quick
3563      * as possible when handling it.
3564      */
3565     public static final String ACTION_USER_INITIALIZE =
3566             "android.intent.action.USER_INITIALIZE";
3567 
3568     /**
3569      * Sent when a user switch is happening, causing the process's user to be
3570      * brought to the foreground.  This is only sent to receivers registered
3571      * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3572      * Context.registerReceiver}.  It is sent to the user that is going to the
3573      * foreground.  This is sent as a foreground
3574      * broadcast, since it is part of a visible user interaction; be as quick
3575      * as possible when handling it.
3576      */
3577     public static final String ACTION_USER_FOREGROUND =
3578             "android.intent.action.USER_FOREGROUND";
3579 
3580     /**
3581      * Sent when a user switch is happening, causing the process's user to be
3582      * sent to the background.  This is only sent to receivers registered
3583      * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3584      * Context.registerReceiver}.  It is sent to the user that is going to the
3585      * background.  This is sent as a foreground
3586      * broadcast, since it is part of a visible user interaction; be as quick
3587      * as possible when handling it.
3588      */
3589     public static final String ACTION_USER_BACKGROUND =
3590             "android.intent.action.USER_BACKGROUND";
3591 
3592     /**
3593      * Broadcast sent to the system when a user is added. Carries an extra
3594      * EXTRA_USER_HANDLE that has the userHandle of the new user.  It is sent to
3595      * all running users.  You must hold
3596      * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3597      * @hide
3598      */
3599     @SystemApi
3600     public static final String ACTION_USER_ADDED =
3601             "android.intent.action.USER_ADDED";
3602 
3603     /**
3604      * Broadcast sent by the system when a user is started. Carries an extra
3605      * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only sent to
3606      * registered receivers, not manifest receivers.  It is sent to the user
3607      * that has been started.  This is sent as a foreground
3608      * broadcast, since it is part of a visible user interaction; be as quick
3609      * as possible when handling it.
3610      * @hide
3611      */
3612     public static final String ACTION_USER_STARTED =
3613             "android.intent.action.USER_STARTED";
3614 
3615     /**
3616      * Broadcast sent when a user is in the process of starting.  Carries an extra
3617      * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only
3618      * sent to registered receivers, not manifest receivers.  It is sent to all
3619      * users (including the one that is being started).  You must hold
3620      * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3621      * this broadcast.  This is sent as a background broadcast, since
3622      * its result is not part of the primary UX flow; to safely keep track of
3623      * started/stopped state of a user you can use this in conjunction with
3624      * {@link #ACTION_USER_STOPPING}.  It is <b>not</b> generally safe to use with
3625      * other user state broadcasts since those are foreground broadcasts so can
3626      * execute in a different order.
3627      * @hide
3628      */
3629     public static final String ACTION_USER_STARTING =
3630             "android.intent.action.USER_STARTING";
3631 
3632     /**
3633      * Broadcast sent when a user is going to be stopped.  Carries an extra
3634      * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only
3635      * sent to registered receivers, not manifest receivers.  It is sent to all
3636      * users (including the one that is being stopped).  You must hold
3637      * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3638      * this broadcast.  The user will not stop until all receivers have
3639      * handled the broadcast.  This is sent as a background broadcast, since
3640      * its result is not part of the primary UX flow; to safely keep track of
3641      * started/stopped state of a user you can use this in conjunction with
3642      * {@link #ACTION_USER_STARTING}.  It is <b>not</b> generally safe to use with
3643      * other user state broadcasts since those are foreground broadcasts so can
3644      * execute in a different order.
3645      * @hide
3646      */
3647     public static final String ACTION_USER_STOPPING =
3648             "android.intent.action.USER_STOPPING";
3649 
3650     /**
3651      * Broadcast sent to the system when a user is stopped. Carries an extra
3652      * EXTRA_USER_HANDLE that has the userHandle of the user.  This is similar to
3653      * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3654      * specific package.  This is only sent to registered receivers, not manifest
3655      * receivers.  It is sent to all running users <em>except</em> the one that
3656      * has just been stopped (which is no longer running).
3657      * @hide
3658      */
3659     public static final String ACTION_USER_STOPPED =
3660             "android.intent.action.USER_STOPPED";
3661 
3662     /**
3663      * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
3664      * the userHandle of the user.  It is sent to all running users except the
3665      * one that has been removed. The user will not be completely removed until all receivers have
3666      * handled the broadcast. You must hold
3667      * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3668      * @hide
3669      */
3670     @SystemApi
3671     public static final String ACTION_USER_REMOVED =
3672             "android.intent.action.USER_REMOVED";
3673 
3674     /**
3675      * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
3676      * the userHandle of the user to become the current one. This is only sent to
3677      * registered receivers, not manifest receivers.  It is sent to all running users.
3678      * You must hold
3679      * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3680      * @hide
3681      */
3682     @UnsupportedAppUsage
3683     public static final String ACTION_USER_SWITCHED =
3684             "android.intent.action.USER_SWITCHED";
3685 
3686     /**
3687      * Broadcast Action: Sent when the credential-encrypted private storage has
3688      * become unlocked for the target user. This is only sent to registered
3689      * receivers, not manifest receivers.
3690      */
3691     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3692     public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3693 
3694     /**
3695      * Broadcast sent to the system when a user's information changes. Carries an extra
3696      * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
3697      * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
3698      * @hide
3699      */
3700     public static final String ACTION_USER_INFO_CHANGED =
3701             "android.intent.action.USER_INFO_CHANGED";
3702 
3703     /**
3704      * Broadcast sent to the primary user when an associated managed profile is added (the profile
3705      * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
3706      * the UserHandle of the profile that was added. Only applications (for example Launchers)
3707      * that need to display merged content across both primary and managed profiles need to
3708      * worry about this broadcast. This is only sent to registered receivers,
3709      * not manifest receivers.
3710      */
3711     public static final String ACTION_MANAGED_PROFILE_ADDED =
3712             "android.intent.action.MANAGED_PROFILE_ADDED";
3713 
3714     /**
3715      * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
3716      * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3717      * Only applications (for example Launchers) that need to display merged content across both
3718      * primary and managed profiles need to worry about this broadcast. This is only sent to
3719      * registered receivers, not manifest receivers.
3720      */
3721     public static final String ACTION_MANAGED_PROFILE_REMOVED =
3722             "android.intent.action.MANAGED_PROFILE_REMOVED";
3723 
3724     /**
3725      * Broadcast sent to the primary user when the credential-encrypted private storage for
3726      * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3727      * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3728      * Launchers) that need to display merged content across both primary and managed profiles
3729      * need to worry about this broadcast. This is only sent to registered receivers,
3730      * not manifest receivers.
3731      */
3732     public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3733             "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3734 
3735     /**
3736      * Broadcast sent to the primary user when an associated managed profile has become available.
3737      * Currently this includes when the user disables quiet mode for the profile. Carries an extra
3738      * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3739      * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3740      * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3741      */
3742     public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3743             "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3744 
3745     /**
3746      * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3747      * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3748      * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3749      * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3750      * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3751      */
3752     public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3753             "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
3754 
3755     /**
3756      * Broadcast sent to the system user when the 'device locked' state changes for any user.
3757      * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3758      * the device was locked or unlocked.
3759      *
3760      * This is only sent to registered receivers.
3761      *
3762      * @hide
3763      */
3764     public static final String ACTION_DEVICE_LOCKED_CHANGED =
3765             "android.intent.action.DEVICE_LOCKED_CHANGED";
3766 
3767     /**
3768      * Sent when the user taps on the clock widget in the system's "quick settings" area.
3769      */
3770     public static final String ACTION_QUICK_CLOCK =
3771             "android.intent.action.QUICK_CLOCK";
3772 
3773     /**
3774      * Activity Action: Shows the brightness setting dialog.
3775      * @hide
3776      */
3777     public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3778             "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3779 
3780     /**
3781      * Broadcast Action:  A global button was pressed.  Includes a single
3782      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3783      * caused the broadcast.
3784      * @hide
3785      */
3786     @SystemApi
3787     public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3788 
3789     /**
3790      * Broadcast Action: Sent when media resource is granted.
3791      * <p>
3792      * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3793      * granted.
3794      * </p>
3795      * <p class="note">
3796      * This is a protected intent that can only be sent by the system.
3797      * </p>
3798      * <p class="note">
3799      * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
3800      * </p>
3801      *
3802      * @hide
3803      */
3804     public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3805             "android.intent.action.MEDIA_RESOURCE_GRANTED";
3806 
3807     /**
3808      * Broadcast Action: An overlay package has changed. The data contains the
3809      * name of the overlay package which has changed. This is broadcast on all
3810      * changes to the OverlayInfo returned by {@link
3811      * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3812      * most common change is a state change that will change whether the
3813      * overlay is enabled or not.
3814      * @hide
3815      */
3816     public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3817 
3818     /**
3819      * Activity Action: Allow the user to select and return one or more existing
3820      * documents. When invoked, the system will display the various
3821      * {@link DocumentsProvider} instances installed on the device, letting the
3822      * user interactively navigate through them. These documents include local
3823      * media, such as photos and video, and documents provided by installed
3824      * cloud storage providers.
3825      * <p>
3826      * Each document is represented as a {@code content://} URI backed by a
3827      * {@link DocumentsProvider}, which can be opened as a stream with
3828      * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3829      * {@link android.provider.DocumentsContract.Document} metadata.
3830      * <p>
3831      * All selected documents are returned to the calling application with
3832      * persistable read and write permission grants. If you want to maintain
3833      * access to the documents across device reboots, you need to explicitly
3834      * take the persistable permissions using
3835      * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3836      * <p>
3837      * Callers must indicate the acceptable document MIME types through
3838      * {@link #setType(String)}. For example, to select photos, use
3839      * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3840      * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3841      * {@literal *}/*.
3842      * <p>
3843      * If the caller can handle multiple returned items (the user performing
3844      * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3845      * to indicate this.
3846      * <p>
3847      * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3848      * URIs that can be opened with
3849      * {@link ContentResolver#openFileDescriptor(Uri, String)}.
3850      * <p>
3851      * Callers can set a document URI through
3852      * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3853      * location of documents navigator. System will do its best to launch the
3854      * navigator in the specified document if it's a folder, or the folder that
3855      * contains the specified document if not.
3856      * <p>
3857      * Output: The URI of the item that was picked, returned in
3858      * {@link #getData()}. This must be a {@code content://} URI so that any
3859      * receiver can access it. If multiple documents were selected, they are
3860      * returned in {@link #getClipData()}.
3861      *
3862      * @see DocumentsContract
3863      * @see #ACTION_OPEN_DOCUMENT_TREE
3864      * @see #ACTION_CREATE_DOCUMENT
3865      * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
3866      */
3867     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3868     public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3869 
3870     /**
3871      * Activity Action: Allow the user to create a new document. When invoked,
3872      * the system will display the various {@link DocumentsProvider} instances
3873      * installed on the device, letting the user navigate through them. The
3874      * returned document may be a newly created document with no content, or it
3875      * may be an existing document with the requested MIME type.
3876      * <p>
3877      * Each document is represented as a {@code content://} URI backed by a
3878      * {@link DocumentsProvider}, which can be opened as a stream with
3879      * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3880      * {@link android.provider.DocumentsContract.Document} metadata.
3881      * <p>
3882      * Callers must indicate the concrete MIME type of the document being
3883      * created by setting {@link #setType(String)}. This MIME type cannot be
3884      * changed after the document is created.
3885      * <p>
3886      * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3887      * but the user may change this value before creating the file.
3888      * <p>
3889      * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3890      * URIs that can be opened with
3891      * {@link ContentResolver#openFileDescriptor(Uri, String)}.
3892      * <p>
3893      * Callers can set a document URI through
3894      * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3895      * location of documents navigator. System will do its best to launch the
3896      * navigator in the specified document if it's a folder, or the folder that
3897      * contains the specified document if not.
3898      * <p>
3899      * Output: The URI of the item that was created. This must be a
3900      * {@code content://} URI so that any receiver can access it.
3901      *
3902      * @see DocumentsContract
3903      * @see #ACTION_OPEN_DOCUMENT
3904      * @see #ACTION_OPEN_DOCUMENT_TREE
3905      * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
3906      */
3907     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3908     public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3909 
3910     /**
3911      * Activity Action: Allow the user to pick a directory subtree. When
3912      * invoked, the system will display the various {@link DocumentsProvider}
3913      * instances installed on the device, letting the user navigate through
3914      * them. Apps can fully manage documents within the returned directory.
3915      * <p>
3916      * To gain access to descendant (child, grandchild, etc) documents, use
3917      * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3918      * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3919      * with the returned URI.
3920      * <p>
3921      * Callers can set a document URI through
3922      * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3923      * location of documents navigator. System will do its best to launch the
3924      * navigator in the specified document if it's a folder, or the folder that
3925      * contains the specified document if not.
3926      * <p>
3927      * Output: The URI representing the selected directory tree.
3928      *
3929      * @see DocumentsContract
3930      */
3931     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3932     public static final String
3933             ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
3934 
3935 
3936     /**
3937      * Activity Action: Perform text translation.
3938      * <p>
3939      * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate.
3940      * <p>
3941      * Output: nothing.
3942      */
3943     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3944     public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE";
3945 
3946     /**
3947      * Activity Action: Define the meaning of the selected word(s).
3948      * <p>
3949      * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define.
3950      * <p>
3951      * Output: nothing.
3952      */
3953     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3954     public static final String ACTION_DEFINE = "android.intent.action.DEFINE";
3955 
3956     /**
3957      * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3958      * exisiting sensor being disconnected.
3959      *
3960      * <p class="note">This is a protected intent that can only be sent by the system.</p>
3961      *
3962      * {@hide}
3963      */
3964     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3965     public static final String
3966             ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3967 
3968     /**
3969      * Deprecated - use ACTION_FACTORY_RESET instead.
3970      * @hide
3971      * @removed
3972      */
3973     @Deprecated
3974     @SystemApi
3975     public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3976 
3977     /**
3978      * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3979      * is about to be performed.
3980      * @hide
3981      */
3982     @SystemApi
3983     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3984     public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3985             = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3986 
3987     /**
3988      * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3989      * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3990      *
3991      * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3992      *
3993      * @hide
3994      */
3995     @Deprecated
3996     public static final String EXTRA_FORCE_MASTER_CLEAR =
3997             "android.intent.extra.FORCE_MASTER_CLEAR";
3998 
3999     /**
4000      * A broadcast action to trigger a factory reset.
4001      *
4002      * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
4003      * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
4004      *
4005      * <p>Not for use by third-party applications.
4006      *
4007      * @see #EXTRA_FORCE_FACTORY_RESET
4008      *
4009      * {@hide}
4010      */
4011     @SystemApi
4012     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4013     public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
4014 
4015     /**
4016      * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
4017      * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
4018      *
4019      * <p>Not for use by third-party applications.
4020      *
4021      * @hide
4022      */
4023     @SystemApi
4024     public static final String EXTRA_FORCE_FACTORY_RESET =
4025             "android.intent.extra.FORCE_FACTORY_RESET";
4026 
4027     /**
4028      * Broadcast action: report that a settings element is being restored from backup. The intent
4029      * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
4030      * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
4031      * is the value of that settings entry prior to the restore operation, and
4032      * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
4033      * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
4034      * values are represented as strings, the fourth one as int.
4035      *
4036      * <p>This broadcast is sent only for settings provider entries known to require special handling
4037      * around restore time.  These entries are found in the BROADCAST_ON_RESTORE table within
4038      * the provider's backup agent implementation.
4039      *
4040      * @see #EXTRA_SETTING_NAME
4041      * @see #EXTRA_SETTING_PREVIOUS_VALUE
4042      * @see #EXTRA_SETTING_NEW_VALUE
4043      * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
4044      * {@hide}
4045      */
4046     public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
4047 
4048     /** {@hide} */
4049     public static final String EXTRA_SETTING_NAME = "setting_name";
4050     /** {@hide} */
4051     public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
4052     /** {@hide} */
4053     public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
4054     /** {@hide} */
4055     public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
4056 
4057     /**
4058      * Activity Action: Process a piece of text.
4059      * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
4060      * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
4061      * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
4062      */
4063     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4064     public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
4065 
4066     /**
4067      * Broadcast Action: The sim card state has changed.
4068      * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
4069      * because TelephonyIntents is an internal class.
4070      * The intent will have following extras.</p>
4071      * <p>
4072      * @see #EXTRA_SIM_STATE
4073      * @see #EXTRA_SIM_LOCKED_REASON
4074      * @see #EXTRA_REBROADCAST_ON_UNLOCK
4075      *
4076      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
4077      * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4078      *
4079      * @hide
4080      */
4081     @Deprecated
4082     @SystemApi
4083     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4084     public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
4085 
4086     /**
4087      * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE.
4088      * This will have one of the following intent values.
4089      * @see #SIM_STATE_UNKNOWN
4090      * @see #SIM_STATE_NOT_READY
4091      * @see #SIM_STATE_ABSENT
4092      * @see #SIM_STATE_PRESENT
4093      * @see #SIM_STATE_CARD_IO_ERROR
4094      * @see #SIM_STATE_CARD_RESTRICTED
4095      * @see #SIM_STATE_LOCKED
4096      * @see #SIM_STATE_READY
4097      * @see #SIM_STATE_IMSI
4098      * @see #SIM_STATE_LOADED
4099      * @hide
4100      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4101      */
4102     public static final String EXTRA_SIM_STATE = "ss";
4103 
4104     /**
4105      * The intent value UNKNOWN represents the SIM state unknown
4106      * @hide
4107      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4108      */
4109     public static final String SIM_STATE_UNKNOWN = "UNKNOWN";
4110 
4111     /**
4112      * The intent value NOT_READY means that the SIM is not ready eg. radio is off or powering on
4113      * @hide
4114      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4115      */
4116     public static final String SIM_STATE_NOT_READY = "NOT_READY";
4117 
4118     /**
4119      * The intent value ABSENT means the SIM card is missing
4120      * @hide
4121      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4122      */
4123     public static final String SIM_STATE_ABSENT = "ABSENT";
4124 
4125     /**
4126      * The intent value PRESENT means the device has a SIM card inserted
4127      * @hide
4128      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4129      */
4130     public static final String SIM_STATE_PRESENT = "PRESENT";
4131 
4132     /**
4133      * The intent value CARD_IO_ERROR means for three consecutive times there was SIM IO error
4134      * @hide
4135      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4136      */
4137     static public final String SIM_STATE_CARD_IO_ERROR = "CARD_IO_ERROR";
4138 
4139     /**
4140      * The intent value CARD_RESTRICTED means card is present but not usable due to carrier
4141      * restrictions
4142      * @hide
4143      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4144      */
4145     static public final String SIM_STATE_CARD_RESTRICTED = "CARD_RESTRICTED";
4146 
4147     /**
4148      * The intent value LOCKED means the SIM is locked by PIN or by network
4149      * @hide
4150      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4151      */
4152     public static final String SIM_STATE_LOCKED = "LOCKED";
4153 
4154     /**
4155      * The intent value READY means the SIM is ready to be accessed
4156      * @hide
4157      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4158      */
4159     public static final String SIM_STATE_READY = "READY";
4160 
4161     /**
4162      * The intent value IMSI means the SIM IMSI is ready in property
4163      * @hide
4164      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4165      */
4166     public static final String SIM_STATE_IMSI = "IMSI";
4167 
4168     /**
4169      * The intent value LOADED means all SIM records, including IMSI, are loaded
4170      * @hide
4171      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4172      */
4173     public static final String SIM_STATE_LOADED = "LOADED";
4174 
4175     /**
4176      * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE.
4177      * This extra will have one of the following intent values.
4178      * <p>
4179      * @see #SIM_LOCKED_ON_PIN
4180      * @see #SIM_LOCKED_ON_PUK
4181      * @see #SIM_LOCKED_NETWORK
4182      * @see #SIM_ABSENT_ON_PERM_DISABLED
4183      *
4184      * @hide
4185      * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4186      */
4187     public static final String EXTRA_SIM_LOCKED_REASON = "reason";
4188 
4189     /**
4190      * The intent value PIN means the SIM is locked on PIN1
4191      * @hide
4192      * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4193      */
4194     public static final String SIM_LOCKED_ON_PIN = "PIN";
4195 
4196     /**
4197      * The intent value PUK means the SIM is locked on PUK1
4198      * @hide
4199      * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4200      */
4201     /* PUK means ICC is locked on PUK1 */
4202     public static final String SIM_LOCKED_ON_PUK = "PUK";
4203 
4204     /**
4205      * The intent value NETWORK means the SIM is locked on NETWORK PERSONALIZATION
4206      * @hide
4207      * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4208      */
4209     public static final String SIM_LOCKED_NETWORK = "NETWORK";
4210 
4211     /**
4212      * The intent value PERM_DISABLED means SIM is permanently disabled due to puk fails
4213      * @hide
4214      * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4215      */
4216     public static final String SIM_ABSENT_ON_PERM_DISABLED = "PERM_DISABLED";
4217 
4218     /**
4219      * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for indicating whether this broadcast
4220      * is a rebroadcast on unlock. Defaults to {@code false} if not specified.
4221      *
4222      * @hide
4223      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
4224      * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4225      */
4226     public static final String EXTRA_REBROADCAST_ON_UNLOCK = "rebroadcastOnUnlock";
4227 
4228     /**
4229      * Broadcast Action: indicate that the phone service state has changed.
4230      * The intent will have the following extra values:</p>
4231      * <p>
4232      * @see #EXTRA_VOICE_REG_STATE
4233      * @see #EXTRA_DATA_REG_STATE
4234      * @see #EXTRA_VOICE_ROAMING_TYPE
4235      * @see #EXTRA_DATA_ROAMING_TYPE
4236      * @see #EXTRA_OPERATOR_ALPHA_LONG
4237      * @see #EXTRA_OPERATOR_ALPHA_SHORT
4238      * @see #EXTRA_OPERATOR_NUMERIC
4239      * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
4240      * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
4241      * @see #EXTRA_DATA_OPERATOR_NUMERIC
4242      * @see #EXTRA_MANUAL
4243      * @see #EXTRA_VOICE_RADIO_TECH
4244      * @see #EXTRA_DATA_RADIO_TECH
4245      * @see #EXTRA_CSS_INDICATOR
4246      * @see #EXTRA_NETWORK_ID
4247      * @see #EXTRA_SYSTEM_ID
4248      * @see #EXTRA_CDMA_ROAMING_INDICATOR
4249      * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
4250      * @see #EXTRA_EMERGENCY_ONLY
4251      * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
4252      * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
4253      * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
4254      *
4255      * <p class="note">
4256      * Requires the READ_PHONE_STATE permission.
4257      *
4258      * <p class="note">This is a protected intent that can only be sent by the system.
4259      * @hide
4260      * @removed
4261      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
4262      * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
4263      * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
4264      * for a given subscription id and field with a ContentObserver or using JobScheduler.
4265      */
4266     @Deprecated
4267     @SystemApi
4268     @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
4269     public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
4270 
4271     /**
4272      * Used by {@link services.core.java.com.android.server.pm.DataLoaderManagerService}
4273      * for querying Data Loader Service providers. Data loader service providers register this
4274      * intent filter in their manifests, so that they can be looked up and bound to by
4275      * {@code DataLoaderManagerService}.
4276      *
4277      * <p class="note">This is a protected intent that can only be sent by the system.
4278      *
4279      * Data loader service providers must be privileged apps.
4280      * See {@link com.android.server.pm.PackageManagerShellCommandDataLoader} as an example of such
4281      * data loader service provider.
4282      *
4283      * @hide
4284      */
4285     @SystemApi
4286     @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
4287     public static final String ACTION_LOAD_DATA = "android.intent.action.LOAD_DATA";
4288 
4289     /**
4290      * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
4291      * state.
4292      * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4293      * @see android.telephony.ServiceState#STATE_IN_SERVICE
4294      * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4295      * @see android.telephony.ServiceState#STATE_POWER_OFF
4296      * @hide
4297      * @removed
4298      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
4299      */
4300     @Deprecated
4301     @SystemApi
4302     public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
4303 
4304     /**
4305      * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
4306      * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4307      * @see android.telephony.ServiceState#STATE_IN_SERVICE
4308      * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4309      * @see android.telephony.ServiceState#STATE_POWER_OFF
4310      * @hide
4311      * @removed
4312      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
4313      */
4314     @Deprecated
4315     @SystemApi
4316     public static final String EXTRA_DATA_REG_STATE = "dataRegState";
4317 
4318     /**
4319      * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
4320      * type.
4321      * @hide
4322      * @removed
4323      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
4324      */
4325     @Deprecated
4326     @SystemApi
4327     public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
4328 
4329     /**
4330      * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
4331      * type.
4332      * @hide
4333      * @removed
4334      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
4335      */
4336     @Deprecated
4337     @SystemApi
4338     public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
4339 
4340     /**
4341      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4342      * registered voice operator name in long alphanumeric format.
4343      * {@code null} if the operator name is not known or unregistered.
4344      * @hide
4345      * @removed
4346      * @deprecated Use
4347      * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
4348      */
4349     @Deprecated
4350     @SystemApi
4351     public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
4352 
4353     /**
4354      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4355      * registered voice operator name in short alphanumeric format.
4356      * {@code null} if the operator name is not known or unregistered.
4357      * @hide
4358      * @removed
4359      * @deprecated Use
4360      * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
4361      */
4362     @Deprecated
4363     @SystemApi
4364     public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
4365 
4366     /**
4367      * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4368      * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
4369      * network.
4370      * @hide
4371      * @removed
4372      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
4373      */
4374     @Deprecated
4375     @SystemApi
4376     public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
4377 
4378     /**
4379      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4380      * registered data operator name in long alphanumeric format.
4381      * {@code null} if the operator name is not known or unregistered.
4382      * @hide
4383      * @removed
4384      * @deprecated Use
4385      * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
4386      */
4387     @Deprecated
4388     @SystemApi
4389     public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
4390 
4391     /**
4392      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4393      * registered data operator name in short alphanumeric format.
4394      * {@code null} if the operator name is not known or unregistered.
4395      * @hide
4396      * @removed
4397      * @deprecated Use
4398      * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
4399      */
4400     @Deprecated
4401     @SystemApi
4402     public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
4403 
4404     /**
4405      * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4406      * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
4407      * data operator.
4408      * @hide
4409      * @removed
4410      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
4411      */
4412     @Deprecated
4413     @SystemApi
4414     public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
4415 
4416     /**
4417      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
4418      * network selection mode is manual.
4419      * Will be {@code true} if manual mode, {@code false} if automatic mode.
4420      * @hide
4421      * @removed
4422      * @deprecated Use
4423      * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
4424      */
4425     @Deprecated
4426     @SystemApi
4427     public static final String EXTRA_MANUAL = "manual";
4428 
4429     /**
4430      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
4431      * radio technology.
4432      * @hide
4433      * @removed
4434      * @deprecated Use
4435      * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
4436      */
4437     @Deprecated
4438     @SystemApi
4439     public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
4440 
4441     /**
4442      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
4443      * radio technology.
4444      * @hide
4445      * @removed
4446      * @deprecated Use
4447      * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
4448      */
4449     @Deprecated
4450     @SystemApi
4451     public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
4452 
4453     /**
4454      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
4455      * support on CDMA network.
4456      * Will be {@code true} if support, {@code false} otherwise.
4457      * @hide
4458      * @removed
4459      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
4460      */
4461     @Deprecated
4462     @SystemApi
4463     public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
4464 
4465     /**
4466      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
4467      * id. {@code Integer.MAX_VALUE} if unknown.
4468      * @hide
4469      * @removed
4470      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
4471      */
4472     @Deprecated
4473     @SystemApi
4474     public static final String EXTRA_NETWORK_ID = "networkId";
4475 
4476     /**
4477      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
4478      * {@code Integer.MAX_VALUE} if unknown.
4479      * @hide
4480      * @removed
4481      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
4482      */
4483     @Deprecated
4484     @SystemApi
4485     public static final String EXTRA_SYSTEM_ID = "systemId";
4486 
4487     /**
4488      * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
4489      * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
4490      * @hide
4491      * @removed
4492      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
4493      */
4494     @Deprecated
4495     @SystemApi
4496     public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
4497 
4498     /**
4499      * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
4500      * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
4501      * @hide
4502      * @removed
4503      * @deprecated Use
4504      * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
4505      */
4506     @Deprecated
4507     @SystemApi
4508     public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
4509 
4510     /**
4511      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
4512      * only mode.
4513      * {@code true} if in emergency only mode, {@code false} otherwise.
4514      * @hide
4515      * @removed
4516      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
4517      */
4518     @Deprecated
4519     @SystemApi
4520     public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
4521 
4522     /**
4523      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
4524      * registration state is roaming.
4525      * {@code true} if registration indicates roaming, {@code false} otherwise
4526      * @hide
4527      * @removed
4528      * @deprecated Use
4529      * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
4530      */
4531     @Deprecated
4532     @SystemApi
4533     public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
4534             "isDataRoamingFromRegistration";
4535 
4536     /**
4537      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
4538      * aggregation is in use.
4539      * {@code true} if carrier aggregation is in use, {@code false} otherwise.
4540      * @hide
4541      * @removed
4542      * @deprecated Use
4543      * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
4544      */
4545     @Deprecated
4546     @SystemApi
4547     public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
4548 
4549     /**
4550      * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
4551      * is reduced from the rsrp threshold while calculating signal strength level.
4552      * @hide
4553      * @removed
4554      */
4555     @Deprecated
4556     @SystemApi
4557     public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
4558 
4559     /**
4560      * The name of the extra used to define the text to be processed, as a
4561      * CharSequence. Note that this may be a styled CharSequence, so you must use
4562      * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
4563      */
4564     public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
4565     /**
4566      * The name of the boolean extra used to define if the processed text will be used as read-only.
4567      */
4568     public static final String EXTRA_PROCESS_TEXT_READONLY =
4569             "android.intent.extra.PROCESS_TEXT_READONLY";
4570 
4571     /**
4572      * Broadcast action: reports when a new thermal event has been reached. When the device
4573      * is reaching its maximum temperatue, the thermal level reported
4574      * {@hide}
4575      */
4576     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4577     public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
4578 
4579     /** {@hide} */
4580     public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
4581 
4582     /**
4583      * Thermal state when the device is normal. This state is sent in the
4584      * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4585      * {@hide}
4586      */
4587     public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
4588 
4589     /**
4590      * Thermal state where the device is approaching its maximum threshold. This state is sent in
4591      * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4592      * {@hide}
4593      */
4594     public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4595 
4596     /**
4597      * Thermal state where the device has reached its maximum threshold. This state is sent in the
4598      * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4599      * {@hide}
4600      */
4601     public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4602 
4603     /**
4604      * Broadcast Action: Indicates the dock in idle state while device is docked.
4605      *
4606      * <p class="note">This is a protected intent that can only be sent
4607      * by the system.
4608      *
4609      * @hide
4610      */
4611     public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4612 
4613     /**
4614      * Broadcast Action: Indicates the dock in active state while device is docked.
4615      *
4616      * <p class="note">This is a protected intent that can only be sent
4617      * by the system.
4618      *
4619      * @hide
4620      */
4621     public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4622 
4623     /**
4624      * Broadcast Action: Indicates that a new device customization has been
4625      * downloaded and applied (packages installed, runtime resource overlays
4626      * enabled, xml files copied, ...), and that it is time for components that
4627      * need to for example clear their caches to do so now.
4628      *
4629      * @hide
4630      */
4631     @SystemApi
4632     public static final String ACTION_DEVICE_CUSTOMIZATION_READY =
4633             "android.intent.action.DEVICE_CUSTOMIZATION_READY";
4634 
4635 
4636     /**
4637      * Activity Action: Display an activity state associated with an unique {@link LocusId}.
4638      *
4639      * <p>For example, a chat app could use the context to resume a conversation between 2 users.
4640      *
4641      * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the
4642      * app domain. Should be stable across reboots and backup / restore.
4643      * <p>Output: nothing.
4644      */
4645     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4646     public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS";
4647 
4648     /**
4649      * Broadcast Action: Sent to the integrity component when a package
4650      * needs to be verified. The data contains the package URI along with other relevant
4651      * information.
4652      *
4653      * <p class="note">
4654      * This is a protected intent that can only be sent by the system.
4655      * </p>
4656      *
4657      * @hide
4658      */
4659     @SystemApi
4660     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4661     public static final String ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION =
4662             "android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION";
4663 
4664     // ---------------------------------------------------------------------
4665     // ---------------------------------------------------------------------
4666     // Standard intent categories (see addCategory()).
4667 
4668     /**
4669      * Set if the activity should be an option for the default action
4670      * (center press) to perform on a piece of data.  Setting this will
4671      * hide from the user any activities without it set when performing an
4672      * action on some data.  Note that this is normally -not- set in the
4673      * Intent when initiating an action -- it is for use in intent filters
4674      * specified in packages.
4675      */
4676     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4677     public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4678     /**
4679      * Activities that can be safely invoked from a browser must support this
4680      * category.  For example, if the user is viewing a web page or an e-mail
4681      * and clicks on a link in the text, the Intent generated execute that
4682      * link will require the BROWSABLE category, so that only activities
4683      * supporting this category will be considered as possible actions.  By
4684      * supporting this category, you are promising that there is nothing
4685      * damaging (without user intervention) that can happen by invoking any
4686      * matching Intent.
4687      */
4688     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4689     public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4690     /**
4691      * Categories for activities that can participate in voice interaction.
4692      * An activity that supports this category must be prepared to run with
4693      * no UI shown at all (though in some case it may have a UI shown), and
4694      * rely on {@link android.app.VoiceInteractor} to interact with the user.
4695      */
4696     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4697     public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4698     /**
4699      * Set if the activity should be considered as an alternative action to
4700      * the data the user is currently viewing.  See also
4701      * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4702      * applies to the selection in a list of items.
4703      *
4704      * <p>Supporting this category means that you would like your activity to be
4705      * displayed in the set of alternative things the user can do, usually as
4706      * part of the current activity's options menu.  You will usually want to
4707      * include a specific label in the &lt;intent-filter&gt; of this action
4708      * describing to the user what it does.
4709      *
4710      * <p>The action of IntentFilter with this category is important in that it
4711      * describes the specific action the target will perform.  This generally
4712      * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4713      * a specific name such as "com.android.camera.action.CROP.  Only one
4714      * alternative of any particular action will be shown to the user, so using
4715      * a specific action like this makes sure that your alternative will be
4716      * displayed while also allowing other applications to provide their own
4717      * overrides of that particular action.
4718      */
4719     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4720     public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4721     /**
4722      * Set if the activity should be considered as an alternative selection
4723      * action to the data the user has currently selected.  This is like
4724      * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4725      * of items from which the user can select, giving them alternatives to the
4726      * default action that will be performed on it.
4727      */
4728     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4729     public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4730     /**
4731      * Intended to be used as a tab inside of a containing TabActivity.
4732      */
4733     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4734     public static final String CATEGORY_TAB = "android.intent.category.TAB";
4735     /**
4736      * Should be displayed in the top-level launcher.
4737      */
4738     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4739     public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4740     /**
4741      * Indicates an activity optimized for Leanback mode, and that should
4742      * be displayed in the Leanback launcher.
4743      */
4744     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4745     public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4746     /**
4747      * Indicates the preferred entry-point activity when an application is launched from a Car
4748      * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4749      * fallback, or exclude the application entirely.
4750      * @hide
4751      */
4752     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4753     public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4754     /**
4755      * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4756      * @hide
4757      */
4758     @SystemApi
4759     public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4760     /**
4761      * Provides information about the package it is in; typically used if
4762      * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4763      * a front-door to the user without having to be shown in the all apps list.
4764      */
4765     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4766     public static final String CATEGORY_INFO = "android.intent.category.INFO";
4767     /**
4768      * This is the home activity, that is the first activity that is displayed
4769      * when the device boots.
4770      */
4771     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4772     public static final String CATEGORY_HOME = "android.intent.category.HOME";
4773     /**
4774      * This is the home activity that is displayed when the device is finished setting up and ready
4775      * for use.
4776      * @hide
4777      */
4778     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4779     public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4780     /**
4781      * The home activity shown on secondary displays that support showing home activities.
4782      */
4783     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4784     public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME";
4785     /**
4786      * This is the setup wizard activity, that is the first activity that is displayed
4787      * when the user sets up the device for the first time.
4788      * @hide
4789      */
4790     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4791     public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4792     /**
4793      * This is the home activity, that is the activity that serves as the launcher app
4794      * from there the user can start other apps. Often components with lower/higher
4795      * priority intent filters handle the home intent, for example SetupWizard, to
4796      * setup the device and we need to be able to distinguish the home app from these
4797      * setup helpers.
4798      * @hide
4799      */
4800     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4801     public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4802     /**
4803      * This activity is a preference panel.
4804      */
4805     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4806     public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4807     /**
4808      * This activity is a development preference panel.
4809      */
4810     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4811     public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4812     /**
4813      * Capable of running inside a parent activity container.
4814      */
4815     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4816     public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4817     /**
4818      * This activity allows the user to browse and download new applications.
4819      */
4820     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4821     public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4822     /**
4823      * This activity may be exercised by the monkey or other automated test tools.
4824      */
4825     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4826     public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4827     /**
4828      * To be used as a test (not part of the normal user experience).
4829      */
4830     public static final String CATEGORY_TEST = "android.intent.category.TEST";
4831     /**
4832      * To be used as a unit test (run through the Test Harness).
4833      */
4834     public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4835     /**
4836      * To be used as a sample code example (not part of the normal user
4837      * experience).
4838      */
4839     public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
4840 
4841     /**
4842      * Used to indicate that an intent only wants URIs that can be opened with
4843      * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4844      * must support at least the columns defined in {@link OpenableColumns} when
4845      * queried.
4846      *
4847      * @see #ACTION_GET_CONTENT
4848      * @see #ACTION_OPEN_DOCUMENT
4849      * @see #ACTION_CREATE_DOCUMENT
4850      */
4851     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4852     public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4853 
4854     /**
4855      * Used to indicate that an intent filter can accept files which are not necessarily
4856      * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4857      * at least streamable via
4858      * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4859      * using one of the stream types exposed via
4860      * {@link ContentResolver#getStreamTypes(Uri, String)}.
4861      *
4862      * @see #ACTION_SEND
4863      * @see #ACTION_SEND_MULTIPLE
4864      */
4865     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4866     public static final String CATEGORY_TYPED_OPENABLE  =
4867             "android.intent.category.TYPED_OPENABLE";
4868 
4869     /**
4870      * To be used as code under test for framework instrumentation tests.
4871      */
4872     public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4873             "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
4874     /**
4875      * An activity to run when device is inserted into a car dock.
4876      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
4877      * information, see {@link android.app.UiModeManager}.
4878      */
4879     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4880     public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4881     /**
4882      * An activity to run when device is inserted into a car dock.
4883      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
4884      * information, see {@link android.app.UiModeManager}.
4885      */
4886     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4887     public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
4888     /**
4889      * An activity to run when device is inserted into a analog (low end) dock.
4890      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
4891      * information, see {@link android.app.UiModeManager}.
4892      */
4893     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4894     public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4895 
4896     /**
4897      * An activity to run when device is inserted into a digital (high end) dock.
4898      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
4899      * information, see {@link android.app.UiModeManager}.
4900      */
4901     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4902     public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
4903 
4904     /**
4905      * Used to indicate that the activity can be used in a car environment.
4906      */
4907     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4908     public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4909 
4910     /**
4911      * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4912      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
4913      * information, see {@link android.app.UiModeManager}.
4914      */
4915     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4916     public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
4917 
4918     /**
4919      * The accessibility shortcut is a global gesture for users with disabilities to trigger an
4920      * important for them accessibility feature to help developers determine whether they want to
4921      * make their activity a shortcut target.
4922      * <p>
4923      * An activity of interest to users with accessibility needs may request to be the target of
4924      * the accessibility shortcut. It handles intent {@link #ACTION_MAIN} with this category,
4925      * which will be dispatched by the system when the user activates the shortcut when it is
4926      * configured to point at this target.
4927      * </p>
4928      * <p>
4929      * An activity declared itself to be a target of the shortcut in AndroidManifest.xml. It must
4930      * also do two things:
4931      * <ul>
4932      *     <ol>
4933      *         Specify that it handles the <code>android.intent.action.MAIN</code>
4934      *         {@link android.content.Intent}
4935      *         with category <code>android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET</code>.
4936      *     </ol>
4937      *     <ol>
4938      *         Provide a meta-data entry <code>android.accessibilityshortcut.target</code> in the
4939      *         manifest when declaring the activity.
4940      *     </ol>
4941      * </ul>
4942      * If either of these items is missing, the system will ignore the accessibility shortcut
4943      * target. Following is an example declaration:
4944      * </p>
4945      * <pre>
4946      * &lt;activity android:name=".MainActivity"
4947      * . . .
4948      *   &lt;intent-filter&gt;
4949      *       &lt;action android:name="android.intent.action.MAIN" /&gt;
4950      *       &lt;category android:name="android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET" /&gt;
4951      *   &lt;/intent-filter&gt;
4952      *   &lt;meta-data android:name="android.accessibilityshortcut.target"
4953      *                   android:resource="@xml/accessibilityshortcut" /&gt;
4954      * &lt;/activity&gt;
4955      * </pre>
4956      * <p> This is a sample XML file configuring a accessibility shortcut target: </p>
4957      * <pre>
4958      * &lt;accessibility-shortcut-target
4959      *     android:description="@string/shortcut_target_description"
4960      *     android:summary="@string/shortcut_target_summary"
4961      *     android:animatedImageDrawable="@drawable/shortcut_target_animated_image"
4962      *     android:htmlDescription="@string/shortcut_target_html_description"
4963      *     android:settingsActivity="com.example.android.shortcut.target.SettingsActivity" /&gt;
4964      * </pre>
4965      * <p>
4966      * Both description and summary are necessary. The system will ignore the accessibility
4967      * shortcut target if they are missing. The animated image and html description are supported
4968      * to help users understand how to use the shortcut target. The settings activity is a
4969      * component name that allows the user to modify the settings for this accessibility shortcut
4970      * target.
4971      * </p>
4972      */
4973     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4974     public static final String CATEGORY_ACCESSIBILITY_SHORTCUT_TARGET =
4975             "android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET";
4976     // ---------------------------------------------------------------------
4977     // ---------------------------------------------------------------------
4978     // Application launch intent categories (see addCategory()).
4979 
4980     /**
4981      * Used with {@link #ACTION_MAIN} to launch the browser application.
4982      * The activity should be able to browse the Internet.
4983      * <p>NOTE: This should not be used as the primary key of an Intent,
4984      * since it will not result in the app launching with the correct
4985      * action and category.  Instead, use this with
4986      * {@link #makeMainSelectorActivity(String, String)} to generate a main
4987      * Intent with this category in the selector.</p>
4988      */
4989     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4990     public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4991 
4992     /**
4993      * Used with {@link #ACTION_MAIN} to launch the calculator application.
4994      * The activity should be able to perform standard arithmetic operations.
4995      * <p>NOTE: This should not be used as the primary key of an Intent,
4996      * since it will not result in the app launching with the correct
4997      * action and category.  Instead, use this with
4998      * {@link #makeMainSelectorActivity(String, String)} to generate a main
4999      * Intent with this category in the selector.</p>
5000      */
5001     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5002     public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
5003 
5004     /**
5005      * Used with {@link #ACTION_MAIN} to launch the calendar application.
5006      * The activity should be able to view and manipulate calendar entries.
5007      * <p>NOTE: This should not be used as the primary key of an Intent,
5008      * since it will not result in the app launching with the correct
5009      * action and category.  Instead, use this with
5010      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5011      * Intent with this category in the selector.</p>
5012      */
5013     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5014     public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
5015 
5016     /**
5017      * Used with {@link #ACTION_MAIN} to launch the contacts application.
5018      * The activity should be able to view and manipulate address book entries.
5019      * <p>NOTE: This should not be used as the primary key of an Intent,
5020      * since it will not result in the app launching with the correct
5021      * action and category.  Instead, use this with
5022      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5023      * Intent with this category in the selector.</p>
5024      */
5025     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5026     public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
5027 
5028     /**
5029      * Used with {@link #ACTION_MAIN} to launch the email application.
5030      * The activity should be able to send and receive email.
5031      * <p>NOTE: This should not be used as the primary key of an Intent,
5032      * since it will not result in the app launching with the correct
5033      * action and category.  Instead, use this with
5034      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5035      * Intent with this category in the selector.</p>
5036      */
5037     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5038     public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
5039 
5040     /**
5041      * Used with {@link #ACTION_MAIN} to launch the gallery application.
5042      * The activity should be able to view and manipulate image and video files
5043      * stored on the device.
5044      * <p>NOTE: This should not be used as the primary key of an Intent,
5045      * since it will not result in the app launching with the correct
5046      * action and category.  Instead, use this with
5047      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5048      * Intent with this category in the selector.</p>
5049      */
5050     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5051     public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
5052 
5053     /**
5054      * Used with {@link #ACTION_MAIN} to launch the maps application.
5055      * The activity should be able to show the user's current location and surroundings.
5056      * <p>NOTE: This should not be used as the primary key of an Intent,
5057      * since it will not result in the app launching with the correct
5058      * action and category.  Instead, use this with
5059      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5060      * Intent with this category in the selector.</p>
5061      */
5062     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5063     public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
5064 
5065     /**
5066      * Used with {@link #ACTION_MAIN} to launch the messaging application.
5067      * The activity should be able to send and receive text messages.
5068      * <p>NOTE: This should not be used as the primary key of an Intent,
5069      * since it will not result in the app launching with the correct
5070      * action and category.  Instead, use this with
5071      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5072      * Intent with this category in the selector.</p>
5073      */
5074     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5075     public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
5076 
5077     /**
5078      * Used with {@link #ACTION_MAIN} to launch the music application.
5079      * The activity should be able to play, browse, or manipulate music files
5080      * stored on the device.
5081      * <p>NOTE: This should not be used as the primary key of an Intent,
5082      * since it will not result in the app launching with the correct
5083      * action and category.  Instead, use this with
5084      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5085      * Intent with this category in the selector.</p>
5086      */
5087     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5088     public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
5089 
5090     /**
5091      * Used with {@link #ACTION_MAIN} to launch the files application.
5092      * The activity should be able to browse and manage files stored on the device.
5093      * <p>NOTE: This should not be used as the primary key of an Intent,
5094      * since it will not result in the app launching with the correct
5095      * action and category.  Instead, use this with
5096      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5097      * Intent with this category in the selector.</p>
5098      */
5099     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5100     public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES";
5101 
5102     // ---------------------------------------------------------------------
5103     // ---------------------------------------------------------------------
5104     // Standard extra data keys.
5105 
5106     /**
5107      * The initial data to place in a newly created record.  Use with
5108      * {@link #ACTION_INSERT}.  The data here is a Map containing the same
5109      * fields as would be given to the underlying ContentProvider.insert()
5110      * call.
5111      */
5112     public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
5113 
5114     /**
5115      * A constant CharSequence that is associated with the Intent, used with
5116      * {@link #ACTION_SEND} to supply the literal data to be sent.  Note that
5117      * this may be a styled CharSequence, so you must use
5118      * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
5119      * retrieve it.
5120      */
5121     public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
5122 
5123     /**
5124      * A constant String that is associated with the Intent, used with
5125      * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
5126      * as HTML formatted text.  Note that you <em>must</em> also supply
5127      * {@link #EXTRA_TEXT}.
5128      */
5129     public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
5130 
5131     /**
5132      * A content: URI holding a stream of data associated with the Intent,
5133      * used with {@link #ACTION_SEND} to supply the data being sent.
5134      */
5135     public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
5136 
5137     /**
5138      * A String[] holding e-mail addresses that should be delivered to.
5139      */
5140     public static final String EXTRA_EMAIL       = "android.intent.extra.EMAIL";
5141 
5142     /**
5143      * A String[] holding e-mail addresses that should be carbon copied.
5144      */
5145     public static final String EXTRA_CC       = "android.intent.extra.CC";
5146 
5147     /**
5148      * A String[] holding e-mail addresses that should be blind carbon copied.
5149      */
5150     public static final String EXTRA_BCC      = "android.intent.extra.BCC";
5151 
5152     /**
5153      * A constant string holding the desired subject line of a message.
5154      */
5155     public static final String EXTRA_SUBJECT  = "android.intent.extra.SUBJECT";
5156 
5157     /**
5158      * An Intent describing the choices you would like shown with
5159      * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
5160      */
5161     public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
5162 
5163     /**
5164      * An int representing the user id to be used.
5165      *
5166      * @hide
5167      */
5168     public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
5169 
5170     /**
5171      * An int representing the task id to be retrieved. This is used when a launch from recents is
5172      * intercepted by another action such as credentials confirmation to remember which task should
5173      * be resumed when complete.
5174      *
5175      * @hide
5176      */
5177     public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
5178 
5179     /**
5180      * An Intent[] describing additional, alternate choices you would like shown with
5181      * {@link #ACTION_CHOOSER}.
5182      *
5183      * <p>An app may be capable of providing several different payload types to complete a
5184      * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
5185      * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
5186      * several different supported sending mechanisms for sharing, such as the actual "image/*"
5187      * photo data or a hosted link where the photos can be viewed.</p>
5188      *
5189      * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
5190      * first/primary/preferred intent in the set. Additional intents specified in
5191      * this extra are ordered; by default intents that appear earlier in the array will be
5192      * preferred over intents that appear later in the array as matches for the same
5193      * target component. To alter this preference, a calling app may also supply
5194      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
5195      */
5196     public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
5197 
5198     /**
5199      * A {@link ComponentName ComponentName[]} describing components that should be filtered out
5200      * and omitted from a list of components presented to the user.
5201      *
5202      * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
5203      * in this array if it otherwise would have shown them. Useful for omitting specific targets
5204      * from your own package or other apps from your organization if the idea of sending to those
5205      * targets would be redundant with other app functionality. Filtered components will not
5206      * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
5207      */
5208     public static final String EXTRA_EXCLUDE_COMPONENTS
5209             = "android.intent.extra.EXCLUDE_COMPONENTS";
5210 
5211     /**
5212      * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
5213      * describing additional high-priority deep-link targets for the chooser to present to the user.
5214      *
5215      * <p>Targets provided in this way will be presented inline with all other targets provided
5216      * by services from other apps. They will be prioritized before other service targets, but
5217      * after those targets provided by sources that the user has manually pinned to the front.</p>
5218      *
5219      * @see #ACTION_CHOOSER
5220      */
5221     public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
5222 
5223     /**
5224      * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
5225      * from the chooser activity presented by {@link #ACTION_CHOOSER}.
5226      *
5227      * <p>An app preparing an action for another app to complete may wish to allow the user to
5228      * disambiguate between several options for completing the action based on the chosen target
5229      * or otherwise refine the action before it is invoked.
5230      * </p>
5231      *
5232      * <p>When sent, this IntentSender may be filled in with the following extras:</p>
5233      * <ul>
5234      *     <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
5235      *     <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
5236      *     chosen target beyond the first</li>
5237      *     <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
5238      *     should fill in and send once the disambiguation is complete</li>
5239      * </ul>
5240      */
5241     public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
5242             = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
5243 
5244     /**
5245      * An {@code ArrayList} of {@code String} annotations describing content for
5246      * {@link #ACTION_CHOOSER}.
5247      *
5248      * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
5249      * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
5250      *
5251      * <p>Annotations should describe the major components or topics of the content. It is up to
5252      * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
5253      * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
5254      * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
5255      * character. Performance on customized annotations can suffer, if they are rarely used for
5256      * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
5257      * following annotations when applicable.</p>
5258      * <ul>
5259      *     <li>"product" represents that the topic of the content is mainly about products, e.g.,
5260      *     health & beauty, and office supplies.</li>
5261      *     <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
5262      *     happy, and sad.</li>
5263      *     <li>"person" represents that the topic of the content is mainly about persons, e.g.,
5264      *     face, finger, standing, and walking.</li>
5265      *     <li>"child" represents that the topic of the content is mainly about children, e.g.,
5266      *     child, and baby.</li>
5267      *     <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
5268      *     <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
5269      *     <li>"party" represents that the topic of the content is mainly about parties.</li>
5270      *     <li>"animal" represent that the topic of the content is mainly about animals.</li>
5271      *     <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
5272      *     flowers.</li>
5273      *     <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
5274      *     <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
5275      *     sunglasses, jewelry, handbags and clothing.</li>
5276      *     <li>"material" represents that the topic of the content is mainly about materials, e.g.,
5277      *     paper, and silk.</li>
5278      *     <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
5279      *     cars, and boats.</li>
5280      *     <li>"document" represents that the topic of the content is mainly about documents, e.g.
5281      *     posters.</li>
5282      *     <li>"design" represents that the topic of the content is mainly about design, e.g. arts
5283      *     and designs of houses.</li>
5284      *     <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
5285      *     Christmas and Thanksgiving.</li>
5286      * </ul>
5287      */
5288     public static final String EXTRA_CONTENT_ANNOTATIONS
5289             = "android.intent.extra.CONTENT_ANNOTATIONS";
5290 
5291     /**
5292      * A {@link ResultReceiver} used to return data back to the sender.
5293      *
5294      * <p>Used to complete an app-specific
5295      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
5296      *
5297      * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
5298      * used to start a {@link #ACTION_CHOOSER} activity this extra will be
5299      * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
5300      * when the user selects a target component from the chooser. It is up to the recipient
5301      * to send a result to this ResultReceiver to signal that disambiguation is complete
5302      * and that the chooser should invoke the user's choice.</p>
5303      *
5304      * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
5305      * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
5306      * to match and fill in the final Intent or ChooserTarget before starting it.
5307      * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
5308      * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
5309      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
5310      *
5311      * <p>The result code passed to the ResultReceiver should be
5312      * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
5313      * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
5314      * the chooser should finish without starting a target.</p>
5315      */
5316     public static final String EXTRA_RESULT_RECEIVER
5317             = "android.intent.extra.RESULT_RECEIVER";
5318 
5319     /**
5320      * A CharSequence dialog title to provide to the user when used with a
5321      * {@link #ACTION_CHOOSER}.
5322      */
5323     public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
5324 
5325     /**
5326      * A Parcelable[] of {@link Intent} or
5327      * {@link android.content.pm.LabeledIntent} objects as set with
5328      * {@link #putExtra(String, Parcelable[])} of additional activities to place
5329      * a the front of the list of choices, when shown to the user with a
5330      * {@link #ACTION_CHOOSER}.
5331      */
5332     public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
5333 
5334     /**
5335      * A {@link IntentSender} to start after instant app installation success.
5336      * @hide
5337      */
5338     @SystemApi
5339     public static final String EXTRA_INSTANT_APP_SUCCESS =
5340             "android.intent.extra.INSTANT_APP_SUCCESS";
5341 
5342     /**
5343      * A {@link IntentSender} to start after instant app installation failure.
5344      * @hide
5345      */
5346     @SystemApi
5347     public static final String EXTRA_INSTANT_APP_FAILURE =
5348             "android.intent.extra.INSTANT_APP_FAILURE";
5349 
5350     /**
5351      * The host name that triggered an instant app resolution.
5352      * @hide
5353      */
5354     @SystemApi
5355     public static final String EXTRA_INSTANT_APP_HOSTNAME =
5356             "android.intent.extra.INSTANT_APP_HOSTNAME";
5357 
5358     /**
5359      * An opaque token to track instant app resolution.
5360      * @hide
5361      */
5362     @SystemApi
5363     public static final String EXTRA_INSTANT_APP_TOKEN =
5364             "android.intent.extra.INSTANT_APP_TOKEN";
5365 
5366     /**
5367      * The action that triggered an instant application resolution.
5368      * @hide
5369      */
5370     @SystemApi
5371     public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
5372 
5373     /**
5374      * An array of {@link Bundle}s containing details about resolved instant apps..
5375      * @hide
5376      */
5377     @SystemApi
5378     public static final String EXTRA_INSTANT_APP_BUNDLES =
5379             "android.intent.extra.INSTANT_APP_BUNDLES";
5380 
5381     /**
5382      * A {@link Bundle} of metadata that describes the instant application that needs to be
5383      * installed. This data is populated from the response to
5384      * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
5385      * instant application resolver.
5386      * @hide
5387      */
5388     @SystemApi
5389     public static final String EXTRA_INSTANT_APP_EXTRAS =
5390             "android.intent.extra.INSTANT_APP_EXTRAS";
5391 
5392     /**
5393      * A boolean value indicating that the instant app resolver was unable to state with certainty
5394      * that it did or did not have an app for the sanitized {@link Intent} defined at
5395      * {@link #EXTRA_INTENT}.
5396      * @hide
5397      */
5398     @SystemApi
5399     public static final String EXTRA_UNKNOWN_INSTANT_APP =
5400             "android.intent.extra.UNKNOWN_INSTANT_APP";
5401 
5402     /**
5403      * The version code of the app to install components from.
5404      * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
5405      * @hide
5406      */
5407     @Deprecated
5408     public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
5409 
5410     /**
5411      * The version code of the app to install components from.
5412      * @hide
5413      */
5414     @SystemApi
5415     public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
5416 
5417     /**
5418      * The app that triggered the instant app installation.
5419      * @hide
5420      */
5421     @SystemApi
5422     public static final String EXTRA_CALLING_PACKAGE
5423             = "android.intent.extra.CALLING_PACKAGE";
5424 
5425     /**
5426      * Optional calling app provided bundle containing additional launch information the
5427      * installer may use.
5428      * @hide
5429      */
5430     @SystemApi
5431     public static final String EXTRA_VERIFICATION_BUNDLE
5432             = "android.intent.extra.VERIFICATION_BUNDLE";
5433 
5434     /**
5435      * A Bundle forming a mapping of potential target package names to different extras Bundles
5436      * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
5437      * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
5438      * be currently installed on the device.
5439      *
5440      * <p>An application may choose to provide alternate extras for the case where a user
5441      * selects an activity from a predetermined set of target packages. If the activity
5442      * the user selects from the chooser belongs to a package with its package name as
5443      * a key in this bundle, the corresponding extras for that package will be merged with
5444      * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
5445      * extra has the same key as an extra already present in the intent it will overwrite
5446      * the extra from the intent.</p>
5447      *
5448      * <p><em>Examples:</em>
5449      * <ul>
5450      *     <li>An application may offer different {@link #EXTRA_TEXT} to an application
5451      *     when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
5452      *     parameters for that target.</li>
5453      *     <li>An application may offer additional metadata for known targets of a given intent
5454      *     to pass along information only relevant to that target such as account or content
5455      *     identifiers already known to that application.</li>
5456      * </ul></p>
5457      */
5458     public static final String EXTRA_REPLACEMENT_EXTRAS =
5459             "android.intent.extra.REPLACEMENT_EXTRAS";
5460 
5461     /**
5462      * An {@link IntentSender} that will be notified if a user successfully chooses a target
5463      * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
5464      * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
5465      * {@link ComponentName} of the chosen component.
5466      *
5467      * <p>In some situations this callback may never come, for example if the user abandons
5468      * the chooser, switches to another task or any number of other reasons. Apps should not
5469      * be written assuming that this callback will always occur.</p>
5470      */
5471     public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
5472             "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
5473 
5474     /**
5475      * The {@link ComponentName} chosen by the user to complete an action.
5476      *
5477      * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
5478      */
5479     public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
5480 
5481     /**
5482      * A {@link android.view.KeyEvent} object containing the event that
5483      * triggered the creation of the Intent it is in.
5484      */
5485     public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
5486 
5487     /**
5488      * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
5489      * before shutting down.
5490      *
5491      * {@hide}
5492      */
5493     public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
5494 
5495     /**
5496      * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
5497      * requested by the user.
5498      *
5499      * {@hide}
5500      */
5501     public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
5502             "android.intent.extra.USER_REQUESTED_SHUTDOWN";
5503 
5504     /**
5505      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5506      * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
5507      * of restarting the application.
5508      */
5509     public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
5510 
5511     /**
5512      * A String holding the phone number originally entered in
5513      * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
5514      * number to call in a {@link android.content.Intent#ACTION_CALL}.
5515      */
5516     public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
5517 
5518     /**
5519      * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
5520      * intents to supply the uid the package had been assigned.  Also an optional
5521      * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5522      * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
5523      * purpose.
5524      */
5525     public static final String EXTRA_UID = "android.intent.extra.UID";
5526 
5527     /**
5528      * @hide String array of package names.
5529      */
5530     @SystemApi
5531     public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
5532 
5533     /**
5534      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5535      * intents to indicate whether this represents a full uninstall (removing
5536      * both the code and its data) or a partial uninstall (leaving its data,
5537      * implying that this is an update).
5538      */
5539     public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
5540 
5541     /**
5542      * @hide
5543      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5544      * intents to indicate that at this point the package has been removed for
5545      * all users on the device.
5546      */
5547     public static final String EXTRA_REMOVED_FOR_ALL_USERS
5548             = "android.intent.extra.REMOVED_FOR_ALL_USERS";
5549 
5550     /**
5551      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5552      * intents to indicate that this is a replacement of the package, so this
5553      * broadcast will immediately be followed by an add broadcast for a
5554      * different version of the same package.
5555      */
5556     public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
5557 
5558     /**
5559      * Used as an int extra field in {@link android.app.AlarmManager} intents
5560      * to tell the application being invoked how many pending alarms are being
5561      * delievered with the intent.  For one-shot alarms this will always be 1.
5562      * For recurring alarms, this might be greater than 1 if the device was
5563      * asleep or powered off at the time an earlier alarm would have been
5564      * delivered.
5565      */
5566     public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
5567 
5568     /**
5569      * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
5570      * intents to request the dock state.  Possible values are
5571      * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
5572      * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
5573      * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
5574      * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
5575      * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
5576      */
5577     public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
5578 
5579     /**
5580      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5581      * to represent that the phone is not in any dock.
5582      */
5583     public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
5584 
5585     /**
5586      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5587      * to represent that the phone is in a desk dock.
5588      */
5589     public static final int EXTRA_DOCK_STATE_DESK = 1;
5590 
5591     /**
5592      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5593      * to represent that the phone is in a car dock.
5594      */
5595     public static final int EXTRA_DOCK_STATE_CAR = 2;
5596 
5597     /**
5598      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5599      * to represent that the phone is in a analog (low end) dock.
5600      */
5601     public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
5602 
5603     /**
5604      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5605      * to represent that the phone is in a digital (high end) dock.
5606      */
5607     public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
5608 
5609     /**
5610      * Boolean that can be supplied as meta-data with a dock activity, to
5611      * indicate that the dock should take over the home key when it is active.
5612      */
5613     public static final String METADATA_DOCK_HOME = "android.dock_home";
5614 
5615     /**
5616      * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
5617      * the bug report.
5618      */
5619     public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
5620 
5621     /**
5622      * Used in the extra field in the remote intent. It's astring token passed with the
5623      * remote intent.
5624      */
5625     public static final String EXTRA_REMOTE_INTENT_TOKEN =
5626             "android.intent.extra.remote_intent_token";
5627 
5628     /**
5629      * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
5630      * will contain only the first name in the list.
5631      */
5632     @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
5633             "android.intent.extra.changed_component_name";
5634 
5635     /**
5636      * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
5637      * and contains a string array of all of the components that have changed.  If
5638      * the state of the overall package has changed, then it will contain an entry
5639      * with the package name itself.
5640      */
5641     public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
5642             "android.intent.extra.changed_component_name_list";
5643 
5644     /**
5645      * This field is part of
5646      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5647      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
5648      * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
5649      * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
5650      * and contains a string array of all of the components that have changed.
5651      */
5652     public static final String EXTRA_CHANGED_PACKAGE_LIST =
5653             "android.intent.extra.changed_package_list";
5654 
5655     /**
5656      * This field is part of
5657      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5658      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
5659      * and contains an integer array of uids of all of the components
5660      * that have changed.
5661      */
5662     public static final String EXTRA_CHANGED_UID_LIST =
5663             "android.intent.extra.changed_uid_list";
5664 
5665     /**
5666      * An integer denoting a bitwise combination of restrictions set on distracting packages via
5667      * {@link PackageManager#setDistractingPackageRestrictions(String[], int)}
5668      *
5669      * @hide
5670      * @see PackageManager.DistractionRestriction
5671      * @see PackageManager#setDistractingPackageRestrictions(String[], int)
5672      */
5673     public static final String EXTRA_DISTRACTION_RESTRICTIONS =
5674             "android.intent.extra.distraction_restrictions";
5675 
5676     /**
5677      * @hide
5678      * Magic extra system code can use when binding, to give a label for
5679      * who it is that has bound to a service.  This is an integer giving
5680      * a framework string resource that can be displayed to the user.
5681      */
5682     public static final String EXTRA_CLIENT_LABEL =
5683             "android.intent.extra.client_label";
5684 
5685     /**
5686      * @hide
5687      * Magic extra system code can use when binding, to give a PendingIntent object
5688      * that can be launched for the user to disable the system's use of this
5689      * service.
5690      */
5691     public static final String EXTRA_CLIENT_INTENT =
5692             "android.intent.extra.client_intent";
5693 
5694     /**
5695      * Extra used to indicate that an intent should only return data that is on
5696      * the local device. This is a boolean extra; the default is false. If true,
5697      * an implementation should only allow the user to select data that is
5698      * already on the device, not requiring it be downloaded from a remote
5699      * service when opened.
5700      *
5701      * @see #ACTION_GET_CONTENT
5702      * @see #ACTION_OPEN_DOCUMENT
5703      * @see #ACTION_OPEN_DOCUMENT_TREE
5704      * @see #ACTION_CREATE_DOCUMENT
5705      */
5706     public static final String EXTRA_LOCAL_ONLY =
5707             "android.intent.extra.LOCAL_ONLY";
5708 
5709     /**
5710      * Extra used to indicate that an intent can allow the user to select and
5711      * return multiple items. This is a boolean extra; the default is false. If
5712      * true, an implementation is allowed to present the user with a UI where
5713      * they can pick multiple items that are all returned to the caller. When
5714      * this happens, they should be returned as the {@link #getClipData()} part
5715      * of the result Intent.
5716      *
5717      * @see #ACTION_GET_CONTENT
5718      * @see #ACTION_OPEN_DOCUMENT
5719      */
5720     public static final String EXTRA_ALLOW_MULTIPLE =
5721             "android.intent.extra.ALLOW_MULTIPLE";
5722 
5723     /**
5724      * The integer userHandle (i.e. userId) carried with broadcast intents related to addition,
5725      * removal and switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5726      * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5727      *
5728      * @hide
5729      */
5730     public static final String EXTRA_USER_HANDLE =
5731             "android.intent.extra.user_handle";
5732 
5733     /**
5734      * The UserHandle carried with intents.
5735      */
5736     public static final String EXTRA_USER =
5737             "android.intent.extra.USER";
5738 
5739     /**
5740      * Extra used in the response from a BroadcastReceiver that handles
5741      * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5742      * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
5743      */
5744     public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5745 
5746     /**
5747      * Extra sent in the intent to the BroadcastReceiver that handles
5748      * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5749      * the restrictions as key/value pairs.
5750      */
5751     public static final String EXTRA_RESTRICTIONS_BUNDLE =
5752             "android.intent.extra.restrictions_bundle";
5753 
5754     /**
5755      * Extra used in the response from a BroadcastReceiver that handles
5756      * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5757      */
5758     public static final String EXTRA_RESTRICTIONS_INTENT =
5759             "android.intent.extra.restrictions_intent";
5760 
5761     /**
5762      * Extra used to communicate a set of acceptable MIME types. The type of the
5763      * extra is {@code String[]}. Values may be a combination of concrete MIME
5764      * types (such as "image/png") and/or partial MIME types (such as
5765      * "audio/*").
5766      *
5767      * @see #ACTION_GET_CONTENT
5768      * @see #ACTION_OPEN_DOCUMENT
5769      */
5770     public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5771 
5772     /**
5773      * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5774      * this shutdown is only for the user space of the system, not a complete shutdown.
5775      * When this is true, hardware devices can use this information to determine that
5776      * they shouldn't do a complete shutdown of their device since this is not a
5777      * complete shutdown down to the kernel, but only user space restarting.
5778      * The default if not supplied is false.
5779      */
5780     public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5781             = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5782 
5783     /**
5784      * Optional extra specifying a time in milliseconds since the Epoch. The value must be
5785      * non-negative.
5786      * <p>
5787      * Type: long
5788      * </p>
5789      */
5790     public static final String EXTRA_TIME = "android.intent.extra.TIME";
5791 
5792     /**
5793      * Extra sent with {@link #ACTION_TIMEZONE_CHANGED} specifying the new time zone of the device.
5794      *
5795      * <p>Type: String, the same as returned by {@link TimeZone#getID()} to identify time zones.
5796      */
5797     @SuppressLint("ActionValue")
5798     public static final String EXTRA_TIMEZONE = "time-zone";
5799 
5800     /**
5801      * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5802      * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5803      * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5804      * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
5805      *
5806      * @hide for internal use only.
5807      */
5808     public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5809             "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
5810     /** @hide */
5811     public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5812     /** @hide */
5813     public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5814     /** @hide */
5815     public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
5816 
5817     /**
5818      * Intent extra: the reason that the operation associated with this intent is being performed.
5819      *
5820      * <p>Type: String
5821      * @hide
5822      */
5823     @SystemApi
5824     public static final String EXTRA_REASON = "android.intent.extra.REASON";
5825 
5826     /**
5827      * {@hide}
5828      * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5829      */
5830     public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5831 
5832     /**
5833      * {@hide}
5834      * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5835      * reset for the device with eSIM. This extra will be sent together with
5836      * {@link #ACTION_FACTORY_RESET}
5837      */
5838     public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5839 
5840     /**
5841      * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5842      * activation request.
5843      * TODO: Add information about the structure and response data used with the pending intent.
5844      * @hide
5845      */
5846     public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5847             "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5848 
5849     /**
5850      * Optional index with semantics depending on the intent action.
5851      *
5852      * <p>The value must be an integer greater or equal to 0.
5853      * @see #ACTION_QUICK_VIEW
5854      */
5855     public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5856 
5857     /**
5858      * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5859      * such as opening in other apps, sharing, opening, editing, printing, deleting,
5860      * casting, etc.
5861      *
5862      * <p>The value is boolean. By default false.
5863      * @see #ACTION_QUICK_VIEW
5864      * @removed
5865      */
5866     @Deprecated
5867     public static final String EXTRA_QUICK_VIEW_ADVANCED =
5868             "android.intent.extra.QUICK_VIEW_ADVANCED";
5869 
5870     /**
5871      * An optional extra of {@code String[]} indicating which quick view features should be made
5872      * available to the user in the quick view UI while handing a
5873      * {@link Intent#ACTION_QUICK_VIEW} intent.
5874      * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5875      * Quick viewer can implement features not listed below.
5876      * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
5877      * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5878      * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5879      * {@link QuickViewConstants#FEATURE_PRINT}.
5880      * <p>
5881      * Requirements:
5882      * <li>Quick viewer shouldn't show a feature if the feature is absent in
5883      * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5884      * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5885      * internal policies.
5886      * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5887      * requirement that the feature be shown. Quick viewer may, according to its own policies,
5888      * disable or hide features.
5889      *
5890      * @see #ACTION_QUICK_VIEW
5891      */
5892     public static final String EXTRA_QUICK_VIEW_FEATURES =
5893             "android.intent.extra.QUICK_VIEW_FEATURES";
5894 
5895     /**
5896      * Optional boolean extra indicating whether quiet mode has been switched on or off.
5897      * When a profile goes into quiet mode, all apps in the profile are killed and the
5898      * profile user is stopped. Widgets originating from the profile are masked, and app
5899      * launcher icons are grayed out.
5900      */
5901     public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
5902 
5903     /**
5904      * Optional CharSequence extra to provide a search query.
5905      * The format of this query is dependent on the receiving application.
5906      *
5907      * <p>Applicable to {@link Intent} with actions:
5908      * <ul>
5909      *      <li>{@link Intent#ACTION_GET_CONTENT}</li>
5910      *      <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li>
5911      * </ul>
5912      */
5913     public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY";
5914 
5915     /**
5916      * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
5917      * intents to specify the resource type granted. Possible values are
5918      * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5919      * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
5920      *
5921      * @hide
5922      */
5923     public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5924             "android.intent.extra.MEDIA_RESOURCE_TYPE";
5925 
5926     /**
5927      * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5928      * whether to show the chooser or not when there is only one application available
5929      * to choose from.
5930      */
5931     public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5932             "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5933 
5934     /**
5935      * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
5936      * to represent that a video codec is allowed to use.
5937      *
5938      * @hide
5939      */
5940     public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5941 
5942     /**
5943      * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
5944      * to represent that a audio codec is allowed to use.
5945      *
5946      * @hide
5947      */
5948     public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5949 
5950     /**
5951      * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}.
5952      *
5953      * <p>
5954      * Type: {@link LocusId}
5955      * </p>
5956      */
5957     public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID";
5958 
5959     // ---------------------------------------------------------------------
5960     // ---------------------------------------------------------------------
5961     // Intent flags (see mFlags variable).
5962 
5963     /** @hide */
5964     @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
5965             FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5966             FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
5967     @Retention(RetentionPolicy.SOURCE)
5968     public @interface GrantUriMode {}
5969 
5970     /** @hide */
5971     @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
5972             FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5973     @Retention(RetentionPolicy.SOURCE)
5974     public @interface AccessUriMode {}
5975 
5976     /**
5977      * Test if given mode flags specify an access mode, which must be at least
5978      * read and/or write.
5979      *
5980      * @hide
5981      */
isAccessUriMode(int modeFlags)5982     public static boolean isAccessUriMode(int modeFlags) {
5983         return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5984                 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5985     }
5986 
5987     /** @hide */
5988     @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5989             FLAG_GRANT_READ_URI_PERMISSION,
5990             FLAG_GRANT_WRITE_URI_PERMISSION,
5991             FLAG_FROM_BACKGROUND,
5992             FLAG_DEBUG_LOG_RESOLUTION,
5993             FLAG_EXCLUDE_STOPPED_PACKAGES,
5994             FLAG_INCLUDE_STOPPED_PACKAGES,
5995             FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5996             FLAG_GRANT_PREFIX_URI_PERMISSION,
5997             FLAG_DEBUG_TRIAGED_MISSING,
5998             FLAG_IGNORE_EPHEMERAL,
5999             FLAG_ACTIVITY_MATCH_EXTERNAL,
6000             FLAG_ACTIVITY_NO_HISTORY,
6001             FLAG_ACTIVITY_SINGLE_TOP,
6002             FLAG_ACTIVITY_NEW_TASK,
6003             FLAG_ACTIVITY_MULTIPLE_TASK,
6004             FLAG_ACTIVITY_CLEAR_TOP,
6005             FLAG_ACTIVITY_FORWARD_RESULT,
6006             FLAG_ACTIVITY_PREVIOUS_IS_TOP,
6007             FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
6008             FLAG_ACTIVITY_BROUGHT_TO_FRONT,
6009             FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
6010             FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
6011             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6012             FLAG_ACTIVITY_NEW_DOCUMENT,
6013             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6014             FLAG_ACTIVITY_NO_USER_ACTION,
6015             FLAG_ACTIVITY_REORDER_TO_FRONT,
6016             FLAG_ACTIVITY_NO_ANIMATION,
6017             FLAG_ACTIVITY_CLEAR_TASK,
6018             FLAG_ACTIVITY_TASK_ON_HOME,
6019             FLAG_ACTIVITY_RETAIN_IN_RECENTS,
6020             FLAG_ACTIVITY_LAUNCH_ADJACENT,
6021             FLAG_ACTIVITY_REQUIRE_NON_BROWSER,
6022             FLAG_ACTIVITY_REQUIRE_DEFAULT,
6023             FLAG_RECEIVER_REGISTERED_ONLY,
6024             FLAG_RECEIVER_REPLACE_PENDING,
6025             FLAG_RECEIVER_FOREGROUND,
6026             FLAG_RECEIVER_NO_ABORT,
6027             FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
6028             FLAG_RECEIVER_BOOT_UPGRADE,
6029             FLAG_RECEIVER_INCLUDE_BACKGROUND,
6030             FLAG_RECEIVER_EXCLUDE_BACKGROUND,
6031             FLAG_RECEIVER_FROM_SHELL,
6032             FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
6033             FLAG_RECEIVER_OFFLOAD,
6034     })
6035     @Retention(RetentionPolicy.SOURCE)
6036     public @interface Flags {}
6037 
6038     /** @hide */
6039     @IntDef(flag = true, prefix = { "FLAG_" }, value = {
6040             FLAG_FROM_BACKGROUND,
6041             FLAG_DEBUG_LOG_RESOLUTION,
6042             FLAG_EXCLUDE_STOPPED_PACKAGES,
6043             FLAG_INCLUDE_STOPPED_PACKAGES,
6044             FLAG_DEBUG_TRIAGED_MISSING,
6045             FLAG_IGNORE_EPHEMERAL,
6046             FLAG_ACTIVITY_MATCH_EXTERNAL,
6047             FLAG_ACTIVITY_NO_HISTORY,
6048             FLAG_ACTIVITY_SINGLE_TOP,
6049             FLAG_ACTIVITY_NEW_TASK,
6050             FLAG_ACTIVITY_MULTIPLE_TASK,
6051             FLAG_ACTIVITY_CLEAR_TOP,
6052             FLAG_ACTIVITY_FORWARD_RESULT,
6053             FLAG_ACTIVITY_PREVIOUS_IS_TOP,
6054             FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
6055             FLAG_ACTIVITY_BROUGHT_TO_FRONT,
6056             FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
6057             FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
6058             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6059             FLAG_ACTIVITY_NEW_DOCUMENT,
6060             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6061             FLAG_ACTIVITY_NO_USER_ACTION,
6062             FLAG_ACTIVITY_REORDER_TO_FRONT,
6063             FLAG_ACTIVITY_NO_ANIMATION,
6064             FLAG_ACTIVITY_CLEAR_TASK,
6065             FLAG_ACTIVITY_TASK_ON_HOME,
6066             FLAG_ACTIVITY_RETAIN_IN_RECENTS,
6067             FLAG_ACTIVITY_LAUNCH_ADJACENT,
6068             FLAG_RECEIVER_REGISTERED_ONLY,
6069             FLAG_RECEIVER_REPLACE_PENDING,
6070             FLAG_RECEIVER_FOREGROUND,
6071             FLAG_RECEIVER_NO_ABORT,
6072             FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
6073             FLAG_RECEIVER_BOOT_UPGRADE,
6074             FLAG_RECEIVER_INCLUDE_BACKGROUND,
6075             FLAG_RECEIVER_EXCLUDE_BACKGROUND,
6076             FLAG_RECEIVER_FROM_SHELL,
6077             FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
6078             FLAG_RECEIVER_OFFLOAD,
6079     })
6080     @Retention(RetentionPolicy.SOURCE)
6081     public @interface MutableFlags {}
6082 
6083     /**
6084      * If set, the recipient of this Intent will be granted permission to
6085      * perform read operations on the URI in the Intent's data and any URIs
6086      * specified in its ClipData.  When applying to an Intent's ClipData,
6087      * all URIs as well as recursive traversals through data or other ClipData
6088      * in Intent items will be granted; only the grant flags of the top-level
6089      * Intent are used.
6090      */
6091     public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
6092     /**
6093      * If set, the recipient of this Intent will be granted permission to
6094      * perform write operations on the URI in the Intent's data and any URIs
6095      * specified in its ClipData.  When applying to an Intent's ClipData,
6096      * all URIs as well as recursive traversals through data or other ClipData
6097      * in Intent items will be granted; only the grant flags of the top-level
6098      * Intent are used.
6099      */
6100     public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
6101     /**
6102      * Can be set by the caller to indicate that this Intent is coming from
6103      * a background operation, not from direct user interaction.
6104      */
6105     public static final int FLAG_FROM_BACKGROUND = 0x00000004;
6106     /**
6107      * A flag you can enable for debugging: when set, log messages will be
6108      * printed during the resolution of this intent to show you what has
6109      * been found to create the final resolved list.
6110      */
6111     public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
6112     /**
6113      * If set, this intent will not match any components in packages that
6114      * are currently stopped.  If this is not set, then the default behavior
6115      * is to include such applications in the result.
6116      */
6117     public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
6118     /**
6119      * If set, this intent will always match any components in packages that
6120      * are currently stopped.  This is the default behavior when
6121      * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set.  If both of these
6122      * flags are set, this one wins (it allows overriding of exclude for
6123      * places where the framework may automatically set the exclude flag).
6124      */
6125     public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
6126 
6127     /**
6128      * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
6129      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
6130      * persisted across device reboots until explicitly revoked with
6131      * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
6132      * grant for possible persisting; the receiving application must call
6133      * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
6134      * actually persist.
6135      *
6136      * @see ContentResolver#takePersistableUriPermission(Uri, int)
6137      * @see ContentResolver#releasePersistableUriPermission(Uri, int)
6138      * @see ContentResolver#getPersistedUriPermissions()
6139      * @see ContentResolver#getOutgoingPersistedUriPermissions()
6140      */
6141     public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
6142 
6143     /**
6144      * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
6145      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
6146      * applies to any URI that is a prefix match against the original granted
6147      * URI. (Without this flag, the URI must match exactly for access to be
6148      * granted.) Another URI is considered a prefix match only when scheme,
6149      * authority, and all path segments defined by the prefix are an exact
6150      * match.
6151      */
6152     public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
6153 
6154     /**
6155      * Flag used to automatically match intents based on their Direct Boot
6156      * awareness and the current user state.
6157      * <p>
6158      * Since the default behavior is to automatically apply the current user
6159      * state, this is effectively a sentinel value that doesn't change the
6160      * output of any queries based on its presence or absence.
6161      * <p>
6162      * Instead, this value can be useful in conjunction with
6163      * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
6164      * to detect when a caller is relying on implicit automatic matching,
6165      * instead of confirming the explicit behavior they want.
6166      */
6167     public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
6168 
6169     /** {@hide} */
6170     @Deprecated
6171     public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
6172 
6173     /**
6174      * Internal flag used to indicate ephemeral applications should not be
6175      * considered when resolving the intent.
6176      *
6177      * @hide
6178      */
6179     public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
6180 
6181     /**
6182      * If set, the new activity is not kept in the history stack.  As soon as
6183      * the user navigates away from it, the activity is finished.  This may also
6184      * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
6185      * noHistory} attribute.
6186      *
6187      * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
6188      * is never invoked when the current activity starts a new activity which
6189      * sets a result and finishes.
6190      */
6191     public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
6192     /**
6193      * If set, the activity will not be launched if it is already running
6194      * at the top of the history stack.
6195      */
6196     public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
6197     /**
6198      * If set, this activity will become the start of a new task on this
6199      * history stack.  A task (from the activity that started it to the
6200      * next task activity) defines an atomic group of activities that the
6201      * user can move to.  Tasks can be moved to the foreground and background;
6202      * all of the activities inside of a particular task always remain in
6203      * the same order.  See
6204      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6205      * Stack</a> for more information about tasks.
6206      *
6207      * <p>This flag is generally used by activities that want
6208      * to present a "launcher" style behavior: they give the user a list of
6209      * separate things that can be done, which otherwise run completely
6210      * independently of the activity launching them.
6211      *
6212      * <p>When using this flag, if a task is already running for the activity
6213      * you are now starting, then a new activity will not be started; instead,
6214      * the current task will simply be brought to the front of the screen with
6215      * the state it was last in.  See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
6216      * to disable this behavior.
6217      *
6218      * <p>This flag can not be used when the caller is requesting a result from
6219      * the activity being launched.
6220      */
6221     public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
6222     /**
6223      * This flag is used to create a new task and launch an activity into it.
6224      * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
6225      * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
6226      * search through existing tasks for ones matching this Intent. Only if no such
6227      * task is found would a new task be created. When paired with
6228      * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
6229      * the search for a matching task and unconditionally start a new task.
6230      *
6231      * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
6232      * flag unless you are implementing your own
6233      * top-level application launcher.</strong>  Used in conjunction with
6234      * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
6235      * behavior of bringing an existing task to the foreground.  When set,
6236      * a new task is <em>always</em> started to host the Activity for the
6237      * Intent, regardless of whether there is already an existing task running
6238      * the same thing.
6239      *
6240      * <p><strong>Because the default system does not include graphical task management,
6241      * you should not use this flag unless you provide some way for a user to
6242      * return back to the tasks you have launched.</strong>
6243      *
6244      * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
6245      * creating new document tasks.
6246      *
6247      * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
6248      * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
6249      *
6250      * <p>See
6251      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6252      * Stack</a> for more information about tasks.
6253      *
6254      * @see #FLAG_ACTIVITY_NEW_DOCUMENT
6255      * @see #FLAG_ACTIVITY_NEW_TASK
6256      */
6257     public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
6258     /**
6259      * If set, and the activity being launched is already running in the
6260      * current task, then instead of launching a new instance of that activity,
6261      * all of the other activities on top of it will be closed and this Intent
6262      * will be delivered to the (now on top) old activity as a new Intent.
6263      *
6264      * <p>For example, consider a task consisting of the activities: A, B, C, D.
6265      * If D calls startActivity() with an Intent that resolves to the component
6266      * of activity B, then C and D will be finished and B receive the given
6267      * Intent, resulting in the stack now being: A, B.
6268      *
6269      * <p>The currently running instance of activity B in the above example will
6270      * either receive the new intent you are starting here in its
6271      * onNewIntent() method, or be itself finished and restarted with the
6272      * new intent.  If it has declared its launch mode to be "multiple" (the
6273      * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
6274      * the same intent, then it will be finished and re-created; for all other
6275      * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
6276      * Intent will be delivered to the current instance's onNewIntent().
6277      *
6278      * <p>This launch mode can also be used to good effect in conjunction with
6279      * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
6280      * of a task, it will bring any currently running instance of that task
6281      * to the foreground, and then clear it to its root state.  This is
6282      * especially useful, for example, when launching an activity from the
6283      * notification manager.
6284      *
6285      * <p>See
6286      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6287      * Stack</a> for more information about tasks.
6288      */
6289     public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
6290     /**
6291      * If set and this intent is being used to launch a new activity from an
6292      * existing one, then the reply target of the existing activity will be
6293      * transferred to the new activity.  This way, the new activity can call
6294      * {@link android.app.Activity#setResult} and have that result sent back to
6295      * the reply target of the original activity.
6296      */
6297     public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
6298     /**
6299      * If set and this intent is being used to launch a new activity from an
6300      * existing one, the current activity will not be counted as the top
6301      * activity for deciding whether the new intent should be delivered to
6302      * the top instead of starting a new one.  The previous activity will
6303      * be used as the top, with the assumption being that the current activity
6304      * will finish itself immediately.
6305      */
6306     public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
6307     /**
6308      * If set, the new activity is not kept in the list of recently launched
6309      * activities.
6310      */
6311     public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
6312     /**
6313      * This flag is not normally set by application code, but set for you by
6314      * the system as described in the
6315      * {@link android.R.styleable#AndroidManifestActivity_launchMode
6316      * launchMode} documentation for the singleTask mode.
6317      */
6318     public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
6319     /**
6320      * If set, and this activity is either being started in a new task or
6321      * bringing to the top an existing task, then it will be launched as
6322      * the front door of the task.  This will result in the application of
6323      * any affinities needed to have that task in the proper state (either
6324      * moving activities to or from it), or simply resetting that task to
6325      * its initial state if needed.
6326      */
6327     public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
6328     /**
6329      * This flag is not normally set by application code, but set for you by
6330      * the system if this activity is being launched from history
6331      * (longpress home key).
6332      */
6333     public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
6334     /**
6335      * @deprecated As of API 21 this performs identically to
6336      * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
6337      */
6338     @Deprecated
6339     public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
6340     /**
6341      * This flag is used to open a document into a new task rooted at the activity launched
6342      * by this Intent. Through the use of this flag, or its equivalent attribute,
6343      * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
6344      * containing different documents will appear in the recent tasks list.
6345      *
6346      * <p>The use of the activity attribute form of this,
6347      * {@link android.R.attr#documentLaunchMode}, is
6348      * preferred over the Intent flag described here. The attribute form allows the
6349      * Activity to specify multiple document behavior for all launchers of the Activity
6350      * whereas using this flag requires each Intent that launches the Activity to specify it.
6351      *
6352      * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
6353      * it is kept after the activity is finished is different than the use of
6354      * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
6355      * this flag is being used to create a new recents entry, then by default that entry
6356      * will be removed once the activity is finished.  You can modify this behavior with
6357      * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
6358      *
6359      * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
6360      * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
6361      * equivalent of the Activity manifest specifying {@link
6362      * android.R.attr#documentLaunchMode}="intoExisting". When used with
6363      * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
6364      * {@link android.R.attr#documentLaunchMode}="always".
6365      *
6366      * Refer to {@link android.R.attr#documentLaunchMode} for more information.
6367      *
6368      * @see android.R.attr#documentLaunchMode
6369      * @see #FLAG_ACTIVITY_MULTIPLE_TASK
6370      */
6371     public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
6372     /**
6373      * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
6374      * callback from occurring on the current frontmost activity before it is
6375      * paused as the newly-started activity is brought to the front.
6376      *
6377      * <p>Typically, an activity can rely on that callback to indicate that an
6378      * explicit user action has caused their activity to be moved out of the
6379      * foreground. The callback marks an appropriate point in the activity's
6380      * lifecycle for it to dismiss any notifications that it intends to display
6381      * "until the user has seen them," such as a blinking LED.
6382      *
6383      * <p>If an activity is ever started via any non-user-driven events such as
6384      * phone-call receipt or an alarm handler, this flag should be passed to {@link
6385      * Context#startActivity Context.startActivity}, ensuring that the pausing
6386      * activity does not think the user has acknowledged its notification.
6387      */
6388     public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
6389     /**
6390      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6391      * this flag will cause the launched activity to be brought to the front of its
6392      * task's history stack if it is already running.
6393      *
6394      * <p>For example, consider a task consisting of four activities: A, B, C, D.
6395      * If D calls startActivity() with an Intent that resolves to the component
6396      * of activity B, then B will be brought to the front of the history stack,
6397      * with this resulting order:  A, C, D, B.
6398      *
6399      * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
6400      * specified.
6401      */
6402     public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
6403     /**
6404      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6405      * this flag will prevent the system from applying an activity transition
6406      * animation to go to the next activity state.  This doesn't mean an
6407      * animation will never run -- if another activity change happens that doesn't
6408      * specify this flag before the activity started here is displayed, then
6409      * that transition will be used.  This flag can be put to good use
6410      * when you are going to do a series of activity operations but the
6411      * animation seen by the user shouldn't be driven by the first activity
6412      * change but rather a later one.
6413      */
6414     public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
6415     /**
6416      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6417      * this flag will cause any existing task that would be associated with the
6418      * activity to be cleared before the activity is started.  That is, the activity
6419      * becomes the new root of an otherwise empty task, and any old activities
6420      * are finished.  This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6421      */
6422     public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
6423     /**
6424      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6425      * this flag will cause a newly launching task to be placed on top of the current
6426      * home activity task (if there is one).  That is, pressing back from the task
6427      * will always return the user to home even if that was not the last activity they
6428      * saw.   This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6429      */
6430     public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
6431     /**
6432      * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
6433      * have its entry in recent tasks removed when the user closes it (with back
6434      * or however else it may finish()). If you would like to instead allow the
6435      * document to be kept in recents so that it can be re-launched, you can use
6436      * this flag. When set and the task's activity is finished, the recents
6437      * entry will remain in the interface for the user to re-launch it, like a
6438      * recents entry for a top-level application.
6439      * <p>
6440      * The receiving activity can override this request with
6441      * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
6442      * {@link android.app.Activity#finishAndRemoveTask()
6443      * Activity.finishAndRemoveTask()}.
6444      */
6445     public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
6446 
6447     /**
6448      * This flag is only used for split-screen multi-window mode. The new activity will be displayed
6449      * adjacent to the one launching it. This can only be used in conjunction with
6450      * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
6451      * required if you want a new instance of an existing activity to be created.
6452      */
6453     public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
6454 
6455 
6456     /**
6457      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6458      * this flag will attempt to launch an instant app if no full app on the device can already
6459      * handle the intent.
6460      * <p>
6461      * When attempting to resolve instant apps externally, the following {@link Intent} properties
6462      * are supported:
6463      * <ul>
6464      *     <li>{@link Intent#setAction(String)}</li>
6465      *     <li>{@link Intent#addCategory(String)}</li>
6466      *     <li>{@link Intent#setData(Uri)}</li>
6467      *     <li>{@link Intent#setType(String)}</li>
6468      *     <li>{@link Intent#setPackage(String)}</li>
6469      *     <li>{@link Intent#addFlags(int)}</li>
6470      * </ul>
6471      * <p>
6472      * In the case that no instant app can be found, the installer will be launched to notify the
6473      * user that the intent could not be resolved. On devices that do not support instant apps,
6474      * the flag will be ignored.
6475      */
6476     public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
6477 
6478     /**
6479      * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this
6480      * flag will only launch the intent if it resolves to a result that is not a browser. If no such
6481      * result exists, an {@link ActivityNotFoundException} will be thrown.
6482      */
6483     public static final int FLAG_ACTIVITY_REQUIRE_NON_BROWSER = 0x00000400;
6484 
6485     /**
6486      * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this
6487      * flag will only launch the intent if it resolves to a single result. If no such result exists
6488      * or if the system chooser would otherwise be displayed, an {@link ActivityNotFoundException}
6489      * will be thrown.
6490      */
6491     public static final int FLAG_ACTIVITY_REQUIRE_DEFAULT = 0x00000200;
6492 
6493     /**
6494      * If set, when sending a broadcast only registered receivers will be
6495      * called -- no BroadcastReceiver components will be launched.
6496      */
6497     public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
6498     /**
6499      * If set, when sending a broadcast the new broadcast will replace
6500      * any existing pending broadcast that matches it.  Matching is defined
6501      * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
6502      * true for the intents of the two broadcasts.  When a match is found,
6503      * the new broadcast (and receivers associated with it) will replace the
6504      * existing one in the pending broadcast list, remaining at the same
6505      * position in the list.
6506      *
6507      * <p>This flag is most typically used with sticky broadcasts, which
6508      * only care about delivering the most recent values of the broadcast
6509      * to their receivers.
6510      */
6511     public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
6512     /**
6513      * If set, when sending a broadcast the recipient is allowed to run at
6514      * foreground priority, with a shorter timeout interval.  During normal
6515      * broadcasts the receivers are not automatically hoisted out of the
6516      * background priority class.
6517      */
6518     public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
6519     /**
6520      * If set, when sending a broadcast the recipient will be run on the offload queue.
6521      *
6522      * @hide
6523      */
6524     public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000;
6525     /**
6526      * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
6527      * They can still propagate results through to later receivers, but they can not prevent
6528      * later receivers from seeing the broadcast.
6529      */
6530     public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
6531     /**
6532      * If set, when sending a broadcast <i>before the system has fully booted up
6533      * (which is even before {@link #ACTION_LOCKED_BOOT_COMPLETED} has been sent)"</i> only
6534      * registered receivers will be called -- no BroadcastReceiver components
6535      * will be launched.  Sticky intent state will be recorded properly even
6536      * if no receivers wind up being called.  If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
6537      * is specified in the broadcast intent, this flag is unnecessary.
6538      *
6539      * <p>This flag is only for use by system services (even services from mainline modules) as a
6540      * convenience to avoid having to implement a more complex mechanism around detection
6541      * of boot completion.
6542      *
6543      * <p>This is useful to system server mainline modules
6544      *
6545      * @hide
6546      */
6547     @SystemApi
6548     public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
6549     /**
6550      * Set when this broadcast is for a boot upgrade, a special mode that
6551      * allows the broadcast to be sent before the system is ready and launches
6552      * the app process with no providers running in it.
6553      * @hide
6554      */
6555     public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
6556     /**
6557      * If set, the broadcast will always go to manifest receivers in background (cached
6558      * or not running) apps, regardless of whether that would be done by default.  By
6559      * default they will only receive broadcasts if the broadcast has specified an
6560      * explicit component or package name.
6561      *
6562      * NOTE: dumpstate uses this flag numerically, so when its value is changed
6563      * the broadcast code there must also be changed to match.
6564      *
6565      * @hide
6566      */
6567     public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
6568     /**
6569      * If set, the broadcast will never go to manifest receivers in background (cached
6570      * or not running) apps, regardless of whether that would be done by default.  By
6571      * default they will receive broadcasts if the broadcast has specified an
6572      * explicit component or package name.
6573      * @hide
6574      */
6575     public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
6576     /**
6577      * If set, this broadcast is being sent from the shell.
6578      * @hide
6579      */
6580     public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
6581 
6582     /**
6583      * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
6584      * will not receive broadcasts.
6585      *
6586      * <em>This flag has no effect when used by an Instant App.</em>
6587      */
6588     public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
6589 
6590     /**
6591      * @hide Flags that can't be changed with PendingIntent.
6592      */
6593     public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
6594             | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6595             | FLAG_GRANT_PREFIX_URI_PERMISSION;
6596 
6597     // ---------------------------------------------------------------------
6598     // ---------------------------------------------------------------------
6599     // toUri() and parseUri() options.
6600 
6601     /** @hide */
6602     @IntDef(flag = true, prefix = { "URI_" }, value = {
6603             URI_ALLOW_UNSAFE,
6604             URI_ANDROID_APP_SCHEME,
6605             URI_INTENT_SCHEME,
6606     })
6607     @Retention(RetentionPolicy.SOURCE)
6608     public @interface UriFlags {}
6609 
6610     /**
6611      * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6612      * always has the "intent:" scheme.  This syntax can be used when you want
6613      * to later disambiguate between URIs that are intended to describe an
6614      * Intent vs. all others that should be treated as raw URIs.  When used
6615      * with {@link #parseUri}, any other scheme will result in a generic
6616      * VIEW action for that raw URI.
6617      */
6618     public static final int URI_INTENT_SCHEME = 1<<0;
6619 
6620     /**
6621      * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6622      * always has the "android-app:" scheme.  This is a variation of
6623      * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
6624      * http/https URI being delivered to a specific package name.  The format
6625      * is:
6626      *
6627      * <pre class="prettyprint">
6628      * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
6629      *
6630      * <p>In this scheme, only the <code>package_id</code> is required.  If you include a host,
6631      * you must also include a scheme; including a path also requires both a host and a scheme.
6632      * The final #Intent; fragment can be used without a scheme, host, or path.
6633      * Note that this can not be
6634      * used with intents that have a {@link #setSelector}, since the base intent
6635      * will always have an explicit package name.</p>
6636      *
6637      * <p>Some examples of how this scheme maps to Intent objects:</p>
6638      * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
6639      *     <colgroup align="left" />
6640      *     <colgroup align="left" />
6641      *     <thead>
6642      *     <tr><th>URI</th> <th>Intent</th></tr>
6643      *     </thead>
6644      *
6645      *     <tbody>
6646      *     <tr><td><code>android-app://com.example.app</code></td>
6647      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6648      *             <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
6649      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6650      *         </table></td>
6651      *     </tr>
6652      *     <tr><td><code>android-app://com.example.app/http/example.com</code></td>
6653      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6654      *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6655      *             <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
6656      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6657      *         </table></td>
6658      *     </tr>
6659      *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
6660      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6661      *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6662      *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6663      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6664      *         </table></td>
6665      *     </tr>
6666      *     <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6667      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6668      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6669      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6670      *         </table></td>
6671      *     </tr>
6672      *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6673      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6674      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6675      *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6676      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6677      *         </table></td>
6678      *     </tr>
6679      *     <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>
6680      *         <td><table border="" style="margin:0" >
6681      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6682      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6683      *             <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
6684      *         </table></td>
6685      *     </tr>
6686      *     </tbody>
6687      * </table>
6688      */
6689     public static final int URI_ANDROID_APP_SCHEME = 1<<1;
6690 
6691     /**
6692      * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
6693      * of unsafe information.  In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
6694      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
6695      * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
6696      * generated Intent can not cause unexpected data access to happen.
6697      *
6698      * <p>If you do not trust the source of the URI being parsed, you should still do further
6699      * processing to protect yourself from it.  In particular, when using it to start an
6700      * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
6701      * that can handle it.</p>
6702      */
6703     public static final int URI_ALLOW_UNSAFE = 1<<2;
6704 
6705     // ---------------------------------------------------------------------
6706 
6707     private String mAction;
6708     private Uri mData;
6709     private String mType;
6710     private String mIdentifier;
6711     private String mPackage;
6712     private ComponentName mComponent;
6713     private int mFlags;
6714     private ArraySet<String> mCategories;
6715     @UnsupportedAppUsage
6716     private Bundle mExtras;
6717     private Rect mSourceBounds;
6718     private Intent mSelector;
6719     private ClipData mClipData;
6720     private int mContentUserHint = UserHandle.USER_CURRENT;
6721     /** Token to track instant app launches. Local only; do not copy cross-process. */
6722     private String mLaunchToken;
6723 
6724     // ---------------------------------------------------------------------
6725 
6726     private static final int COPY_MODE_ALL = 0;
6727     private static final int COPY_MODE_FILTER = 1;
6728     private static final int COPY_MODE_HISTORY = 2;
6729 
6730     /** @hide */
6731     @IntDef(prefix = { "COPY_MODE_" }, value = {
6732             COPY_MODE_ALL,
6733             COPY_MODE_FILTER,
6734             COPY_MODE_HISTORY
6735     })
6736     @Retention(RetentionPolicy.SOURCE)
6737     public @interface CopyMode {}
6738 
6739     /**
6740      * Create an empty intent.
6741      */
Intent()6742     public Intent() {
6743     }
6744 
6745     /**
6746      * Copy constructor.
6747      */
Intent(Intent o)6748     public Intent(Intent o) {
6749         this(o, COPY_MODE_ALL);
6750     }
6751 
Intent(Intent o, @CopyMode int copyMode)6752     private Intent(Intent o, @CopyMode int copyMode) {
6753         this.mAction = o.mAction;
6754         this.mData = o.mData;
6755         this.mType = o.mType;
6756         this.mIdentifier = o.mIdentifier;
6757         this.mPackage = o.mPackage;
6758         this.mComponent = o.mComponent;
6759 
6760         if (o.mCategories != null) {
6761             this.mCategories = new ArraySet<>(o.mCategories);
6762         }
6763 
6764         if (copyMode != COPY_MODE_FILTER) {
6765             this.mFlags = o.mFlags;
6766             this.mContentUserHint = o.mContentUserHint;
6767             this.mLaunchToken = o.mLaunchToken;
6768             if (o.mSourceBounds != null) {
6769                 this.mSourceBounds = new Rect(o.mSourceBounds);
6770             }
6771             if (o.mSelector != null) {
6772                 this.mSelector = new Intent(o.mSelector);
6773             }
6774 
6775             if (copyMode != COPY_MODE_HISTORY) {
6776                 if (o.mExtras != null) {
6777                     this.mExtras = new Bundle(o.mExtras);
6778                 }
6779                 if (o.mClipData != null) {
6780                     this.mClipData = new ClipData(o.mClipData);
6781                 }
6782             } else {
6783                 if (o.mExtras != null && !o.mExtras.isDefinitelyEmpty()) {
6784                     this.mExtras = Bundle.STRIPPED;
6785                 }
6786 
6787                 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
6788                 // history.
6789             }
6790         }
6791     }
6792 
6793     @Override
clone()6794     public Object clone() {
6795         return new Intent(this);
6796     }
6797 
6798     /**
6799      * Make a clone of only the parts of the Intent that are relevant for
6800      * filter matching: the action, data, type, component, and categories.
6801      */
cloneFilter()6802     public @NonNull Intent cloneFilter() {
6803         return new Intent(this, COPY_MODE_FILTER);
6804     }
6805 
6806     /**
6807      * Create an intent with a given action.  All other fields (data, type,
6808      * class) are null.  Note that the action <em>must</em> be in a
6809      * namespace because Intents are used globally in the system -- for
6810      * example the system VIEW action is android.intent.action.VIEW; an
6811      * application's custom action would be something like
6812      * com.google.app.myapp.CUSTOM_ACTION.
6813      *
6814      * @param action The Intent action, such as ACTION_VIEW.
6815      */
Intent(String action)6816     public Intent(String action) {
6817         setAction(action);
6818     }
6819 
6820     /**
6821      * Create an intent with a given action and for a given data url.  Note
6822      * that the action <em>must</em> be in a namespace because Intents are
6823      * used globally in the system -- for example the system VIEW action is
6824      * android.intent.action.VIEW; an application's custom action would be
6825      * something like com.google.app.myapp.CUSTOM_ACTION.
6826      *
6827      * <p><em>Note: scheme and host name matching in the Android framework is
6828      * case-sensitive, unlike the formal RFC.  As a result,
6829      * you should always ensure that you write your Uri with these elements
6830      * using lower case letters, and normalize any Uris you receive from
6831      * outside of Android to ensure the scheme and host is lower case.</em></p>
6832      *
6833      * @param action The Intent action, such as ACTION_VIEW.
6834      * @param uri The Intent data URI.
6835      */
Intent(String action, Uri uri)6836     public Intent(String action, Uri uri) {
6837         setAction(action);
6838         mData = uri;
6839     }
6840 
6841     /**
6842      * Create an intent for a specific component.  All other fields (action, data,
6843      * type, class) are null, though they can be modified later with explicit
6844      * calls.  This provides a convenient way to create an intent that is
6845      * intended to execute a hard-coded class name, rather than relying on the
6846      * system to find an appropriate class for you; see {@link #setComponent}
6847      * for more information on the repercussions of this.
6848      *
6849      * @param packageContext A Context of the application package implementing
6850      * this class.
6851      * @param cls The component class that is to be used for the intent.
6852      *
6853      * @see #setClass
6854      * @see #setComponent
6855      * @see #Intent(String, android.net.Uri , Context, Class)
6856      */
Intent(Context packageContext, Class<?> cls)6857     public Intent(Context packageContext, Class<?> cls) {
6858         mComponent = new ComponentName(packageContext, cls);
6859     }
6860 
6861     /**
6862      * Create an intent for a specific component with a specified action and data.
6863      * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
6864      * construct the Intent and then calling {@link #setClass} to set its
6865      * class.
6866      *
6867      * <p><em>Note: scheme and host name matching in the Android framework is
6868      * case-sensitive, unlike the formal RFC.  As a result,
6869      * you should always ensure that you write your Uri with these elements
6870      * using lower case letters, and normalize any Uris you receive from
6871      * outside of Android to ensure the scheme and host is lower case.</em></p>
6872      *
6873      * @param action The Intent action, such as ACTION_VIEW.
6874      * @param uri The Intent data URI.
6875      * @param packageContext A Context of the application package implementing
6876      * this class.
6877      * @param cls The component class that is to be used for the intent.
6878      *
6879      * @see #Intent(String, android.net.Uri)
6880      * @see #Intent(Context, Class)
6881      * @see #setClass
6882      * @see #setComponent
6883      */
Intent(String action, Uri uri, Context packageContext, Class<?> cls)6884     public Intent(String action, Uri uri,
6885             Context packageContext, Class<?> cls) {
6886         setAction(action);
6887         mData = uri;
6888         mComponent = new ComponentName(packageContext, cls);
6889     }
6890 
6891     /**
6892      * Create an intent to launch the main (root) activity of a task.  This
6893      * is the Intent that is started when the application's is launched from
6894      * Home.  For anything else that wants to launch an application in the
6895      * same way, it is important that they use an Intent structured the same
6896      * way, and can use this function to ensure this is the case.
6897      *
6898      * <p>The returned Intent has the given Activity component as its explicit
6899      * component, {@link #ACTION_MAIN} as its action, and includes the
6900      * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
6901      * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6902      * to do that through {@link #addFlags(int)} on the returned Intent.
6903      *
6904      * @param mainActivity The main activity component that this Intent will
6905      * launch.
6906      * @return Returns a newly created Intent that can be used to launch the
6907      * activity as a main application entry.
6908      *
6909      * @see #setClass
6910      * @see #setComponent
6911      */
makeMainActivity(ComponentName mainActivity)6912     public static Intent makeMainActivity(ComponentName mainActivity) {
6913         Intent intent = new Intent(ACTION_MAIN);
6914         intent.setComponent(mainActivity);
6915         intent.addCategory(CATEGORY_LAUNCHER);
6916         return intent;
6917     }
6918 
6919     /**
6920      * Make an Intent for the main activity of an application, without
6921      * specifying a specific activity to run but giving a selector to find
6922      * the activity.  This results in a final Intent that is structured
6923      * the same as when the application is launched from
6924      * Home.  For anything else that wants to launch an application in the
6925      * same way, it is important that they use an Intent structured the same
6926      * way, and can use this function to ensure this is the case.
6927      *
6928      * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6929      * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
6930      * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6931      * to do that through {@link #addFlags(int)} on the returned Intent.
6932      *
6933      * @param selectorAction The action name of the Intent's selector.
6934      * @param selectorCategory The name of a category to add to the Intent's
6935      * selector.
6936      * @return Returns a newly created Intent that can be used to launch the
6937      * activity as a main application entry.
6938      *
6939      * @see #setSelector(Intent)
6940      */
makeMainSelectorActivity(String selectorAction, String selectorCategory)6941     public static Intent makeMainSelectorActivity(String selectorAction,
6942             String selectorCategory) {
6943         Intent intent = new Intent(ACTION_MAIN);
6944         intent.addCategory(CATEGORY_LAUNCHER);
6945         Intent selector = new Intent();
6946         selector.setAction(selectorAction);
6947         selector.addCategory(selectorCategory);
6948         intent.setSelector(selector);
6949         return intent;
6950     }
6951 
6952     /**
6953      * Make an Intent that can be used to re-launch an application's task
6954      * in its base state.  This is like {@link #makeMainActivity(ComponentName)},
6955      * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6956      * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6957      *
6958      * @param mainActivity The activity component that is the root of the
6959      * task; this is the activity that has been published in the application's
6960      * manifest as the main launcher icon.
6961      *
6962      * @return Returns a newly created Intent that can be used to relaunch the
6963      * activity's task in its root state.
6964      */
makeRestartActivityTask(ComponentName mainActivity)6965     public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6966         Intent intent = makeMainActivity(mainActivity);
6967         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6968                 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6969         return intent;
6970     }
6971 
6972     /**
6973      * Call {@link #parseUri} with 0 flags.
6974      * @deprecated Use {@link #parseUri} instead.
6975      */
6976     @Deprecated
getIntent(String uri)6977     public static Intent getIntent(String uri) throws URISyntaxException {
6978         return parseUri(uri, 0);
6979     }
6980 
6981     /**
6982      * Create an intent from a URI.  This URI may encode the action,
6983      * category, and other intent fields, if it was returned by
6984      * {@link #toUri}.  If the Intent was not generate by toUri(), its data
6985      * will be the entire URI and its action will be ACTION_VIEW.
6986      *
6987      * <p>The URI given here must not be relative -- that is, it must include
6988      * the scheme and full path.
6989      *
6990      * @param uri The URI to turn into an Intent.
6991      * @param flags Additional processing flags.
6992      *
6993      * @return Intent The newly created Intent object.
6994      *
6995      * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6996      * it bad (as parsed by the Uri class) or the Intent data within the
6997      * URI is invalid.
6998      *
6999      * @see #toUri
7000      */
parseUri(String uri, @UriFlags int flags)7001     public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
7002         int i = 0;
7003         try {
7004             final boolean androidApp = uri.startsWith("android-app:");
7005 
7006             // Validate intent scheme if requested.
7007             if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
7008                 if (!uri.startsWith("intent:") && !androidApp) {
7009                     Intent intent = new Intent(ACTION_VIEW);
7010                     try {
7011                         intent.setData(Uri.parse(uri));
7012                     } catch (IllegalArgumentException e) {
7013                         throw new URISyntaxException(uri, e.getMessage());
7014                     }
7015                     return intent;
7016                 }
7017             }
7018 
7019             i = uri.lastIndexOf("#");
7020             // simple case
7021             if (i == -1) {
7022                 if (!androidApp) {
7023                     return new Intent(ACTION_VIEW, Uri.parse(uri));
7024                 }
7025 
7026             // old format Intent URI
7027             } else if (!uri.startsWith("#Intent;", i)) {
7028                 if (!androidApp) {
7029                     return getIntentOld(uri, flags);
7030                 } else {
7031                     i = -1;
7032                 }
7033             }
7034 
7035             // new format
7036             Intent intent = new Intent(ACTION_VIEW);
7037             Intent baseIntent = intent;
7038             boolean explicitAction = false;
7039             boolean inSelector = false;
7040 
7041             // fetch data part, if present
7042             String scheme = null;
7043             String data;
7044             if (i >= 0) {
7045                 data = uri.substring(0, i);
7046                 i += 8; // length of "#Intent;"
7047             } else {
7048                 data = uri;
7049             }
7050 
7051             // loop over contents of Intent, all name=value;
7052             while (i >= 0 && !uri.startsWith("end", i)) {
7053                 int eq = uri.indexOf('=', i);
7054                 if (eq < 0) eq = i-1;
7055                 int semi = uri.indexOf(';', i);
7056                 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
7057 
7058                 // action
7059                 if (uri.startsWith("action=", i)) {
7060                     intent.setAction(value);
7061                     if (!inSelector) {
7062                         explicitAction = true;
7063                     }
7064                 }
7065 
7066                 // categories
7067                 else if (uri.startsWith("category=", i)) {
7068                     intent.addCategory(value);
7069                 }
7070 
7071                 // type
7072                 else if (uri.startsWith("type=", i)) {
7073                     intent.mType = value;
7074                 }
7075 
7076                 // identifier
7077                 else if (uri.startsWith("identifier=", i)) {
7078                     intent.mIdentifier = value;
7079                 }
7080 
7081                 // launch flags
7082                 else if (uri.startsWith("launchFlags=", i)) {
7083                     intent.mFlags = Integer.decode(value).intValue();
7084                     if ((flags& URI_ALLOW_UNSAFE) == 0) {
7085                         intent.mFlags &= ~IMMUTABLE_FLAGS;
7086                     }
7087                 }
7088 
7089                 // package
7090                 else if (uri.startsWith("package=", i)) {
7091                     intent.mPackage = value;
7092                 }
7093 
7094                 // component
7095                 else if (uri.startsWith("component=", i)) {
7096                     intent.mComponent = ComponentName.unflattenFromString(value);
7097                 }
7098 
7099                 // scheme
7100                 else if (uri.startsWith("scheme=", i)) {
7101                     if (inSelector) {
7102                         intent.mData = Uri.parse(value + ":");
7103                     } else {
7104                         scheme = value;
7105                     }
7106                 }
7107 
7108                 // source bounds
7109                 else if (uri.startsWith("sourceBounds=", i)) {
7110                     intent.mSourceBounds = Rect.unflattenFromString(value);
7111                 }
7112 
7113                 // selector
7114                 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
7115                     intent = new Intent();
7116                     inSelector = true;
7117                 }
7118 
7119                 // extra
7120                 else {
7121                     String key = Uri.decode(uri.substring(i + 2, eq));
7122                     // create Bundle if it doesn't already exist
7123                     if (intent.mExtras == null) intent.mExtras = new Bundle();
7124                     Bundle b = intent.mExtras;
7125                     // add EXTRA
7126                     if      (uri.startsWith("S.", i)) b.putString(key, value);
7127                     else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
7128                     else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
7129                     else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
7130                     else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
7131                     else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
7132                     else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
7133                     else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
7134                     else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
7135                     else throw new URISyntaxException(uri, "unknown EXTRA type", i);
7136                 }
7137 
7138                 // move to the next item
7139                 i = semi + 1;
7140             }
7141 
7142             if (inSelector) {
7143                 // The Intent had a selector; fix it up.
7144                 if (baseIntent.mPackage == null) {
7145                     baseIntent.setSelector(intent);
7146                 }
7147                 intent = baseIntent;
7148             }
7149 
7150             if (data != null) {
7151                 if (data.startsWith("intent:")) {
7152                     data = data.substring(7);
7153                     if (scheme != null) {
7154                         data = scheme + ':' + data;
7155                     }
7156                 } else if (data.startsWith("android-app:")) {
7157                     if (data.charAt(12) == '/' && data.charAt(13) == '/') {
7158                         // Correctly formed android-app, first part is package name.
7159                         int end = data.indexOf('/', 14);
7160                         if (end < 0) {
7161                             // All we have is a package name.
7162                             intent.mPackage = data.substring(14);
7163                             if (!explicitAction) {
7164                                 intent.setAction(ACTION_MAIN);
7165                             }
7166                             data = "";
7167                         } else {
7168                             // Target the Intent at the given package name always.
7169                             String authority = null;
7170                             intent.mPackage = data.substring(14, end);
7171                             int newEnd;
7172                             if ((end+1) < data.length()) {
7173                                 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
7174                                     // Found a scheme, remember it.
7175                                     scheme = data.substring(end+1, newEnd);
7176                                     end = newEnd;
7177                                     if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
7178                                         // Found a authority, remember it.
7179                                         authority = data.substring(end+1, newEnd);
7180                                         end = newEnd;
7181                                     }
7182                                 } else {
7183                                     // All we have is a scheme.
7184                                     scheme = data.substring(end+1);
7185                                 }
7186                             }
7187                             if (scheme == null) {
7188                                 // If there was no scheme, then this just targets the package.
7189                                 if (!explicitAction) {
7190                                     intent.setAction(ACTION_MAIN);
7191                                 }
7192                                 data = "";
7193                             } else if (authority == null) {
7194                                 data = scheme + ":";
7195                             } else {
7196                                 data = scheme + "://" + authority + data.substring(end);
7197                             }
7198                         }
7199                     } else {
7200                         data = "";
7201                     }
7202                 }
7203 
7204                 if (data.length() > 0) {
7205                     try {
7206                         intent.mData = Uri.parse(data);
7207                     } catch (IllegalArgumentException e) {
7208                         throw new URISyntaxException(uri, e.getMessage());
7209                     }
7210                 }
7211             }
7212 
7213             return intent;
7214 
7215         } catch (IndexOutOfBoundsException e) {
7216             throw new URISyntaxException(uri, "illegal Intent URI format", i);
7217         }
7218     }
7219 
7220     public static Intent getIntentOld(String uri) throws URISyntaxException {
7221         return getIntentOld(uri, 0);
7222     }
7223 
7224     private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
7225         Intent intent;
7226 
7227         int i = uri.lastIndexOf('#');
7228         if (i >= 0) {
7229             String action = null;
7230             final int intentFragmentStart = i;
7231             boolean isIntentFragment = false;
7232 
7233             i++;
7234 
7235             if (uri.regionMatches(i, "action(", 0, 7)) {
7236                 isIntentFragment = true;
7237                 i += 7;
7238                 int j = uri.indexOf(')', i);
7239                 action = uri.substring(i, j);
7240                 i = j + 1;
7241             }
7242 
7243             intent = new Intent(action);
7244 
7245             if (uri.regionMatches(i, "categories(", 0, 11)) {
7246                 isIntentFragment = true;
7247                 i += 11;
7248                 int j = uri.indexOf(')', i);
7249                 while (i < j) {
7250                     int sep = uri.indexOf('!', i);
7251                     if (sep < 0 || sep > j) sep = j;
7252                     if (i < sep) {
7253                         intent.addCategory(uri.substring(i, sep));
7254                     }
7255                     i = sep + 1;
7256                 }
7257                 i = j + 1;
7258             }
7259 
7260             if (uri.regionMatches(i, "type(", 0, 5)) {
7261                 isIntentFragment = true;
7262                 i += 5;
7263                 int j = uri.indexOf(')', i);
7264                 intent.mType = uri.substring(i, j);
7265                 i = j + 1;
7266             }
7267 
7268             if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
7269                 isIntentFragment = true;
7270                 i += 12;
7271                 int j = uri.indexOf(')', i);
7272                 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
7273                 if ((flags& URI_ALLOW_UNSAFE) == 0) {
7274                     intent.mFlags &= ~IMMUTABLE_FLAGS;
7275                 }
7276                 i = j + 1;
7277             }
7278 
7279             if (uri.regionMatches(i, "component(", 0, 10)) {
7280                 isIntentFragment = true;
7281                 i += 10;
7282                 int j = uri.indexOf(')', i);
7283                 int sep = uri.indexOf('!', i);
7284                 if (sep >= 0 && sep < j) {
7285                     String pkg = uri.substring(i, sep);
7286                     String cls = uri.substring(sep + 1, j);
7287                     intent.mComponent = new ComponentName(pkg, cls);
7288                 }
7289                 i = j + 1;
7290             }
7291 
7292             if (uri.regionMatches(i, "extras(", 0, 7)) {
7293                 isIntentFragment = true;
7294                 i += 7;
7295 
7296                 final int closeParen = uri.indexOf(')', i);
7297                 if (closeParen == -1) throw new URISyntaxException(uri,
7298                         "EXTRA missing trailing ')'", i);
7299 
7300                 while (i < closeParen) {
7301                     // fetch the key value
7302                     int j = uri.indexOf('=', i);
7303                     if (j <= i + 1 || i >= closeParen) {
7304                         throw new URISyntaxException(uri, "EXTRA missing '='", i);
7305                     }
7306                     char type = uri.charAt(i);
7307                     i++;
7308                     String key = uri.substring(i, j);
7309                     i = j + 1;
7310 
7311                     // get type-value
7312                     j = uri.indexOf('!', i);
7313                     if (j == -1 || j >= closeParen) j = closeParen;
7314                     if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
7315                     String value = uri.substring(i, j);
7316                     i = j;
7317 
7318                     // create Bundle if it doesn't already exist
7319                     if (intent.mExtras == null) intent.mExtras = new Bundle();
7320 
7321                     // add item to bundle
7322                     try {
7323                         switch (type) {
7324                             case 'S':
7325                                 intent.mExtras.putString(key, Uri.decode(value));
7326                                 break;
7327                             case 'B':
7328                                 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
7329                                 break;
7330                             case 'b':
7331                                 intent.mExtras.putByte(key, Byte.parseByte(value));
7332                                 break;
7333                             case 'c':
7334                                 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
7335                                 break;
7336                             case 'd':
7337                                 intent.mExtras.putDouble(key, Double.parseDouble(value));
7338                                 break;
7339                             case 'f':
7340                                 intent.mExtras.putFloat(key, Float.parseFloat(value));
7341                                 break;
7342                             case 'i':
7343                                 intent.mExtras.putInt(key, Integer.parseInt(value));
7344                                 break;
7345                             case 'l':
7346                                 intent.mExtras.putLong(key, Long.parseLong(value));
7347                                 break;
7348                             case 's':
7349                                 intent.mExtras.putShort(key, Short.parseShort(value));
7350                                 break;
7351                             default:
7352                                 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
7353                         }
7354                     } catch (NumberFormatException e) {
7355                         throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
7356                     }
7357 
7358                     char ch = uri.charAt(i);
7359                     if (ch == ')') break;
7360                     if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
7361                     i++;
7362                 }
7363             }
7364 
7365             if (isIntentFragment) {
7366                 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
7367             } else {
7368                 intent.mData = Uri.parse(uri);
7369             }
7370 
7371             if (intent.mAction == null) {
7372                 // By default, if no action is specified, then use VIEW.
7373                 intent.mAction = ACTION_VIEW;
7374             }
7375 
7376         } else {
7377             intent = new Intent(ACTION_VIEW, Uri.parse(uri));
7378         }
7379 
7380         return intent;
7381     }
7382 
7383     /** @hide */
7384     public interface CommandOptionHandler {
7385         boolean handleOption(String opt, ShellCommand cmd);
7386     }
7387 
7388     /** @hide */
7389     @UnsupportedAppUsage
parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)7390     public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
7391             throws URISyntaxException {
7392         Intent intent = new Intent();
7393         Intent baseIntent = intent;
7394         boolean hasIntentInfo = false;
7395 
7396         Uri data = null;
7397         String type = null;
7398 
7399         String opt;
7400         while ((opt=cmd.getNextOption()) != null) {
7401             switch (opt) {
7402                 case "-a":
7403                     intent.setAction(cmd.getNextArgRequired());
7404                     if (intent == baseIntent) {
7405                         hasIntentInfo = true;
7406                     }
7407                     break;
7408                 case "-d":
7409                     data = Uri.parse(cmd.getNextArgRequired());
7410                     if (intent == baseIntent) {
7411                         hasIntentInfo = true;
7412                     }
7413                     break;
7414                 case "-t":
7415                     type = cmd.getNextArgRequired();
7416                     if (intent == baseIntent) {
7417                         hasIntentInfo = true;
7418                     }
7419                     break;
7420                 case "-i":
7421                     intent.setIdentifier(cmd.getNextArgRequired());
7422                     if (intent == baseIntent) {
7423                         hasIntentInfo = true;
7424                     }
7425                     break;
7426                 case "-c":
7427                     intent.addCategory(cmd.getNextArgRequired());
7428                     if (intent == baseIntent) {
7429                         hasIntentInfo = true;
7430                     }
7431                     break;
7432                 case "-e":
7433                 case "--es": {
7434                     String key = cmd.getNextArgRequired();
7435                     String value = cmd.getNextArgRequired();
7436                     intent.putExtra(key, value);
7437                 }
7438                 break;
7439                 case "--esn": {
7440                     String key = cmd.getNextArgRequired();
7441                     intent.putExtra(key, (String) null);
7442                 }
7443                 break;
7444                 case "--ei": {
7445                     String key = cmd.getNextArgRequired();
7446                     String value = cmd.getNextArgRequired();
7447                     intent.putExtra(key, Integer.decode(value));
7448                 }
7449                 break;
7450                 case "--eu": {
7451                     String key = cmd.getNextArgRequired();
7452                     String value = cmd.getNextArgRequired();
7453                     intent.putExtra(key, Uri.parse(value));
7454                 }
7455                 break;
7456                 case "--ecn": {
7457                     String key = cmd.getNextArgRequired();
7458                     String value = cmd.getNextArgRequired();
7459                     ComponentName cn = ComponentName.unflattenFromString(value);
7460                     if (cn == null)
7461                         throw new IllegalArgumentException("Bad component name: " + value);
7462                     intent.putExtra(key, cn);
7463                 }
7464                 break;
7465                 case "--eia": {
7466                     String key = cmd.getNextArgRequired();
7467                     String value = cmd.getNextArgRequired();
7468                     String[] strings = value.split(",");
7469                     int[] list = new int[strings.length];
7470                     for (int i = 0; i < strings.length; i++) {
7471                         list[i] = Integer.decode(strings[i]);
7472                     }
7473                     intent.putExtra(key, list);
7474                 }
7475                 break;
7476                 case "--eial": {
7477                     String key = cmd.getNextArgRequired();
7478                     String value = cmd.getNextArgRequired();
7479                     String[] strings = value.split(",");
7480                     ArrayList<Integer> list = new ArrayList<>(strings.length);
7481                     for (int i = 0; i < strings.length; i++) {
7482                         list.add(Integer.decode(strings[i]));
7483                     }
7484                     intent.putExtra(key, list);
7485                 }
7486                 break;
7487                 case "--el": {
7488                     String key = cmd.getNextArgRequired();
7489                     String value = cmd.getNextArgRequired();
7490                     intent.putExtra(key, Long.valueOf(value));
7491                 }
7492                 break;
7493                 case "--ela": {
7494                     String key = cmd.getNextArgRequired();
7495                     String value = cmd.getNextArgRequired();
7496                     String[] strings = value.split(",");
7497                     long[] list = new long[strings.length];
7498                     for (int i = 0; i < strings.length; i++) {
7499                         list[i] = Long.valueOf(strings[i]);
7500                     }
7501                     intent.putExtra(key, list);
7502                     hasIntentInfo = true;
7503                 }
7504                 break;
7505                 case "--elal": {
7506                     String key = cmd.getNextArgRequired();
7507                     String value = cmd.getNextArgRequired();
7508                     String[] strings = value.split(",");
7509                     ArrayList<Long> list = new ArrayList<>(strings.length);
7510                     for (int i = 0; i < strings.length; i++) {
7511                         list.add(Long.valueOf(strings[i]));
7512                     }
7513                     intent.putExtra(key, list);
7514                     hasIntentInfo = true;
7515                 }
7516                 break;
7517                 case "--ef": {
7518                     String key = cmd.getNextArgRequired();
7519                     String value = cmd.getNextArgRequired();
7520                     intent.putExtra(key, Float.valueOf(value));
7521                     hasIntentInfo = true;
7522                 }
7523                 break;
7524                 case "--efa": {
7525                     String key = cmd.getNextArgRequired();
7526                     String value = cmd.getNextArgRequired();
7527                     String[] strings = value.split(",");
7528                     float[] list = new float[strings.length];
7529                     for (int i = 0; i < strings.length; i++) {
7530                         list[i] = Float.valueOf(strings[i]);
7531                     }
7532                     intent.putExtra(key, list);
7533                     hasIntentInfo = true;
7534                 }
7535                 break;
7536                 case "--efal": {
7537                     String key = cmd.getNextArgRequired();
7538                     String value = cmd.getNextArgRequired();
7539                     String[] strings = value.split(",");
7540                     ArrayList<Float> list = new ArrayList<>(strings.length);
7541                     for (int i = 0; i < strings.length; i++) {
7542                         list.add(Float.valueOf(strings[i]));
7543                     }
7544                     intent.putExtra(key, list);
7545                     hasIntentInfo = true;
7546                 }
7547                 break;
7548                 case "--esa": {
7549                     String key = cmd.getNextArgRequired();
7550                     String value = cmd.getNextArgRequired();
7551                     // Split on commas unless they are preceeded by an escape.
7552                     // The escape character must be escaped for the string and
7553                     // again for the regex, thus four escape characters become one.
7554                     String[] strings = value.split("(?<!\\\\),");
7555                     intent.putExtra(key, strings);
7556                     hasIntentInfo = true;
7557                 }
7558                 break;
7559                 case "--esal": {
7560                     String key = cmd.getNextArgRequired();
7561                     String value = cmd.getNextArgRequired();
7562                     // Split on commas unless they are preceeded by an escape.
7563                     // The escape character must be escaped for the string and
7564                     // again for the regex, thus four escape characters become one.
7565                     String[] strings = value.split("(?<!\\\\),");
7566                     ArrayList<String> list = new ArrayList<>(strings.length);
7567                     for (int i = 0; i < strings.length; i++) {
7568                         list.add(strings[i]);
7569                     }
7570                     intent.putExtra(key, list);
7571                     hasIntentInfo = true;
7572                 }
7573                 break;
7574                 case "--ez": {
7575                     String key = cmd.getNextArgRequired();
7576                     String value = cmd.getNextArgRequired().toLowerCase();
7577                     // Boolean.valueOf() results in false for anything that is not "true", which is
7578                     // error-prone in shell commands
7579                     boolean arg;
7580                     if ("true".equals(value) || "t".equals(value)) {
7581                         arg = true;
7582                     } else if ("false".equals(value) || "f".equals(value)) {
7583                         arg = false;
7584                     } else {
7585                         try {
7586                             arg = Integer.decode(value) != 0;
7587                         } catch (NumberFormatException ex) {
7588                             throw new IllegalArgumentException("Invalid boolean value: " + value);
7589                         }
7590                     }
7591 
7592                     intent.putExtra(key, arg);
7593                 }
7594                 break;
7595                 case "-n": {
7596                     String str = cmd.getNextArgRequired();
7597                     ComponentName cn = ComponentName.unflattenFromString(str);
7598                     if (cn == null)
7599                         throw new IllegalArgumentException("Bad component name: " + str);
7600                     intent.setComponent(cn);
7601                     if (intent == baseIntent) {
7602                         hasIntentInfo = true;
7603                     }
7604                 }
7605                 break;
7606                 case "-p": {
7607                     String str = cmd.getNextArgRequired();
7608                     intent.setPackage(str);
7609                     if (intent == baseIntent) {
7610                         hasIntentInfo = true;
7611                     }
7612                 }
7613                 break;
7614                 case "-f":
7615                     String str = cmd.getNextArgRequired();
7616                     intent.setFlags(Integer.decode(str).intValue());
7617                     break;
7618                 case "--grant-read-uri-permission":
7619                     intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
7620                     break;
7621                 case "--grant-write-uri-permission":
7622                     intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
7623                     break;
7624                 case "--grant-persistable-uri-permission":
7625                     intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
7626                     break;
7627                 case "--grant-prefix-uri-permission":
7628                     intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
7629                     break;
7630                 case "--exclude-stopped-packages":
7631                     intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
7632                     break;
7633                 case "--include-stopped-packages":
7634                     intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
7635                     break;
7636                 case "--debug-log-resolution":
7637                     intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
7638                     break;
7639                 case "--activity-brought-to-front":
7640                     intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
7641                     break;
7642                 case "--activity-clear-top":
7643                     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
7644                     break;
7645                 case "--activity-clear-when-task-reset":
7646                     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
7647                     break;
7648                 case "--activity-exclude-from-recents":
7649                     intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
7650                     break;
7651                 case "--activity-launched-from-history":
7652                     intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
7653                     break;
7654                 case "--activity-multiple-task":
7655                     intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
7656                     break;
7657                 case "--activity-no-animation":
7658                     intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
7659                     break;
7660                 case "--activity-no-history":
7661                     intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
7662                     break;
7663                 case "--activity-no-user-action":
7664                     intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
7665                     break;
7666                 case "--activity-previous-is-top":
7667                     intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
7668                     break;
7669                 case "--activity-reorder-to-front":
7670                     intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
7671                     break;
7672                 case "--activity-reset-task-if-needed":
7673                     intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
7674                     break;
7675                 case "--activity-single-top":
7676                     intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
7677                     break;
7678                 case "--activity-clear-task":
7679                     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
7680                     break;
7681                 case "--activity-task-on-home":
7682                     intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
7683                     break;
7684                 case "--activity-match-external":
7685                     intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
7686                     break;
7687                 case "--receiver-registered-only":
7688                     intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
7689                     break;
7690                 case "--receiver-replace-pending":
7691                     intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
7692                     break;
7693                 case "--receiver-foreground":
7694                     intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
7695                     break;
7696                 case "--receiver-no-abort":
7697                     intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
7698                     break;
7699                 case "--receiver-include-background":
7700                     intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
7701                     break;
7702                 case "--selector":
7703                     intent.setDataAndType(data, type);
7704                     intent = new Intent();
7705                     break;
7706                 default:
7707                     if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
7708                         // Okay, caller handled this option.
7709                     } else {
7710                         throw new IllegalArgumentException("Unknown option: " + opt);
7711                     }
7712                     break;
7713             }
7714         }
7715         intent.setDataAndType(data, type);
7716 
7717         final boolean hasSelector = intent != baseIntent;
7718         if (hasSelector) {
7719             // A selector was specified; fix up.
7720             baseIntent.setSelector(intent);
7721             intent = baseIntent;
7722         }
7723 
7724         String arg = cmd.getNextArg();
7725         baseIntent = null;
7726         if (arg == null) {
7727             if (hasSelector) {
7728                 // If a selector has been specified, and no arguments
7729                 // have been supplied for the main Intent, then we can
7730                 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
7731                 // need to have a component name specified yet, the
7732                 // selector will take care of that.
7733                 baseIntent = new Intent(Intent.ACTION_MAIN);
7734                 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7735             }
7736         } else if (arg.indexOf(':') >= 0) {
7737             // The argument is a URI.  Fully parse it, and use that result
7738             // to fill in any data not specified so far.
7739             baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
7740                     | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
7741         } else if (arg.indexOf('/') >= 0) {
7742             // The argument is a component name.  Build an Intent to launch
7743             // it.
7744             baseIntent = new Intent(Intent.ACTION_MAIN);
7745             baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7746             baseIntent.setComponent(ComponentName.unflattenFromString(arg));
7747         } else {
7748             // Assume the argument is a package name.
7749             baseIntent = new Intent(Intent.ACTION_MAIN);
7750             baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7751             baseIntent.setPackage(arg);
7752         }
7753         if (baseIntent != null) {
7754             Bundle extras = intent.getExtras();
7755             intent.replaceExtras((Bundle)null);
7756             Bundle uriExtras = baseIntent.getExtras();
7757             baseIntent.replaceExtras((Bundle)null);
7758             if (intent.getAction() != null && baseIntent.getCategories() != null) {
7759                 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
7760                 for (String c : cats) {
7761                     baseIntent.removeCategory(c);
7762                 }
7763             }
7764             intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
7765             if (extras == null) {
7766                 extras = uriExtras;
7767             } else if (uriExtras != null) {
7768                 uriExtras.putAll(extras);
7769                 extras = uriExtras;
7770             }
7771             intent.replaceExtras(extras);
7772             hasIntentInfo = true;
7773         }
7774 
7775         if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
7776         return intent;
7777     }
7778 
7779     /** @hide */
7780     @UnsupportedAppUsage
printIntentArgsHelp(PrintWriter pw, String prefix)7781     public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
7782         final String[] lines = new String[] {
7783                 "<INTENT> specifications include these flags and arguments:",
7784                 "    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]",
7785                 "    [-c <CATEGORY> [-c <CATEGORY>] ...]",
7786                 "    [-n <COMPONENT_NAME>]",
7787                 "    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
7788                 "    [--esn <EXTRA_KEY> ...]",
7789                 "    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
7790                 "    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
7791                 "    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
7792                 "    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
7793                 "    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
7794                 "    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
7795                 "    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7796                 "        (mutiple extras passed as Integer[])",
7797                 "    [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7798                 "        (mutiple extras passed as List<Integer>)",
7799                 "    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7800                 "        (mutiple extras passed as Long[])",
7801                 "    [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7802                 "        (mutiple extras passed as List<Long>)",
7803                 "    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7804                 "        (mutiple extras passed as Float[])",
7805                 "    [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7806                 "        (mutiple extras passed as List<Float>)",
7807                 "    [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7808                 "        (mutiple extras passed as String[]; to embed a comma into a string,",
7809                 "         escape it using \"\\,\")",
7810                 "    [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7811                 "        (mutiple extras passed as List<String>; to embed a comma into a string,",
7812                 "         escape it using \"\\,\")",
7813                 "    [-f <FLAG>]",
7814                 "    [--grant-read-uri-permission] [--grant-write-uri-permission]",
7815                 "    [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7816                 "    [--debug-log-resolution] [--exclude-stopped-packages]",
7817                 "    [--include-stopped-packages]",
7818                 "    [--activity-brought-to-front] [--activity-clear-top]",
7819                 "    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7820                 "    [--activity-launched-from-history] [--activity-multiple-task]",
7821                 "    [--activity-no-animation] [--activity-no-history]",
7822                 "    [--activity-no-user-action] [--activity-previous-is-top]",
7823                 "    [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7824                 "    [--activity-single-top] [--activity-clear-task]",
7825                 "    [--activity-task-on-home] [--activity-match-external]",
7826                 "    [--receiver-registered-only] [--receiver-replace-pending]",
7827                 "    [--receiver-foreground] [--receiver-no-abort]",
7828                 "    [--receiver-include-background]",
7829                 "    [--selector]",
7830                 "    [<URI> | <PACKAGE> | <COMPONENT>]"
7831         };
7832         for (String line : lines) {
7833             pw.print(prefix);
7834             pw.println(line);
7835         }
7836     }
7837 
7838     /**
7839      * Retrieve the general action to be performed, such as
7840      * {@link #ACTION_VIEW}.  The action describes the general way the rest of
7841      * the information in the intent should be interpreted -- most importantly,
7842      * what to do with the data returned by {@link #getData}.
7843      *
7844      * @return The action of this intent or null if none is specified.
7845      *
7846      * @see #setAction
7847      */
getAction()7848     public @Nullable String getAction() {
7849         return mAction;
7850     }
7851 
7852     /**
7853      * Retrieve data this intent is operating on.  This URI specifies the name
7854      * of the data; often it uses the content: scheme, specifying data in a
7855      * content provider.  Other schemes may be handled by specific activities,
7856      * such as http: by the web browser.
7857      *
7858      * @return The URI of the data this intent is targeting or null.
7859      *
7860      * @see #getScheme
7861      * @see #setData
7862      */
getData()7863     public @Nullable Uri getData() {
7864         return mData;
7865     }
7866 
7867     /**
7868      * The same as {@link #getData()}, but returns the URI as an encoded
7869      * String.
7870      */
getDataString()7871     public @Nullable String getDataString() {
7872         return mData != null ? mData.toString() : null;
7873     }
7874 
7875     /**
7876      * Return the scheme portion of the intent's data.  If the data is null or
7877      * does not include a scheme, null is returned.  Otherwise, the scheme
7878      * prefix without the final ':' is returned, i.e. "http".
7879      *
7880      * <p>This is the same as calling getData().getScheme() (and checking for
7881      * null data).
7882      *
7883      * @return The scheme of this intent.
7884      *
7885      * @see #getData
7886      */
getScheme()7887     public @Nullable String getScheme() {
7888         return mData != null ? mData.getScheme() : null;
7889     }
7890 
7891     /**
7892      * Retrieve any explicit MIME type included in the intent.  This is usually
7893      * null, as the type is determined by the intent data.
7894      *
7895      * @return If a type was manually set, it is returned; else null is
7896      *         returned.
7897      *
7898      * @see #resolveType(ContentResolver)
7899      * @see #setType
7900      */
getType()7901     public @Nullable String getType() {
7902         return mType;
7903     }
7904 
7905     /**
7906      * Return the MIME data type of this intent.  If the type field is
7907      * explicitly set, that is simply returned.  Otherwise, if the data is set,
7908      * the type of that data is returned.  If neither fields are set, a null is
7909      * returned.
7910      *
7911      * @return The MIME type of this intent.
7912      *
7913      * @see #getType
7914      * @see #resolveType(ContentResolver)
7915      */
resolveType(@onNull Context context)7916     public @Nullable String resolveType(@NonNull Context context) {
7917         return resolveType(context.getContentResolver());
7918     }
7919 
7920     /**
7921      * Return the MIME data type of this intent.  If the type field is
7922      * explicitly set, that is simply returned.  Otherwise, if the data is set,
7923      * the type of that data is returned.  If neither fields are set, a null is
7924      * returned.
7925      *
7926      * @param resolver A ContentResolver that can be used to determine the MIME
7927      *                 type of the intent's data.
7928      *
7929      * @return The MIME type of this intent.
7930      *
7931      * @see #getType
7932      * @see #resolveType(Context)
7933      */
resolveType(@onNull ContentResolver resolver)7934     public @Nullable String resolveType(@NonNull ContentResolver resolver) {
7935         if (mType != null) {
7936             return mType;
7937         }
7938         if (mData != null) {
7939             if ("content".equals(mData.getScheme())) {
7940                 return resolver.getType(mData);
7941             }
7942         }
7943         return null;
7944     }
7945 
7946     /**
7947      * Return the MIME data type of this intent, only if it will be needed for
7948      * intent resolution.  This is not generally useful for application code;
7949      * it is used by the frameworks for communicating with back-end system
7950      * services.
7951      *
7952      * @param resolver A ContentResolver that can be used to determine the MIME
7953      *                 type of the intent's data.
7954      *
7955      * @return The MIME type of this intent, or null if it is unknown or not
7956      *         needed.
7957      */
resolveTypeIfNeeded(@onNull ContentResolver resolver)7958     public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
7959         if (mComponent != null) {
7960             return mType;
7961         }
7962         return resolveType(resolver);
7963     }
7964 
7965     /**
7966      * Retrieve the identifier for this Intent.  If non-null, this is an arbitrary identity
7967      * of the Intent to distinguish it from other Intents.
7968      *
7969      * @return The identifier of this intent or null if none is specified.
7970      *
7971      * @see #setIdentifier
7972      */
getIdentifier()7973     public @Nullable String getIdentifier() {
7974         return mIdentifier;
7975     }
7976 
7977     /**
7978      * Check if a category exists in the intent.
7979      *
7980      * @param category The category to check.
7981      *
7982      * @return boolean True if the intent contains the category, else false.
7983      *
7984      * @see #getCategories
7985      * @see #addCategory
7986      */
hasCategory(String category)7987     public boolean hasCategory(String category) {
7988         return mCategories != null && mCategories.contains(category);
7989     }
7990 
7991     /**
7992      * Return the set of all categories in the intent.  If there are no categories,
7993      * returns NULL.
7994      *
7995      * @return The set of categories you can examine.  Do not modify!
7996      *
7997      * @see #hasCategory
7998      * @see #addCategory
7999      */
getCategories()8000     public Set<String> getCategories() {
8001         return mCategories;
8002     }
8003 
8004     /**
8005      * Return the specific selector associated with this Intent.  If there is
8006      * none, returns null.  See {@link #setSelector} for more information.
8007      *
8008      * @see #setSelector
8009      */
getSelector()8010     public @Nullable Intent getSelector() {
8011         return mSelector;
8012     }
8013 
8014     /**
8015      * Return the {@link ClipData} associated with this Intent.  If there is
8016      * none, returns null.  See {@link #setClipData} for more information.
8017      *
8018      * @see #setClipData
8019      */
getClipData()8020     public @Nullable ClipData getClipData() {
8021         return mClipData;
8022     }
8023 
8024     /** @hide */
getContentUserHint()8025     public int getContentUserHint() {
8026         return mContentUserHint;
8027     }
8028 
8029     /** @hide */
getLaunchToken()8030     public String getLaunchToken() {
8031         return mLaunchToken;
8032     }
8033 
8034     /** @hide */
setLaunchToken(String launchToken)8035     public void setLaunchToken(String launchToken) {
8036         mLaunchToken = launchToken;
8037     }
8038 
8039     /**
8040      * Sets the ClassLoader that will be used when unmarshalling
8041      * any Parcelable values from the extras of this Intent.
8042      *
8043      * @param loader a ClassLoader, or null to use the default loader
8044      * at the time of unmarshalling.
8045      */
setExtrasClassLoader(@ullable ClassLoader loader)8046     public void setExtrasClassLoader(@Nullable ClassLoader loader) {
8047         if (mExtras != null) {
8048             mExtras.setClassLoader(loader);
8049         }
8050     }
8051 
8052     /**
8053      * Returns true if an extra value is associated with the given name.
8054      * @param name the extra's name
8055      * @return true if the given extra is present.
8056      */
hasExtra(String name)8057     public boolean hasExtra(String name) {
8058         return mExtras != null && mExtras.containsKey(name);
8059     }
8060 
8061     /**
8062      * Returns true if the Intent's extras contain a parcelled file descriptor.
8063      * @return true if the Intent contains a parcelled file descriptor.
8064      */
hasFileDescriptors()8065     public boolean hasFileDescriptors() {
8066         return mExtras != null && mExtras.hasFileDescriptors();
8067     }
8068 
8069     /** {@hide} */
8070     @UnsupportedAppUsage
setAllowFds(boolean allowFds)8071     public void setAllowFds(boolean allowFds) {
8072         if (mExtras != null) {
8073             mExtras.setAllowFds(allowFds);
8074         }
8075     }
8076 
8077     /** {@hide} */
setDefusable(boolean defusable)8078     public void setDefusable(boolean defusable) {
8079         if (mExtras != null) {
8080             mExtras.setDefusable(defusable);
8081         }
8082     }
8083 
8084     /**
8085      * Retrieve extended data from the intent.
8086      *
8087      * @param name The name of the desired item.
8088      *
8089      * @return the value of an item previously added with putExtra(),
8090      * or null if none was found.
8091      *
8092      * @deprecated
8093      * @hide
8094      */
8095     @Deprecated
8096     @UnsupportedAppUsage
getExtra(String name)8097     public Object getExtra(String name) {
8098         return getExtra(name, null);
8099     }
8100 
8101     /**
8102      * Retrieve extended data from the intent.
8103      *
8104      * @param name The name of the desired item.
8105      * @param defaultValue the value to be returned if no value of the desired
8106      * type is stored with the given name.
8107      *
8108      * @return the value of an item previously added with putExtra(),
8109      * or the default value if none was found.
8110      *
8111      * @see #putExtra(String, boolean)
8112      */
getBooleanExtra(String name, boolean defaultValue)8113     public boolean getBooleanExtra(String name, boolean defaultValue) {
8114         return mExtras == null ? defaultValue :
8115             mExtras.getBoolean(name, defaultValue);
8116     }
8117 
8118     /**
8119      * Retrieve extended data from the intent.
8120      *
8121      * @param name The name of the desired item.
8122      * @param defaultValue the value to be returned if no value of the desired
8123      * type is stored with the given name.
8124      *
8125      * @return the value of an item previously added with putExtra(),
8126      * or the default value if none was found.
8127      *
8128      * @see #putExtra(String, byte)
8129      */
getByteExtra(String name, byte defaultValue)8130     public byte getByteExtra(String name, byte defaultValue) {
8131         return mExtras == null ? defaultValue :
8132             mExtras.getByte(name, defaultValue);
8133     }
8134 
8135     /**
8136      * Retrieve extended data from the intent.
8137      *
8138      * @param name The name of the desired item.
8139      * @param defaultValue the value to be returned if no value of the desired
8140      * type is stored with the given name.
8141      *
8142      * @return the value of an item previously added with putExtra(),
8143      * or the default value if none was found.
8144      *
8145      * @see #putExtra(String, short)
8146      */
getShortExtra(String name, short defaultValue)8147     public short getShortExtra(String name, short defaultValue) {
8148         return mExtras == null ? defaultValue :
8149             mExtras.getShort(name, defaultValue);
8150     }
8151 
8152     /**
8153      * Retrieve extended data from the intent.
8154      *
8155      * @param name The name of the desired item.
8156      * @param defaultValue the value to be returned if no value of the desired
8157      * type is stored with the given name.
8158      *
8159      * @return the value of an item previously added with putExtra(),
8160      * or the default value if none was found.
8161      *
8162      * @see #putExtra(String, char)
8163      */
getCharExtra(String name, char defaultValue)8164     public char getCharExtra(String name, char defaultValue) {
8165         return mExtras == null ? defaultValue :
8166             mExtras.getChar(name, defaultValue);
8167     }
8168 
8169     /**
8170      * Retrieve extended data from the intent.
8171      *
8172      * @param name The name of the desired item.
8173      * @param defaultValue the value to be returned if no value of the desired
8174      * type is stored with the given name.
8175      *
8176      * @return the value of an item previously added with putExtra(),
8177      * or the default value if none was found.
8178      *
8179      * @see #putExtra(String, int)
8180      */
getIntExtra(String name, int defaultValue)8181     public int getIntExtra(String name, int defaultValue) {
8182         return mExtras == null ? defaultValue :
8183             mExtras.getInt(name, defaultValue);
8184     }
8185 
8186     /**
8187      * Retrieve extended data from the intent.
8188      *
8189      * @param name The name of the desired item.
8190      * @param defaultValue the value to be returned if no value of the desired
8191      * type is stored with the given name.
8192      *
8193      * @return the value of an item previously added with putExtra(),
8194      * or the default value if none was found.
8195      *
8196      * @see #putExtra(String, long)
8197      */
getLongExtra(String name, long defaultValue)8198     public long getLongExtra(String name, long defaultValue) {
8199         return mExtras == null ? defaultValue :
8200             mExtras.getLong(name, defaultValue);
8201     }
8202 
8203     /**
8204      * Retrieve extended data from the intent.
8205      *
8206      * @param name The name of the desired item.
8207      * @param defaultValue the value to be returned if no value of the desired
8208      * type is stored with the given name.
8209      *
8210      * @return the value of an item previously added with putExtra(),
8211      * or the default value if no such item is present
8212      *
8213      * @see #putExtra(String, float)
8214      */
getFloatExtra(String name, float defaultValue)8215     public float getFloatExtra(String name, float defaultValue) {
8216         return mExtras == null ? defaultValue :
8217             mExtras.getFloat(name, defaultValue);
8218     }
8219 
8220     /**
8221      * Retrieve extended data from the intent.
8222      *
8223      * @param name The name of the desired item.
8224      * @param defaultValue the value to be returned if no value of the desired
8225      * type is stored with the given name.
8226      *
8227      * @return the value of an item previously added with putExtra(),
8228      * or the default value if none was found.
8229      *
8230      * @see #putExtra(String, double)
8231      */
getDoubleExtra(String name, double defaultValue)8232     public double getDoubleExtra(String name, double defaultValue) {
8233         return mExtras == null ? defaultValue :
8234             mExtras.getDouble(name, defaultValue);
8235     }
8236 
8237     /**
8238      * Retrieve extended data from the intent.
8239      *
8240      * @param name The name of the desired item.
8241      *
8242      * @return the value of an item previously added with putExtra(),
8243      * or null if no String value was found.
8244      *
8245      * @see #putExtra(String, String)
8246      */
getStringExtra(String name)8247     public @Nullable String getStringExtra(String name) {
8248         return mExtras == null ? null : mExtras.getString(name);
8249     }
8250 
8251     /**
8252      * Retrieve extended data from the intent.
8253      *
8254      * @param name The name of the desired item.
8255      *
8256      * @return the value of an item previously added with putExtra(),
8257      * or null if no CharSequence value was found.
8258      *
8259      * @see #putExtra(String, CharSequence)
8260      */
getCharSequenceExtra(String name)8261     public @Nullable CharSequence getCharSequenceExtra(String name) {
8262         return mExtras == null ? null : mExtras.getCharSequence(name);
8263     }
8264 
8265     /**
8266      * Retrieve extended data from the intent.
8267      *
8268      * @param name The name of the desired item.
8269      *
8270      * @return the value of an item previously added with putExtra(),
8271      * or null if no Parcelable value was found.
8272      *
8273      * @see #putExtra(String, Parcelable)
8274      */
getParcelableExtra(String name)8275     public @Nullable <T extends Parcelable> T getParcelableExtra(String name) {
8276         return mExtras == null ? null : mExtras.<T>getParcelable(name);
8277     }
8278 
8279     /**
8280      * Retrieve extended data from the intent.
8281      *
8282      * @param name The name of the desired item.
8283      *
8284      * @return the value of an item previously added with putExtra(),
8285      * or null if no Parcelable[] value was found.
8286      *
8287      * @see #putExtra(String, Parcelable[])
8288      */
getParcelableArrayExtra(String name)8289     public @Nullable Parcelable[] getParcelableArrayExtra(String name) {
8290         return mExtras == null ? null : mExtras.getParcelableArray(name);
8291     }
8292 
8293     /**
8294      * Retrieve extended data from the intent.
8295      *
8296      * @param name The name of the desired item.
8297      *
8298      * @return the value of an item previously added with
8299      * putParcelableArrayListExtra(), or null if no
8300      * ArrayList<Parcelable> value was found.
8301      *
8302      * @see #putParcelableArrayListExtra(String, ArrayList)
8303      */
getParcelableArrayListExtra(String name)8304     public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
8305         return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
8306     }
8307 
8308     /**
8309      * Retrieve extended data from the intent.
8310      *
8311      * @param name The name of the desired item.
8312      *
8313      * @return the value of an item previously added with putExtra(),
8314      * or null if no Serializable value was found.
8315      *
8316      * @see #putExtra(String, Serializable)
8317      */
getSerializableExtra(String name)8318     public @Nullable Serializable getSerializableExtra(String name) {
8319         return mExtras == null ? null : mExtras.getSerializable(name);
8320     }
8321 
8322     /**
8323      * Retrieve extended data from the intent.
8324      *
8325      * @param name The name of the desired item.
8326      *
8327      * @return the value of an item previously added with
8328      * putIntegerArrayListExtra(), or null if no
8329      * ArrayList<Integer> value was found.
8330      *
8331      * @see #putIntegerArrayListExtra(String, ArrayList)
8332      */
getIntegerArrayListExtra(String name)8333     public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) {
8334         return mExtras == null ? null : mExtras.getIntegerArrayList(name);
8335     }
8336 
8337     /**
8338      * Retrieve extended data from the intent.
8339      *
8340      * @param name The name of the desired item.
8341      *
8342      * @return the value of an item previously added with
8343      * putStringArrayListExtra(), or null if no
8344      * ArrayList<String> value was found.
8345      *
8346      * @see #putStringArrayListExtra(String, ArrayList)
8347      */
getStringArrayListExtra(String name)8348     public @Nullable ArrayList<String> getStringArrayListExtra(String name) {
8349         return mExtras == null ? null : mExtras.getStringArrayList(name);
8350     }
8351 
8352     /**
8353      * Retrieve extended data from the intent.
8354      *
8355      * @param name The name of the desired item.
8356      *
8357      * @return the value of an item previously added with
8358      * putCharSequenceArrayListExtra, or null if no
8359      * ArrayList<CharSequence> value was found.
8360      *
8361      * @see #putCharSequenceArrayListExtra(String, ArrayList)
8362      */
getCharSequenceArrayListExtra(String name)8363     public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
8364         return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
8365     }
8366 
8367     /**
8368      * Retrieve extended data from the intent.
8369      *
8370      * @param name The name of the desired item.
8371      *
8372      * @return the value of an item previously added with putExtra(),
8373      * or null if no boolean array value was found.
8374      *
8375      * @see #putExtra(String, boolean[])
8376      */
getBooleanArrayExtra(String name)8377     public @Nullable boolean[] getBooleanArrayExtra(String name) {
8378         return mExtras == null ? null : mExtras.getBooleanArray(name);
8379     }
8380 
8381     /**
8382      * Retrieve extended data from the intent.
8383      *
8384      * @param name The name of the desired item.
8385      *
8386      * @return the value of an item previously added with putExtra(),
8387      * or null if no byte array value was found.
8388      *
8389      * @see #putExtra(String, byte[])
8390      */
getByteArrayExtra(String name)8391     public @Nullable byte[] getByteArrayExtra(String name) {
8392         return mExtras == null ? null : mExtras.getByteArray(name);
8393     }
8394 
8395     /**
8396      * Retrieve extended data from the intent.
8397      *
8398      * @param name The name of the desired item.
8399      *
8400      * @return the value of an item previously added with putExtra(),
8401      * or null if no short array value was found.
8402      *
8403      * @see #putExtra(String, short[])
8404      */
getShortArrayExtra(String name)8405     public @Nullable short[] getShortArrayExtra(String name) {
8406         return mExtras == null ? null : mExtras.getShortArray(name);
8407     }
8408 
8409     /**
8410      * Retrieve extended data from the intent.
8411      *
8412      * @param name The name of the desired item.
8413      *
8414      * @return the value of an item previously added with putExtra(),
8415      * or null if no char array value was found.
8416      *
8417      * @see #putExtra(String, char[])
8418      */
getCharArrayExtra(String name)8419     public @Nullable char[] getCharArrayExtra(String name) {
8420         return mExtras == null ? null : mExtras.getCharArray(name);
8421     }
8422 
8423     /**
8424      * Retrieve extended data from the intent.
8425      *
8426      * @param name The name of the desired item.
8427      *
8428      * @return the value of an item previously added with putExtra(),
8429      * or null if no int array value was found.
8430      *
8431      * @see #putExtra(String, int[])
8432      */
getIntArrayExtra(String name)8433     public @Nullable int[] getIntArrayExtra(String name) {
8434         return mExtras == null ? null : mExtras.getIntArray(name);
8435     }
8436 
8437     /**
8438      * Retrieve extended data from the intent.
8439      *
8440      * @param name The name of the desired item.
8441      *
8442      * @return the value of an item previously added with putExtra(),
8443      * or null if no long array value was found.
8444      *
8445      * @see #putExtra(String, long[])
8446      */
getLongArrayExtra(String name)8447     public @Nullable long[] getLongArrayExtra(String name) {
8448         return mExtras == null ? null : mExtras.getLongArray(name);
8449     }
8450 
8451     /**
8452      * Retrieve extended data from the intent.
8453      *
8454      * @param name The name of the desired item.
8455      *
8456      * @return the value of an item previously added with putExtra(),
8457      * or null if no float array value was found.
8458      *
8459      * @see #putExtra(String, float[])
8460      */
getFloatArrayExtra(String name)8461     public @Nullable float[] getFloatArrayExtra(String name) {
8462         return mExtras == null ? null : mExtras.getFloatArray(name);
8463     }
8464 
8465     /**
8466      * Retrieve extended data from the intent.
8467      *
8468      * @param name The name of the desired item.
8469      *
8470      * @return the value of an item previously added with putExtra(),
8471      * or null if no double array value was found.
8472      *
8473      * @see #putExtra(String, double[])
8474      */
getDoubleArrayExtra(String name)8475     public @Nullable double[] getDoubleArrayExtra(String name) {
8476         return mExtras == null ? null : mExtras.getDoubleArray(name);
8477     }
8478 
8479     /**
8480      * Retrieve extended data from the intent.
8481      *
8482      * @param name The name of the desired item.
8483      *
8484      * @return the value of an item previously added with putExtra(),
8485      * or null if no String array value was found.
8486      *
8487      * @see #putExtra(String, String[])
8488      */
getStringArrayExtra(String name)8489     public @Nullable String[] getStringArrayExtra(String name) {
8490         return mExtras == null ? null : mExtras.getStringArray(name);
8491     }
8492 
8493     /**
8494      * Retrieve extended data from the intent.
8495      *
8496      * @param name The name of the desired item.
8497      *
8498      * @return the value of an item previously added with putExtra(),
8499      * or null if no CharSequence array value was found.
8500      *
8501      * @see #putExtra(String, CharSequence[])
8502      */
getCharSequenceArrayExtra(String name)8503     public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) {
8504         return mExtras == null ? null : mExtras.getCharSequenceArray(name);
8505     }
8506 
8507     /**
8508      * Retrieve extended data from the intent.
8509      *
8510      * @param name The name of the desired item.
8511      *
8512      * @return the value of an item previously added with putExtra(),
8513      * or null if no Bundle value was found.
8514      *
8515      * @see #putExtra(String, Bundle)
8516      */
getBundleExtra(String name)8517     public @Nullable Bundle getBundleExtra(String name) {
8518         return mExtras == null ? null : mExtras.getBundle(name);
8519     }
8520 
8521     /**
8522      * Retrieve extended data from the intent.
8523      *
8524      * @param name The name of the desired item.
8525      *
8526      * @return the value of an item previously added with putExtra(),
8527      * or null if no IBinder value was found.
8528      *
8529      * @see #putExtra(String, IBinder)
8530      *
8531      * @deprecated
8532      * @hide
8533      */
8534     @Deprecated
8535     @UnsupportedAppUsage
getIBinderExtra(String name)8536     public IBinder getIBinderExtra(String name) {
8537         return mExtras == null ? null : mExtras.getIBinder(name);
8538     }
8539 
8540     /**
8541      * Retrieve extended data from the intent.
8542      *
8543      * @param name The name of the desired item.
8544      * @param defaultValue The default value to return in case no item is
8545      * associated with the key 'name'
8546      *
8547      * @return the value of an item previously added with putExtra(),
8548      * or defaultValue if none was found.
8549      *
8550      * @see #putExtra
8551      *
8552      * @deprecated
8553      * @hide
8554      */
8555     @Deprecated
8556     @UnsupportedAppUsage
getExtra(String name, Object defaultValue)8557     public Object getExtra(String name, Object defaultValue) {
8558         Object result = defaultValue;
8559         if (mExtras != null) {
8560             Object result2 = mExtras.get(name);
8561             if (result2 != null) {
8562                 result = result2;
8563             }
8564         }
8565 
8566         return result;
8567     }
8568 
8569     /**
8570      * Retrieves a map of extended data from the intent.
8571      *
8572      * @return the map of all extras previously added with putExtra(),
8573      * or null if none have been added.
8574      */
getExtras()8575     public @Nullable Bundle getExtras() {
8576         return (mExtras != null)
8577                 ? new Bundle(mExtras)
8578                 : null;
8579     }
8580 
8581     /**
8582      * Filter extras to only basic types.
8583      * @hide
8584      */
removeUnsafeExtras()8585     public void removeUnsafeExtras() {
8586         if (mExtras != null) {
8587             mExtras = mExtras.filterValues();
8588         }
8589     }
8590 
8591     /**
8592      * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
8593      * return itself as-is.
8594      * @hide
8595      */
canStripForHistory()8596     public boolean canStripForHistory() {
8597         return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
8598     }
8599 
8600     /**
8601      * Call it when the system needs to keep an intent for logging purposes to remove fields
8602      * that are not needed for logging.
8603      * @hide
8604      */
maybeStripForHistory()8605     public Intent maybeStripForHistory() {
8606         // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
8607 
8608         if (!canStripForHistory()) {
8609             return this;
8610         }
8611         return new Intent(this, COPY_MODE_HISTORY);
8612     }
8613 
8614     /**
8615      * Retrieve any special flags associated with this intent.  You will
8616      * normally just set them with {@link #setFlags} and let the system
8617      * take the appropriate action with them.
8618      *
8619      * @return The currently set flags.
8620      * @see #setFlags
8621      * @see #addFlags
8622      * @see #removeFlags
8623      */
getFlags()8624     public @Flags int getFlags() {
8625         return mFlags;
8626     }
8627 
8628     /** @hide */
8629     @UnsupportedAppUsage
isExcludingStopped()8630     public boolean isExcludingStopped() {
8631         return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
8632                 == FLAG_EXCLUDE_STOPPED_PACKAGES;
8633     }
8634 
8635     /**
8636      * Retrieve the application package name this Intent is limited to.  When
8637      * resolving an Intent, if non-null this limits the resolution to only
8638      * components in the given application package.
8639      *
8640      * @return The name of the application package for the Intent.
8641      *
8642      * @see #resolveActivity
8643      * @see #setPackage
8644      */
getPackage()8645     public @Nullable String getPackage() {
8646         return mPackage;
8647     }
8648 
8649     /**
8650      * Retrieve the concrete component associated with the intent.  When receiving
8651      * an intent, this is the component that was found to best handle it (that is,
8652      * yourself) and will always be non-null; in all other cases it will be
8653      * null unless explicitly set.
8654      *
8655      * @return The name of the application component to handle the intent.
8656      *
8657      * @see #resolveActivity
8658      * @see #setComponent
8659      */
getComponent()8660     public @Nullable ComponentName getComponent() {
8661         return mComponent;
8662     }
8663 
8664     /**
8665      * Get the bounds of the sender of this intent, in screen coordinates.  This can be
8666      * used as a hint to the receiver for animations and the like.  Null means that there
8667      * is no source bounds.
8668      */
getSourceBounds()8669     public @Nullable Rect getSourceBounds() {
8670         return mSourceBounds;
8671     }
8672 
8673     /**
8674      * Return the Activity component that should be used to handle this intent.
8675      * The appropriate component is determined based on the information in the
8676      * intent, evaluated as follows:
8677      *
8678      * <p>If {@link #getComponent} returns an explicit class, that is returned
8679      * without any further consideration.
8680      *
8681      * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
8682      * category to be considered.
8683      *
8684      * <p>If {@link #getAction} is non-NULL, the activity must handle this
8685      * action.
8686      *
8687      * <p>If {@link #resolveType} returns non-NULL, the activity must handle
8688      * this type.
8689      *
8690      * <p>If {@link #addCategory} has added any categories, the activity must
8691      * handle ALL of the categories specified.
8692      *
8693      * <p>If {@link #getPackage} is non-NULL, only activity components in
8694      * that application package will be considered.
8695      *
8696      * <p>If there are no activities that satisfy all of these conditions, a
8697      * null string is returned.
8698      *
8699      * <p>If multiple activities are found to satisfy the intent, the one with
8700      * the highest priority will be used.  If there are multiple activities
8701      * with the same priority, the system will either pick the best activity
8702      * based on user preference, or resolve to a system class that will allow
8703      * the user to pick an activity and forward from there.
8704      *
8705      * <p>This method is implemented simply by calling
8706      * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
8707      * true.</p>
8708      * <p> This API is called for you as part of starting an activity from an
8709      * intent.  You do not normally need to call it yourself.</p>
8710      *
8711      * @param pm The package manager with which to resolve the Intent.
8712      *
8713      * @return Name of the component implementing an activity that can
8714      *         display the intent.
8715      *
8716      * @see #setComponent
8717      * @see #getComponent
8718      * @see #resolveActivityInfo
8719      */
resolveActivity(@onNull PackageManager pm)8720     public ComponentName resolveActivity(@NonNull PackageManager pm) {
8721         if (mComponent != null) {
8722             return mComponent;
8723         }
8724 
8725         ResolveInfo info = pm.resolveActivity(
8726             this, PackageManager.MATCH_DEFAULT_ONLY);
8727         if (info != null) {
8728             return new ComponentName(
8729                     info.activityInfo.applicationInfo.packageName,
8730                     info.activityInfo.name);
8731         }
8732 
8733         return null;
8734     }
8735 
8736     /**
8737      * Resolve the Intent into an {@link ActivityInfo}
8738      * describing the activity that should execute the intent.  Resolution
8739      * follows the same rules as described for {@link #resolveActivity}, but
8740      * you get back the completely information about the resolved activity
8741      * instead of just its class name.
8742      *
8743      * @param pm The package manager with which to resolve the Intent.
8744      * @param flags Addition information to retrieve as per
8745      * {@link PackageManager#getActivityInfo(ComponentName, int)
8746      * PackageManager.getActivityInfo()}.
8747      *
8748      * @return PackageManager.ActivityInfo
8749      *
8750      * @see #resolveActivity
8751      */
resolveActivityInfo(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)8752     public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
8753             @PackageManager.ComponentInfoFlags int flags) {
8754         ActivityInfo ai = null;
8755         if (mComponent != null) {
8756             try {
8757                 ai = pm.getActivityInfo(mComponent, flags);
8758             } catch (PackageManager.NameNotFoundException e) {
8759                 // ignore
8760             }
8761         } else {
8762             ResolveInfo info = pm.resolveActivity(
8763                 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
8764             if (info != null) {
8765                 ai = info.activityInfo;
8766             }
8767         }
8768 
8769         return ai;
8770     }
8771 
8772     /**
8773      * Special function for use by the system to resolve service
8774      * intents to system apps.  Throws an exception if there are
8775      * multiple potential matches to the Intent.  Returns null if
8776      * there are no matches.
8777      * @hide
8778      */
8779     @UnsupportedAppUsage
resolveSystemService(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)8780     public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
8781             @PackageManager.ComponentInfoFlags int flags) {
8782         if (mComponent != null) {
8783             return mComponent;
8784         }
8785 
8786         List<ResolveInfo> results = pm.queryIntentServices(this, flags);
8787         if (results == null) {
8788             return null;
8789         }
8790         ComponentName comp = null;
8791         for (int i=0; i<results.size(); i++) {
8792             ResolveInfo ri = results.get(i);
8793             if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
8794                 continue;
8795             }
8796             ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
8797                     ri.serviceInfo.name);
8798             if (comp != null) {
8799                 throw new IllegalStateException("Multiple system services handle " + this
8800                         + ": " + comp + ", " + foundComp);
8801             }
8802             comp = foundComp;
8803         }
8804         return comp;
8805     }
8806 
8807     /**
8808      * Set the general action to be performed.
8809      *
8810      * @param action An action name, such as ACTION_VIEW.  Application-specific
8811      *               actions should be prefixed with the vendor's package name.
8812      *
8813      * @return Returns the same Intent object, for chaining multiple calls
8814      * into a single statement.
8815      *
8816      * @see #getAction
8817      */
setAction(@ullable String action)8818     public @NonNull Intent setAction(@Nullable String action) {
8819         mAction = action != null ? action.intern() : null;
8820         return this;
8821     }
8822 
8823     /**
8824      * Set the data this intent is operating on.  This method automatically
8825      * clears any type that was previously set by {@link #setType} or
8826      * {@link #setTypeAndNormalize}.
8827      *
8828      * <p><em>Note: scheme matching in the Android framework is
8829      * case-sensitive, unlike the formal RFC. As a result,
8830      * you should always write your Uri with a lower case scheme,
8831      * or use {@link Uri#normalizeScheme} or
8832      * {@link #setDataAndNormalize}
8833      * to ensure that the scheme is converted to lower case.</em>
8834      *
8835      * @param data The Uri of the data this intent is now targeting.
8836      *
8837      * @return Returns the same Intent object, for chaining multiple calls
8838      * into a single statement.
8839      *
8840      * @see #getData
8841      * @see #setDataAndNormalize
8842      * @see android.net.Uri#normalizeScheme()
8843      */
setData(@ullable Uri data)8844     public @NonNull Intent setData(@Nullable Uri data) {
8845         mData = data;
8846         mType = null;
8847         return this;
8848     }
8849 
8850     /**
8851      * Normalize and set the data this intent is operating on.
8852      *
8853      * <p>This method automatically clears any type that was
8854      * previously set (for example, by {@link #setType}).
8855      *
8856      * <p>The data Uri is normalized using
8857      * {@link android.net.Uri#normalizeScheme} before it is set,
8858      * so really this is just a convenience method for
8859      * <pre>
8860      * setData(data.normalize())
8861      * </pre>
8862      *
8863      * @param data The Uri of the data this intent is now targeting.
8864      *
8865      * @return Returns the same Intent object, for chaining multiple calls
8866      * into a single statement.
8867      *
8868      * @see #getData
8869      * @see #setType
8870      * @see android.net.Uri#normalizeScheme
8871      */
setDataAndNormalize(@onNull Uri data)8872     public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
8873         return setData(data.normalizeScheme());
8874     }
8875 
8876     /**
8877      * Set an explicit MIME data type.
8878      *
8879      * <p>This is used to create intents that only specify a type and not data,
8880      * for example to indicate the type of data to return.
8881      *
8882      * <p>This method automatically clears any data that was
8883      * previously set (for example by {@link #setData}).
8884      *
8885      * <p><em>Note: MIME type matching in the Android framework is
8886      * case-sensitive, unlike formal RFC MIME types.  As a result,
8887      * you should always write your MIME types with lower case letters,
8888      * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8889      * to ensure that it is converted to lower case.</em>
8890      *
8891      * @param type The MIME type of the data being handled by this intent.
8892      *
8893      * @return Returns the same Intent object, for chaining multiple calls
8894      * into a single statement.
8895      *
8896      * @see #getType
8897      * @see #setTypeAndNormalize
8898      * @see #setDataAndType
8899      * @see #normalizeMimeType
8900      */
setType(@ullable String type)8901     public @NonNull Intent setType(@Nullable String type) {
8902         mData = null;
8903         mType = type;
8904         return this;
8905     }
8906 
8907     /**
8908      * Normalize and set an explicit MIME data type.
8909      *
8910      * <p>This is used to create intents that only specify a type and not data,
8911      * for example to indicate the type of data to return.
8912      *
8913      * <p>This method automatically clears any data that was
8914      * previously set (for example by {@link #setData}).
8915      *
8916      * <p>The MIME type is normalized using
8917      * {@link #normalizeMimeType} before it is set,
8918      * so really this is just a convenience method for
8919      * <pre>
8920      * setType(Intent.normalizeMimeType(type))
8921      * </pre>
8922      *
8923      * @param type The MIME type of the data being handled by this intent.
8924      *
8925      * @return Returns the same Intent object, for chaining multiple calls
8926      * into a single statement.
8927      *
8928      * @see #getType
8929      * @see #setData
8930      * @see #normalizeMimeType
8931      */
setTypeAndNormalize(@ullable String type)8932     public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
8933         return setType(normalizeMimeType(type));
8934     }
8935 
8936     /**
8937      * (Usually optional) Set the data for the intent along with an explicit
8938      * MIME data type.  This method should very rarely be used -- it allows you
8939      * to override the MIME type that would ordinarily be inferred from the
8940      * data with your own type given here.
8941      *
8942      * <p><em>Note: MIME type and Uri scheme matching in the
8943      * Android framework is case-sensitive, unlike the formal RFC definitions.
8944      * As a result, you should always write these elements with lower case letters,
8945      * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
8946      * {@link #setDataAndTypeAndNormalize}
8947      * to ensure that they are converted to lower case.</em>
8948      *
8949      * @param data The Uri of the data this intent is now targeting.
8950      * @param type The MIME type of the data being handled by this intent.
8951      *
8952      * @return Returns the same Intent object, for chaining multiple calls
8953      * into a single statement.
8954      *
8955      * @see #setType
8956      * @see #setData
8957      * @see #normalizeMimeType
8958      * @see android.net.Uri#normalizeScheme
8959      * @see #setDataAndTypeAndNormalize
8960      */
setDataAndType(@ullable Uri data, @Nullable String type)8961     public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
8962         mData = data;
8963         mType = type;
8964         return this;
8965     }
8966 
8967     /**
8968      * (Usually optional) Normalize and set both the data Uri and an explicit
8969      * MIME data type.  This method should very rarely be used -- it allows you
8970      * to override the MIME type that would ordinarily be inferred from the
8971      * data with your own type given here.
8972      *
8973      * <p>The data Uri and the MIME type are normalize using
8974      * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
8975      * before they are set, so really this is just a convenience method for
8976      * <pre>
8977      * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8978      * </pre>
8979      *
8980      * @param data The Uri of the data this intent is now targeting.
8981      * @param type The MIME type of the data being handled by this intent.
8982      *
8983      * @return Returns the same Intent object, for chaining multiple calls
8984      * into a single statement.
8985      *
8986      * @see #setType
8987      * @see #setData
8988      * @see #setDataAndType
8989      * @see #normalizeMimeType
8990      * @see android.net.Uri#normalizeScheme
8991      */
setDataAndTypeAndNormalize(@onNull Uri data, @Nullable String type)8992     public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
8993         return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
8994     }
8995 
8996     /**
8997      * Set an identifier for this Intent.  If set, this provides a unique identity for this Intent,
8998      * allowing it to be unique from other Intents that would otherwise look the same.  In
8999      * particular, this will be used by {@link #filterEquals(Intent)} to determine if two
9000      * Intents are the same as with other fields like {@link #setAction}.  However, unlike those
9001      * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter};
9002      * it is as if the identifier has not been set on the Intent.
9003      *
9004      * <p>This can be used, for example, to make this Intent unique from other Intents that
9005      * are otherwise the same, for use in creating a {@link android.app.PendingIntent}.  (Be aware
9006      * however that the receiver of the PendingIntent will see whatever you put in here.)  The
9007      * structure of this string is completely undefined by the platform, however if you are going
9008      * to be exposing identifier strings across different applications you may need to define
9009      * your own structure if there is no central party defining the contents of this field.</p>
9010      *
9011      * @param identifier The identifier for this Intent.  The contents of the string have no
9012      *                   meaning to the system, except whether they are exactly the same as
9013      *                   another identifier.
9014      *
9015      * @return Returns the same Intent object, for chaining multiple calls
9016      * into a single statement.
9017      *
9018      * @see #getIdentifier
9019      */
setIdentifier(@ullable String identifier)9020     public @NonNull Intent setIdentifier(@Nullable String identifier) {
9021         mIdentifier = identifier;
9022         return this;
9023     }
9024 
9025     /**
9026      * Add a new category to the intent.  Categories provide additional detail
9027      * about the action the intent performs.  When resolving an intent, only
9028      * activities that provide <em>all</em> of the requested categories will be
9029      * used.
9030      *
9031      * @param category The desired category.  This can be either one of the
9032      *               predefined Intent categories, or a custom category in your own
9033      *               namespace.
9034      *
9035      * @return Returns the same Intent object, for chaining multiple calls
9036      * into a single statement.
9037      *
9038      * @see #hasCategory
9039      * @see #removeCategory
9040      */
addCategory(String category)9041     public @NonNull Intent addCategory(String category) {
9042         if (mCategories == null) {
9043             mCategories = new ArraySet<String>();
9044         }
9045         mCategories.add(category.intern());
9046         return this;
9047     }
9048 
9049     /**
9050      * Remove a category from an intent.
9051      *
9052      * @param category The category to remove.
9053      *
9054      * @see #addCategory
9055      */
removeCategory(String category)9056     public void removeCategory(String category) {
9057         if (mCategories != null) {
9058             mCategories.remove(category);
9059             if (mCategories.size() == 0) {
9060                 mCategories = null;
9061             }
9062         }
9063     }
9064 
9065     /**
9066      * Set a selector for this Intent.  This is a modification to the kinds of
9067      * things the Intent will match.  If the selector is set, it will be used
9068      * when trying to find entities that can handle the Intent, instead of the
9069      * main contents of the Intent.  This allows you build an Intent containing
9070      * a generic protocol while targeting it more specifically.
9071      *
9072      * <p>An example of where this may be used is with things like
9073      * {@link #CATEGORY_APP_BROWSER}.  This category allows you to build an
9074      * Intent that will launch the Browser application.  However, the correct
9075      * main entry point of an application is actually {@link #ACTION_MAIN}
9076      * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
9077      * used to specify the actual Activity to launch.  If you launch the browser
9078      * with something different, undesired behavior may happen if the user has
9079      * previously or later launches it the normal way, since they do not match.
9080      * Instead, you can build an Intent with the MAIN action (but no ComponentName
9081      * yet specified) and set a selector with {@link #ACTION_MAIN} and
9082      * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
9083      *
9084      * <p>Setting a selector does not impact the behavior of
9085      * {@link #filterEquals(Intent)} and {@link #filterHashCode()}.  This is part of the
9086      * desired behavior of a selector -- it does not impact the base meaning
9087      * of the Intent, just what kinds of things will be matched against it
9088      * when determining who can handle it.</p>
9089      *
9090      * <p>You can not use both a selector and {@link #setPackage(String)} on
9091      * the same base Intent.</p>
9092      *
9093      * @param selector The desired selector Intent; set to null to not use
9094      * a special selector.
9095      */
setSelector(@ullable Intent selector)9096     public void setSelector(@Nullable Intent selector) {
9097         if (selector == this) {
9098             throw new IllegalArgumentException(
9099                     "Intent being set as a selector of itself");
9100         }
9101         if (selector != null && mPackage != null) {
9102             throw new IllegalArgumentException(
9103                     "Can't set selector when package name is already set");
9104         }
9105         mSelector = selector;
9106     }
9107 
9108     /**
9109      * Set a {@link ClipData} associated with this Intent.  This replaces any
9110      * previously set ClipData.
9111      *
9112      * <p>The ClipData in an intent is not used for Intent matching or other
9113      * such operations.  Semantically it is like extras, used to transmit
9114      * additional data with the Intent.  The main feature of using this over
9115      * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
9116      * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
9117      * items included in the clip data.  This is useful, in particular, if
9118      * you want to transmit an Intent containing multiple <code>content:</code>
9119      * URIs for which the recipient may not have global permission to access the
9120      * content provider.
9121      *
9122      * <p>If the ClipData contains items that are themselves Intents, any
9123      * grant flags in those Intents will be ignored.  Only the top-level flags
9124      * of the main Intent are respected, and will be applied to all Uri or
9125      * Intent items in the clip (or sub-items of the clip).
9126      *
9127      * <p>The MIME type, label, and icon in the ClipData object are not
9128      * directly used by Intent.  Applications should generally rely on the
9129      * MIME type of the Intent itself, not what it may find in the ClipData.
9130      * A common practice is to construct a ClipData for use with an Intent
9131      * with a MIME type of "*&#47;*".
9132      *
9133      * @param clip The new clip to set.  May be null to clear the current clip.
9134      */
setClipData(@ullable ClipData clip)9135     public void setClipData(@Nullable ClipData clip) {
9136         mClipData = clip;
9137     }
9138 
9139     /**
9140      * This is NOT a secure mechanism to identify the user who sent the intent.
9141      * When the intent is sent to a different user, it is used to fix uris by adding the userId
9142      * who sent the intent.
9143      * @hide
9144      */
prepareToLeaveUser(int userId)9145     public void prepareToLeaveUser(int userId) {
9146         // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
9147         // We want mContentUserHint to refer to the original user, so don't do anything.
9148         if (mContentUserHint == UserHandle.USER_CURRENT) {
9149             mContentUserHint = userId;
9150         }
9151     }
9152 
9153     /**
9154      * Add extended data to the intent.  The name must include a package
9155      * prefix, for example the app com.android.contacts would use names
9156      * like "com.android.contacts.ShowAll".
9157      *
9158      * @param name The name of the extra data, with package prefix.
9159      * @param value The boolean data value.
9160      *
9161      * @return Returns the same Intent object, for chaining multiple calls
9162      * into a single statement.
9163      *
9164      * @see #putExtras
9165      * @see #removeExtra
9166      * @see #getBooleanExtra(String, boolean)
9167      */
putExtra(String name, boolean value)9168     public @NonNull Intent putExtra(String name, boolean value) {
9169         if (mExtras == null) {
9170             mExtras = new Bundle();
9171         }
9172         mExtras.putBoolean(name, value);
9173         return this;
9174     }
9175 
9176     /**
9177      * Add extended data to the intent.  The name must include a package
9178      * prefix, for example the app com.android.contacts would use names
9179      * like "com.android.contacts.ShowAll".
9180      *
9181      * @param name The name of the extra data, with package prefix.
9182      * @param value The byte data value.
9183      *
9184      * @return Returns the same Intent object, for chaining multiple calls
9185      * into a single statement.
9186      *
9187      * @see #putExtras
9188      * @see #removeExtra
9189      * @see #getByteExtra(String, byte)
9190      */
putExtra(String name, byte value)9191     public @NonNull Intent putExtra(String name, byte value) {
9192         if (mExtras == null) {
9193             mExtras = new Bundle();
9194         }
9195         mExtras.putByte(name, value);
9196         return this;
9197     }
9198 
9199     /**
9200      * Add extended data to the intent.  The name must include a package
9201      * prefix, for example the app com.android.contacts would use names
9202      * like "com.android.contacts.ShowAll".
9203      *
9204      * @param name The name of the extra data, with package prefix.
9205      * @param value The char data value.
9206      *
9207      * @return Returns the same Intent object, for chaining multiple calls
9208      * into a single statement.
9209      *
9210      * @see #putExtras
9211      * @see #removeExtra
9212      * @see #getCharExtra(String, char)
9213      */
putExtra(String name, char value)9214     public @NonNull Intent putExtra(String name, char value) {
9215         if (mExtras == null) {
9216             mExtras = new Bundle();
9217         }
9218         mExtras.putChar(name, value);
9219         return this;
9220     }
9221 
9222     /**
9223      * Add extended data to the intent.  The name must include a package
9224      * prefix, for example the app com.android.contacts would use names
9225      * like "com.android.contacts.ShowAll".
9226      *
9227      * @param name The name of the extra data, with package prefix.
9228      * @param value The short data value.
9229      *
9230      * @return Returns the same Intent object, for chaining multiple calls
9231      * into a single statement.
9232      *
9233      * @see #putExtras
9234      * @see #removeExtra
9235      * @see #getShortExtra(String, short)
9236      */
putExtra(String name, short value)9237     public @NonNull Intent putExtra(String name, short value) {
9238         if (mExtras == null) {
9239             mExtras = new Bundle();
9240         }
9241         mExtras.putShort(name, value);
9242         return this;
9243     }
9244 
9245     /**
9246      * Add extended data to the intent.  The name must include a package
9247      * prefix, for example the app com.android.contacts would use names
9248      * like "com.android.contacts.ShowAll".
9249      *
9250      * @param name The name of the extra data, with package prefix.
9251      * @param value The integer data value.
9252      *
9253      * @return Returns the same Intent object, for chaining multiple calls
9254      * into a single statement.
9255      *
9256      * @see #putExtras
9257      * @see #removeExtra
9258      * @see #getIntExtra(String, int)
9259      */
putExtra(String name, int value)9260     public @NonNull Intent putExtra(String name, int value) {
9261         if (mExtras == null) {
9262             mExtras = new Bundle();
9263         }
9264         mExtras.putInt(name, value);
9265         return this;
9266     }
9267 
9268     /**
9269      * Add extended data to the intent.  The name must include a package
9270      * prefix, for example the app com.android.contacts would use names
9271      * like "com.android.contacts.ShowAll".
9272      *
9273      * @param name The name of the extra data, with package prefix.
9274      * @param value The long data value.
9275      *
9276      * @return Returns the same Intent object, for chaining multiple calls
9277      * into a single statement.
9278      *
9279      * @see #putExtras
9280      * @see #removeExtra
9281      * @see #getLongExtra(String, long)
9282      */
putExtra(String name, long value)9283     public @NonNull Intent putExtra(String name, long value) {
9284         if (mExtras == null) {
9285             mExtras = new Bundle();
9286         }
9287         mExtras.putLong(name, value);
9288         return this;
9289     }
9290 
9291     /**
9292      * Add extended data to the intent.  The name must include a package
9293      * prefix, for example the app com.android.contacts would use names
9294      * like "com.android.contacts.ShowAll".
9295      *
9296      * @param name The name of the extra data, with package prefix.
9297      * @param value The float data value.
9298      *
9299      * @return Returns the same Intent object, for chaining multiple calls
9300      * into a single statement.
9301      *
9302      * @see #putExtras
9303      * @see #removeExtra
9304      * @see #getFloatExtra(String, float)
9305      */
putExtra(String name, float value)9306     public @NonNull Intent putExtra(String name, float value) {
9307         if (mExtras == null) {
9308             mExtras = new Bundle();
9309         }
9310         mExtras.putFloat(name, value);
9311         return this;
9312     }
9313 
9314     /**
9315      * Add extended data to the intent.  The name must include a package
9316      * prefix, for example the app com.android.contacts would use names
9317      * like "com.android.contacts.ShowAll".
9318      *
9319      * @param name The name of the extra data, with package prefix.
9320      * @param value The double data value.
9321      *
9322      * @return Returns the same Intent object, for chaining multiple calls
9323      * into a single statement.
9324      *
9325      * @see #putExtras
9326      * @see #removeExtra
9327      * @see #getDoubleExtra(String, double)
9328      */
putExtra(String name, double value)9329     public @NonNull Intent putExtra(String name, double value) {
9330         if (mExtras == null) {
9331             mExtras = new Bundle();
9332         }
9333         mExtras.putDouble(name, value);
9334         return this;
9335     }
9336 
9337     /**
9338      * Add extended data to the intent.  The name must include a package
9339      * prefix, for example the app com.android.contacts would use names
9340      * like "com.android.contacts.ShowAll".
9341      *
9342      * @param name The name of the extra data, with package prefix.
9343      * @param value The String data value.
9344      *
9345      * @return Returns the same Intent object, for chaining multiple calls
9346      * into a single statement.
9347      *
9348      * @see #putExtras
9349      * @see #removeExtra
9350      * @see #getStringExtra(String)
9351      */
putExtra(String name, @Nullable String value)9352     public @NonNull Intent putExtra(String name, @Nullable String value) {
9353         if (mExtras == null) {
9354             mExtras = new Bundle();
9355         }
9356         mExtras.putString(name, value);
9357         return this;
9358     }
9359 
9360     /**
9361      * Add extended data to the intent.  The name must include a package
9362      * prefix, for example the app com.android.contacts would use names
9363      * like "com.android.contacts.ShowAll".
9364      *
9365      * @param name The name of the extra data, with package prefix.
9366      * @param value The CharSequence data value.
9367      *
9368      * @return Returns the same Intent object, for chaining multiple calls
9369      * into a single statement.
9370      *
9371      * @see #putExtras
9372      * @see #removeExtra
9373      * @see #getCharSequenceExtra(String)
9374      */
putExtra(String name, @Nullable CharSequence value)9375     public @NonNull Intent putExtra(String name, @Nullable CharSequence value) {
9376         if (mExtras == null) {
9377             mExtras = new Bundle();
9378         }
9379         mExtras.putCharSequence(name, value);
9380         return this;
9381     }
9382 
9383     /**
9384      * Add extended data to the intent.  The name must include a package
9385      * prefix, for example the app com.android.contacts would use names
9386      * like "com.android.contacts.ShowAll".
9387      *
9388      * @param name The name of the extra data, with package prefix.
9389      * @param value The Parcelable data value.
9390      *
9391      * @return Returns the same Intent object, for chaining multiple calls
9392      * into a single statement.
9393      *
9394      * @see #putExtras
9395      * @see #removeExtra
9396      * @see #getParcelableExtra(String)
9397      */
putExtra(String name, @Nullable Parcelable value)9398     public @NonNull Intent putExtra(String name, @Nullable Parcelable value) {
9399         if (mExtras == null) {
9400             mExtras = new Bundle();
9401         }
9402         mExtras.putParcelable(name, value);
9403         return this;
9404     }
9405 
9406     /**
9407      * Add extended data to the intent.  The name must include a package
9408      * prefix, for example the app com.android.contacts would use names
9409      * like "com.android.contacts.ShowAll".
9410      *
9411      * @param name The name of the extra data, with package prefix.
9412      * @param value The Parcelable[] data value.
9413      *
9414      * @return Returns the same Intent object, for chaining multiple calls
9415      * into a single statement.
9416      *
9417      * @see #putExtras
9418      * @see #removeExtra
9419      * @see #getParcelableArrayExtra(String)
9420      */
putExtra(String name, @Nullable Parcelable[] value)9421     public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) {
9422         if (mExtras == null) {
9423             mExtras = new Bundle();
9424         }
9425         mExtras.putParcelableArray(name, value);
9426         return this;
9427     }
9428 
9429     /**
9430      * Add extended data to the intent.  The name must include a package
9431      * prefix, for example the app com.android.contacts would use names
9432      * like "com.android.contacts.ShowAll".
9433      *
9434      * @param name The name of the extra data, with package prefix.
9435      * @param value The ArrayList<Parcelable> data value.
9436      *
9437      * @return Returns the same Intent object, for chaining multiple calls
9438      * into a single statement.
9439      *
9440      * @see #putExtras
9441      * @see #removeExtra
9442      * @see #getParcelableArrayListExtra(String)
9443      */
putParcelableArrayListExtra(String name, @Nullable ArrayList<? extends Parcelable> value)9444     public @NonNull Intent putParcelableArrayListExtra(String name,
9445             @Nullable ArrayList<? extends Parcelable> value) {
9446         if (mExtras == null) {
9447             mExtras = new Bundle();
9448         }
9449         mExtras.putParcelableArrayList(name, value);
9450         return this;
9451     }
9452 
9453     /**
9454      * Add extended data to the intent.  The name must include a package
9455      * prefix, for example the app com.android.contacts would use names
9456      * like "com.android.contacts.ShowAll".
9457      *
9458      * @param name The name of the extra data, with package prefix.
9459      * @param value The ArrayList<Integer> data value.
9460      *
9461      * @return Returns the same Intent object, for chaining multiple calls
9462      * into a single statement.
9463      *
9464      * @see #putExtras
9465      * @see #removeExtra
9466      * @see #getIntegerArrayListExtra(String)
9467      */
putIntegerArrayListExtra(String name, @Nullable ArrayList<Integer> value)9468     public @NonNull Intent putIntegerArrayListExtra(String name,
9469             @Nullable ArrayList<Integer> value) {
9470         if (mExtras == null) {
9471             mExtras = new Bundle();
9472         }
9473         mExtras.putIntegerArrayList(name, value);
9474         return this;
9475     }
9476 
9477     /**
9478      * Add extended data to the intent.  The name must include a package
9479      * prefix, for example the app com.android.contacts would use names
9480      * like "com.android.contacts.ShowAll".
9481      *
9482      * @param name The name of the extra data, with package prefix.
9483      * @param value The ArrayList<String> data value.
9484      *
9485      * @return Returns the same Intent object, for chaining multiple calls
9486      * into a single statement.
9487      *
9488      * @see #putExtras
9489      * @see #removeExtra
9490      * @see #getStringArrayListExtra(String)
9491      */
putStringArrayListExtra(String name, @Nullable ArrayList<String> value)9492     public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) {
9493         if (mExtras == null) {
9494             mExtras = new Bundle();
9495         }
9496         mExtras.putStringArrayList(name, value);
9497         return this;
9498     }
9499 
9500     /**
9501      * Add extended data to the intent.  The name must include a package
9502      * prefix, for example the app com.android.contacts would use names
9503      * like "com.android.contacts.ShowAll".
9504      *
9505      * @param name The name of the extra data, with package prefix.
9506      * @param value The ArrayList<CharSequence> data value.
9507      *
9508      * @return Returns the same Intent object, for chaining multiple calls
9509      * into a single statement.
9510      *
9511      * @see #putExtras
9512      * @see #removeExtra
9513      * @see #getCharSequenceArrayListExtra(String)
9514      */
putCharSequenceArrayListExtra(String name, @Nullable ArrayList<CharSequence> value)9515     public @NonNull Intent putCharSequenceArrayListExtra(String name,
9516             @Nullable ArrayList<CharSequence> value) {
9517         if (mExtras == null) {
9518             mExtras = new Bundle();
9519         }
9520         mExtras.putCharSequenceArrayList(name, value);
9521         return this;
9522     }
9523 
9524     /**
9525      * Add extended data to the intent.  The name must include a package
9526      * prefix, for example the app com.android.contacts would use names
9527      * like "com.android.contacts.ShowAll".
9528      *
9529      * @param name The name of the extra data, with package prefix.
9530      * @param value The Serializable data value.
9531      *
9532      * @return Returns the same Intent object, for chaining multiple calls
9533      * into a single statement.
9534      *
9535      * @see #putExtras
9536      * @see #removeExtra
9537      * @see #getSerializableExtra(String)
9538      */
putExtra(String name, @Nullable Serializable value)9539     public @NonNull Intent putExtra(String name, @Nullable Serializable value) {
9540         if (mExtras == null) {
9541             mExtras = new Bundle();
9542         }
9543         mExtras.putSerializable(name, value);
9544         return this;
9545     }
9546 
9547     /**
9548      * Add extended data to the intent.  The name must include a package
9549      * prefix, for example the app com.android.contacts would use names
9550      * like "com.android.contacts.ShowAll".
9551      *
9552      * @param name The name of the extra data, with package prefix.
9553      * @param value The boolean array data value.
9554      *
9555      * @return Returns the same Intent object, for chaining multiple calls
9556      * into a single statement.
9557      *
9558      * @see #putExtras
9559      * @see #removeExtra
9560      * @see #getBooleanArrayExtra(String)
9561      */
putExtra(String name, @Nullable boolean[] value)9562     public @NonNull Intent putExtra(String name, @Nullable boolean[] value) {
9563         if (mExtras == null) {
9564             mExtras = new Bundle();
9565         }
9566         mExtras.putBooleanArray(name, value);
9567         return this;
9568     }
9569 
9570     /**
9571      * Add extended data to the intent.  The name must include a package
9572      * prefix, for example the app com.android.contacts would use names
9573      * like "com.android.contacts.ShowAll".
9574      *
9575      * @param name The name of the extra data, with package prefix.
9576      * @param value The byte array data value.
9577      *
9578      * @return Returns the same Intent object, for chaining multiple calls
9579      * into a single statement.
9580      *
9581      * @see #putExtras
9582      * @see #removeExtra
9583      * @see #getByteArrayExtra(String)
9584      */
putExtra(String name, @Nullable byte[] value)9585     public @NonNull Intent putExtra(String name, @Nullable byte[] value) {
9586         if (mExtras == null) {
9587             mExtras = new Bundle();
9588         }
9589         mExtras.putByteArray(name, value);
9590         return this;
9591     }
9592 
9593     /**
9594      * Add extended data to the intent.  The name must include a package
9595      * prefix, for example the app com.android.contacts would use names
9596      * like "com.android.contacts.ShowAll".
9597      *
9598      * @param name The name of the extra data, with package prefix.
9599      * @param value The short array data value.
9600      *
9601      * @return Returns the same Intent object, for chaining multiple calls
9602      * into a single statement.
9603      *
9604      * @see #putExtras
9605      * @see #removeExtra
9606      * @see #getShortArrayExtra(String)
9607      */
putExtra(String name, @Nullable short[] value)9608     public @NonNull Intent putExtra(String name, @Nullable short[] value) {
9609         if (mExtras == null) {
9610             mExtras = new Bundle();
9611         }
9612         mExtras.putShortArray(name, value);
9613         return this;
9614     }
9615 
9616     /**
9617      * Add extended data to the intent.  The name must include a package
9618      * prefix, for example the app com.android.contacts would use names
9619      * like "com.android.contacts.ShowAll".
9620      *
9621      * @param name The name of the extra data, with package prefix.
9622      * @param value The char array data value.
9623      *
9624      * @return Returns the same Intent object, for chaining multiple calls
9625      * into a single statement.
9626      *
9627      * @see #putExtras
9628      * @see #removeExtra
9629      * @see #getCharArrayExtra(String)
9630      */
putExtra(String name, @Nullable char[] value)9631     public @NonNull Intent putExtra(String name, @Nullable char[] value) {
9632         if (mExtras == null) {
9633             mExtras = new Bundle();
9634         }
9635         mExtras.putCharArray(name, value);
9636         return this;
9637     }
9638 
9639     /**
9640      * Add extended data to the intent.  The name must include a package
9641      * prefix, for example the app com.android.contacts would use names
9642      * like "com.android.contacts.ShowAll".
9643      *
9644      * @param name The name of the extra data, with package prefix.
9645      * @param value The int array data value.
9646      *
9647      * @return Returns the same Intent object, for chaining multiple calls
9648      * into a single statement.
9649      *
9650      * @see #putExtras
9651      * @see #removeExtra
9652      * @see #getIntArrayExtra(String)
9653      */
putExtra(String name, @Nullable int[] value)9654     public @NonNull Intent putExtra(String name, @Nullable int[] value) {
9655         if (mExtras == null) {
9656             mExtras = new Bundle();
9657         }
9658         mExtras.putIntArray(name, value);
9659         return this;
9660     }
9661 
9662     /**
9663      * Add extended data to the intent.  The name must include a package
9664      * prefix, for example the app com.android.contacts would use names
9665      * like "com.android.contacts.ShowAll".
9666      *
9667      * @param name The name of the extra data, with package prefix.
9668      * @param value The byte array data value.
9669      *
9670      * @return Returns the same Intent object, for chaining multiple calls
9671      * into a single statement.
9672      *
9673      * @see #putExtras
9674      * @see #removeExtra
9675      * @see #getLongArrayExtra(String)
9676      */
putExtra(String name, @Nullable long[] value)9677     public @NonNull Intent putExtra(String name, @Nullable long[] value) {
9678         if (mExtras == null) {
9679             mExtras = new Bundle();
9680         }
9681         mExtras.putLongArray(name, value);
9682         return this;
9683     }
9684 
9685     /**
9686      * Add extended data to the intent.  The name must include a package
9687      * prefix, for example the app com.android.contacts would use names
9688      * like "com.android.contacts.ShowAll".
9689      *
9690      * @param name The name of the extra data, with package prefix.
9691      * @param value The float array data value.
9692      *
9693      * @return Returns the same Intent object, for chaining multiple calls
9694      * into a single statement.
9695      *
9696      * @see #putExtras
9697      * @see #removeExtra
9698      * @see #getFloatArrayExtra(String)
9699      */
putExtra(String name, @Nullable float[] value)9700     public @NonNull Intent putExtra(String name, @Nullable float[] value) {
9701         if (mExtras == null) {
9702             mExtras = new Bundle();
9703         }
9704         mExtras.putFloatArray(name, value);
9705         return this;
9706     }
9707 
9708     /**
9709      * Add extended data to the intent.  The name must include a package
9710      * prefix, for example the app com.android.contacts would use names
9711      * like "com.android.contacts.ShowAll".
9712      *
9713      * @param name The name of the extra data, with package prefix.
9714      * @param value The double array data value.
9715      *
9716      * @return Returns the same Intent object, for chaining multiple calls
9717      * into a single statement.
9718      *
9719      * @see #putExtras
9720      * @see #removeExtra
9721      * @see #getDoubleArrayExtra(String)
9722      */
putExtra(String name, @Nullable double[] value)9723     public @NonNull Intent putExtra(String name, @Nullable double[] value) {
9724         if (mExtras == null) {
9725             mExtras = new Bundle();
9726         }
9727         mExtras.putDoubleArray(name, value);
9728         return this;
9729     }
9730 
9731     /**
9732      * Add extended data to the intent.  The name must include a package
9733      * prefix, for example the app com.android.contacts would use names
9734      * like "com.android.contacts.ShowAll".
9735      *
9736      * @param name The name of the extra data, with package prefix.
9737      * @param value The String array data value.
9738      *
9739      * @return Returns the same Intent object, for chaining multiple calls
9740      * into a single statement.
9741      *
9742      * @see #putExtras
9743      * @see #removeExtra
9744      * @see #getStringArrayExtra(String)
9745      */
putExtra(String name, @Nullable String[] value)9746     public @NonNull Intent putExtra(String name, @Nullable String[] value) {
9747         if (mExtras == null) {
9748             mExtras = new Bundle();
9749         }
9750         mExtras.putStringArray(name, value);
9751         return this;
9752     }
9753 
9754     /**
9755      * Add extended data to the intent.  The name must include a package
9756      * prefix, for example the app com.android.contacts would use names
9757      * like "com.android.contacts.ShowAll".
9758      *
9759      * @param name The name of the extra data, with package prefix.
9760      * @param value The CharSequence array data value.
9761      *
9762      * @return Returns the same Intent object, for chaining multiple calls
9763      * into a single statement.
9764      *
9765      * @see #putExtras
9766      * @see #removeExtra
9767      * @see #getCharSequenceArrayExtra(String)
9768      */
putExtra(String name, @Nullable CharSequence[] value)9769     public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) {
9770         if (mExtras == null) {
9771             mExtras = new Bundle();
9772         }
9773         mExtras.putCharSequenceArray(name, value);
9774         return this;
9775     }
9776 
9777     /**
9778      * Add extended data to the intent.  The name must include a package
9779      * prefix, for example the app com.android.contacts would use names
9780      * like "com.android.contacts.ShowAll".
9781      *
9782      * @param name The name of the extra data, with package prefix.
9783      * @param value The Bundle data value.
9784      *
9785      * @return Returns the same Intent object, for chaining multiple calls
9786      * into a single statement.
9787      *
9788      * @see #putExtras
9789      * @see #removeExtra
9790      * @see #getBundleExtra(String)
9791      */
putExtra(String name, @Nullable Bundle value)9792     public @NonNull Intent putExtra(String name, @Nullable Bundle value) {
9793         if (mExtras == null) {
9794             mExtras = new Bundle();
9795         }
9796         mExtras.putBundle(name, value);
9797         return this;
9798     }
9799 
9800     /**
9801      * Add extended data to the intent.  The name must include a package
9802      * prefix, for example the app com.android.contacts would use names
9803      * like "com.android.contacts.ShowAll".
9804      *
9805      * @param name The name of the extra data, with package prefix.
9806      * @param value The IBinder data value.
9807      *
9808      * @return Returns the same Intent object, for chaining multiple calls
9809      * into a single statement.
9810      *
9811      * @see #putExtras
9812      * @see #removeExtra
9813      * @see #getIBinderExtra(String)
9814      *
9815      * @deprecated
9816      * @hide
9817      */
9818     @Deprecated
9819     @UnsupportedAppUsage
putExtra(String name, IBinder value)9820     public @NonNull Intent putExtra(String name, IBinder value) {
9821         if (mExtras == null) {
9822             mExtras = new Bundle();
9823         }
9824         mExtras.putIBinder(name, value);
9825         return this;
9826     }
9827 
9828     /**
9829      * Copy all extras in 'src' in to this intent.
9830      *
9831      * @param src Contains the extras to copy.
9832      *
9833      * @see #putExtra
9834      */
putExtras(@onNull Intent src)9835     public @NonNull Intent putExtras(@NonNull Intent src) {
9836         if (src.mExtras != null) {
9837             if (mExtras == null) {
9838                 mExtras = new Bundle(src.mExtras);
9839             } else {
9840                 mExtras.putAll(src.mExtras);
9841             }
9842         }
9843         return this;
9844     }
9845 
9846     /**
9847      * Add a set of extended data to the intent.  The keys must include a package
9848      * prefix, for example the app com.android.contacts would use names
9849      * like "com.android.contacts.ShowAll".
9850      *
9851      * @param extras The Bundle of extras to add to this intent.
9852      *
9853      * @see #putExtra
9854      * @see #removeExtra
9855      */
putExtras(@onNull Bundle extras)9856     public @NonNull Intent putExtras(@NonNull Bundle extras) {
9857         if (mExtras == null) {
9858             mExtras = new Bundle();
9859         }
9860         mExtras.putAll(extras);
9861         return this;
9862     }
9863 
9864     /**
9865      * Completely replace the extras in the Intent with the extras in the
9866      * given Intent.
9867      *
9868      * @param src The exact extras contained in this Intent are copied
9869      * into the target intent, replacing any that were previously there.
9870      */
replaceExtras(@onNull Intent src)9871     public @NonNull Intent replaceExtras(@NonNull Intent src) {
9872         mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9873         return this;
9874     }
9875 
9876     /**
9877      * Completely replace the extras in the Intent with the given Bundle of
9878      * extras.
9879      *
9880      * @param extras The new set of extras in the Intent, or null to erase
9881      * all extras.
9882      */
replaceExtras(@ullable Bundle extras)9883     public @NonNull Intent replaceExtras(@Nullable Bundle extras) {
9884         mExtras = extras != null ? new Bundle(extras) : null;
9885         return this;
9886     }
9887 
9888     /**
9889      * Remove extended data from the intent.
9890      *
9891      * @see #putExtra
9892      */
removeExtra(String name)9893     public void removeExtra(String name) {
9894         if (mExtras != null) {
9895             mExtras.remove(name);
9896             if (mExtras.size() == 0) {
9897                 mExtras = null;
9898             }
9899         }
9900     }
9901 
9902     /**
9903      * Set special flags controlling how this intent is handled.  Most values
9904      * here depend on the type of component being executed by the Intent,
9905      * specifically the FLAG_ACTIVITY_* flags are all for use with
9906      * {@link Context#startActivity Context.startActivity()} and the
9907      * FLAG_RECEIVER_* flags are all for use with
9908      * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9909      *
9910      * <p>See the
9911      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9912      * Stack</a> documentation for important information on how some of these options impact
9913      * the behavior of your application.
9914      *
9915      * @param flags The desired flags.
9916      * @return Returns the same Intent object, for chaining multiple calls
9917      * into a single statement.
9918      * @see #getFlags
9919      * @see #addFlags
9920      * @see #removeFlags
9921      */
setFlags(@lags int flags)9922     public @NonNull Intent setFlags(@Flags int flags) {
9923         mFlags = flags;
9924         return this;
9925     }
9926 
9927     /**
9928      * Add additional flags to the intent (or with existing flags value).
9929      *
9930      * @param flags The new flags to set.
9931      * @return Returns the same Intent object, for chaining multiple calls into
9932      *         a single statement.
9933      * @see #setFlags
9934      * @see #getFlags
9935      * @see #removeFlags
9936      */
addFlags(@lags int flags)9937     public @NonNull Intent addFlags(@Flags int flags) {
9938         mFlags |= flags;
9939         return this;
9940     }
9941 
9942     /**
9943      * Remove these flags from the intent.
9944      *
9945      * @param flags The flags to remove.
9946      * @see #setFlags
9947      * @see #getFlags
9948      * @see #addFlags
9949      */
removeFlags(@lags int flags)9950     public void removeFlags(@Flags int flags) {
9951         mFlags &= ~flags;
9952     }
9953 
9954     /**
9955      * (Usually optional) Set an explicit application package name that limits
9956      * the components this Intent will resolve to.  If left to the default
9957      * value of null, all components in all applications will considered.
9958      * If non-null, the Intent can only match the components in the given
9959      * application package.
9960      *
9961      * @param packageName The name of the application package to handle the
9962      * intent, or null to allow any application package.
9963      *
9964      * @return Returns the same Intent object, for chaining multiple calls
9965      * into a single statement.
9966      *
9967      * @see #getPackage
9968      * @see #resolveActivity
9969      */
setPackage(@ullable String packageName)9970     public @NonNull Intent setPackage(@Nullable String packageName) {
9971         if (packageName != null && mSelector != null) {
9972             throw new IllegalArgumentException(
9973                     "Can't set package name when selector is already set");
9974         }
9975         mPackage = packageName;
9976         return this;
9977     }
9978 
9979     /**
9980      * (Usually optional) Explicitly set the component to handle the intent.
9981      * If left with the default value of null, the system will determine the
9982      * appropriate class to use based on the other fields (action, data,
9983      * type, categories) in the Intent.  If this class is defined, the
9984      * specified class will always be used regardless of the other fields.  You
9985      * should only set this value when you know you absolutely want a specific
9986      * class to be used; otherwise it is better to let the system find the
9987      * appropriate class so that you will respect the installed applications
9988      * and user preferences.
9989      *
9990      * @param component The name of the application component to handle the
9991      * intent, or null to let the system find one for you.
9992      *
9993      * @return Returns the same Intent object, for chaining multiple calls
9994      * into a single statement.
9995      *
9996      * @see #setClass
9997      * @see #setClassName(Context, String)
9998      * @see #setClassName(String, String)
9999      * @see #getComponent
10000      * @see #resolveActivity
10001      */
setComponent(@ullable ComponentName component)10002     public @NonNull Intent setComponent(@Nullable ComponentName component) {
10003         mComponent = component;
10004         return this;
10005     }
10006 
10007     /**
10008      * Convenience for calling {@link #setComponent} with an
10009      * explicit class name.
10010      *
10011      * @param packageContext A Context of the application package implementing
10012      * this class.
10013      * @param className The name of a class inside of the application package
10014      * that will be used as the component for this Intent.
10015      *
10016      * @return Returns the same Intent object, for chaining multiple calls
10017      * into a single statement.
10018      *
10019      * @see #setComponent
10020      * @see #setClass
10021      */
setClassName(@onNull Context packageContext, @NonNull String className)10022     public @NonNull Intent setClassName(@NonNull Context packageContext,
10023             @NonNull String className) {
10024         mComponent = new ComponentName(packageContext, className);
10025         return this;
10026     }
10027 
10028     /**
10029      * Convenience for calling {@link #setComponent} with an
10030      * explicit application package name and class name.
10031      *
10032      * @param packageName The name of the package implementing the desired
10033      * component.
10034      * @param className The name of a class inside of the application package
10035      * that will be used as the component for this Intent.
10036      *
10037      * @return Returns the same Intent object, for chaining multiple calls
10038      * into a single statement.
10039      *
10040      * @see #setComponent
10041      * @see #setClass
10042      */
setClassName(@onNull String packageName, @NonNull String className)10043     public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
10044         mComponent = new ComponentName(packageName, className);
10045         return this;
10046     }
10047 
10048     /**
10049      * Convenience for calling {@link #setComponent(ComponentName)} with the
10050      * name returned by a {@link Class} object.
10051      *
10052      * @param packageContext A Context of the application package implementing
10053      * this class.
10054      * @param cls The class name to set, equivalent to
10055      *            <code>setClassName(context, cls.getName())</code>.
10056      *
10057      * @return Returns the same Intent object, for chaining multiple calls
10058      * into a single statement.
10059      *
10060      * @see #setComponent
10061      */
setClass(@onNull Context packageContext, @NonNull Class<?> cls)10062     public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
10063         mComponent = new ComponentName(packageContext, cls);
10064         return this;
10065     }
10066 
10067     /**
10068      * Set the bounds of the sender of this intent, in screen coordinates.  This can be
10069      * used as a hint to the receiver for animations and the like.  Null means that there
10070      * is no source bounds.
10071      */
setSourceBounds(@ullable Rect r)10072     public void setSourceBounds(@Nullable Rect r) {
10073         if (r != null) {
10074             mSourceBounds = new Rect(r);
10075         } else {
10076             mSourceBounds = null;
10077         }
10078     }
10079 
10080     /** @hide */
10081     @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
10082             FILL_IN_ACTION,
10083             FILL_IN_DATA,
10084             FILL_IN_CATEGORIES,
10085             FILL_IN_COMPONENT,
10086             FILL_IN_PACKAGE,
10087             FILL_IN_SOURCE_BOUNDS,
10088             FILL_IN_SELECTOR,
10089             FILL_IN_CLIP_DATA
10090     })
10091     @Retention(RetentionPolicy.SOURCE)
10092     public @interface FillInFlags {}
10093 
10094     /**
10095      * Use with {@link #fillIn} to allow the current action value to be
10096      * overwritten, even if it is already set.
10097      */
10098     public static final int FILL_IN_ACTION = 1<<0;
10099 
10100     /**
10101      * Use with {@link #fillIn} to allow the current data or type value
10102      * overwritten, even if it is already set.
10103      */
10104     public static final int FILL_IN_DATA = 1<<1;
10105 
10106     /**
10107      * Use with {@link #fillIn} to allow the current categories to be
10108      * overwritten, even if they are already set.
10109      */
10110     public static final int FILL_IN_CATEGORIES = 1<<2;
10111 
10112     /**
10113      * Use with {@link #fillIn} to allow the current component value to be
10114      * overwritten, even if it is already set.
10115      */
10116     public static final int FILL_IN_COMPONENT = 1<<3;
10117 
10118     /**
10119      * Use with {@link #fillIn} to allow the current package value to be
10120      * overwritten, even if it is already set.
10121      */
10122     public static final int FILL_IN_PACKAGE = 1<<4;
10123 
10124     /**
10125      * Use with {@link #fillIn} to allow the current bounds rectangle to be
10126      * overwritten, even if it is already set.
10127      */
10128     public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
10129 
10130     /**
10131      * Use with {@link #fillIn} to allow the current selector to be
10132      * overwritten, even if it is already set.
10133      */
10134     public static final int FILL_IN_SELECTOR = 1<<6;
10135 
10136     /**
10137      * Use with {@link #fillIn} to allow the current ClipData to be
10138      * overwritten, even if it is already set.
10139      */
10140     public static final int FILL_IN_CLIP_DATA = 1<<7;
10141 
10142     /**
10143      * Use with {@link #fillIn} to allow the current identifier value to be
10144      * overwritten, even if it is already set.
10145      */
10146     public static final int FILL_IN_IDENTIFIER = 1<<8;
10147 
10148     /**
10149      * Copy the contents of <var>other</var> in to this object, but only
10150      * where fields are not defined by this object.  For purposes of a field
10151      * being defined, the following pieces of data in the Intent are
10152      * considered to be separate fields:
10153      *
10154      * <ul>
10155      * <li> action, as set by {@link #setAction}.
10156      * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
10157      * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
10158      * <li> identifier, as set by {@link #setIdentifier}.
10159      * <li> categories, as set by {@link #addCategory}.
10160      * <li> package, as set by {@link #setPackage}.
10161      * <li> component, as set by {@link #setComponent(ComponentName)} or
10162      * related methods.
10163      * <li> source bounds, as set by {@link #setSourceBounds}.
10164      * <li> selector, as set by {@link #setSelector(Intent)}.
10165      * <li> clip data, as set by {@link #setClipData(ClipData)}.
10166      * <li> each top-level name in the associated extras.
10167      * </ul>
10168      *
10169      * <p>In addition, you can use the {@link #FILL_IN_ACTION},
10170      * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES},
10171      * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
10172      * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
10173      * the restriction where the corresponding field will not be replaced if
10174      * it is already set.
10175      *
10176      * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
10177      * is explicitly specified.  The selector will only be copied if
10178      * {@link #FILL_IN_SELECTOR} is explicitly specified.
10179      *
10180      * <p>For example, consider Intent A with {data="foo", categories="bar"}
10181      * and Intent B with {action="gotit", data-type="some/thing",
10182      * categories="one","two"}.
10183      *
10184      * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
10185      * containing: {action="gotit", data-type="some/thing",
10186      * categories="bar"}.
10187      *
10188      * @param other Another Intent whose values are to be used to fill in
10189      * the current one.
10190      * @param flags Options to control which fields can be filled in.
10191      *
10192      * @return Returns a bit mask of {@link #FILL_IN_ACTION},
10193      * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
10194      * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
10195      * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
10196      * changed.
10197      */
10198     @FillInFlags
fillIn(@onNull Intent other, @FillInFlags int flags)10199     public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
10200         int changes = 0;
10201         boolean mayHaveCopiedUris = false;
10202         if (other.mAction != null
10203                 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
10204             mAction = other.mAction;
10205             changes |= FILL_IN_ACTION;
10206         }
10207         if ((other.mData != null || other.mType != null)
10208                 && ((mData == null && mType == null)
10209                         || (flags&FILL_IN_DATA) != 0)) {
10210             mData = other.mData;
10211             mType = other.mType;
10212             changes |= FILL_IN_DATA;
10213             mayHaveCopiedUris = true;
10214         }
10215         if (other.mIdentifier != null
10216                 && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) {
10217             mIdentifier = other.mIdentifier;
10218             changes |= FILL_IN_IDENTIFIER;
10219         }
10220         if (other.mCategories != null
10221                 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
10222             if (other.mCategories != null) {
10223                 mCategories = new ArraySet<String>(other.mCategories);
10224             }
10225             changes |= FILL_IN_CATEGORIES;
10226         }
10227         if (other.mPackage != null
10228                 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
10229             // Only do this if mSelector is not set.
10230             if (mSelector == null) {
10231                 mPackage = other.mPackage;
10232                 changes |= FILL_IN_PACKAGE;
10233             }
10234         }
10235         // Selector is special: it can only be set if explicitly allowed,
10236         // for the same reason as the component name.
10237         if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
10238             if (mPackage == null) {
10239                 mSelector = new Intent(other.mSelector);
10240                 mPackage = null;
10241                 changes |= FILL_IN_SELECTOR;
10242             }
10243         }
10244         if (other.mClipData != null
10245                 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
10246             mClipData = other.mClipData;
10247             changes |= FILL_IN_CLIP_DATA;
10248             mayHaveCopiedUris = true;
10249         }
10250         // Component is special: it can -only- be set if explicitly allowed,
10251         // since otherwise the sender could force the intent somewhere the
10252         // originator didn't intend.
10253         if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
10254             mComponent = other.mComponent;
10255             changes |= FILL_IN_COMPONENT;
10256         }
10257         mFlags |= other.mFlags;
10258         if (other.mSourceBounds != null
10259                 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
10260             mSourceBounds = new Rect(other.mSourceBounds);
10261             changes |= FILL_IN_SOURCE_BOUNDS;
10262         }
10263         if (mExtras == null) {
10264             if (other.mExtras != null) {
10265                 mExtras = new Bundle(other.mExtras);
10266                 mayHaveCopiedUris = true;
10267             }
10268         } else if (other.mExtras != null) {
10269             try {
10270                 Bundle newb = new Bundle(other.mExtras);
10271                 newb.putAll(mExtras);
10272                 mExtras = newb;
10273                 mayHaveCopiedUris = true;
10274             } catch (RuntimeException e) {
10275                 // Modifying the extras can cause us to unparcel the contents
10276                 // of the bundle, and if we do this in the system process that
10277                 // may fail.  We really should handle this (i.e., the Bundle
10278                 // impl shouldn't be on top of a plain map), but for now just
10279                 // ignore it and keep the original contents. :(
10280                 Log.w(TAG, "Failure filling in extras", e);
10281             }
10282         }
10283         if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
10284                 && other.mContentUserHint != UserHandle.USER_CURRENT) {
10285             mContentUserHint = other.mContentUserHint;
10286         }
10287         return changes;
10288     }
10289 
10290     /**
10291      * Wrapper class holding an Intent and implementing comparisons on it for
10292      * the purpose of filtering.  The class implements its
10293      * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
10294      * simple calls to {@link Intent#filterEquals(Intent)}  filterEquals()} and
10295      * {@link android.content.Intent#filterHashCode()}  filterHashCode()}
10296      * on the wrapped Intent.
10297      */
10298     public static final class FilterComparison {
10299         private final Intent mIntent;
10300         private final int mHashCode;
10301 
FilterComparison(Intent intent)10302         public FilterComparison(Intent intent) {
10303             mIntent = intent;
10304             mHashCode = intent.filterHashCode();
10305         }
10306 
10307         /**
10308          * Return the Intent that this FilterComparison represents.
10309          * @return Returns the Intent held by the FilterComparison.  Do
10310          * not modify!
10311          */
getIntent()10312         public Intent getIntent() {
10313             return mIntent;
10314         }
10315 
10316         @Override
equals(Object obj)10317         public boolean equals(Object obj) {
10318             if (obj instanceof FilterComparison) {
10319                 Intent other = ((FilterComparison)obj).mIntent;
10320                 return mIntent.filterEquals(other);
10321             }
10322             return false;
10323         }
10324 
10325         @Override
hashCode()10326         public int hashCode() {
10327             return mHashCode;
10328         }
10329     }
10330 
10331     /**
10332      * Determine if two intents are the same for the purposes of intent
10333      * resolution (filtering). That is, if their action, data, type, identity,
10334      * class, and categories are the same.  This does <em>not</em> compare
10335      * any extra data included in the intents.  Note that technically when actually
10336      * matching against an {@link IntentFilter} the identifier is ignored, while here
10337      * it is directly compared for equality like the other fields.
10338      *
10339      * @param other The other Intent to compare against.
10340      *
10341      * @return Returns true if action, data, type, class, and categories
10342      *         are the same.
10343      */
filterEquals(Intent other)10344     public boolean filterEquals(Intent other) {
10345         if (other == null) {
10346             return false;
10347         }
10348         if (!Objects.equals(this.mAction, other.mAction)) return false;
10349         if (!Objects.equals(this.mData, other.mData)) return false;
10350         if (!Objects.equals(this.mType, other.mType)) return false;
10351         if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false;
10352         if (!(this.hasPackageEquivalentComponent() && other.hasPackageEquivalentComponent())
10353                 && !Objects.equals(this.mPackage, other.mPackage)) {
10354             return false;
10355         }
10356         if (!Objects.equals(this.mComponent, other.mComponent)) return false;
10357         if (!Objects.equals(this.mCategories, other.mCategories)) return false;
10358 
10359         return true;
10360     }
10361 
10362     /**
10363      * Return {@code true} if the component name is not null and is in the same package that this
10364      * intent limited to. otherwise return {@code false}.
10365      */
hasPackageEquivalentComponent()10366     private boolean hasPackageEquivalentComponent() {
10367         return mComponent != null
10368             && (mPackage == null || mPackage.equals(mComponent.getPackageName()));
10369     }
10370 
10371     /**
10372      * Generate hash code that matches semantics of filterEquals().
10373      *
10374      * @return Returns the hash value of the action, data, type, class, and
10375      *         categories.
10376      *
10377      * @see #filterEquals
10378      */
filterHashCode()10379     public int filterHashCode() {
10380         int code = 0;
10381         if (mAction != null) {
10382             code += mAction.hashCode();
10383         }
10384         if (mData != null) {
10385             code += mData.hashCode();
10386         }
10387         if (mType != null) {
10388             code += mType.hashCode();
10389         }
10390         if (mIdentifier != null) {
10391             code += mIdentifier.hashCode();
10392         }
10393         if (mPackage != null) {
10394             code += mPackage.hashCode();
10395         }
10396         if (mComponent != null) {
10397             code += mComponent.hashCode();
10398         }
10399         if (mCategories != null) {
10400             code += mCategories.hashCode();
10401         }
10402         return code;
10403     }
10404 
10405     @Override
toString()10406     public String toString() {
10407         StringBuilder b = new StringBuilder(128);
10408 
10409         b.append("Intent { ");
10410         toShortString(b, true, true, true, false);
10411         b.append(" }");
10412 
10413         return b.toString();
10414     }
10415 
10416     /** @hide */
10417     @UnsupportedAppUsage
toInsecureString()10418     public String toInsecureString() {
10419         StringBuilder b = new StringBuilder(128);
10420 
10421         b.append("Intent { ");
10422         toShortString(b, false, true, true, false);
10423         b.append(" }");
10424 
10425         return b.toString();
10426     }
10427 
10428     /** @hide */
toInsecureStringWithClip()10429     public String toInsecureStringWithClip() {
10430         StringBuilder b = new StringBuilder(128);
10431 
10432         b.append("Intent { ");
10433         toShortString(b, false, true, true, true);
10434         b.append(" }");
10435 
10436         return b.toString();
10437     }
10438 
10439     /** @hide */
toShortString(boolean secure, boolean comp, boolean extras, boolean clip)10440     public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
10441         StringBuilder b = new StringBuilder(128);
10442         toShortString(b, secure, comp, extras, clip);
10443         return b.toString();
10444     }
10445 
10446     /** @hide */
toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, boolean clip)10447     public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
10448             boolean clip) {
10449         boolean first = true;
10450         if (mAction != null) {
10451             b.append("act=").append(mAction);
10452             first = false;
10453         }
10454         if (mCategories != null) {
10455             if (!first) {
10456                 b.append(' ');
10457             }
10458             first = false;
10459             b.append("cat=[");
10460             for (int i=0; i<mCategories.size(); i++) {
10461                 if (i > 0) b.append(',');
10462                 b.append(mCategories.valueAt(i));
10463             }
10464             b.append("]");
10465         }
10466         if (mData != null) {
10467             if (!first) {
10468                 b.append(' ');
10469             }
10470             first = false;
10471             b.append("dat=");
10472             if (secure) {
10473                 b.append(mData.toSafeString());
10474             } else {
10475                 b.append(mData);
10476             }
10477         }
10478         if (mType != null) {
10479             if (!first) {
10480                 b.append(' ');
10481             }
10482             first = false;
10483             b.append("typ=").append(mType);
10484         }
10485         if (mIdentifier != null) {
10486             if (!first) {
10487                 b.append(' ');
10488             }
10489             first = false;
10490             b.append("id=").append(mIdentifier);
10491         }
10492         if (mFlags != 0) {
10493             if (!first) {
10494                 b.append(' ');
10495             }
10496             first = false;
10497             b.append("flg=0x").append(Integer.toHexString(mFlags));
10498         }
10499         if (mPackage != null) {
10500             if (!first) {
10501                 b.append(' ');
10502             }
10503             first = false;
10504             b.append("pkg=").append(mPackage);
10505         }
10506         if (comp && mComponent != null) {
10507             if (!first) {
10508                 b.append(' ');
10509             }
10510             first = false;
10511             b.append("cmp=").append(mComponent.flattenToShortString());
10512         }
10513         if (mSourceBounds != null) {
10514             if (!first) {
10515                 b.append(' ');
10516             }
10517             first = false;
10518             b.append("bnds=").append(mSourceBounds.toShortString());
10519         }
10520         if (mClipData != null) {
10521             if (!first) {
10522                 b.append(' ');
10523             }
10524             b.append("clip={");
10525             if (clip) {
10526                 mClipData.toShortString(b);
10527             } else {
10528                 if (mClipData.getDescription() != null) {
10529                     first = !mClipData.getDescription().toShortStringTypesOnly(b);
10530                 } else {
10531                     first = true;
10532                 }
10533                 mClipData.toShortStringShortItems(b, first);
10534             }
10535             first = false;
10536             b.append('}');
10537         }
10538         if (extras && mExtras != null) {
10539             if (!first) {
10540                 b.append(' ');
10541             }
10542             first = false;
10543             b.append("(has extras)");
10544         }
10545         if (mContentUserHint != UserHandle.USER_CURRENT) {
10546             if (!first) {
10547                 b.append(' ');
10548             }
10549             first = false;
10550             b.append("u=").append(mContentUserHint);
10551         }
10552         if (mSelector != null) {
10553             b.append(" sel=");
10554             mSelector.toShortString(b, secure, comp, extras, clip);
10555             b.append("}");
10556         }
10557     }
10558 
10559     /** @hide */
dumpDebug(ProtoOutputStream proto, long fieldId)10560     public void dumpDebug(ProtoOutputStream proto, long fieldId) {
10561         // Same input parameters that toString() gives to toShortString().
10562         dumpDebug(proto, fieldId, true, true, true, false);
10563     }
10564 
10565     /** @hide */
dumpDebug(ProtoOutputStream proto)10566     public void dumpDebug(ProtoOutputStream proto) {
10567         // Same input parameters that toString() gives to toShortString().
10568         dumpDebugWithoutFieldId(proto, true, true, true, false);
10569     }
10570 
10571     /** @hide */
dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, boolean extras, boolean clip)10572     public void dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
10573             boolean extras, boolean clip) {
10574         long token = proto.start(fieldId);
10575         dumpDebugWithoutFieldId(proto, secure, comp, extras, clip);
10576         proto.end(token);
10577     }
10578 
dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, boolean extras, boolean clip)10579     private void dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp,
10580             boolean extras, boolean clip) {
10581         if (mAction != null) {
10582             proto.write(IntentProto.ACTION, mAction);
10583         }
10584         if (mCategories != null)  {
10585             for (String category : mCategories) {
10586                 proto.write(IntentProto.CATEGORIES, category);
10587             }
10588         }
10589         if (mData != null) {
10590             proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
10591         }
10592         if (mType != null) {
10593             proto.write(IntentProto.TYPE, mType);
10594         }
10595         if (mIdentifier != null) {
10596             proto.write(IntentProto.IDENTIFIER, mIdentifier);
10597         }
10598         if (mFlags != 0) {
10599             proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
10600         }
10601         if (mPackage != null) {
10602             proto.write(IntentProto.PACKAGE, mPackage);
10603         }
10604         if (comp && mComponent != null) {
10605             mComponent.dumpDebug(proto, IntentProto.COMPONENT);
10606         }
10607         if (mSourceBounds != null) {
10608             proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
10609         }
10610         if (mClipData != null) {
10611             StringBuilder b = new StringBuilder();
10612             if (clip) {
10613                 mClipData.toShortString(b);
10614             } else {
10615                 mClipData.toShortStringShortItems(b, false);
10616             }
10617             proto.write(IntentProto.CLIP_DATA, b.toString());
10618         }
10619         if (extras && mExtras != null) {
10620             proto.write(IntentProto.EXTRAS, mExtras.toShortString());
10621         }
10622         if (mContentUserHint != 0) {
10623             proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
10624         }
10625         if (mSelector != null) {
10626             proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
10627         }
10628     }
10629 
10630     /**
10631      * Call {@link #toUri} with 0 flags.
10632      * @deprecated Use {@link #toUri} instead.
10633      */
10634     @Deprecated
toURI()10635     public String toURI() {
10636         return toUri(0);
10637     }
10638 
10639     /**
10640      * Convert this Intent into a String holding a URI representation of it.
10641      * The returned URI string has been properly URI encoded, so it can be
10642      * used with {@link Uri#parse Uri.parse(String)}.  The URI contains the
10643      * Intent's data as the base URI, with an additional fragment describing
10644      * the action, categories, type, flags, package, component, and extras.
10645      *
10646      * <p>You can convert the returned string back to an Intent with
10647      * {@link #getIntent}.
10648      *
10649      * @param flags Additional operating flags.
10650      *
10651      * @return Returns a URI encoding URI string describing the entire contents
10652      * of the Intent.
10653      */
toUri(@riFlags int flags)10654     public String toUri(@UriFlags int flags) {
10655         StringBuilder uri = new StringBuilder(128);
10656         if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
10657             if (mPackage == null) {
10658                 throw new IllegalArgumentException(
10659                         "Intent must include an explicit package name to build an android-app: "
10660                         + this);
10661             }
10662             uri.append("android-app://");
10663             uri.append(mPackage);
10664             String scheme = null;
10665             if (mData != null) {
10666                 scheme = mData.getScheme();
10667                 if (scheme != null) {
10668                     uri.append('/');
10669                     uri.append(scheme);
10670                     String authority = mData.getEncodedAuthority();
10671                     if (authority != null) {
10672                         uri.append('/');
10673                         uri.append(authority);
10674                         String path = mData.getEncodedPath();
10675                         if (path != null) {
10676                             uri.append(path);
10677                         }
10678                         String queryParams = mData.getEncodedQuery();
10679                         if (queryParams != null) {
10680                             uri.append('?');
10681                             uri.append(queryParams);
10682                         }
10683                         String fragment = mData.getEncodedFragment();
10684                         if (fragment != null) {
10685                             uri.append('#');
10686                             uri.append(fragment);
10687                         }
10688                     }
10689                 }
10690             }
10691             toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
10692                     mPackage, flags);
10693             return uri.toString();
10694         }
10695         String scheme = null;
10696         if (mData != null) {
10697             String data = mData.toString();
10698             if ((flags&URI_INTENT_SCHEME) != 0) {
10699                 final int N = data.length();
10700                 for (int i=0; i<N; i++) {
10701                     char c = data.charAt(i);
10702                     if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
10703                             || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
10704                         continue;
10705                     }
10706                     if (c == ':' && i > 0) {
10707                         // Valid scheme.
10708                         scheme = data.substring(0, i);
10709                         uri.append("intent:");
10710                         data = data.substring(i+1);
10711                         break;
10712                     }
10713 
10714                     // No scheme.
10715                     break;
10716                 }
10717             }
10718             uri.append(data);
10719 
10720         } else if ((flags&URI_INTENT_SCHEME) != 0) {
10721             uri.append("intent:");
10722         }
10723 
10724         toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
10725 
10726         return uri.toString();
10727     }
10728 
toUriFragment(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)10729     private void toUriFragment(StringBuilder uri, String scheme, String defAction,
10730             String defPackage, int flags) {
10731         StringBuilder frag = new StringBuilder(128);
10732 
10733         toUriInner(frag, scheme, defAction, defPackage, flags);
10734         if (mSelector != null) {
10735             frag.append("SEL;");
10736             // Note that for now we are not going to try to handle the
10737             // data part; not clear how to represent this as a URI, and
10738             // not much utility in it.
10739             mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
10740                     null, null, flags);
10741         }
10742 
10743         if (frag.length() > 0) {
10744             uri.append("#Intent;");
10745             uri.append(frag);
10746             uri.append("end");
10747         }
10748     }
10749 
toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)10750     private void toUriInner(StringBuilder uri, String scheme, String defAction,
10751             String defPackage, int flags) {
10752         if (scheme != null) {
10753             uri.append("scheme=").append(scheme).append(';');
10754         }
10755         if (mAction != null && !mAction.equals(defAction)) {
10756             uri.append("action=").append(Uri.encode(mAction)).append(';');
10757         }
10758         if (mCategories != null) {
10759             for (int i=0; i<mCategories.size(); i++) {
10760                 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
10761             }
10762         }
10763         if (mType != null) {
10764             uri.append("type=").append(Uri.encode(mType, "/")).append(';');
10765         }
10766         if (mIdentifier != null) {
10767             uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';');
10768         }
10769         if (mFlags != 0) {
10770             uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
10771         }
10772         if (mPackage != null && !mPackage.equals(defPackage)) {
10773             uri.append("package=").append(Uri.encode(mPackage)).append(';');
10774         }
10775         if (mComponent != null) {
10776             uri.append("component=").append(Uri.encode(
10777                     mComponent.flattenToShortString(), "/")).append(';');
10778         }
10779         if (mSourceBounds != null) {
10780             uri.append("sourceBounds=")
10781                     .append(Uri.encode(mSourceBounds.flattenToString()))
10782                     .append(';');
10783         }
10784         if (mExtras != null) {
10785             for (String key : mExtras.keySet()) {
10786                 final Object value = mExtras.get(key);
10787                 char entryType =
10788                         value instanceof String    ? 'S' :
10789                         value instanceof Boolean   ? 'B' :
10790                         value instanceof Byte      ? 'b' :
10791                         value instanceof Character ? 'c' :
10792                         value instanceof Double    ? 'd' :
10793                         value instanceof Float     ? 'f' :
10794                         value instanceof Integer   ? 'i' :
10795                         value instanceof Long      ? 'l' :
10796                         value instanceof Short     ? 's' :
10797                         '\0';
10798 
10799                 if (entryType != '\0') {
10800                     uri.append(entryType);
10801                     uri.append('.');
10802                     uri.append(Uri.encode(key));
10803                     uri.append('=');
10804                     uri.append(Uri.encode(value.toString()));
10805                     uri.append(';');
10806                 }
10807             }
10808         }
10809     }
10810 
describeContents()10811     public int describeContents() {
10812         return (mExtras != null) ? mExtras.describeContents() : 0;
10813     }
10814 
writeToParcel(Parcel out, int flags)10815     public void writeToParcel(Parcel out, int flags) {
10816         out.writeString8(mAction);
10817         Uri.writeToParcel(out, mData);
10818         out.writeString8(mType);
10819         out.writeString8(mIdentifier);
10820         out.writeInt(mFlags);
10821         out.writeString8(mPackage);
10822         ComponentName.writeToParcel(mComponent, out);
10823 
10824         if (mSourceBounds != null) {
10825             out.writeInt(1);
10826             mSourceBounds.writeToParcel(out, flags);
10827         } else {
10828             out.writeInt(0);
10829         }
10830 
10831         if (mCategories != null) {
10832             final int N = mCategories.size();
10833             out.writeInt(N);
10834             for (int i=0; i<N; i++) {
10835                 out.writeString8(mCategories.valueAt(i));
10836             }
10837         } else {
10838             out.writeInt(0);
10839         }
10840 
10841         if (mSelector != null) {
10842             out.writeInt(1);
10843             mSelector.writeToParcel(out, flags);
10844         } else {
10845             out.writeInt(0);
10846         }
10847 
10848         if (mClipData != null) {
10849             out.writeInt(1);
10850             mClipData.writeToParcel(out, flags);
10851         } else {
10852             out.writeInt(0);
10853         }
10854         out.writeInt(mContentUserHint);
10855         out.writeBundle(mExtras);
10856     }
10857 
10858     public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR
10859             = new Parcelable.Creator<Intent>() {
10860         public Intent createFromParcel(Parcel in) {
10861             return new Intent(in);
10862         }
10863         public Intent[] newArray(int size) {
10864             return new Intent[size];
10865         }
10866     };
10867 
10868     /** @hide */
Intent(Parcel in)10869     protected Intent(Parcel in) {
10870         readFromParcel(in);
10871     }
10872 
readFromParcel(Parcel in)10873     public void readFromParcel(Parcel in) {
10874         setAction(in.readString8());
10875         mData = Uri.CREATOR.createFromParcel(in);
10876         mType = in.readString8();
10877         mIdentifier = in.readString8();
10878         mFlags = in.readInt();
10879         mPackage = in.readString8();
10880         mComponent = ComponentName.readFromParcel(in);
10881 
10882         if (in.readInt() != 0) {
10883             mSourceBounds = Rect.CREATOR.createFromParcel(in);
10884         }
10885 
10886         int N = in.readInt();
10887         if (N > 0) {
10888             mCategories = new ArraySet<String>();
10889             int i;
10890             for (i=0; i<N; i++) {
10891                 mCategories.add(in.readString8().intern());
10892             }
10893         } else {
10894             mCategories = null;
10895         }
10896 
10897         if (in.readInt() != 0) {
10898             mSelector = new Intent(in);
10899         }
10900 
10901         if (in.readInt() != 0) {
10902             mClipData = new ClipData(in);
10903         }
10904         mContentUserHint = in.readInt();
10905         mExtras = in.readBundle();
10906     }
10907 
10908     /**
10909      * Parses the "intent" element (and its children) from XML and instantiates
10910      * an Intent object.  The given XML parser should be located at the tag
10911      * where parsing should start (often named "intent"), from which the
10912      * basic action, data, type, and package and class name will be
10913      * retrieved.  The function will then parse in to any child elements,
10914      * looking for <category android:name="xxx"> tags to add categories and
10915      * <extra android:name="xxx" android:value="yyy"> to attach extra data
10916      * to the intent.
10917      *
10918      * @param resources The Resources to use when inflating resources.
10919      * @param parser The XML parser pointing at an "intent" tag.
10920      * @param attrs The AttributeSet interface for retrieving extended
10921      * attribute data at the current <var>parser</var> location.
10922      * @return An Intent object matching the XML data.
10923      * @throws XmlPullParserException If there was an XML parsing error.
10924      * @throws IOException If there was an I/O error.
10925      */
parseIntent(@onNull Resources resources, @NonNull XmlPullParser parser, AttributeSet attrs)10926     public static @NonNull Intent parseIntent(@NonNull Resources resources,
10927             @NonNull XmlPullParser parser, AttributeSet attrs)
10928             throws XmlPullParserException, IOException {
10929         Intent intent = new Intent();
10930 
10931         TypedArray sa = resources.obtainAttributes(attrs,
10932                 com.android.internal.R.styleable.Intent);
10933 
10934         intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10935 
10936         String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10937         String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10938         intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10939 
10940         intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier));
10941 
10942         String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10943         String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10944         if (packageName != null && className != null) {
10945             intent.setComponent(new ComponentName(packageName, className));
10946         }
10947 
10948         sa.recycle();
10949 
10950         int outerDepth = parser.getDepth();
10951         int type;
10952         while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10953                && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10954             if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10955                 continue;
10956             }
10957 
10958             String nodeName = parser.getName();
10959             if (nodeName.equals(TAG_CATEGORIES)) {
10960                 sa = resources.obtainAttributes(attrs,
10961                         com.android.internal.R.styleable.IntentCategory);
10962                 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10963                 sa.recycle();
10964 
10965                 if (cat != null) {
10966                     intent.addCategory(cat);
10967                 }
10968                 XmlUtils.skipCurrentTag(parser);
10969 
10970             } else if (nodeName.equals(TAG_EXTRA)) {
10971                 if (intent.mExtras == null) {
10972                     intent.mExtras = new Bundle();
10973                 }
10974                 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
10975                 XmlUtils.skipCurrentTag(parser);
10976 
10977             } else {
10978                 XmlUtils.skipCurrentTag(parser);
10979             }
10980         }
10981 
10982         return intent;
10983     }
10984 
10985     /** @hide */
saveToXml(XmlSerializer out)10986     public void saveToXml(XmlSerializer out) throws IOException {
10987         if (mAction != null) {
10988             out.attribute(null, ATTR_ACTION, mAction);
10989         }
10990         if (mData != null) {
10991             out.attribute(null, ATTR_DATA, mData.toString());
10992         }
10993         if (mType != null) {
10994             out.attribute(null, ATTR_TYPE, mType);
10995         }
10996         if (mIdentifier != null) {
10997             out.attribute(null, ATTR_IDENTIFIER, mIdentifier);
10998         }
10999         if (mComponent != null) {
11000             out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
11001         }
11002         out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
11003 
11004         if (mCategories != null) {
11005             out.startTag(null, TAG_CATEGORIES);
11006             for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
11007                 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
11008             }
11009             out.endTag(null, TAG_CATEGORIES);
11010         }
11011     }
11012 
11013     /** @hide */
restoreFromXml(XmlPullParser in)11014     public static Intent restoreFromXml(XmlPullParser in) throws IOException,
11015             XmlPullParserException {
11016         Intent intent = new Intent();
11017         final int outerDepth = in.getDepth();
11018 
11019         int attrCount = in.getAttributeCount();
11020         for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
11021             final String attrName = in.getAttributeName(attrNdx);
11022             final String attrValue = in.getAttributeValue(attrNdx);
11023             if (ATTR_ACTION.equals(attrName)) {
11024                 intent.setAction(attrValue);
11025             } else if (ATTR_DATA.equals(attrName)) {
11026                 intent.setData(Uri.parse(attrValue));
11027             } else if (ATTR_TYPE.equals(attrName)) {
11028                 intent.setType(attrValue);
11029             } else if (ATTR_IDENTIFIER.equals(attrName)) {
11030                 intent.setIdentifier(attrValue);
11031             } else if (ATTR_COMPONENT.equals(attrName)) {
11032                 intent.setComponent(ComponentName.unflattenFromString(attrValue));
11033             } else if (ATTR_FLAGS.equals(attrName)) {
11034                 intent.setFlags(Integer.parseInt(attrValue, 16));
11035             } else {
11036                 Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName);
11037             }
11038         }
11039 
11040         int event;
11041         String name;
11042         while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
11043                 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
11044             if (event == XmlPullParser.START_TAG) {
11045                 name = in.getName();
11046                 if (TAG_CATEGORIES.equals(name)) {
11047                     attrCount = in.getAttributeCount();
11048                     for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
11049                         intent.addCategory(in.getAttributeValue(attrNdx));
11050                     }
11051                 } else {
11052                     Log.w(TAG, "restoreFromXml: unknown name=" + name);
11053                     XmlUtils.skipCurrentTag(in);
11054                 }
11055             }
11056         }
11057 
11058         return intent;
11059     }
11060 
11061     /**
11062      * Normalize a MIME data type.
11063      *
11064      * <p>A normalized MIME type has white-space trimmed,
11065      * content-type parameters removed, and is lower-case.
11066      * This aligns the type with Android best practices for
11067      * intent filtering.
11068      *
11069      * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
11070      * "text/x-vCard" becomes "text/x-vcard".
11071      *
11072      * <p>All MIME types received from outside Android (such as user input,
11073      * or external sources like Bluetooth, NFC, or the Internet) should
11074      * be normalized before they are used to create an Intent.
11075      *
11076      * @param type MIME data type to normalize
11077      * @return normalized MIME data type, or null if the input was null
11078      * @see #setType
11079      * @see #setTypeAndNormalize
11080      */
normalizeMimeType(@ullable String type)11081     public static @Nullable String normalizeMimeType(@Nullable String type) {
11082         if (type == null) {
11083             return null;
11084         }
11085 
11086         type = type.trim().toLowerCase(Locale.ROOT);
11087 
11088         final int semicolonIndex = type.indexOf(';');
11089         if (semicolonIndex != -1) {
11090             type = type.substring(0, semicolonIndex);
11091         }
11092         return type;
11093     }
11094 
11095     /**
11096      * Prepare this {@link Intent} to leave an app process.
11097      *
11098      * @hide
11099      */
11100     @UnsupportedAppUsage
prepareToLeaveProcess(Context context)11101     public void prepareToLeaveProcess(Context context) {
11102         final boolean leavingPackage = (mComponent == null)
11103                 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
11104         prepareToLeaveProcess(leavingPackage);
11105     }
11106 
11107     /**
11108      * Prepare this {@link Intent} to leave an app process.
11109      *
11110      * @hide
11111      */
prepareToLeaveProcess(boolean leavingPackage)11112     public void prepareToLeaveProcess(boolean leavingPackage) {
11113         setAllowFds(false);
11114 
11115         if (mSelector != null) {
11116             mSelector.prepareToLeaveProcess(leavingPackage);
11117         }
11118         if (mClipData != null) {
11119             mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
11120         }
11121 
11122         if (mExtras != null && !mExtras.isParcelled()) {
11123             final Object intent = mExtras.get(Intent.EXTRA_INTENT);
11124             if (intent instanceof Intent) {
11125                 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
11126             }
11127         }
11128 
11129         if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
11130                 && leavingPackage) {
11131             switch (mAction) {
11132                 case ACTION_MEDIA_REMOVED:
11133                 case ACTION_MEDIA_UNMOUNTED:
11134                 case ACTION_MEDIA_CHECKING:
11135                 case ACTION_MEDIA_NOFS:
11136                 case ACTION_MEDIA_MOUNTED:
11137                 case ACTION_MEDIA_SHARED:
11138                 case ACTION_MEDIA_UNSHARED:
11139                 case ACTION_MEDIA_BAD_REMOVAL:
11140                 case ACTION_MEDIA_UNMOUNTABLE:
11141                 case ACTION_MEDIA_EJECT:
11142                 case ACTION_MEDIA_SCANNER_STARTED:
11143                 case ACTION_MEDIA_SCANNER_FINISHED:
11144                 case ACTION_MEDIA_SCANNER_SCAN_FILE:
11145                 case ACTION_PACKAGE_NEEDS_VERIFICATION:
11146                 case ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION:
11147                 case ACTION_PACKAGE_VERIFIED:
11148                 case ACTION_PACKAGE_ENABLE_ROLLBACK:
11149                     // Ignore legacy actions
11150                     break;
11151                 default:
11152                     mData.checkFileUriExposed("Intent.getData()");
11153             }
11154         }
11155 
11156         if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
11157                 && leavingPackage) {
11158             switch (mAction) {
11159                 case ACTION_PROVIDER_CHANGED:
11160                 case QuickContact.ACTION_QUICK_CONTACT:
11161                     // Ignore actions that don't need to grant
11162                     break;
11163                 default:
11164                     mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
11165             }
11166         }
11167 
11168         // Translate raw filesystem paths out of storage sandbox
11169         if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null
11170                 && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) {
11171             final StorageManager sm = AppGlobals.getInitialApplication()
11172                     .getSystemService(StorageManager.class);
11173             final File before = new File(mData.getPath());
11174             final File after = sm.translateAppToSystem(before,
11175                     android.os.Process.myPid(), android.os.Process.myUid());
11176             if (!Objects.equals(before, after)) {
11177                 Log.v(TAG, "Translated " + before + " to " + after);
11178                 mData = Uri.fromFile(after);
11179             }
11180         }
11181     }
11182 
11183     /**
11184      * @hide
11185      */
prepareToEnterProcess()11186     public void prepareToEnterProcess() {
11187         // We just entered destination process, so we should be able to read all
11188         // parcelables inside.
11189         setDefusable(true);
11190 
11191         if (mSelector != null) {
11192             mSelector.prepareToEnterProcess();
11193         }
11194         if (mClipData != null) {
11195             mClipData.prepareToEnterProcess();
11196         }
11197 
11198         if (mContentUserHint != UserHandle.USER_CURRENT) {
11199             if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
11200                 fixUris(mContentUserHint);
11201                 mContentUserHint = UserHandle.USER_CURRENT;
11202             }
11203         }
11204     }
11205 
11206     /** @hide */
hasWebURI()11207     public boolean hasWebURI() {
11208         if (getData() == null) {
11209             return false;
11210         }
11211         final String scheme = getScheme();
11212         if (TextUtils.isEmpty(scheme)) {
11213             return false;
11214         }
11215         return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
11216     }
11217 
11218     /** @hide */
isWebIntent()11219     public boolean isWebIntent() {
11220         return ACTION_VIEW.equals(mAction)
11221                 && hasWebURI();
11222     }
11223 
isImageCaptureIntent()11224     private boolean isImageCaptureIntent() {
11225         return (MediaStore.ACTION_IMAGE_CAPTURE.equals(mAction)
11226                 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(mAction)
11227                 || MediaStore.ACTION_VIDEO_CAPTURE.equals(mAction));
11228     }
11229 
11230     /** @hide */
isImplicitImageCaptureIntent()11231     public boolean isImplicitImageCaptureIntent() {
11232         return mPackage == null && mComponent == null && isImageCaptureIntent();
11233     }
11234 
11235     /**
11236      * @hide
11237      */
fixUris(int contentUserHint)11238      public void fixUris(int contentUserHint) {
11239         Uri data = getData();
11240         if (data != null) {
11241             mData = maybeAddUserId(data, contentUserHint);
11242         }
11243         if (mClipData != null) {
11244             mClipData.fixUris(contentUserHint);
11245         }
11246         String action = getAction();
11247         if (ACTION_SEND.equals(action)) {
11248             final Uri stream = getParcelableExtra(EXTRA_STREAM);
11249             if (stream != null) {
11250                 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
11251             }
11252         } else if (ACTION_SEND_MULTIPLE.equals(action)) {
11253             final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
11254             if (streams != null) {
11255                 ArrayList<Uri> newStreams = new ArrayList<Uri>();
11256                 for (int i = 0; i < streams.size(); i++) {
11257                     newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
11258                 }
11259                 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
11260             }
11261         } else if (isImageCaptureIntent()) {
11262             final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
11263             if (output != null) {
11264                 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
11265             }
11266         }
11267      }
11268 
11269     /**
11270      * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
11271      * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
11272      * intents in {@link #ACTION_CHOOSER}.
11273      *
11274      * @return Whether any contents were migrated.
11275      * @hide
11276      */
migrateExtraStreamToClipData()11277     public boolean migrateExtraStreamToClipData() {
11278         return migrateExtraStreamToClipData(AppGlobals.getInitialApplication());
11279     }
11280 
11281     /**
11282      * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
11283      * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
11284      * intents in {@link #ACTION_CHOOSER}.
11285      *
11286      * @param context app context
11287      * @return Whether any contents were migrated.
11288      * @hide
11289      */
migrateExtraStreamToClipData(Context context)11290     public boolean migrateExtraStreamToClipData(Context context) {
11291         // Refuse to touch if extras already parcelled
11292         if (mExtras != null && mExtras.isParcelled()) return false;
11293 
11294         // Bail when someone already gave us ClipData
11295         if (getClipData() != null) return false;
11296 
11297         final String action = getAction();
11298         if (ACTION_CHOOSER.equals(action)) {
11299             // Inspect contained intents to see if we need to migrate extras. We
11300             // don't promote ClipData to the parent, since ChooserActivity will
11301             // already start the picked item as the caller, and we can't combine
11302             // the flags in a safe way.
11303 
11304             boolean migrated = false;
11305             try {
11306                 final Intent intent = getParcelableExtra(EXTRA_INTENT);
11307                 if (intent != null) {
11308                     migrated |= intent.migrateExtraStreamToClipData(context);
11309                 }
11310             } catch (ClassCastException e) {
11311             }
11312             try {
11313                 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
11314                 if (intents != null) {
11315                     for (int i = 0; i < intents.length; i++) {
11316                         final Intent intent = (Intent) intents[i];
11317                         if (intent != null) {
11318                             migrated |= intent.migrateExtraStreamToClipData(context);
11319                         }
11320                     }
11321                 }
11322             } catch (ClassCastException e) {
11323             }
11324             return migrated;
11325 
11326         } else if (ACTION_SEND.equals(action)) {
11327             try {
11328                 final Uri stream = getParcelableExtra(EXTRA_STREAM);
11329                 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
11330                 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
11331                 if (stream != null || text != null || htmlText != null) {
11332                     final ClipData clipData = new ClipData(
11333                             null, new String[] { getType() },
11334                             new ClipData.Item(text, htmlText, null, stream));
11335                     setClipData(clipData);
11336                     addFlags(FLAG_GRANT_READ_URI_PERMISSION);
11337                     return true;
11338                 }
11339             } catch (ClassCastException e) {
11340             }
11341 
11342         } else if (ACTION_SEND_MULTIPLE.equals(action)) {
11343             try {
11344                 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
11345                 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
11346                 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
11347                 int num = -1;
11348                 if (streams != null) {
11349                     num = streams.size();
11350                 }
11351                 if (texts != null) {
11352                     if (num >= 0 && num != texts.size()) {
11353                         // Wha...!  F- you.
11354                         return false;
11355                     }
11356                     num = texts.size();
11357                 }
11358                 if (htmlTexts != null) {
11359                     if (num >= 0 && num != htmlTexts.size()) {
11360                         // Wha...!  F- you.
11361                         return false;
11362                     }
11363                     num = htmlTexts.size();
11364                 }
11365                 if (num > 0) {
11366                     final ClipData clipData = new ClipData(
11367                             null, new String[] { getType() },
11368                             makeClipItem(streams, texts, htmlTexts, 0));
11369 
11370                     for (int i = 1; i < num; i++) {
11371                         clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
11372                     }
11373 
11374                     setClipData(clipData);
11375                     addFlags(FLAG_GRANT_READ_URI_PERMISSION);
11376                     return true;
11377                 }
11378             } catch (ClassCastException e) {
11379             }
11380         } else if (isImageCaptureIntent()) {
11381             Uri output;
11382             try {
11383                 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
11384             } catch (ClassCastException e) {
11385                 return false;
11386             }
11387 
11388             if (output != null) {
11389                 output = maybeConvertFileToContentUri(context, output);
11390                 putExtra(MediaStore.EXTRA_OUTPUT, output);
11391 
11392                 setClipData(ClipData.newRawUri("", output));
11393                 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
11394                 return true;
11395             }
11396         }
11397 
11398         return false;
11399     }
11400 
maybeConvertFileToContentUri(Context context, Uri uri)11401     private Uri maybeConvertFileToContentUri(Context context, Uri uri) {
11402         if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())
11403                 && context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.R) {
11404             File file = new File(uri.getPath());
11405             try {
11406                 if (!file.exists()) file.createNewFile();
11407                 uri = MediaStore.scanFile(context.getContentResolver(), new File(uri.getPath()));
11408                 if (uri != null) {
11409                     return uri;
11410                 }
11411             } catch (IOException e) {
11412                 Log.e(TAG, "Ignoring failure to create file " + file, e);
11413             }
11414         }
11415         return uri;
11416     }
11417 
11418     /**
11419      * Convert the dock state to a human readable format.
11420      * @hide
11421      */
dockStateToString(int dock)11422     public static String dockStateToString(int dock) {
11423         switch (dock) {
11424             case EXTRA_DOCK_STATE_HE_DESK:
11425                 return "EXTRA_DOCK_STATE_HE_DESK";
11426             case EXTRA_DOCK_STATE_LE_DESK:
11427                 return "EXTRA_DOCK_STATE_LE_DESK";
11428             case EXTRA_DOCK_STATE_CAR:
11429                 return "EXTRA_DOCK_STATE_CAR";
11430             case EXTRA_DOCK_STATE_DESK:
11431                 return "EXTRA_DOCK_STATE_DESK";
11432             case EXTRA_DOCK_STATE_UNDOCKED:
11433                 return "EXTRA_DOCK_STATE_UNDOCKED";
11434             default:
11435                 return Integer.toString(dock);
11436         }
11437     }
11438 
makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, ArrayList<String> htmlTexts, int which)11439     private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
11440             ArrayList<String> htmlTexts, int which) {
11441         Uri uri = streams != null ? streams.get(which) : null;
11442         CharSequence text = texts != null ? texts.get(which) : null;
11443         String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
11444         return new ClipData.Item(text, htmlText, null, uri);
11445     }
11446 
11447     /** @hide */
isDocument()11448     public boolean isDocument() {
11449         return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
11450     }
11451 }
11452