• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.accessibilityservice.AccessibilityService;
22 import android.annotation.AnyRes;
23 import android.annotation.BroadcastBehavior;
24 import android.annotation.IntDef;
25 import android.annotation.NonNull;
26 import android.annotation.Nullable;
27 import android.annotation.RequiresPermission;
28 import android.annotation.SdkConstant;
29 import android.annotation.SdkConstant.SdkConstantType;
30 import android.annotation.SuppressLint;
31 import android.annotation.SystemApi;
32 import android.annotation.TestApi;
33 import android.app.AppGlobals;
34 import android.bluetooth.BluetoothDevice;
35 import android.compat.annotation.UnsupportedAppUsage;
36 import android.content.pm.ActivityInfo;
37 import android.content.pm.ApplicationInfo;
38 import android.content.pm.ComponentInfo;
39 import android.content.pm.PackageManager;
40 import android.content.pm.ResolveInfo;
41 import android.content.pm.ShortcutInfo;
42 import android.content.pm.SuspendDialogInfo;
43 import android.content.pm.verify.domain.DomainVerificationManager;
44 import android.content.res.Resources;
45 import android.content.res.TypedArray;
46 import android.graphics.Rect;
47 import android.net.Uri;
48 import android.os.Build;
49 import android.os.Bundle;
50 import android.os.IBinder;
51 import android.os.IncidentManager;
52 import android.os.Parcel;
53 import android.os.Parcelable;
54 import android.os.PersistableBundle;
55 import android.os.Process;
56 import android.os.ResultReceiver;
57 import android.os.ShellCommand;
58 import android.os.StrictMode;
59 import android.os.UserHandle;
60 import android.os.storage.StorageManager;
61 import android.provider.ContactsContract.QuickContact;
62 import android.provider.DocumentsContract;
63 import android.provider.DocumentsProvider;
64 import android.provider.MediaStore;
65 import android.provider.OpenableColumns;
66 import android.telecom.PhoneAccount;
67 import android.telecom.TelecomManager;
68 import android.text.TextUtils;
69 import android.util.ArraySet;
70 import android.util.AttributeSet;
71 import android.util.Log;
72 import android.util.proto.ProtoOutputStream;
73 
74 import com.android.internal.util.XmlUtils;
75 
76 import org.xmlpull.v1.XmlPullParser;
77 import org.xmlpull.v1.XmlPullParserException;
78 import org.xmlpull.v1.XmlSerializer;
79 
80 import java.io.File;
81 import java.io.IOException;
82 import java.io.PrintWriter;
83 import java.io.Serializable;
84 import java.lang.annotation.Retention;
85 import java.lang.annotation.RetentionPolicy;
86 import java.net.URISyntaxException;
87 import java.util.ArrayList;
88 import java.util.HashSet;
89 import java.util.List;
90 import java.util.Locale;
91 import java.util.Objects;
92 import java.util.Set;
93 import java.util.TimeZone;
94 
95 /**
96  * An intent is an abstract description of an operation to be performed.  It
97  * can be used with {@link Context#startActivity(Intent) startActivity} to
98  * launch an {@link android.app.Activity},
99  * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
100  * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
101  * and {@link android.content.Context#startService} or
102  * {@link android.content.Context#bindService} to communicate with a
103  * background {@link android.app.Service}.
104  *
105  * <p>An Intent provides a facility for performing late runtime binding between the code in
106  * different applications. Its most significant use is in the launching of activities, where it
107  * can be thought of as the glue between activities. It is basically a passive data structure
108  * holding an abstract description of an action to be performed.</p>
109  *
110  * <div class="special reference">
111  * <h3>Developer Guides</h3>
112  * <p>For information about how to create and resolve intents, read the
113  * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
114  * developer guide.</p>
115  * </div>
116  *
117  * <a name="IntentStructure"></a>
118  * <h3>Intent Structure</h3>
119  * <p>The primary pieces of information in an intent are:</p>
120  *
121  * <ul>
122  *   <li> <p><b>action</b> -- The general action to be performed, such as
123  *     {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
124  *     etc.</p>
125  *   </li>
126  *   <li> <p><b>data</b> -- The data to operate on, such as a person record
127  *     in the contacts database, expressed as a {@link android.net.Uri}.</p>
128  *   </li>
129  * </ul>
130  *
131  *
132  * <p>Some examples of action/data pairs are:</p>
133  *
134  * <ul>
135  *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
136  *     information about the person whose identifier is "1".</p>
137  *   </li>
138  *   <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
139  *     the phone dialer with the person filled in.</p>
140  *   </li>
141  *   <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
142  *     the phone dialer with the given number filled in.  Note how the
143  *     VIEW action does what is considered the most reasonable thing for
144  *     a particular URI.</p>
145  *   </li>
146  *   <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
147  *     the phone dialer with the given number filled in.</p>
148  *   </li>
149  *   <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
150  *     information about the person whose identifier is "1".</p>
151  *   </li>
152  *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
153  *     a list of people, which the user can browse through.  This example is a
154  *     typical top-level entry into the Contacts application, showing you the
155  *     list of people. Selecting a particular person to view would result in a
156  *     new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
157  *     being used to start an activity to display that person.</p>
158  *   </li>
159  * </ul>
160  *
161  * <p>In addition to these primary attributes, there are a number of secondary
162  * attributes that you can also include with an intent:</p>
163  *
164  * <ul>
165  *     <li> <p><b>category</b> -- Gives additional information about the action
166  *         to execute.  For example, {@link #CATEGORY_LAUNCHER} means it should
167  *         appear in the Launcher as a top-level application, while
168  *         {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
169  *         of alternative actions the user can perform on a piece of data.</p>
170  *     <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
171  *         intent data.  Normally the type is inferred from the data itself.
172  *         By setting this attribute, you disable that evaluation and force
173  *         an explicit type.</p>
174  *     <li> <p><b>component</b> -- Specifies an explicit name of a component
175  *         class to use for the intent.  Normally this is determined by looking
176  *         at the other information in the intent (the action, data/type, and
177  *         categories) and matching that with a component that can handle it.
178  *         If this attribute is set then none of the evaluation is performed,
179  *         and this component is used exactly as is.  By specifying this attribute,
180  *         all of the other Intent attributes become optional.</p>
181  *     <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
182  *         This can be used to provide extended information to the component.
183  *         For example, if we have a action to send an e-mail message, we could
184  *         also include extra pieces of data here to supply a subject, body,
185  *         etc.</p>
186  * </ul>
187  *
188  * <p>Here are some examples of other operations you can specify as intents
189  * using these additional parameters:</p>
190  *
191  * <ul>
192  *   <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
193  *     Launch the home screen.</p>
194  *   </li>
195  *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
196  *     <i>{@link android.provider.Contacts.Phones#CONTENT_URI
197  *     vnd.android.cursor.item/phone}</i></b>
198  *     -- Display the list of people's phone numbers, allowing the user to
199  *     browse through them and pick one and return it to the parent activity.</p>
200  *   </li>
201  *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
202  *     <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
203  *     -- Display all pickers for data that can be opened with
204  *     {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
205  *     allowing the user to pick one of them and then some data inside of it
206  *     and returning the resulting URI to the caller.  This can be used,
207  *     for example, in an e-mail application to allow the user to pick some
208  *     data to include as an attachment.</p>
209  *   </li>
210  * </ul>
211  *
212  * <p>There are a variety of standard Intent action and category constants
213  * defined in the Intent class, but applications can also define their own.
214  * These strings use Java-style scoping, to ensure they are unique -- for
215  * example, the standard {@link #ACTION_VIEW} is called
216  * "android.intent.action.VIEW".</p>
217  *
218  * <p>Put together, the set of actions, data types, categories, and extra data
219  * defines a language for the system allowing for the expression of phrases
220  * such as "call john smith's cell".  As applications are added to the system,
221  * they can extend this language by adding new actions, types, and categories, or
222  * they can modify the behavior of existing phrases by supplying their own
223  * activities that handle them.</p>
224  *
225  * <a name="IntentResolution"></a>
226  * <h3>Intent Resolution</h3>
227  *
228  * <p>There are two primary forms of intents you will use.
229  *
230  * <ul>
231  *     <li> <p><b>Explicit Intents</b> have specified a component (via
232  *     {@link #setComponent} or {@link #setClass}), which provides the exact
233  *     class to be run.  Often these will not include any other information,
234  *     simply being a way for an application to launch various internal
235  *     activities it has as the user interacts with the application.
236  *
237  *     <li> <p><b>Implicit Intents</b> have not specified a component;
238  *     instead, they must include enough information for the system to
239  *     determine which of the available components is best to run for that
240  *     intent.
241  * </ul>
242  *
243  * <p>When using implicit intents, given such an arbitrary intent we need to
244  * know what to do with it. This is handled by the process of <em>Intent
245  * resolution</em>, which maps an Intent to an {@link android.app.Activity},
246  * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
247  * more activities/receivers) that can handle it.</p>
248  *
249  * <p>The intent resolution mechanism basically revolves around matching an
250  * Intent against all of the &lt;intent-filter&gt; descriptions in the
251  * installed application packages.  (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
252  * objects explicitly registered with {@link Context#registerReceiver}.)  More
253  * details on this can be found in the documentation on the {@link
254  * IntentFilter} class.</p>
255  *
256  * <p>There are three pieces of information in the Intent that are used for
257  * resolution: the action, type, and category.  Using this information, a query
258  * is done on the {@link PackageManager} for a component that can handle the
259  * intent. The appropriate component is determined based on the intent
260  * information supplied in the <code>AndroidManifest.xml</code> file as
261  * follows:</p>
262  *
263  * <ul>
264  *     <li> <p>The <b>action</b>, if given, must be listed by the component as
265  *         one it handles.</p>
266  *     <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
267  *         already supplied in the Intent.  Like the action, if a type is
268  *         included in the intent (either explicitly or implicitly in its
269  *         data), then this must be listed by the component as one it handles.</p>
270  *     <li> For data that is not a <code>content:</code> URI and where no explicit
271  *         type is included in the Intent, instead the <b>scheme</b> of the
272  *         intent data (such as <code>http:</code> or <code>mailto:</code>) is
273  *         considered. Again like the action, if we are matching a scheme it
274  *         must be listed by the component as one it can handle.
275  *     <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
276  *         by the activity as categories it handles.  That is, if you include
277  *         the categories {@link #CATEGORY_LAUNCHER} and
278  *         {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
279  *         with an intent that lists <em>both</em> of those categories.
280  *         Activities will very often need to support the
281  *         {@link #CATEGORY_DEFAULT} so that they can be found by
282  *         {@link Context#startActivity Context.startActivity()}.</p>
283  * </ul>
284  *
285  * <p>For example, consider the Note Pad sample application that
286  * allows a user to browse through a list of notes data and view details about
287  * individual items.  Text in italics indicates places where you would replace a
288  * name with one specific to your own package.</p>
289  *
290  * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
291  *       package="<i>com.android.notepad</i>"&gt;
292  *     &lt;application android:icon="@drawable/app_notes"
293  *             android:label="@string/app_name"&gt;
294  *
295  *         &lt;provider class=".NotePadProvider"
296  *                 android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
297  *
298  *         &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
299  *             &lt;intent-filter&gt;
300  *                 &lt;action android:name="android.intent.action.MAIN" /&gt;
301  *                 &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
302  *             &lt;/intent-filter&gt;
303  *             &lt;intent-filter&gt;
304  *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
305  *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
306  *                 &lt;action android:name="android.intent.action.PICK" /&gt;
307  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
308  *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
309  *             &lt;/intent-filter&gt;
310  *             &lt;intent-filter&gt;
311  *                 &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
312  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
313  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
314  *             &lt;/intent-filter&gt;
315  *         &lt;/activity&gt;
316  *
317  *         &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
318  *             &lt;intent-filter android:label="@string/resolve_edit"&gt;
319  *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
320  *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
321  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
322  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
323  *             &lt;/intent-filter&gt;
324  *
325  *             &lt;intent-filter&gt;
326  *                 &lt;action android:name="android.intent.action.INSERT" /&gt;
327  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
328  *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
329  *             &lt;/intent-filter&gt;
330  *
331  *         &lt;/activity&gt;
332  *
333  *         &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
334  *                 android:theme="@android:style/Theme.Dialog"&gt;
335  *             &lt;intent-filter android:label="@string/resolve_title"&gt;
336  *                 &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
337  *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
338  *                 &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
339  *                 &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
340  *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
341  *             &lt;/intent-filter&gt;
342  *         &lt;/activity&gt;
343  *
344  *     &lt;/application&gt;
345  * &lt;/manifest&gt;</pre>
346  *
347  * <p>The first activity,
348  * <code>com.android.notepad.NotesList</code>, serves as our main
349  * entry into the app.  It can do three things as described by its three intent
350  * templates:
351  * <ol>
352  * <li><pre>
353  * &lt;intent-filter&gt;
354  *     &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
355  *     &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
356  * &lt;/intent-filter&gt;</pre>
357  * <p>This provides a top-level entry into the NotePad application: the standard
358  * MAIN action is a main entry point (not requiring any other information in
359  * the Intent), and the LAUNCHER category says that this entry point should be
360  * listed in the application launcher.</p>
361  * <li><pre>
362  * &lt;intent-filter&gt;
363  *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
364  *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
365  *     &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
366  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
367  *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
368  * &lt;/intent-filter&gt;</pre>
369  * <p>This declares the things that the activity can do on a directory of
370  * notes.  The type being supported is given with the &lt;type&gt; tag, where
371  * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
372  * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
373  * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
374  * The activity allows the user to view or edit the directory of data (via
375  * the VIEW and EDIT actions), or to pick a particular note and return it
376  * to the caller (via the PICK action).  Note also the DEFAULT category
377  * supplied here: this is <em>required</em> for the
378  * {@link Context#startActivity Context.startActivity} method to resolve your
379  * activity when its component name is not explicitly specified.</p>
380  * <li><pre>
381  * &lt;intent-filter&gt;
382  *     &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
383  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
384  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
385  * &lt;/intent-filter&gt;</pre>
386  * <p>This filter describes the ability to return to the caller a note selected by
387  * the user without needing to know where it came from.  The data type
388  * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
389  * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
390  * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
391  * The GET_CONTENT action is similar to the PICK action, where the activity
392  * will return to its caller a piece of data selected by the user.  Here,
393  * however, the caller specifies the type of data they desire instead of
394  * the type of data the user will be picking from.</p>
395  * </ol>
396  *
397  * <p>Given these capabilities, the following intents will resolve to the
398  * NotesList activity:</p>
399  *
400  * <ul>
401  *     <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
402  *         activities that can be used as top-level entry points into an
403  *         application.</p>
404  *     <li> <p><b>{ action=android.app.action.MAIN,
405  *         category=android.app.category.LAUNCHER }</b> is the actual intent
406  *         used by the Launcher to populate its top-level list.</p>
407  *     <li> <p><b>{ action=android.intent.action.VIEW
408  *          data=content://com.google.provider.NotePad/notes }</b>
409  *         displays a list of all the notes under
410  *         "content://com.google.provider.NotePad/notes", which
411  *         the user can browse through and see the details on.</p>
412  *     <li> <p><b>{ action=android.app.action.PICK
413  *          data=content://com.google.provider.NotePad/notes }</b>
414  *         provides a list of the notes under
415  *         "content://com.google.provider.NotePad/notes", from which
416  *         the user can pick a note whose data URL is returned back to the caller.</p>
417  *     <li> <p><b>{ action=android.app.action.GET_CONTENT
418  *          type=vnd.android.cursor.item/vnd.google.note }</b>
419  *         is similar to the pick action, but allows the caller to specify the
420  *         kind of data they want back so that the system can find the appropriate
421  *         activity to pick something of that data type.</p>
422  * </ul>
423  *
424  * <p>The second activity,
425  * <code>com.android.notepad.NoteEditor</code>, shows the user a single
426  * note entry and allows them to edit it.  It can do two things as described
427  * by its two intent templates:
428  * <ol>
429  * <li><pre>
430  * &lt;intent-filter android:label="@string/resolve_edit"&gt;
431  *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
432  *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
433  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
434  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
435  * &lt;/intent-filter&gt;</pre>
436  * <p>The first, primary, purpose of this activity is to let the user interact
437  * with a single note, as decribed by the MIME type
438  * <code>vnd.android.cursor.item/vnd.google.note</code>.  The activity can
439  * either VIEW a note or allow the user to EDIT it.  Again we support the
440  * DEFAULT category to allow the activity to be launched without explicitly
441  * specifying its component.</p>
442  * <li><pre>
443  * &lt;intent-filter&gt;
444  *     &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
445  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
446  *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
447  * &lt;/intent-filter&gt;</pre>
448  * <p>The secondary use of this activity is to insert a new note entry into
449  * an existing directory of notes.  This is used when the user creates a new
450  * note: the INSERT action is executed on the directory of notes, causing
451  * this activity to run and have the user create the new note data which
452  * it then adds to the content provider.</p>
453  * </ol>
454  *
455  * <p>Given these capabilities, the following intents will resolve to the
456  * NoteEditor activity:</p>
457  *
458  * <ul>
459  *     <li> <p><b>{ action=android.intent.action.VIEW
460  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
461  *         shows the user the content of note <var>{ID}</var>.</p>
462  *     <li> <p><b>{ action=android.app.action.EDIT
463  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
464  *         allows the user to edit the content of note <var>{ID}</var>.</p>
465  *     <li> <p><b>{ action=android.app.action.INSERT
466  *          data=content://com.google.provider.NotePad/notes }</b>
467  *         creates a new, empty note in the notes list at
468  *         "content://com.google.provider.NotePad/notes"
469  *         and allows the user to edit it.  If they keep their changes, the URI
470  *         of the newly created note is returned to the caller.</p>
471  * </ul>
472  *
473  * <p>The last activity,
474  * <code>com.android.notepad.TitleEditor</code>, allows the user to
475  * edit the title of a note.  This could be implemented as a class that the
476  * application directly invokes (by explicitly setting its component in
477  * the Intent), but here we show a way you can publish alternative
478  * operations on existing data:</p>
479  *
480  * <pre>
481  * &lt;intent-filter android:label="@string/resolve_title"&gt;
482  *     &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
483  *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
484  *     &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
485  *     &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
486  *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
487  * &lt;/intent-filter&gt;</pre>
488  *
489  * <p>In the single intent template here, we
490  * have created our own private action called
491  * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
492  * edit the title of a note.  It must be invoked on a specific note
493  * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
494  * view and edit actions, but here displays and edits the title contained
495  * in the note data.
496  *
497  * <p>In addition to supporting the default category as usual, our title editor
498  * also supports two other standard categories: ALTERNATIVE and
499  * SELECTED_ALTERNATIVE.  Implementing
500  * these categories allows others to find the special action it provides
501  * without directly knowing about it, through the
502  * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
503  * more often to build dynamic menu items with
504  * {@link android.view.Menu#addIntentOptions}.  Note that in the intent
505  * template here was also supply an explicit name for the template
506  * (via <code>android:label="@string/resolve_title"</code>) to better control
507  * what the user sees when presented with this activity as an alternative
508  * action to the data they are viewing.
509  *
510  * <p>Given these capabilities, the following intent will resolve to the
511  * TitleEditor activity:</p>
512  *
513  * <ul>
514  *     <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
515  *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
516  *         displays and allows the user to edit the title associated
517  *         with note <var>{ID}</var>.</p>
518  * </ul>
519  *
520  * <h3>Standard Activity Actions</h3>
521  *
522  * <p>These are the current standard actions that Intent defines for launching
523  * activities (usually through {@link Context#startActivity}.  The most
524  * important, and by far most frequently used, are {@link #ACTION_MAIN} and
525  * {@link #ACTION_EDIT}.
526  *
527  * <ul>
528  *     <li> {@link #ACTION_MAIN}
529  *     <li> {@link #ACTION_VIEW}
530  *     <li> {@link #ACTION_ATTACH_DATA}
531  *     <li> {@link #ACTION_EDIT}
532  *     <li> {@link #ACTION_PICK}
533  *     <li> {@link #ACTION_CHOOSER}
534  *     <li> {@link #ACTION_GET_CONTENT}
535  *     <li> {@link #ACTION_DIAL}
536  *     <li> {@link #ACTION_CALL}
537  *     <li> {@link #ACTION_SEND}
538  *     <li> {@link #ACTION_SENDTO}
539  *     <li> {@link #ACTION_ANSWER}
540  *     <li> {@link #ACTION_INSERT}
541  *     <li> {@link #ACTION_DELETE}
542  *     <li> {@link #ACTION_RUN}
543  *     <li> {@link #ACTION_SYNC}
544  *     <li> {@link #ACTION_PICK_ACTIVITY}
545  *     <li> {@link #ACTION_SEARCH}
546  *     <li> {@link #ACTION_WEB_SEARCH}
547  *     <li> {@link #ACTION_FACTORY_TEST}
548  * </ul>
549  *
550  * <h3>Standard Broadcast Actions</h3>
551  *
552  * <p>These are the current standard actions that Intent defines for receiving
553  * broadcasts (usually through {@link Context#registerReceiver} or a
554  * &lt;receiver&gt; tag in a manifest).
555  *
556  * <ul>
557  *     <li> {@link #ACTION_TIME_TICK}
558  *     <li> {@link #ACTION_TIME_CHANGED}
559  *     <li> {@link #ACTION_TIMEZONE_CHANGED}
560  *     <li> {@link #ACTION_BOOT_COMPLETED}
561  *     <li> {@link #ACTION_PACKAGE_ADDED}
562  *     <li> {@link #ACTION_PACKAGE_CHANGED}
563  *     <li> {@link #ACTION_PACKAGE_REMOVED}
564  *     <li> {@link #ACTION_PACKAGE_RESTARTED}
565  *     <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
566  *     <li> {@link #ACTION_PACKAGES_SUSPENDED}
567  *     <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
568  *     <li> {@link #ACTION_UID_REMOVED}
569  *     <li> {@link #ACTION_BATTERY_CHANGED}
570  *     <li> {@link #ACTION_POWER_CONNECTED}
571  *     <li> {@link #ACTION_POWER_DISCONNECTED}
572  *     <li> {@link #ACTION_SHUTDOWN}
573  * </ul>
574  *
575  * <h3>Standard Categories</h3>
576  *
577  * <p>These are the current standard categories that can be used to further
578  * clarify an Intent via {@link #addCategory}.
579  *
580  * <ul>
581  *     <li> {@link #CATEGORY_DEFAULT}
582  *     <li> {@link #CATEGORY_BROWSABLE}
583  *     <li> {@link #CATEGORY_TAB}
584  *     <li> {@link #CATEGORY_ALTERNATIVE}
585  *     <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
586  *     <li> {@link #CATEGORY_LAUNCHER}
587  *     <li> {@link #CATEGORY_INFO}
588  *     <li> {@link #CATEGORY_HOME}
589  *     <li> {@link #CATEGORY_PREFERENCE}
590  *     <li> {@link #CATEGORY_TEST}
591  *     <li> {@link #CATEGORY_CAR_DOCK}
592  *     <li> {@link #CATEGORY_DESK_DOCK}
593  *     <li> {@link #CATEGORY_LE_DESK_DOCK}
594  *     <li> {@link #CATEGORY_HE_DESK_DOCK}
595  *     <li> {@link #CATEGORY_CAR_MODE}
596  *     <li> {@link #CATEGORY_APP_MARKET}
597  *     <li> {@link #CATEGORY_VR_HOME}
598  * </ul>
599  *
600  * <h3>Standard Extra Data</h3>
601  *
602  * <p>These are the current standard fields that can be used as extra data via
603  * {@link #putExtra}.
604  *
605  * <ul>
606  *     <li> {@link #EXTRA_ALARM_COUNT}
607  *     <li> {@link #EXTRA_BCC}
608  *     <li> {@link #EXTRA_CC}
609  *     <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
610  *     <li> {@link #EXTRA_DATA_REMOVED}
611  *     <li> {@link #EXTRA_DOCK_STATE}
612  *     <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
613  *     <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
614  *     <li> {@link #EXTRA_DOCK_STATE_CAR}
615  *     <li> {@link #EXTRA_DOCK_STATE_DESK}
616  *     <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
617  *     <li> {@link #EXTRA_DONT_KILL_APP}
618  *     <li> {@link #EXTRA_EMAIL}
619  *     <li> {@link #EXTRA_INITIAL_INTENTS}
620  *     <li> {@link #EXTRA_INTENT}
621  *     <li> {@link #EXTRA_KEY_EVENT}
622  *     <li> {@link #EXTRA_ORIGINATING_URI}
623  *     <li> {@link #EXTRA_PHONE_NUMBER}
624  *     <li> {@link #EXTRA_REFERRER}
625  *     <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
626  *     <li> {@link #EXTRA_REPLACING}
627  *     <li> {@link #EXTRA_SHORTCUT_ICON}
628  *     <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
629  *     <li> {@link #EXTRA_SHORTCUT_INTENT}
630  *     <li> {@link #EXTRA_STREAM}
631  *     <li> {@link #EXTRA_SHORTCUT_NAME}
632  *     <li> {@link #EXTRA_SUBJECT}
633  *     <li> {@link #EXTRA_TEMPLATE}
634  *     <li> {@link #EXTRA_TEXT}
635  *     <li> {@link #EXTRA_TITLE}
636  *     <li> {@link #EXTRA_UID}
637  *     <li> {@link #EXTRA_USER_INITIATED}
638  * </ul>
639  *
640  * <h3>Flags</h3>
641  *
642  * <p>These are the possible flags that can be used in the Intent via
643  * {@link #setFlags} and {@link #addFlags}.  See {@link #setFlags} for a list
644  * of all possible flags.
645  */
646 public class Intent implements Parcelable, Cloneable {
647     private static final String TAG = "Intent";
648 
649     private static final String ATTR_ACTION = "action";
650     private static final String TAG_CATEGORIES = "categories";
651     private static final String ATTR_CATEGORY = "category";
652     private static final String TAG_EXTRA = "extra";
653     private static final String ATTR_TYPE = "type";
654     private static final String ATTR_IDENTIFIER = "ident";
655     private static final String ATTR_COMPONENT = "component";
656     private static final String ATTR_DATA = "data";
657     private static final String ATTR_FLAGS = "flags";
658 
659     // ---------------------------------------------------------------------
660     // ---------------------------------------------------------------------
661     // Standard intent activity actions (see action variable).
662 
663     /**
664      *  Activity Action: Start as a main entry point, does not expect to
665      *  receive data.
666      *  <p>Input: nothing
667      *  <p>Output: nothing
668      */
669     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
670     public static final String ACTION_MAIN = "android.intent.action.MAIN";
671 
672     /**
673      * Activity Action: Display the data to the user.  This is the most common
674      * action performed on data -- it is the generic action you can use on
675      * a piece of data to get the most reasonable thing to occur.  For example,
676      * when used on a contacts entry it will view the entry; when used on a
677      * mailto: URI it will bring up a compose window filled with the information
678      * supplied by the URI; when used with a tel: URI it will invoke the
679      * dialer.
680      * <p>Input: {@link #getData} is URI from which to retrieve data.
681      * <p>Output: nothing.
682      */
683     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
684     public static final String ACTION_VIEW = "android.intent.action.VIEW";
685 
686     /**
687      * Extra that can be included on activity intents coming from the storage UI
688      * when it launches sub-activities to manage various types of storage.  For example,
689      * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
690      * the images on the device, and in that case also include this extra to tell the
691      * app it is coming from the storage UI so should help the user manage storage of
692      * this type.
693      */
694     public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
695 
696     /**
697      * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
698      * performed on a piece of data.
699      */
700     public static final String ACTION_DEFAULT = ACTION_VIEW;
701 
702     /**
703      * Activity Action: Quick view the data. Launches a quick viewer for
704      * a URI or a list of URIs.
705      * <p>Activities handling this intent action should handle the vast majority of
706      * MIME types rather than only specific ones.
707      * <p>Quick viewers must render the quick view image locally, and must not send
708      * file content outside current device.
709      * <p>Input: {@link #getData} is a mandatory content URI of the item to
710      * preview. {@link #getClipData} contains an optional list of content URIs
711      * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
712      * optional index of the URI in the clip data to show first.
713      * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
714      * that can be shown in the quick view UI.
715      * <p>Output: nothing.
716      * @see #EXTRA_INDEX
717      * @see #EXTRA_QUICK_VIEW_FEATURES
718      */
719     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
720     public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
721 
722     /**
723      * Used to indicate that some piece of data should be attached to some other
724      * place.  For example, image data could be attached to a contact.  It is up
725      * to the recipient to decide where the data should be attached; the intent
726      * does not specify the ultimate destination.
727      * <p>Input: {@link #getData} is URI of data to be attached.
728      * <p>Output: nothing.
729      */
730     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
731     public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
732 
733     /**
734      * Activity Action: Provide explicit editable access to the given data.
735      * <p>Input: {@link #getData} is URI of data to be edited.
736      * <p>Output: nothing.
737      */
738     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
739     public static final String ACTION_EDIT = "android.intent.action.EDIT";
740 
741     /**
742      * Activity Action: Pick an existing item, or insert a new item, and then edit it.
743      * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
744      * The extras can contain type specific data to pass through to the editing/creating
745      * activity.
746      * <p>Output: The URI of the item that was picked.  This must be a content:
747      * URI so that any receiver can access it.
748      */
749     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
750     public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
751 
752     /**
753      * Activity Action: Pick an item from the data, returning what was selected.
754      * <p>Input: {@link #getData} is URI containing a directory of data
755      * (vnd.android.cursor.dir/*) from which to pick an item.
756      * <p>Output: The URI of the item that was picked.
757      */
758     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
759     public static final String ACTION_PICK = "android.intent.action.PICK";
760 
761     /**
762      * Activity Action: Creates a reminder.
763      * <p>Input: {@link #EXTRA_TITLE} The title of the reminder that will be shown to the user.
764      * {@link #EXTRA_TEXT} The reminder text that will be shown to the user. The intent should at
765      * least specify a title or a text. {@link #EXTRA_TIME} The time when the reminder will
766      * be shown to the user. The time is specified in milliseconds since the Epoch (optional).
767      * </p>
768      * <p>Output: Nothing.</p>
769      *
770      * @see #EXTRA_TITLE
771      * @see #EXTRA_TEXT
772      * @see #EXTRA_TIME
773      */
774     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
775     public static final String ACTION_CREATE_REMINDER = "android.intent.action.CREATE_REMINDER";
776 
777     /**
778      * Activity Action: Creates a shortcut.
779      * <p>Input: Nothing.</p>
780      * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
781      * <p>For compatibility with older versions of android the intent may also contain three
782      * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
783      * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
784      * (value: ShortcutIconResource).</p>
785      *
786      * @see android.content.pm.ShortcutManager#createShortcutResultIntent
787      * @see #EXTRA_SHORTCUT_INTENT
788      * @see #EXTRA_SHORTCUT_NAME
789      * @see #EXTRA_SHORTCUT_ICON
790      * @see #EXTRA_SHORTCUT_ICON_RESOURCE
791      * @see android.content.Intent.ShortcutIconResource
792      */
793     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
794     public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
795 
796     /**
797      * The name of the extra used to define the Intent of a shortcut.
798      *
799      * @see #ACTION_CREATE_SHORTCUT
800      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
801      */
802     @Deprecated
803     public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
804     /**
805      * The name of the extra used to define the name of a shortcut.
806      *
807      * @see #ACTION_CREATE_SHORTCUT
808      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
809      */
810     @Deprecated
811     public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
812     /**
813      * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
814      *
815      * @see #ACTION_CREATE_SHORTCUT
816      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
817      */
818     @Deprecated
819     public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
820     /**
821      * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
822      *
823      * @see #ACTION_CREATE_SHORTCUT
824      * @see android.content.Intent.ShortcutIconResource
825      * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
826      */
827     @Deprecated
828     public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
829             "android.intent.extra.shortcut.ICON_RESOURCE";
830 
831     /**
832      * An activity that provides a user interface for adjusting application preferences.
833      * Optional but recommended settings for all applications which have settings.
834      */
835     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
836     public static final String ACTION_APPLICATION_PREFERENCES
837             = "android.intent.action.APPLICATION_PREFERENCES";
838 
839     /**
840      * Activity Action: Launch an activity showing the app information.
841      * For applications which install other applications (such as app stores), it is recommended
842      * to handle this action for providing the app information to the user.
843      *
844      * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
845      * to be displayed.
846      * <p>Output: Nothing.
847      */
848     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
849     public static final String ACTION_SHOW_APP_INFO
850             = "android.intent.action.SHOW_APP_INFO";
851 
852     /**
853      * Activity Action: Placeholder that the component handling it can do activity
854      * recognition. Can be placed on a service. Only one service per package is
855      * supported.
856      *
857      * <p>Input: Nothing.</p>
858      * <p>Output: Nothing </p>
859      *
860      * @hide
861      */
862     @SystemApi
863     @SdkConstant(SdkConstantType.SERVICE_ACTION)
864     public static final String ACTION_ACTIVITY_RECOGNIZER =
865             "android.intent.action.ACTIVITY_RECOGNIZER";
866 
867     /**
868      * Represents a shortcut/live folder icon resource.
869      *
870      * @see Intent#ACTION_CREATE_SHORTCUT
871      * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
872      * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
873      * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
874      */
875     public static class ShortcutIconResource implements Parcelable {
876         /**
877          * The package name of the application containing the icon.
878          */
879         public String packageName;
880 
881         /**
882          * The resource name of the icon, including package, name and type.
883          */
884         public String resourceName;
885 
886         /**
887          * Creates a new ShortcutIconResource for the specified context and resource
888          * identifier.
889          *
890          * @param context The context of the application.
891          * @param resourceId The resource identifier for the icon.
892          * @return A new ShortcutIconResource with the specified's context package name
893          *         and icon resource identifier.``
894          */
fromContext(Context context, @AnyRes int resourceId)895         public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
896             ShortcutIconResource icon = new ShortcutIconResource();
897             icon.packageName = context.getPackageName();
898             icon.resourceName = context.getResources().getResourceName(resourceId);
899             return icon;
900         }
901 
902         /**
903          * Used to read a ShortcutIconResource from a Parcel.
904          */
905         public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR =
906             new Parcelable.Creator<ShortcutIconResource>() {
907 
908                 public ShortcutIconResource createFromParcel(Parcel source) {
909                     ShortcutIconResource icon = new ShortcutIconResource();
910                     icon.packageName = source.readString8();
911                     icon.resourceName = source.readString8();
912                     return icon;
913                 }
914 
915                 public ShortcutIconResource[] newArray(int size) {
916                     return new ShortcutIconResource[size];
917                 }
918             };
919 
920         /**
921          * No special parcel contents.
922          */
describeContents()923         public int describeContents() {
924             return 0;
925         }
926 
writeToParcel(Parcel dest, int flags)927         public void writeToParcel(Parcel dest, int flags) {
928             dest.writeString8(packageName);
929             dest.writeString8(resourceName);
930         }
931 
932         @Override
toString()933         public String toString() {
934             return resourceName;
935         }
936     }
937 
938     /**
939      * Activity Action: Display an activity chooser, allowing the user to pick
940      * what they want to before proceeding.  This can be used as an alternative
941      * to the standard activity picker that is displayed by the system when
942      * you try to start an activity with multiple possible matches, with these
943      * differences in behavior:
944      * <ul>
945      * <li>You can specify the title that will appear in the activity chooser.
946      * <li>The user does not have the option to make one of the matching
947      * activities a preferred activity, and all possible activities will
948      * always be shown even if one of them is currently marked as the
949      * preferred activity.
950      * </ul>
951      * <p>
952      * This action should be used when the user will naturally expect to
953      * select an activity in order to proceed.  An example if when not to use
954      * it is when the user clicks on a "mailto:" link.  They would naturally
955      * expect to go directly to their mail app, so startActivity() should be
956      * called directly: it will
957      * either launch the current preferred app, or put up a dialog allowing the
958      * user to pick an app to use and optionally marking that as preferred.
959      * <p>
960      * In contrast, if the user is selecting a menu item to send a picture
961      * they are viewing to someone else, there are many different things they
962      * may want to do at this point: send it through e-mail, upload it to a
963      * web service, etc.  In this case the CHOOSER action should be used, to
964      * always present to the user a list of the things they can do, with a
965      * nice title given by the caller such as "Send this photo with:".
966      * <p>
967      * If you need to grant URI permissions through a chooser, you must specify
968      * the permissions to be granted on the ACTION_CHOOSER Intent
969      * <em>in addition</em> to the EXTRA_INTENT inside.  This means using
970      * {@link #setClipData} to specify the URIs to be granted as well as
971      * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
972      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
973      * <p>
974      * As a convenience, an Intent of this form can be created with the
975      * {@link #createChooser} function.
976      * <p>
977      * Input: No data should be specified.  get*Extra must have
978      * a {@link #EXTRA_INTENT} field containing the Intent being executed,
979      * and can optionally have a {@link #EXTRA_TITLE} field containing the
980      * title text to display in the chooser.
981      * <p>
982      * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
983      */
984     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
985     public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
986 
987     /**
988      * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
989      *
990      * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
991      * target intent, also optionally supplying a title.  If the target
992      * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
993      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
994      * set in the returned chooser intent, with its ClipData set appropriately:
995      * either a direct reflection of {@link #getClipData()} if that is non-null,
996      * or a new ClipData built from {@link #getData()}.
997      *
998      * @param target The Intent that the user will be selecting an activity
999      * to perform.
1000      * @param title Optional title that will be displayed in the chooser,
1001      * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
1002      * @return Return a new Intent object that you can hand to
1003      * {@link Context#startActivity(Intent) Context.startActivity()} and
1004      * related methods.
1005      */
createChooser(Intent target, CharSequence title)1006     public static Intent createChooser(Intent target, CharSequence title) {
1007         return createChooser(target, title, null);
1008     }
1009 
1010     /**
1011      * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
1012      *
1013      * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
1014      * target intent, also optionally supplying a title.  If the target
1015      * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
1016      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
1017      * set in the returned chooser intent, with its ClipData set appropriately:
1018      * either a direct reflection of {@link #getClipData()} if that is non-null,
1019      * or a new ClipData built from {@link #getData()}.</p>
1020      *
1021      * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
1022      * when the user makes a choice. This can be useful if the calling application wants
1023      * to remember the last chosen target and surface it as a more prominent or one-touch
1024      * affordance elsewhere in the UI for next time.</p>
1025      *
1026      * @param target The Intent that the user will be selecting an activity
1027      * to perform.
1028      * @param title Optional title that will be displayed in the chooser,
1029      * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
1030      * @param sender Optional IntentSender to be called when a choice is made.
1031      * @return Return a new Intent object that you can hand to
1032      * {@link Context#startActivity(Intent) Context.startActivity()} and
1033      * related methods.
1034      */
createChooser(Intent target, CharSequence title, IntentSender sender)1035     public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
1036         Intent intent = new Intent(ACTION_CHOOSER);
1037         intent.putExtra(EXTRA_INTENT, target);
1038         if (title != null) {
1039             intent.putExtra(EXTRA_TITLE, title);
1040         }
1041 
1042         if (sender != null) {
1043             intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
1044         }
1045 
1046         // Migrate any clip data and flags from target.
1047         int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
1048                 | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
1049                 | FLAG_GRANT_PREFIX_URI_PERMISSION);
1050         if (permFlags != 0) {
1051             ClipData targetClipData = target.getClipData();
1052             if (targetClipData == null && target.getData() != null) {
1053                 ClipData.Item item = new ClipData.Item(target.getData());
1054                 String[] mimeTypes;
1055                 if (target.getType() != null) {
1056                     mimeTypes = new String[] { target.getType() };
1057                 } else {
1058                     mimeTypes = new String[] { };
1059                 }
1060                 targetClipData = new ClipData(null, mimeTypes, item);
1061             }
1062             if (targetClipData != null) {
1063                 intent.setClipData(targetClipData);
1064                 intent.addFlags(permFlags);
1065             }
1066         }
1067 
1068         return intent;
1069     }
1070 
1071     /**
1072      * Activity Action: Allow the user to select a particular kind of data and
1073      * return it.  This is different than {@link #ACTION_PICK} in that here we
1074      * just say what kind of data is desired, not a URI of existing data from
1075      * which the user can pick.  An ACTION_GET_CONTENT could allow the user to
1076      * create the data as it runs (for example taking a picture or recording a
1077      * sound), let them browse over the web and download the desired data,
1078      * etc.
1079      * <p>
1080      * There are two main ways to use this action: if you want a specific kind
1081      * of data, such as a person contact, you set the MIME type to the kind of
1082      * data you want and launch it with {@link Context#startActivity(Intent)}.
1083      * The system will then launch the best application to select that kind
1084      * of data for you.
1085      * <p>
1086      * You may also be interested in any of a set of types of content the user
1087      * can pick.  For example, an e-mail application that wants to allow the
1088      * user to add an attachment to an e-mail message can use this action to
1089      * bring up a list of all of the types of content the user can attach.
1090      * <p>
1091      * In this case, you should wrap the GET_CONTENT intent with a chooser
1092      * (through {@link #createChooser}), which will give the proper interface
1093      * for the user to pick how to send your data and allow you to specify
1094      * a prompt indicating what they are doing.  You will usually specify a
1095      * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1096      * broad range of content types the user can select from.
1097      * <p>
1098      * When using such a broad GET_CONTENT action, it is often desirable to
1099      * only pick from data that can be represented as a stream.  This is
1100      * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1101      * <p>
1102      * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
1103      * the launched content chooser only returns results representing data that
1104      * is locally available on the device.  For example, if this extra is set
1105      * to true then an image picker should not show any pictures that are available
1106      * from a remote server but not already on the local device (thus requiring
1107      * they be downloaded when opened).
1108      * <p>
1109      * If the caller can handle multiple returned items (the user performing
1110      * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1111      * to indicate this.
1112      * <p>
1113      * Input: {@link #getType} is the desired MIME type to retrieve.  Note
1114      * that no URI is supplied in the intent, as there are no constraints on
1115      * where the returned data originally comes from.  You may also include the
1116      * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
1117      * opened as a stream.  You may use {@link #EXTRA_LOCAL_ONLY} to limit content
1118      * selection to local data.  You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1119      * allow the user to select multiple items.
1120      * <p>
1121      * Output: The URI of the item that was picked.  This must be a content:
1122      * URI so that any receiver can access it.
1123      */
1124     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1125     public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1126     /**
1127      * Activity Action: Dial a number as specified by the data.  This shows a
1128      * UI with the number being dialed, allowing the user to explicitly
1129      * initiate the call.
1130      * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1131      * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1132      * number.
1133      * <p>Output: nothing.
1134      */
1135     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1136     public static final String ACTION_DIAL = "android.intent.action.DIAL";
1137     /**
1138      * Activity Action: Perform a call to someone specified by the data.
1139      * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1140      * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1141      * number.
1142      * <p>Output: nothing.
1143      *
1144      * <p>Note: there will be restrictions on which applications can initiate a
1145      * call; most applications should use the {@link #ACTION_DIAL}.
1146      * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1147      * numbers.  Applications can <strong>dial</strong> emergency numbers using
1148      * {@link #ACTION_DIAL}, however.
1149      *
1150      * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
1151      * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
1152      * permission which is not granted, then attempting to use this action will
1153      * result in a {@link java.lang.SecurityException}.
1154      */
1155     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1156     public static final String ACTION_CALL = "android.intent.action.CALL";
1157     /**
1158      * Activity Action: Perform a call to an emergency number specified by the
1159      * data.
1160      * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1161      * tel: URI of an explicit phone number.
1162      * <p>Output: nothing.
1163      *
1164      * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on
1165      * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE}
1166      * extra (if specified) and may be placed on another {@link PhoneAccount} with the
1167      * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external
1168      * factors, such as network conditions and Modem/SIM status.
1169      * @hide
1170      */
1171     @SystemApi
1172     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1173     public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1174     /**
1175      * Activity Action: Dial a emergency number specified by the data.  This shows a
1176      * UI with the number being dialed, allowing the user to explicitly
1177      * initiate the call.
1178      * <p>Input: If nothing, an empty emergency dialer is started; else {@link #getData}
1179      * is a tel: URI of an explicit emergency phone number.
1180      * <p>Output: nothing.
1181      * @hide
1182      */
1183     @SystemApi
1184     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1185     public static final String ACTION_DIAL_EMERGENCY = "android.intent.action.DIAL_EMERGENCY";
1186     /**
1187      * Activity action: Perform a call to any number (emergency or not)
1188      * specified by the data.
1189      * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1190      * tel: URI of an explicit phone number.
1191      * <p>Output: nothing.
1192      * @hide
1193      */
1194     @SystemApi
1195     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1196     public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1197 
1198     /**
1199      * Activity Action: Main entry point for carrier setup apps.
1200      * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1201      * carrier service and typically require
1202      * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1203      * fulfill their duties.
1204      */
1205     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1206     public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1207     /**
1208      * Activity Action: Send a message to someone specified by the data.
1209      * <p>Input: {@link #getData} is URI describing the target.
1210      * <p>Output: nothing.
1211      */
1212     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1213     public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1214     /**
1215      * Activity Action: Deliver some data to someone else.  Who the data is
1216      * being delivered to is not specified; it is up to the receiver of this
1217      * action to ask the user where the data should be sent.
1218      * <p>
1219      * When launching a SEND intent, you should usually wrap it in a chooser
1220      * (through {@link #createChooser}), which will give the proper interface
1221      * for the user to pick how to send your data and allow you to specify
1222      * a prompt indicating what they are doing.
1223      * <p>
1224      * Input: {@link #getType} is the MIME type of the data being sent.
1225      * get*Extra can have either a {@link #EXTRA_TEXT}
1226      * or {@link #EXTRA_STREAM} field, containing the data to be sent.  If
1227      * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1228      * should be the MIME type of the data in EXTRA_STREAM.  Use {@literal *}/*
1229      * if the MIME type is unknown (this will only allow senders that can
1230      * handle generic data streams).  If using {@link #EXTRA_TEXT}, you can
1231      * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1232      * your text with HTML formatting.
1233      * <p>
1234      * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1235      * being sent can be supplied through {@link #setClipData(ClipData)}.  This
1236      * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1237      * content: URIs and other advanced features of {@link ClipData}.  If
1238      * using this approach, you still must supply the same data through the
1239      * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1240      * for compatibility with old applications.  If you don't set a ClipData,
1241      * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1242      * <p>
1243      * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1244      * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1245      * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1246      * be openable only as asset typed files using
1247      * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1248      * <p>
1249      * Optional standard extras, which may be interpreted by some recipients as
1250      * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1251      * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1252      * <p>
1253      * Output: nothing.
1254      */
1255     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1256     public static final String ACTION_SEND = "android.intent.action.SEND";
1257     /**
1258      * Activity Action: Deliver multiple data to someone else.
1259      * <p>
1260      * Like {@link #ACTION_SEND}, except the data is multiple.
1261      * <p>
1262      * Input: {@link #getType} is the MIME type of the data being sent.
1263      * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
1264      * #EXTRA_STREAM} field, containing the data to be sent.  If using
1265      * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1266      * for clients to retrieve your text with HTML formatting.
1267      * <p>
1268      * Multiple types are supported, and receivers should handle mixed types
1269      * whenever possible. The right way for the receiver to check them is to
1270      * use the content resolver on each URI. The intent sender should try to
1271      * put the most concrete mime type in the intent type, but it can fall
1272      * back to {@literal <type>/*} or {@literal *}/* as needed.
1273      * <p>
1274      * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1275      * be image/jpg, but if you are sending image/jpg and image/png, then the
1276      * intent's type should be image/*.
1277      * <p>
1278      * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1279      * being sent can be supplied through {@link #setClipData(ClipData)}.  This
1280      * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1281      * content: URIs and other advanced features of {@link ClipData}.  If
1282      * using this approach, you still must supply the same data through the
1283      * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1284      * for compatibility with old applications.  If you don't set a ClipData,
1285      * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1286      * <p>
1287      * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1288      * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1289      * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1290      * be openable only as asset typed files using
1291      * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1292      * <p>
1293      * Optional standard extras, which may be interpreted by some recipients as
1294      * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1295      * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1296      * <p>
1297      * Output: nothing.
1298      */
1299     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1300     public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1301     /**
1302      * Activity Action: Handle an incoming phone call.
1303      * <p>Input: nothing.
1304      * <p>Output: nothing.
1305      */
1306     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1307     public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1308     /**
1309      * Activity Action: Insert an empty item into the given container.
1310      * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1311      * in which to place the data.
1312      * <p>Output: URI of the new data that was created.
1313      */
1314     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1315     public static final String ACTION_INSERT = "android.intent.action.INSERT";
1316     /**
1317      * Activity Action: Create a new item in the given container, initializing it
1318      * from the current contents of the clipboard.
1319      * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1320      * in which to place the data.
1321      * <p>Output: URI of the new data that was created.
1322      */
1323     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1324     public static final String ACTION_PASTE = "android.intent.action.PASTE";
1325     /**
1326      * Activity Action: Delete the given data from its container.
1327      * <p>Input: {@link #getData} is URI of data to be deleted.
1328      * <p>Output: nothing.
1329      */
1330     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1331     public static final String ACTION_DELETE = "android.intent.action.DELETE";
1332     /**
1333      * Activity Action: Run the data, whatever that means.
1334      * <p>Input: ?  (Note: this is currently specific to the test harness.)
1335      * <p>Output: nothing.
1336      */
1337     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1338     public static final String ACTION_RUN = "android.intent.action.RUN";
1339     /**
1340      * Activity Action: Perform a data synchronization.
1341      * <p>Input: ?
1342      * <p>Output: ?
1343      */
1344     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1345     public static final String ACTION_SYNC = "android.intent.action.SYNC";
1346     /**
1347      * Activity Action: Pick an activity given an intent, returning the class
1348      * selected.
1349      * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1350      * used with {@link PackageManager#queryIntentActivities} to determine the
1351      * set of activities from which to pick.
1352      * <p>Output: Class name of the activity that was selected.
1353      */
1354     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1355     public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1356     /**
1357      * Activity Action: Perform a search.
1358      * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1359      * is the text to search for.  If empty, simply
1360      * enter your search results Activity with the search UI activated.
1361      * <p>Output: nothing.
1362      */
1363     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1364     public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1365     /**
1366      * Activity Action: Start the platform-defined tutorial
1367      * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1368      * is the text to search for.  If empty, simply
1369      * enter your search results Activity with the search UI activated.
1370      * <p>Output: nothing.
1371      */
1372     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1373     public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1374     /**
1375      * Activity Action: Perform a web search.
1376      * <p>
1377      * Input: {@link android.app.SearchManager#QUERY
1378      * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1379      * a url starts with http or https, the site will be opened. If it is plain
1380      * text, Google search will be applied.
1381      * <p>
1382      * Output: nothing.
1383      */
1384     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1385     public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1386 
1387     /**
1388      * Activity Action: Perform assist action.
1389      * <p>
1390      * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1391      * additional optional contextual information about where the user was when they
1392      * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1393      * information.
1394      * Output: nothing.
1395      */
1396     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1397     public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
1398 
1399     /**
1400      * Activity Action: Perform voice assist action.
1401      * <p>
1402      * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1403      * additional optional contextual information about where the user was when they
1404      * requested the voice assist.
1405      * Output: nothing.
1406      * @hide
1407      */
1408     @SystemApi
1409     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1410     public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1411 
1412     /**
1413      * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1414      * application package at the time the assist was invoked.
1415      */
1416     public static final String EXTRA_ASSIST_PACKAGE
1417             = "android.intent.extra.ASSIST_PACKAGE";
1418 
1419     /**
1420      * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1421      * application package at the time the assist was invoked.
1422      */
1423     public static final String EXTRA_ASSIST_UID
1424             = "android.intent.extra.ASSIST_UID";
1425 
1426     /**
1427      * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1428      * information supplied by the current foreground app at the time of the assist request.
1429      * This is a {@link Bundle} of additional data.
1430      */
1431     public static final String EXTRA_ASSIST_CONTEXT
1432             = "android.intent.extra.ASSIST_CONTEXT";
1433 
1434     /**
1435      * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1436      * keyboard as the primary input device for assistance.
1437      */
1438     public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1439             "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1440 
1441     /**
1442      * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1443      * that was used to invoke the assist.
1444      */
1445     public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1446             "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1447 
1448     /**
1449      * Activity Action: List all available applications.
1450      * <p>Input: Nothing.
1451      * <p>Output: nothing.
1452      */
1453     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1454     public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1455     /**
1456      * Activity Action: Show settings for choosing wallpaper.
1457      * <p>Input: Nothing.
1458      * <p>Output: Nothing.
1459      */
1460     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1461     public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1462 
1463     /**
1464      * Activity Action: Show activity for reporting a bug.
1465      * <p>Input: Nothing.
1466      * <p>Output: Nothing.
1467      */
1468     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1469     public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1470 
1471     /**
1472      *  Activity Action: Main entry point for factory tests.  Only used when
1473      *  the device is booting in factory test node.  The implementing package
1474      *  must be installed in the system image.
1475      *  <p>Input: nothing
1476      *  <p>Output: nothing
1477      */
1478     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1479     public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1480 
1481     /**
1482      * Activity Action: The user pressed the "call" button to go to the dialer
1483      * or other appropriate UI for placing a call.
1484      * <p>Input: Nothing.
1485      * <p>Output: Nothing.
1486      */
1487     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1488     public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1489 
1490     /**
1491      * Activity Action: Start Voice Command.
1492      * <p>Input: Nothing.
1493      * <p>Output: Nothing.
1494      * <p class="note">
1495      * In some cases, a matching Activity may not exist, so ensure you
1496      * safeguard against this.
1497      */
1498     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1499     public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
1500 
1501     /**
1502      * Activity Action: Start action associated with long pressing on the
1503      * search key.
1504      * <p>Input: Nothing.
1505      * <p>Output: Nothing.
1506      */
1507     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1508     public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
1509 
1510     /**
1511      * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1512      * This intent is delivered to the package which installed the application, usually
1513      * Google Play.
1514      * <p>Input: No data is specified. The bug report is passed in using
1515      * an {@link #EXTRA_BUG_REPORT} field.
1516      * <p>Output: Nothing.
1517      *
1518      * @see #EXTRA_BUG_REPORT
1519      */
1520     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1521     public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
1522 
1523     /**
1524      * An incident or bug report has been taken, and a system app has requested it to be shared,
1525      * so trigger the confirmation screen.
1526      *
1527      * This will be sent directly to the registered receiver with the
1528      * android.permission.APPROVE_INCIDENT_REPORTS permission.
1529      * @hide
1530      */
1531     @SystemApi
1532     public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED =
1533             "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED";
1534 
1535     /**
1536      * An incident report has been taken, and the user has approved it for sharing.
1537      * <p>
1538      * This will be sent directly to the registered receiver, which must have
1539      * both the DUMP and USAGE_STATS permissions.
1540      * <p>
1541      * After receiving this, the application should wait until a suitable time
1542      * (e.g. network available), get the list of available reports with
1543      * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)}
1544      * and then when the reports have been successfully uploaded, call
1545      * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}.
1546      *
1547      * @hide
1548      */
1549     @SystemApi
1550     public static final String ACTION_INCIDENT_REPORT_READY =
1551             "android.intent.action.INCIDENT_REPORT_READY";
1552 
1553     /**
1554      * Activity Action: Show power usage information to the user.
1555      * <p>Input: Nothing.
1556      * <p>Output: Nothing.
1557      */
1558     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1559     public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
1560 
1561     /**
1562      * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1563      * to run.
1564      * <p>Input: Nothing.
1565      * <p>Output: Nothing.
1566      * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1567      * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1568      * @hide
1569      * @removed
1570      */
1571     @Deprecated
1572     @SystemApi
1573     public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1574             "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1575 
1576     /**
1577      * Activity Action: Setup wizard to launch after a platform update.  This
1578      * activity should have a string meta-data field associated with it,
1579      * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1580      * the platform for setup.  The activity will be launched only if
1581      * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1582      * same value.
1583      * <p>Input: Nothing.
1584      * <p>Output: Nothing.
1585      * @hide
1586      */
1587     @SystemApi
1588     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1589     public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
1590 
1591     /**
1592      * Activity Action: Start the Keyboard Shortcuts Helper screen.
1593      * <p>Input: Nothing.
1594      * <p>Output: Nothing.
1595      * @hide
1596      */
1597     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1598     public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
1599             "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
1600 
1601     /**
1602      * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1603      * <p>Input: Nothing.
1604      * <p>Output: Nothing.
1605      * @hide
1606      */
1607     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1608     public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
1609             "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
1610 
1611     /**
1612      * Activity Action: Show settings for managing network data usage of a
1613      * specific application. Applications should define an activity that offers
1614      * options to control data usage.
1615      */
1616     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1617     public static final String ACTION_MANAGE_NETWORK_USAGE =
1618             "android.intent.action.MANAGE_NETWORK_USAGE";
1619 
1620     /**
1621      * Activity Action: Launch application installer.
1622      * <p>
1623      * Input: The data must be a content: URI at which the application
1624      * can be retrieved.  As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1625      * you can also use "package:<package-name>" to install an application for the
1626      * current user that is already installed for another user. You can optionally supply
1627      * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1628      * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1629      * <p>
1630      * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1631      * succeeded.
1632      * <p>
1633      * <strong>Note:</strong>If your app is targeting API level higher than 25 you
1634      * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1635      * in order to launch the application installer.
1636      * </p>
1637      *
1638      * @see #EXTRA_INSTALLER_PACKAGE_NAME
1639      * @see #EXTRA_NOT_UNKNOWN_SOURCE
1640      * @see #EXTRA_RETURN_RESULT
1641      *
1642      * @deprecated use {@link android.content.pm.PackageInstaller} instead
1643      */
1644     @Deprecated
1645     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1646     public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1647 
1648     /**
1649      * Activity Action: Activity to handle split installation failures.
1650      * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1651      * but the split that contains the application isn't installed. When a split is
1652      * installed in this manner, the containing package usually doesn't know this is
1653      * happening. However, if an error occurs during installation, the containing
1654      * package can define a single activity handling this action to deal with such
1655      * failures.
1656      * <p>The activity handling this action must be in the base package.
1657      * <p>
1658      * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1659      * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1660      */
1661     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1662     public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1663 
1664     /**
1665      * Activity Action: Launch instant application installer.
1666      * <p class="note">
1667      * This is a protected intent that can only be sent by the system.
1668      * </p>
1669      *
1670      * @hide
1671      */
1672     @SystemApi
1673     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1674     public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1675             = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
1676 
1677     /**
1678      * Service Action: Resolve instant application.
1679      * <p>
1680      * The system will have a persistent connection to this service.
1681      * This is a protected intent that can only be sent by the system.
1682      * </p>
1683      *
1684      * @hide
1685      */
1686     @SystemApi
1687     @SdkConstant(SdkConstantType.SERVICE_ACTION)
1688     public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1689             = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
1690 
1691     /**
1692      * Activity Action: Launch instant app settings.
1693      *
1694      * <p class="note">
1695      * This is a protected intent that can only be sent by the system.
1696      * </p>
1697      *
1698      * @hide
1699      */
1700     @SystemApi
1701     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1702     public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1703             = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
1704 
1705     /**
1706      * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1707      * package.  Specifies the installer package name; this package will receive the
1708      * {@link #ACTION_APP_ERROR} intent.
1709      */
1710     public static final String EXTRA_INSTALLER_PACKAGE_NAME
1711             = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1712 
1713     /**
1714      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1715      * package.  Specifies that the application being installed should not be
1716      * treated as coming from an unknown source, but as coming from the app
1717      * invoking the Intent.  For this to work you must start the installer with
1718      * startActivityForResult().
1719      */
1720     public static final String EXTRA_NOT_UNKNOWN_SOURCE
1721             = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1722 
1723     /**
1724      * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1725      * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
1726      * data field originated from.
1727      */
1728     public static final String EXTRA_ORIGINATING_URI
1729             = "android.intent.extra.ORIGINATING_URI";
1730 
1731     /**
1732      * This extra can be used with any Intent used to launch an activity, supplying information
1733      * about who is launching that activity.  This field contains a {@link android.net.Uri}
1734      * object, typically an http: or https: URI of the web site that the referral came from;
1735      * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1736      * a native application that it came from.
1737      *
1738      * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1739      * instead of directly retrieving the extra.  It is also valid for applications to
1740      * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1741      * a string, not a Uri; the field here, if supplied, will always take precedence,
1742      * however.</p>
1743      *
1744      * @see #EXTRA_REFERRER_NAME
1745      */
1746     public static final String EXTRA_REFERRER
1747             = "android.intent.extra.REFERRER";
1748 
1749     /**
1750      * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1751      * than a {@link android.net.Uri} object.  Only for use in cases where Uri objects can
1752      * not be created, in particular when Intent extras are supplied through the
1753      * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1754      * schemes.
1755      *
1756      * @see #EXTRA_REFERRER
1757      */
1758     public static final String EXTRA_REFERRER_NAME
1759             = "android.intent.extra.REFERRER_NAME";
1760 
1761     /**
1762      * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1763      * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
1764      * Currently only a system app that hosts the provider authority "downloads" or holds the
1765      * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
1766      * @hide
1767      */
1768     @SystemApi
1769     public static final String EXTRA_ORIGINATING_UID
1770             = "android.intent.extra.ORIGINATING_UID";
1771 
1772     /**
1773      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1774      * package.  Tells the installer UI to skip the confirmation with the user
1775      * if the .apk is replacing an existing one.
1776      * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1777      * will no longer show an interstitial message about updating existing
1778      * applications so this is no longer needed.
1779      */
1780     @Deprecated
1781     public static final String EXTRA_ALLOW_REPLACE
1782             = "android.intent.extra.ALLOW_REPLACE";
1783 
1784     /**
1785      * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1786      * {@link #ACTION_UNINSTALL_PACKAGE}.  Specifies that the installer UI should
1787      * return to the application the result code of the install/uninstall.  The returned result
1788      * code will be {@link android.app.Activity#RESULT_OK} on success or
1789      * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1790      */
1791     public static final String EXTRA_RETURN_RESULT
1792             = "android.intent.extra.RETURN_RESULT";
1793 
1794     /**
1795      * Package manager install result code.  @hide because result codes are not
1796      * yet ready to be exposed.
1797      */
1798     public static final String EXTRA_INSTALL_RESULT
1799             = "android.intent.extra.INSTALL_RESULT";
1800 
1801     /**
1802      * Activity Action: Launch application uninstaller.
1803      * <p>
1804      * Input: The data must be a package: URI whose scheme specific part is
1805      * the package name of the current installed package to be uninstalled.
1806      * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1807      * <p>
1808      * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1809      * succeeded.
1810      * <p>
1811      * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1812      * since {@link Build.VERSION_CODES#P}.
1813      *
1814      * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1815      *             instead
1816      */
1817     @Deprecated
1818     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1819     public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1820 
1821     /**
1822      * Specify whether the package should be uninstalled for all users.
1823      * @hide because these should not be part of normal application flow.
1824      */
1825     public static final String EXTRA_UNINSTALL_ALL_USERS
1826             = "android.intent.extra.UNINSTALL_ALL_USERS";
1827 
1828     /**
1829      * A string that associates with a metadata entry, indicating the last run version of the
1830      * platform that was setup.
1831      *
1832      * @see #ACTION_UPGRADE_SETUP
1833      *
1834      * @hide
1835      */
1836     @SystemApi
1837     public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1838 
1839     /**
1840      * Activity action: Launch UI to manage the permissions of an app.
1841      * <p>
1842      * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1843      * will be managed by the launched UI.
1844      * </p>
1845      * <p>
1846      * Output: Nothing.
1847      * </p>
1848      *
1849      * @see #EXTRA_PACKAGE_NAME
1850      *
1851      * @hide
1852      */
1853     @SystemApi
1854     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1855     public static final String ACTION_MANAGE_APP_PERMISSIONS =
1856             "android.intent.action.MANAGE_APP_PERMISSIONS";
1857 
1858     /**
1859      * Activity action: Launch UI to manage a specific permissions of an app.
1860      * <p>
1861      * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission
1862      * will be managed by the launched UI.
1863      * </p>
1864      * <p>
1865      * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission
1866      * that should be managed by the launched UI.
1867      * </p>
1868      * <p>
1869      * <li> {@link #EXTRA_USER} specifies the UserHandle of the user that owns the app.
1870      * </p>
1871      * <p>
1872      * Output: Nothing.
1873      * </p>
1874      *
1875      * @see #EXTRA_PACKAGE_NAME
1876      * @see #EXTRA_PERMISSION_NAME
1877      * @see #EXTRA_USER
1878      *
1879      * @hide
1880      */
1881     @SystemApi
1882     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
1883     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1884     public static final String ACTION_MANAGE_APP_PERMISSION =
1885             "android.intent.action.MANAGE_APP_PERMISSION";
1886 
1887     /**
1888      * Activity action: Launch UI to manage permissions.
1889      * <p>
1890      * Input: Nothing.
1891      * </p>
1892      * <p>
1893      * Output: Nothing.
1894      * </p>
1895      *
1896      * @hide
1897      */
1898     @SystemApi
1899     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1900     public static final String ACTION_MANAGE_PERMISSIONS =
1901             "android.intent.action.MANAGE_PERMISSIONS";
1902 
1903     /**
1904      * Activity action: Launch UI to manage auto-revoke state.
1905      *
1906      * This is equivalent to Intent#ACTION_APPLICATION_DETAILS_SETTINGS
1907      *
1908      * <p>
1909      * Input: {@link Intent#setData data} should be a {@code package}-scheme {@link Uri} with
1910      * a package name, whose auto-revoke state will be reviewed (mandatory).
1911      * E.g. {@code Uri.fromParts("package", packageName, null) }
1912      * </p>
1913      * <p>
1914      * Output: Nothing.
1915      * </p>
1916      */
1917     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1918     public static final String ACTION_AUTO_REVOKE_PERMISSIONS =
1919             "android.intent.action.AUTO_REVOKE_PERMISSIONS";
1920 
1921     /**
1922      * Activity action: Launch UI to manage unused apps (hibernated apps).
1923      *
1924      * <p>
1925      * Input: Nothing.
1926      * </p>
1927      * <p>
1928      * Output: Nothing.
1929      * </p>
1930      */
1931     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1932     public static final String ACTION_MANAGE_UNUSED_APPS =
1933             "android.intent.action.MANAGE_UNUSED_APPS";
1934 
1935     /**
1936      * Activity action: Launch UI to review permissions for an app.
1937      * The system uses this intent if permission review for apps not
1938      * supporting the new runtime permissions model is enabled. In
1939      * this mode a permission review is required before any of the
1940      * app components can run.
1941      * <p>
1942      * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1943      * permissions will be reviewed (mandatory).
1944      * </p>
1945      * <p>
1946      * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1947      * be fired after the permission review (optional).
1948      * </p>
1949      * <p>
1950      * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1951      * be invoked after the permission review (optional).
1952      * </p>
1953      * <p>
1954      * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1955      * passed via {@link #EXTRA_INTENT} needs a result (optional).
1956      * </p>
1957      * <p>
1958      * Output: Nothing.
1959      * </p>
1960      *
1961      * @see #EXTRA_PACKAGE_NAME
1962      * @see #EXTRA_INTENT
1963      * @see #EXTRA_REMOTE_CALLBACK
1964      * @see #EXTRA_RESULT_NEEDED
1965      *
1966      * @hide
1967      */
1968     @SystemApi
1969     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1970     public static final String ACTION_REVIEW_PERMISSIONS =
1971             "android.intent.action.REVIEW_PERMISSIONS";
1972 
1973     /**
1974      * Activity action: Launch UI to show information about the usage
1975      * of a given permission group. This action would be handled by apps that
1976      * want to show details about how and why given permission group is being
1977      * used.
1978      * <p>
1979      * <strong>Important:</strong>You must protect the activity that handles
1980      * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE
1981      *  START_VIEW_PERMISSION_USAGE} permission to ensure that only the
1982      * system can launch this activity. The system will not launch
1983      * activities that are not properly protected.
1984      *
1985      * <p>
1986      * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group
1987      * for which the launched UI would be targeted.
1988      * </p>
1989      * <p>
1990      * Output: Nothing.
1991      * </p>
1992      */
1993     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1994     @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
1995     public static final String ACTION_VIEW_PERMISSION_USAGE =
1996             "android.intent.action.VIEW_PERMISSION_USAGE";
1997 
1998     /**
1999      * Activity action: Launch UI to show information about the usage of a given permission group in
2000      * a given period. This action would be handled by apps that want to show details about how and
2001      * why given permission group is being used.
2002      * <p>
2003      * <strong>Important:</strong>You must protect the activity that handles this action with the
2004      * {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE} permission to ensure that
2005      * only the system can launch this activity. The system will not launch activities that are not
2006      * properly protected.
2007      *
2008      * <p>
2009      * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group for which the
2010      * launched UI would be targeted.
2011      * </p>
2012      * <p>
2013      * Input: {@link #EXTRA_ATTRIBUTION_TAGS} specifies the attribution tags for the usage entry.
2014      * </p>
2015      * <p>
2016      * Input: {@link #EXTRA_START_TIME} specifies the start time of the period (epoch time in
2017      * millis). Both start time and end time are needed and start time must be <= end time.
2018      * </p>
2019      * <p>
2020      * Input: {@link #EXTRA_END_TIME} specifies the end time of the period (epoch time in
2021      * millis). Both start time and end time are needed and start time must be <= end time.
2022      * </p>
2023      * <p>
2024      * Output: Nothing.
2025      * </p>
2026      */
2027     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2028     @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
2029     public static final String ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD =
2030             "android.intent.action.VIEW_PERMISSION_USAGE_FOR_PERIOD";
2031 
2032     /**
2033      * Activity action: Launch UI to manage a default app.
2034      * <p>
2035      * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed
2036      * by the launched UI.
2037      * </p>
2038      * <p>
2039      * Output: Nothing.
2040      * </p>
2041      *
2042      * @hide
2043      */
2044     @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
2045     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2046     @SystemApi
2047     public static final String ACTION_MANAGE_DEFAULT_APP =
2048             "android.intent.action.MANAGE_DEFAULT_APP";
2049 
2050     /**
2051      * Intent extra: A role name.
2052      * <p>
2053      * Type: String
2054      * </p>
2055      *
2056      * @see android.app.role.RoleManager
2057      *
2058      * @hide
2059      */
2060     @SystemApi
2061     public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME";
2062 
2063     /**
2064      * Activity action: Launch UI to manage special app accesses.
2065      * <p>
2066      * Input: Nothing.
2067      * </p>
2068      * <p>
2069      * Output: Nothing.
2070      * </p>
2071      *
2072      * @hide
2073      */
2074     @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
2075     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2076     @SystemApi
2077     public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES =
2078             "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES";
2079 
2080     /**
2081      * Intent extra: A callback for reporting remote result as a bundle.
2082      * <p>
2083      * Type: IRemoteCallback
2084      * </p>
2085      *
2086      * @hide
2087      */
2088     @SystemApi
2089     public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
2090 
2091     /**
2092      * Intent extra: An app package name.
2093      * <p>
2094      * Type: String
2095      * </p>
2096      *
2097      */
2098     public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
2099 
2100     /**
2101      * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
2102      * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
2103      *
2104      * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
2105      * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
2106      * This is meant to enable the suspended app to better handle the state of being suspended.
2107      *
2108      * @see #ACTION_MY_PACKAGE_SUSPENDED
2109      * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2110      * @see PackageManager#isPackageSuspended()
2111      * @see PackageManager#getSuspendedPackageAppExtras()
2112      */
2113     public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
2114 
2115     /**
2116      * Intent extra: An app split name.
2117      * <p>
2118      * Type: String
2119      * </p>
2120      */
2121     public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
2122 
2123     /**
2124      * Intent extra: A {@link ComponentName} value.
2125      * <p>
2126      * Type: String
2127      * </p>
2128      */
2129     public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
2130 
2131     /**
2132      * Intent extra: An extra for specifying whether a result is needed.
2133      * <p>
2134      * Type: boolean
2135      * </p>
2136      *
2137      * @hide
2138      */
2139     @SystemApi
2140     public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
2141 
2142     /**
2143      * Intent extra: ID of the shortcut used to send the share intent. Will be sent with
2144      * {@link #ACTION_SEND}.
2145      *
2146      * @see ShortcutInfo#getId()
2147      *
2148      * <p>
2149      * Type: String
2150      * </p>
2151      */
2152     public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID";
2153 
2154     /**
2155      * Activity action: Launch UI to manage which apps have a given permission.
2156      * <p>
2157      * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission group
2158      * which will be managed by the launched UI.
2159      * </p>
2160      * <p>
2161      * Output: Nothing.
2162      * </p>
2163      *
2164      * @see #EXTRA_PERMISSION_NAME
2165      *
2166      * @hide
2167      */
2168     @SystemApi
2169     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2170     public static final String ACTION_MANAGE_PERMISSION_APPS =
2171             "android.intent.action.MANAGE_PERMISSION_APPS";
2172 
2173     /**
2174      * Intent extra: The name of a permission.
2175      * <p>
2176      * Type: String
2177      * </p>
2178      *
2179      * @hide
2180      */
2181     @SystemApi
2182     public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
2183 
2184     /**
2185      * Intent extra: The name of a permission group.
2186      * <p>
2187      * Type: String
2188      * </p>
2189      */
2190     public static final String EXTRA_PERMISSION_GROUP_NAME =
2191             "android.intent.extra.PERMISSION_GROUP_NAME";
2192 
2193     /**
2194      * Intent extra: The number of milliseconds.
2195      * <p>
2196      * Type: long
2197      * </p>
2198      */
2199     public static final String EXTRA_DURATION_MILLIS =
2200             "android.intent.extra.DURATION_MILLIS";
2201 
2202     /**
2203      * Activity action: Launch UI to review app uses of permissions.
2204      * <p>
2205      * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name
2206      * that will be displayed by the launched UI.  Do not pass both this and
2207      * {@link #EXTRA_PERMISSION_GROUP_NAME} .
2208      * </p>
2209      * <p>
2210      * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2211      * that will be displayed by the launched UI.  Do not pass both this and
2212      * {@link #EXTRA_PERMISSION_NAME}.
2213      * </p>
2214      * <p>
2215      * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2216      * activity to show (optional).  Must be non-negative.
2217      * </p>
2218      * <p>
2219      * Output: Nothing.
2220      * </p>
2221      * <p class="note">
2222      * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2223      * </p>
2224      *
2225      * @see #EXTRA_PERMISSION_NAME
2226      * @see #EXTRA_PERMISSION_GROUP_NAME
2227      * @see #EXTRA_DURATION_MILLIS
2228      *
2229      * @hide
2230      */
2231     @SystemApi
2232     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2233     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2234     public static final String ACTION_REVIEW_PERMISSION_USAGE =
2235             "android.intent.action.REVIEW_PERMISSION_USAGE";
2236 
2237     /**
2238      * Activity action: Launch UI to review the timeline history of permissions.
2239      * <p>
2240      * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2241      * that will be displayed by the launched UI.
2242      * </p>
2243      * <p>
2244      * Output: Nothing.
2245      * </p>
2246      * <p class="note">
2247      * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2248      * </p>
2249      *
2250      * @see #EXTRA_PERMISSION_GROUP_NAME
2251      *
2252      * @hide
2253      */
2254     @SystemApi
2255     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2256     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2257     public static final String ACTION_REVIEW_PERMISSION_HISTORY =
2258             "android.intent.action.REVIEW_PERMISSION_HISTORY";
2259 
2260     /**
2261      * Activity action: Launch UI to review ongoing app uses of permissions.
2262      * <p>
2263      * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2264      * activity to show (optional).  Must be non-negative.
2265      * </p>
2266      * <p>
2267      * Output: Nothing.
2268      * </p>
2269      * <p class="note">
2270      * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2271      * </p>
2272      *
2273      * @see #EXTRA_DURATION_MILLIS
2274      *
2275      * @hide
2276      */
2277     @SystemApi
2278     @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2279     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2280     public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE =
2281             "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE";
2282 
2283     /**
2284      * Activity action: Launch UI to review running accessibility services.
2285      * <p>
2286      * Input: Nothing.
2287      * </p>
2288      * <p>
2289      * Output: Nothing.
2290      * </p>
2291      *
2292      * @hide
2293      */
2294     @SystemApi
2295     @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES)
2296     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2297     public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES =
2298             "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES";
2299 
2300     // ---------------------------------------------------------------------
2301     // ---------------------------------------------------------------------
2302     // Standard intent broadcast actions (see action variable).
2303 
2304     /**
2305      * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
2306      * <p>
2307      * For historical reasons, the name of this broadcast action refers to the power
2308      * state of the screen but it is actually sent in response to changes in the
2309      * overall interactive state of the device.
2310      * </p><p>
2311      * This broadcast is sent when the device becomes non-interactive which may have
2312      * nothing to do with the screen turning off.  To determine the
2313      * actual state of the screen, use {@link android.view.Display#getState}.
2314      * </p><p>
2315      * See {@link android.os.PowerManager#isInteractive} for details.
2316      * </p>
2317      * You <em>cannot</em> receive this through components declared in
2318      * manifests, only by explicitly registering for it with
2319      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2320      * Context.registerReceiver()}.
2321      *
2322      * <p class="note">This is a protected intent that can only be sent
2323      * by the system.
2324      */
2325     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2326     public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
2327 
2328     /**
2329      * Broadcast Action: Sent when the device wakes up and becomes interactive.
2330      * <p>
2331      * For historical reasons, the name of this broadcast action refers to the power
2332      * state of the screen but it is actually sent in response to changes in the
2333      * overall interactive state of the device.
2334      * </p><p>
2335      * This broadcast is sent when the device becomes interactive which may have
2336      * nothing to do with the screen turning on.  To determine the
2337      * actual state of the screen, use {@link android.view.Display#getState}.
2338      * </p><p>
2339      * See {@link android.os.PowerManager#isInteractive} for details.
2340      * </p>
2341      * You <em>cannot</em> receive this through components declared in
2342      * manifests, only by explicitly registering for it with
2343      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2344      * Context.registerReceiver()}.
2345      *
2346      * <p class="note">This is a protected intent that can only be sent
2347      * by the system.
2348      */
2349     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2350     public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
2351 
2352     /**
2353      * Broadcast Action: Sent after the system stops dreaming.
2354      *
2355      * <p class="note">This is a protected intent that can only be sent by the system.
2356      * It is only sent to registered receivers.</p>
2357      */
2358     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2359     public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
2360 
2361     /**
2362      * Broadcast Action: Sent after the system starts dreaming.
2363      *
2364      * <p class="note">This is a protected intent that can only be sent by the system.
2365      * It is only sent to registered receivers.</p>
2366      */
2367     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2368     public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
2369 
2370     /**
2371      * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
2372      * keyguard is gone).
2373      *
2374      * <p class="note">This is a protected intent that can only be sent
2375      * by the system.
2376      */
2377     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2378     public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
2379 
2380     /**
2381      * Broadcast Action: The current time has changed.  Sent every
2382      * minute.  You <em>cannot</em> receive this through components declared
2383      * in manifests, only by explicitly registering for it with
2384      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2385      * Context.registerReceiver()}.
2386      *
2387      * <p class="note">This is a protected intent that can only be sent
2388      * by the system.
2389      */
2390     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2391     public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2392     /**
2393      * Broadcast Action: The time was set.
2394      */
2395     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2396     public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2397     /**
2398      * Broadcast Action: The date has changed.
2399      */
2400     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2401     public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2402     /**
2403      * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2404      * <ul>
2405      *   <li>{@link #EXTRA_TIMEZONE} - The java.util.TimeZone.getID() value identifying the new
2406      *   time zone.</li>
2407      * </ul>
2408      *
2409      * <p class="note">This is a protected intent that can only be sent
2410      * by the system.
2411      */
2412     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2413     public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2414     /**
2415      * Alarm Changed Action: This is broadcast when the AlarmClock
2416      * application's alarm is set or unset.  It is used by the
2417      * AlarmClock application and the StatusBar service.
2418      * @hide
2419      */
2420     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2421     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
2422     public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
2423 
2424     /**
2425      * Broadcast Action: This is broadcast once, after the user has finished
2426      * booting, but while still in the "locked" state. It can be used to perform
2427      * application-specific initialization, such as installing alarms. You must
2428      * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2429      * permission in order to receive this broadcast.
2430      * <p>
2431      * This broadcast is sent immediately at boot by all devices (regardless of
2432      * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2433      * higher. Upon receipt of this broadcast, the user is still locked and only
2434      * device-protected storage can be accessed safely. If you want to access
2435      * credential-protected storage, you need to wait for the user to be
2436      * unlocked (typically by entering their lock pattern or PIN for the first
2437      * time), after which the {@link #ACTION_USER_UNLOCKED} and
2438      * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2439      * <p>
2440      * To receive this broadcast, your receiver component must be marked as
2441      * being {@link ComponentInfo#directBootAware}.
2442      * <p class="note">
2443      * This is a protected intent that can only be sent by the system.
2444      *
2445      * @see Context#createDeviceProtectedStorageContext()
2446      */
2447     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2448     public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2449 
2450     /**
2451      * Broadcast Action: This is broadcast once, after the user has finished
2452      * booting. It can be used to perform application-specific initialization,
2453      * such as installing alarms. You must hold the
2454      * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2455      * order to receive this broadcast.
2456      * <p>
2457      * This broadcast is sent at boot by all devices (both with and without
2458      * direct boot support). Upon receipt of this broadcast, the user is
2459      * unlocked and both device-protected and credential-protected storage can
2460      * accessed safely.
2461      * <p>
2462      * If you need to run while the user is still locked (before they've entered
2463      * their lock pattern or PIN for the first time), you can listen for the
2464      * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2465      * <p class="note">
2466      * This is a protected intent that can only be sent by the system.
2467      */
2468     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2469     @BroadcastBehavior(includeBackground = true)
2470     public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
2471 
2472     /**
2473      * Broadcast Action: This is broadcast when a user action should request a
2474      * temporary system dialog to dismiss.  Some examples of temporary system
2475      * dialogs are the notification window-shade and the recent tasks dialog.
2476      *
2477      * @deprecated This intent is deprecated for third-party applications starting from Android
2478      *     {@link Build.VERSION_CODES#S} for security reasons. Unauthorized usage by applications
2479      *     will result in the broadcast intent being dropped for apps targeting API level less than
2480      *     {@link Build.VERSION_CODES#S} and in a {@link SecurityException} for apps targeting SDK
2481      *     level {@link Build.VERSION_CODES#S} or higher. Instrumentation initiated from the shell
2482      *     (eg. tests) is still able to use the intent. The platform will automatically collapse
2483      *     the proper system dialogs in the proper use-cases. For all others, the user is the one in
2484      *     control of closing dialogs.
2485      *
2486      * @see AccessibilityService#GLOBAL_ACTION_DISMISS_NOTIFICATION_SHADE
2487      */
2488     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2489     @RequiresPermission(android.Manifest.permission.BROADCAST_CLOSE_SYSTEM_DIALOGS)
2490     @Deprecated
2491     public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2492     /**
2493      * Broadcast Action: Trigger the download and eventual installation
2494      * of a package.
2495      * <p>Input: {@link #getData} is the URI of the package file to download.
2496      *
2497      * <p class="note">This is a protected intent that can only be sent
2498      * by the system.
2499      *
2500      * @deprecated This constant has never been used.
2501      */
2502     @Deprecated
2503     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2504     public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2505     /**
2506      * Broadcast Action: A new application package has been installed on the
2507      * device. The data contains the name of the package.  Note that the
2508      * newly installed package does <em>not</em> receive this broadcast.
2509      * <p>May include the following extras:
2510      * <ul>
2511      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2512      * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2513      * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2514      * </ul>
2515      *
2516      * <p class="note">This is a protected intent that can only be sent
2517      * by the system.
2518      */
2519     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2520     public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2521     /**
2522      * Broadcast Action: A new version of an application package has been
2523      * installed, replacing an existing version that was previously installed.
2524      * The data contains the name of the package.
2525      * <p>May include the following extras:
2526      * <ul>
2527      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2528      * </ul>
2529      *
2530      * <p class="note">This is a protected intent that can only be sent
2531      * by the system.
2532      */
2533     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2534     public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2535     /**
2536      * Broadcast Action: A new version of your application has been installed
2537      * over an existing one.  This is only sent to the application that was
2538      * replaced.  It does not contain any additional data; to receive it, just
2539      * use an intent filter for this action.
2540      *
2541      * <p class="note">This is a protected intent that can only be sent
2542      * by the system.
2543      */
2544     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2545     public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2546     /**
2547      * Broadcast Action: An existing application package has been removed from
2548      * the device.  The data contains the name of the package.  The package
2549      * that is being removed does <em>not</em> receive this Intent.
2550      * <ul>
2551      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2552      * to the package.
2553      * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2554      * application -- data and code -- is being removed.
2555      * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2556      * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2557      * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal that the application
2558      * was removed with the user-initiated action.
2559      * </ul>
2560      *
2561      * <p class="note">This is a protected intent that can only be sent
2562      * by the system.
2563      */
2564     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2565     public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2566     /**
2567      * Broadcast Action: An existing application package has been removed from
2568      * the device. The data contains the name of the package and the visibility
2569      * allow list. The package that is being removed does <em>not</em> receive
2570      * this Intent.
2571      * <ul>
2572      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2573      * to the package.
2574      * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2575      * application -- data and code -- is being removed.
2576      * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2577      * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2578      * <li> {@link #EXTRA_USER_INITIATED} containing boolean field to signal
2579      * that the application was removed with the user-initiated action.
2580      * <li> {@link #EXTRA_VISIBILITY_ALLOW_LIST} containing an int array to
2581      * indicate the visibility allow list.
2582      * </ul>
2583      *
2584      * <p class="note">This is a protected intent that can only be sent
2585      * by the system.
2586      *
2587      * @hide This broadcast is used internally by the system.
2588      */
2589     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2590     public static final String ACTION_PACKAGE_REMOVED_INTERNAL =
2591             "android.intent.action.PACKAGE_REMOVED_INTERNAL";
2592     /**
2593      * Broadcast Action: An existing application package has been completely
2594      * removed from the device.  The data contains the name of the package.
2595      * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2596      * {@link #EXTRA_DATA_REMOVED} is true and
2597      * {@link #EXTRA_REPLACING} is false of that broadcast.
2598      *
2599      * <ul>
2600      * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2601      * to the package.
2602      * </ul>
2603      *
2604      * <p class="note">This is a protected intent that can only be sent
2605      * by the system.
2606      */
2607     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2608     public static final String ACTION_PACKAGE_FULLY_REMOVED
2609             = "android.intent.action.PACKAGE_FULLY_REMOVED";
2610     /**
2611      * Broadcast Action: An existing application package has been changed (for
2612      * example, a component has been enabled or disabled).  The data contains
2613      * the name of the package.
2614      * <ul>
2615      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2616      * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
2617      * of the changed components (or the package name itself).
2618      * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2619      * default action of restarting the application.
2620      * </ul>
2621      *
2622      * <p class="note">This is a protected intent that can only be sent
2623      * by the system.
2624      */
2625     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2626     public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2627     /**
2628      * Broadcast Action: Sent to the system rollback manager when a package
2629      * needs to have rollback enabled.
2630      * <p class="note">
2631      * This is a protected intent that can only be sent by the system.
2632      * </p>
2633      *
2634      * @hide This broadcast is used internally by the system.
2635      */
2636     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2637     public static final String ACTION_PACKAGE_ENABLE_ROLLBACK =
2638             "android.intent.action.PACKAGE_ENABLE_ROLLBACK";
2639     /**
2640      * Broadcast Action: Sent to the system rollback manager when the rollback for a certain
2641      * package needs to be cancelled.
2642      *
2643      * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager
2644      * that enabling a specific rollback has timed out.
2645      *
2646      * @hide
2647      */
2648     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2649     public static final String ACTION_CANCEL_ENABLE_ROLLBACK =
2650             "android.intent.action.CANCEL_ENABLE_ROLLBACK";
2651     /**
2652      * Broadcast Action: A rollback has been committed.
2653      *
2654      * <p class="note">This is a protected intent that can only be sent
2655      * by the system. The receiver must hold MANAGE_ROLLBACK permission.
2656      *
2657      * @hide
2658      */
2659     @SystemApi
2660     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2661     public static final String ACTION_ROLLBACK_COMMITTED =
2662             "android.intent.action.ROLLBACK_COMMITTED";
2663     /**
2664      * @hide
2665      * Broadcast Action: Ask system services if there is any reason to
2666      * restart the given package.  The data contains the name of the
2667      * package.
2668      * <ul>
2669      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2670      * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2671      * </ul>
2672      *
2673      * <p class="note">This is a protected intent that can only be sent
2674      * by the system.
2675      */
2676     @SystemApi
2677     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2678     public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2679     /**
2680      * Broadcast Action: The user has restarted a package, and all of its
2681      * processes have been killed.  All runtime state
2682      * associated with it (processes, alarms, notifications, etc) should
2683      * be removed.  Note that the restarted package does <em>not</em>
2684      * receive this broadcast.
2685      * The data contains the name of the package.
2686      * <ul>
2687      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2688      * </ul>
2689      *
2690      * <p class="note">This is a protected intent that can only be sent
2691      * by the system.
2692      */
2693     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2694     public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2695     /**
2696      * Broadcast Action: The user has cleared the data of a package.  This should
2697      * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
2698      * its persistent data is erased and this broadcast sent.
2699      * Note that the cleared package does <em>not</em>
2700      * receive this broadcast. The data contains the name of the package.
2701      * <ul>
2702      * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2703      *      package whose data was cleared is an uninstalled instant app, then the UID
2704      *      will be -1. The platform keeps some meta-data associated with instant apps
2705      *      after they are uninstalled.
2706      * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2707      *      data was for an instant app.
2708      * </ul>
2709      *
2710      * <p class="note">This is a protected intent that can only be sent
2711      * by the system.
2712      */
2713     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2714     public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2715     /**
2716      * Broadcast Action: Packages have been suspended.
2717      * <p>Includes the following extras:
2718      * <ul>
2719      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2720      * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
2721      * </ul>
2722      *
2723      * <p class="note">This is a protected intent that can only be sent
2724      * by the system. It is only sent to registered receivers.
2725      */
2726     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2727     public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2728     /**
2729      * Broadcast Action: Packages have been unsuspended.
2730      * <p>Includes the following extras:
2731      * <ul>
2732      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2733      * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
2734      * </ul>
2735      *
2736      * <p class="note">This is a protected intent that can only be sent
2737      * by the system. It is only sent to registered receivers.
2738      */
2739     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2740     public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2741 
2742     /**
2743      * Broadcast Action: Distracting packages have been changed.
2744      * <p>Includes the following extras:
2745      * <ul>
2746      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed.
2747      * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed.
2748      * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages.
2749      * </ul>
2750      *
2751      * <p class="note">This is a protected intent that can only be sent
2752      * by the system. It is only sent to registered receivers.
2753      *
2754      * @see PackageManager#setDistractingPackageRestrictions(String[], int)
2755      * @hide
2756      */
2757     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2758     public static final String ACTION_DISTRACTING_PACKAGES_CHANGED =
2759             "android.intent.action.DISTRACTING_PACKAGES_CHANGED";
2760 
2761     /**
2762      * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
2763      * whenever a package is put into a suspended state or any of its app extras change while in the
2764      * suspended state.
2765      * <p> Optionally includes the following extras:
2766      * <ul>
2767      *     <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2768      *     useful information for the app being suspended.
2769      * </ul>
2770      * <p class="note">This is a protected intent that can only be sent
2771      * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2772      * the manifest.</em>
2773      *
2774      * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2775      * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2776      * @see PackageManager#isPackageSuspended()
2777      * @see PackageManager#getSuspendedPackageAppExtras()
2778      */
2779     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2780     public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2781 
2782     /**
2783      * Activity Action: Started to show more details about why an application was suspended.
2784      *
2785      * <p>Whenever the system detects an activity launch for a suspended app, this action can
2786      * be used to show more details about the reason for suspension.
2787      *
2788      * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2789      * handling this intent and protect it with
2790      * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2791      *
2792      * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2793      *
2794      * <p class="note">This is a protected intent that can only be sent
2795      * by the system.
2796      *
2797      * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2798      * PersistableBundle, String)
2799      * @see PackageManager#isPackageSuspended()
2800      * @see #ACTION_PACKAGES_SUSPENDED
2801      *
2802      * @hide
2803      */
2804     @SystemApi
2805     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2806     public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2807             "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2808 
2809     /**
2810      * Broadcast Action: Sent to indicate that the user unsuspended a package.
2811      *
2812      * <p>This can happen when the user taps on the neutral button of the
2813      * {@linkplain SuspendDialogInfo suspend-dialog} which was created by using
2814      * {@link SuspendDialogInfo#BUTTON_ACTION_UNSUSPEND}. This broadcast is only sent to the
2815      * suspending app that originally specified this dialog while calling
2816      * {@link PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2817      * PersistableBundle, SuspendDialogInfo)}.
2818      *
2819      * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the package that just
2820      * got unsuspended.
2821      *
2822      * <p class="note">This is a protected intent that can only be sent
2823      * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2824      * the manifest.</em>
2825      *
2826      * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2827      * PersistableBundle, SuspendDialogInfo)
2828      * @see PackageManager#isPackageSuspended()
2829      * @see SuspendDialogInfo#BUTTON_ACTION_MORE_DETAILS
2830      * @hide
2831      */
2832     @SystemApi
2833     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2834     public static final String ACTION_PACKAGE_UNSUSPENDED_MANUALLY =
2835             "android.intent.action.PACKAGE_UNSUSPENDED_MANUALLY";
2836 
2837     /**
2838      * Broadcast Action: Sent to a package that has been unsuspended.
2839      *
2840      * <p class="note">This is a protected intent that can only be sent
2841      * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2842      * the manifest.</em>
2843      *
2844      * @see #ACTION_MY_PACKAGE_SUSPENDED
2845      * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2846      * @see PackageManager#isPackageSuspended()
2847      * @see PackageManager#getSuspendedPackageAppExtras()
2848      */
2849     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2850     public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2851 
2852     /**
2853      * Broadcast Action: A user ID has been removed from the system.  The user
2854      * ID number is stored in the extra data under {@link #EXTRA_UID}.
2855      *
2856      * <p class="note">This is a protected intent that can only be sent
2857      * by the system.
2858      */
2859     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2860     public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
2861 
2862     /**
2863      * Broadcast Action: Sent to the installer package of an application when
2864      * that application is first launched (that is the first time it is moved
2865      * out of the stopped state).  The data contains the name of the package.
2866      *
2867      * <p>When the application is first launched, the application itself doesn't receive this
2868      * broadcast.</p>
2869      *
2870      * <p class="note">This is a protected intent that can only be sent
2871      * by the system.
2872      */
2873     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2874     public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2875 
2876     /**
2877      * Broadcast Action: Sent to the system package verifier when a package
2878      * needs to be verified. The data contains the package URI.
2879      * <p class="note">
2880      * This is a protected intent that can only be sent by the system.
2881      * </p>
2882      */
2883     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2884     public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2885 
2886     /**
2887      * Broadcast Action: Sent to the system package verifier when a package is
2888      * verified. The data contains the package URI.
2889      * <p class="note">
2890      * This is a protected intent that can only be sent by the system.
2891      */
2892     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2893     public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2894 
2895     /**
2896      * Broadcast Action: Sent to the system intent filter verifier when an
2897      * intent filter needs to be verified. The data contains the filter data
2898      * hosts to be verified against.
2899      * <p class="note">
2900      * This is a protected intent that can only be sent by the system.
2901      * </p>
2902      *
2903      * @hide
2904      * @deprecated Superseded by domain verification APIs. See {@link DomainVerificationManager}.
2905      */
2906     @Deprecated
2907     @SystemApi
2908     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2909     public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION =
2910             "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2911 
2912 
2913     /**
2914      * Broadcast Action: Sent to the system domain verification agent when an app's domains need
2915      * to be verified. The data contains the domains hosts to be verified against.
2916      * <p class="note">
2917      * This is a protected intent that can only be sent by the system.
2918      * </p>
2919      *
2920      * @hide
2921      */
2922     @SystemApi
2923     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2924     public static final String ACTION_DOMAINS_NEED_VERIFICATION =
2925             "android.intent.action.DOMAINS_NEED_VERIFICATION";
2926 
2927     /**
2928      * Broadcast Action: Resources for a set of packages (which were
2929      * previously unavailable) are currently
2930      * available since the media on which they exist is available.
2931      * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2932      * list of packages whose availability changed.
2933      * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2934      * list of uids of packages whose availability changed.
2935      * Note that the
2936      * packages in this list do <em>not</em> receive this broadcast.
2937      * The specified set of packages are now available on the system.
2938      * <p>Includes the following extras:
2939      * <ul>
2940      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2941      * whose resources(were previously unavailable) are currently available.
2942      * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2943      * packages whose resources(were previously unavailable)
2944      * are  currently available.
2945      * </ul>
2946      *
2947      * <p class="note">This is a protected intent that can only be sent
2948      * by the system.
2949      */
2950     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2951     public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2952         "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
2953 
2954     /**
2955      * Broadcast Action: Resources for a set of packages are currently
2956      * unavailable since the media on which they exist is unavailable.
2957      * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2958      * list of packages whose availability changed.
2959      * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2960      * list of uids of packages whose availability changed.
2961      * The specified set of packages can no longer be
2962      * launched and are practically unavailable on the system.
2963      * <p>Inclues the following extras:
2964      * <ul>
2965      * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2966      * whose resources are no longer available.
2967      * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2968      * whose resources are no longer available.
2969      * </ul>
2970      *
2971      * <p class="note">This is a protected intent that can only be sent
2972      * by the system.
2973      */
2974     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2975     public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
2976         "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
2977 
2978     /**
2979      * Broadcast Action: preferred activities have changed *explicitly*.
2980      *
2981      * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2982      * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2983      * be sent.
2984      *
2985      * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2986      *
2987      * @hide
2988      */
2989     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2990     public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2991             "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2992 
2993 
2994     /**
2995      * Broadcast Action:  The current system wallpaper has changed.  See
2996      * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
2997      * This should <em>only</em> be used to determine when the wallpaper
2998      * has changed to show the new wallpaper to the user.  You should certainly
2999      * never, in response to this, change the wallpaper or other attributes of
3000      * it such as the suggested size.  That would be unexpected, right?  You'd cause
3001      * all kinds of loops, especially if other apps are doing similar things,
3002      * right?  Of course.  So please don't do this.
3003      *
3004      * @deprecated Modern applications should use
3005      * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
3006      * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
3007      * shown behind their UI, rather than watching for this broadcast and
3008      * rendering the wallpaper on their own.
3009      */
3010     @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3011     public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
3012     /**
3013      * Broadcast Action: The current device {@link android.content.res.Configuration}
3014      * (orientation, locale, etc) has changed.  When such a change happens, the
3015      * UIs (view hierarchy) will need to be rebuilt based on this new
3016      * information; for the most part, applications don't need to worry about
3017      * this, because the system will take care of stopping and restarting the
3018      * application to make sure it sees the new changes.  Some system code that
3019      * can not be restarted will need to watch for this action and handle it
3020      * appropriately.
3021      *
3022      * <p class="note">
3023      * You <em>cannot</em> receive this through components declared
3024      * in manifests, only by explicitly registering for it with
3025      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3026      * Context.registerReceiver()}.
3027      *
3028      * <p class="note">This is a protected intent that can only be sent
3029      * by the system.
3030      *
3031      * @see android.content.res.Configuration
3032      */
3033     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3034     public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
3035 
3036     /**
3037      * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
3038      * such that the device may be eligible for the installation of additional configuration splits.
3039      * Configuration properties that can trigger this broadcast include locale and display density.
3040      *
3041      * <p class="note">
3042      * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
3043      * components declared in manifests. However, the receiver <em>must</em> hold the
3044      * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
3045      *
3046      * <p class="note">
3047      * This is a protected intent that can only be sent by the system.
3048      *
3049      * @hide
3050      */
3051     @SystemApi
3052     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3053     public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
3054             "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
3055     /**
3056      * Broadcast Action: The current device's locale has changed.
3057      *
3058      * <p class="note">This is a protected intent that can only be sent
3059      * by the system.
3060      */
3061     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3062     public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
3063     /**
3064      * Broadcast Action:  This is a <em>sticky broadcast</em> containing the
3065      * charging state, level, and other information about the battery.
3066      * See {@link android.os.BatteryManager} for documentation on the
3067      * contents of the Intent.
3068      *
3069      * <p class="note">
3070      * You <em>cannot</em> receive this through components declared
3071      * in manifests, only by explicitly registering for it with
3072      * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3073      * Context.registerReceiver()}.  See {@link #ACTION_BATTERY_LOW},
3074      * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
3075      * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
3076      * broadcasts that are sent and can be received through manifest
3077      * receivers.
3078      *
3079      * <p class="note">This is a protected intent that can only be sent
3080      * by the system.
3081      */
3082     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3083     public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
3084 
3085 
3086     /**
3087      * Broadcast Action: Sent when the current battery level changes.
3088      *
3089      * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
3090      * instances representing individual battery level changes with associated
3091      * extras from {@link #ACTION_BATTERY_CHANGED}.
3092      *
3093      * <p class="note">
3094      * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
3095      *
3096      * @hide
3097      */
3098     @SystemApi
3099     public static final String ACTION_BATTERY_LEVEL_CHANGED =
3100             "android.intent.action.BATTERY_LEVEL_CHANGED";
3101     /**
3102      * Broadcast Action:  Indicates low battery condition on the device.
3103      * This broadcast corresponds to the "Low battery warning" system dialog.
3104      *
3105      * <p class="note">This is a protected intent that can only be sent
3106      * by the system.
3107      */
3108     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3109     public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
3110     /**
3111      * Broadcast Action:  Indicates the battery is now okay after being low.
3112      * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
3113      * gone back up to an okay state.
3114      *
3115      * <p class="note">This is a protected intent that can only be sent
3116      * by the system.
3117      */
3118     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3119     public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
3120     /**
3121      * Broadcast Action:  External power has been connected to the device.
3122      * This is intended for applications that wish to register specifically to this notification.
3123      * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
3124      * stay active to receive this notification.  This action can be used to implement actions
3125      * that wait until power is available to trigger.
3126      *
3127      * <p class="note">This is a protected intent that can only be sent
3128      * by the system.
3129      */
3130     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3131     public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
3132     /**
3133      * Broadcast Action:  External power has been removed from the device.
3134      * This is intended for applications that wish to register specifically to this notification.
3135      * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
3136      * stay active to receive this notification.  This action can be used to implement actions
3137      * that wait until power is available to trigger.
3138      *
3139      * <p class="note">This is a protected intent that can only be sent
3140      * by the system.
3141      */
3142     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3143     public static final String ACTION_POWER_DISCONNECTED =
3144             "android.intent.action.ACTION_POWER_DISCONNECTED";
3145     /**
3146      * Broadcast Action:  Device is shutting down.
3147      * This is broadcast when the device is being shut down (completely turned
3148      * off, not sleeping).  Once the broadcast is complete, the final shutdown
3149      * will proceed and all unsaved data lost.  Apps will not normally need
3150      * to handle this, since the foreground activity will be paused as well.
3151      * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
3152      * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3153      * Context.registerReceiver}.
3154      *
3155      * <p class="note">This is a protected intent that can only be sent
3156      * by the system.
3157      * <p>May include the following extras:
3158      * <ul>
3159      * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
3160      * shutdown is only for userspace processes.  If not set, assumed to be false.
3161      * </ul>
3162      */
3163     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3164     public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
3165     /**
3166      * Activity Action:  Start this activity to request system shutdown.
3167      * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
3168      * to request confirmation from the user before shutting down. The optional boolean
3169      * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
3170      * indicate that the shutdown is requested by the user.
3171      *
3172      * <p class="note">This is a protected intent that can only be sent
3173      * by the system.
3174      *
3175      * {@hide}
3176      */
3177     public static final String ACTION_REQUEST_SHUTDOWN
3178             = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
3179     /**
3180      * Broadcast Action: A sticky broadcast that indicates low storage space
3181      * condition on the device
3182      * <p class="note">
3183      * This is a protected intent that can only be sent by the system.
3184      *
3185      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3186      *             or above, this broadcast will no longer be delivered to any
3187      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3188      *             apps are strongly encouraged to use the improved
3189      *             {@link Context#getCacheDir()} behavior so the system can
3190      *             automatically free up storage when needed.
3191      */
3192     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3193     @Deprecated
3194     public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
3195     /**
3196      * Broadcast Action: Indicates low storage space condition on the device no
3197      * longer exists
3198      * <p class="note">
3199      * This is a protected intent that can only be sent by the system.
3200      *
3201      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3202      *             or above, this broadcast will no longer be delivered to any
3203      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3204      *             apps are strongly encouraged to use the improved
3205      *             {@link Context#getCacheDir()} behavior so the system can
3206      *             automatically free up storage when needed.
3207      */
3208     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3209     @Deprecated
3210     public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
3211     /**
3212      * Broadcast Action: A sticky broadcast that indicates a storage space full
3213      * condition on the device. This is intended for activities that want to be
3214      * able to fill the data partition completely, leaving only enough free
3215      * space to prevent system-wide SQLite failures.
3216      * <p class="note">
3217      * This is a protected intent that can only be sent by the system.
3218      *
3219      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3220      *             or above, this broadcast will no longer be delivered to any
3221      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3222      *             apps are strongly encouraged to use the improved
3223      *             {@link Context#getCacheDir()} behavior so the system can
3224      *             automatically free up storage when needed.
3225      * @hide
3226      */
3227     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3228     @Deprecated
3229     public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
3230     /**
3231      * Broadcast Action: Indicates storage space full condition on the device no
3232      * longer exists.
3233      * <p class="note">
3234      * This is a protected intent that can only be sent by the system.
3235      *
3236      * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3237      *             or above, this broadcast will no longer be delivered to any
3238      *             {@link BroadcastReceiver} defined in your manifest. Instead,
3239      *             apps are strongly encouraged to use the improved
3240      *             {@link Context#getCacheDir()} behavior so the system can
3241      *             automatically free up storage when needed.
3242      * @hide
3243      */
3244     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3245     @Deprecated
3246     public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
3247     /**
3248      * Broadcast Action:  Indicates low memory condition notification acknowledged by user
3249      * and package management should be started.
3250      * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
3251      * notification.
3252      */
3253     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3254     public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
3255     /**
3256      * Broadcast Action:  The device has entered USB Mass Storage mode.
3257      * This is used mainly for the USB Settings panel.
3258      * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3259      * when the SD card file system is mounted or unmounted
3260      * @deprecated replaced by android.os.storage.StorageEventListener
3261      */
3262     @Deprecated
3263     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3264     public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
3265 
3266     /**
3267      * Broadcast Action:  The device has exited USB Mass Storage mode.
3268      * This is used mainly for the USB Settings panel.
3269      * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3270      * when the SD card file system is mounted or unmounted
3271      * @deprecated replaced by android.os.storage.StorageEventListener
3272      */
3273     @Deprecated
3274     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3275     public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
3276 
3277     /**
3278      * Broadcast Action:  External media has been removed.
3279      * The path to the mount point for the removed media is contained in the Intent.mData field.
3280      */
3281     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3282     public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
3283 
3284     /**
3285      * Broadcast Action:  External media is present, but not mounted at its mount point.
3286      * The path to the mount point for the unmounted media is contained in the Intent.mData field.
3287      */
3288     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3289     public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
3290 
3291     /**
3292      * Broadcast Action:  External media is present, and being disk-checked
3293      * The path to the mount point for the checking media is contained in the Intent.mData field.
3294      */
3295     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3296     public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
3297 
3298     /**
3299      * Broadcast Action:  External media is present, but is using an incompatible fs (or is blank)
3300      * The path to the mount point for the checking media is contained in the Intent.mData field.
3301      */
3302     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3303     public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
3304 
3305     /**
3306      * Broadcast Action:  External media is present and mounted at its mount point.
3307      * The path to the mount point for the mounted media is contained in the Intent.mData field.
3308      * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
3309      * media was mounted read only.
3310      */
3311     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3312     public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
3313 
3314     /**
3315      * Broadcast Action:  External media is unmounted because it is being shared via USB mass storage.
3316      * The path to the mount point for the shared media is contained in the Intent.mData field.
3317      */
3318     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3319     public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
3320 
3321     /**
3322      * Broadcast Action:  External media is no longer being shared via USB mass storage.
3323      * The path to the mount point for the previously shared media is contained in the Intent.mData field.
3324      *
3325      * @hide
3326      */
3327     public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
3328 
3329     /**
3330      * Broadcast Action:  External media was removed from SD card slot, but mount point was not unmounted.
3331      * The path to the mount point for the removed media is contained in the Intent.mData field.
3332      */
3333     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3334     public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
3335 
3336     /**
3337      * Broadcast Action:  External media is present but cannot be mounted.
3338      * The path to the mount point for the unmountable media is contained in the Intent.mData field.
3339      */
3340     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3341     public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
3342 
3343    /**
3344      * Broadcast Action:  User has expressed the desire to remove the external storage media.
3345      * Applications should close all files they have open within the mount point when they receive this intent.
3346      * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
3347      */
3348     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3349     public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
3350 
3351     /**
3352      * Broadcast Action:  The media scanner has started scanning a directory.
3353      * The path to the directory being scanned is contained in the Intent.mData field.
3354      */
3355     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3356     public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
3357 
3358    /**
3359      * Broadcast Action:  The media scanner has finished scanning a directory.
3360      * The path to the scanned directory is contained in the Intent.mData field.
3361      */
3362     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3363     public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
3364 
3365     /**
3366      * Broadcast Action: Request the media scanner to scan a file and add it to
3367      * the media database.
3368      * <p>
3369      * The path to the file is contained in {@link Intent#getData()}.
3370      *
3371      * @deprecated Callers should migrate to inserting items directly into
3372      *             {@link MediaStore}, where they will be automatically scanned
3373      *             after each mutation.
3374      */
3375     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3376     @Deprecated
3377     public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
3378 
3379    /**
3380      * Broadcast Action:  The "Media Button" was pressed.  Includes a single
3381      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3382      * caused the broadcast.
3383      */
3384     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3385     public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
3386 
3387     /**
3388      * Broadcast Action:  The "Camera Button" was pressed.  Includes a single
3389      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3390      * caused the broadcast.
3391      */
3392     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3393     public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
3394 
3395     // *** NOTE: @todo(*) The following really should go into a more domain-specific
3396     // location; they are not general-purpose actions.
3397 
3398     /**
3399      * Broadcast Action: A GTalk connection has been established.
3400      */
3401     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3402     public static final String ACTION_GTALK_SERVICE_CONNECTED =
3403             "android.intent.action.GTALK_CONNECTED";
3404 
3405     /**
3406      * Broadcast Action: A GTalk connection has been disconnected.
3407      */
3408     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3409     public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
3410             "android.intent.action.GTALK_DISCONNECTED";
3411 
3412     /**
3413      * Broadcast Action: An input method has been changed.
3414      */
3415     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3416     public static final String ACTION_INPUT_METHOD_CHANGED =
3417             "android.intent.action.INPUT_METHOD_CHANGED";
3418 
3419     /**
3420      * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
3421      * more radios have been turned off or on. The intent will have the following extra value:</p>
3422      * <ul>
3423      *   <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
3424      *   then cell radio and possibly other radios such as bluetooth or WiFi may have also been
3425      *   turned off</li>
3426      * </ul>
3427      *
3428      * <p class="note">This is a protected intent that can only be sent by the system.</p>
3429      */
3430     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3431     public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
3432 
3433     /**
3434      * Broadcast Action: Some content providers have parts of their namespace
3435      * where they publish new events or items that the user may be especially
3436      * interested in. For these things, they may broadcast this action when the
3437      * set of interesting items change.
3438      *
3439      * For example, GmailProvider sends this notification when the set of unread
3440      * mail in the inbox changes.
3441      *
3442      * <p>The data of the intent identifies which part of which provider
3443      * changed. When queried through the content resolver, the data URI will
3444      * return the data set in question.
3445      *
3446      * <p>The intent will have the following extra values:
3447      * <ul>
3448      *   <li><em>count</em> - The number of items in the data set. This is the
3449      *       same as the number of items in the cursor returned by querying the
3450      *       data URI. </li>
3451      * </ul>
3452      *
3453      * This intent will be sent at boot (if the count is non-zero) and when the
3454      * data set changes. It is possible for the data set to change without the
3455      * count changing (for example, if a new unread message arrives in the same
3456      * sync operation in which a message is archived). The phone should still
3457      * ring/vibrate/etc as normal in this case.
3458      */
3459     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3460     public static final String ACTION_PROVIDER_CHANGED =
3461             "android.intent.action.PROVIDER_CHANGED";
3462 
3463     /**
3464      * Broadcast Action: Wired Headset plugged in or unplugged.
3465      *
3466      * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
3467      *   and documentation.
3468      * <p>If the minimum SDK version of your application is
3469      * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
3470      * to the <code>AudioManager</code> constant in your receiver registration code instead.
3471      */
3472     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3473     public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
3474 
3475     /**
3476      * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
3477      * <ul>
3478      *   <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
3479      * </ul>
3480      *
3481      * <p class="note">This is a protected intent that can only be sent
3482      * by the system.
3483      *
3484      * @hide
3485      */
3486     //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3487     public static final String ACTION_ADVANCED_SETTINGS_CHANGED
3488             = "android.intent.action.ADVANCED_SETTINGS";
3489 
3490     /**
3491      *  Broadcast Action: Sent after application restrictions are changed.
3492      *
3493      * <p class="note">This is a protected intent that can only be sent
3494      * by the system.</p>
3495      */
3496     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3497     public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
3498             "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
3499 
3500     /**
3501      * Broadcast Action: An outgoing call is about to be placed.
3502      *
3503      * <p>The Intent will have the following extra value:</p>
3504      * <ul>
3505      *   <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
3506      *       the phone number originally intended to be dialed.</li>
3507      * </ul>
3508      * <p>Once the broadcast is finished, the resultData is used as the actual
3509      * number to call.  If  <code>null</code>, no call will be placed.</p>
3510      * <p>It is perfectly acceptable for multiple receivers to process the
3511      * outgoing call in turn: for example, a parental control application
3512      * might verify that the user is authorized to place the call at that
3513      * time, then a number-rewriting application might add an area code if
3514      * one was not specified.</p>
3515      * <p>For consistency, any receiver whose purpose is to prohibit phone
3516      * calls should have a priority of 0, to ensure it will see the final
3517      * phone number to be dialed.
3518      * Any receiver whose purpose is to rewrite phone numbers to be called
3519      * should have a positive priority.
3520      * Negative priorities are reserved for the system for this broadcast;
3521      * using them may cause problems.</p>
3522      * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3523      * abort the broadcast.</p>
3524      * <p>Emergency calls cannot be intercepted using this mechanism, and
3525      * other calls cannot be modified to call emergency numbers using this
3526      * mechanism.
3527      * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3528      * call to use their own service instead. Those apps should first prevent
3529      * the call from being placed by setting resultData to <code>null</code>
3530      * and then start their own app to make the call.
3531      * <p>You must hold the
3532      * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3533      * permission to receive this Intent.</p>
3534      *
3535      * <p class="note">This is a protected intent that can only be sent
3536      * by the system.
3537      *
3538      * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to
3539      * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast.
3540      * This means that attempts to re-write the outgoing call by other apps using this intent will
3541      * be ignored.
3542      * </p>
3543      *
3544      * @deprecated Apps that redirect outgoing calls should use the
3545      * {@link android.telecom.CallRedirectionService} API.  Apps that perform call screening
3546      * should use the {@link android.telecom.CallScreeningService} API.  Apps which need to be
3547      * notified of basic call state should use
3548      * {@link android.telephony.PhoneStateListener#onCallStateChanged(int, String)} to determine
3549      * when a new outgoing call is placed.
3550      */
3551     @Deprecated
3552     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3553     public static final String ACTION_NEW_OUTGOING_CALL =
3554             "android.intent.action.NEW_OUTGOING_CALL";
3555 
3556     /**
3557      * Broadcast Action: Have the device reboot.  This is only for use by
3558      * system code.
3559      *
3560      * <p class="note">This is a protected intent that can only be sent
3561      * by the system.
3562      */
3563     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3564     public static final String ACTION_REBOOT =
3565             "android.intent.action.REBOOT";
3566 
3567     /**
3568      * Broadcast Action:  A sticky broadcast for changes in the physical
3569      * docking state of the device.
3570      *
3571      * <p>The intent will have the following extra values:
3572      * <ul>
3573      *   <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
3574      *       state, indicating which dock the device is physically in.</li>
3575      * </ul>
3576      * <p>This is intended for monitoring the current physical dock state.
3577      * See {@link android.app.UiModeManager} for the normal API dealing with
3578      * dock mode changes.
3579      */
3580     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3581     public static final String ACTION_DOCK_EVENT =
3582             "android.intent.action.DOCK_EVENT";
3583 
3584     /**
3585      * Broadcast Action: A broadcast when idle maintenance can be started.
3586      * This means that the user is not interacting with the device and is
3587      * not expected to do so soon. Typical use of the idle maintenance is
3588      * to perform somehow expensive tasks that can be postponed at a moment
3589      * when they will not degrade user experience.
3590      * <p>
3591      * <p class="note">In order to keep the device responsive in case of an
3592      * unexpected user interaction, implementations of a maintenance task
3593      * should be interruptible. In such a scenario a broadcast with action
3594      * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3595      * should not do the maintenance work in
3596      * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3597      * maintenance service by {@link Context#startService(Intent)}. Also
3598      * you should hold a wake lock while your maintenance service is running
3599      * to prevent the device going to sleep.
3600      * </p>
3601      * <p>
3602      * <p class="note">This is a protected intent that can only be sent by
3603      * the system.
3604      * </p>
3605      *
3606      * @see #ACTION_IDLE_MAINTENANCE_END
3607      *
3608      * @hide
3609      */
3610     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3611     public static final String ACTION_IDLE_MAINTENANCE_START =
3612             "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3613 
3614     /**
3615      * Broadcast Action:  A broadcast when idle maintenance should be stopped.
3616      * This means that the user was not interacting with the device as a result
3617      * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3618      * was sent and now the user started interacting with the device. Typical
3619      * use of the idle maintenance is to perform somehow expensive tasks that
3620      * can be postponed at a moment when they will not degrade user experience.
3621      * <p>
3622      * <p class="note">In order to keep the device responsive in case of an
3623      * unexpected user interaction, implementations of a maintenance task
3624      * should be interruptible. Hence, on receiving a broadcast with this
3625      * action, the maintenance task should be interrupted as soon as possible.
3626      * In other words, you should not do the maintenance work in
3627      * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3628      * maintenance service that was started on receiving of
3629      * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3630      * lock you acquired when your maintenance service started.
3631      * </p>
3632      * <p class="note">This is a protected intent that can only be sent
3633      * by the system.
3634      *
3635      * @see #ACTION_IDLE_MAINTENANCE_START
3636      *
3637      * @hide
3638      */
3639     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3640     public static final String ACTION_IDLE_MAINTENANCE_END =
3641             "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3642 
3643     /**
3644      * Broadcast Action: a remote intent is to be broadcasted.
3645      *
3646      * A remote intent is used for remote RPC between devices. The remote intent
3647      * is serialized and sent from one device to another device. The receiving
3648      * device parses the remote intent and broadcasts it. Note that anyone can
3649      * broadcast a remote intent. However, if the intent receiver of the remote intent
3650      * does not trust intent broadcasts from arbitrary intent senders, it should require
3651      * the sender to hold certain permissions so only trusted sender's broadcast will be
3652      * let through.
3653      * @hide
3654      */
3655     public static final String ACTION_REMOTE_INTENT =
3656             "com.google.android.c2dm.intent.RECEIVE";
3657 
3658     /**
3659      * Broadcast Action: This is broadcast once when the user is booting after a
3660      * system update. It can be used to perform cleanup or upgrades after a
3661      * system update.
3662      * <p>
3663      * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3664      * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3665      * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3666      * sent to receivers in the system image.
3667      *
3668      * @hide
3669      */
3670     @SystemApi
3671     public static final String ACTION_PRE_BOOT_COMPLETED =
3672             "android.intent.action.PRE_BOOT_COMPLETED";
3673 
3674     /**
3675      * Broadcast to a specific application to query any supported restrictions to impose
3676      * on restricted users. The broadcast intent contains an extra
3677      * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3678      * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3679      * String[] depending on the restriction type.<p/>
3680      * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
3681      * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3682      * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3683      * The activity specified by that intent will be launched for a result which must contain
3684      * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3685      * The keys and values of the returned restrictions will be persisted.
3686      * @see RestrictionEntry
3687      */
3688     public static final String ACTION_GET_RESTRICTION_ENTRIES =
3689             "android.intent.action.GET_RESTRICTION_ENTRIES";
3690 
3691     /**
3692      * Sent the first time a user is starting, to allow system apps to
3693      * perform one time initialization.  (This will not be seen by third
3694      * party applications because a newly initialized user does not have any
3695      * third party applications installed for it.)  This is sent early in
3696      * starting the user, around the time the home app is started, before
3697      * {@link #ACTION_BOOT_COMPLETED} is sent.  This is sent as a foreground
3698      * broadcast, since it is part of a visible user interaction; be as quick
3699      * as possible when handling it.
3700      */
3701     public static final String ACTION_USER_INITIALIZE =
3702             "android.intent.action.USER_INITIALIZE";
3703 
3704     /**
3705      * Sent when a user switch is happening, causing the process's user to be
3706      * brought to the foreground.  This is only sent to receivers registered
3707      * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3708      * Context.registerReceiver}.  It is sent to the user that is going to the
3709      * foreground.  This is sent as a foreground
3710      * broadcast, since it is part of a visible user interaction; be as quick
3711      * as possible when handling it.
3712      */
3713     public static final String ACTION_USER_FOREGROUND =
3714             "android.intent.action.USER_FOREGROUND";
3715 
3716     /**
3717      * Sent when a user switch is happening, causing the process's user to be
3718      * sent to the background.  This is only sent to receivers registered
3719      * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3720      * Context.registerReceiver}.  It is sent to the user that is going to the
3721      * background.  This is sent as a foreground
3722      * broadcast, since it is part of a visible user interaction; be as quick
3723      * as possible when handling it.
3724      */
3725     public static final String ACTION_USER_BACKGROUND =
3726             "android.intent.action.USER_BACKGROUND";
3727 
3728     /**
3729      * Broadcast sent to the system when a user is added. Carries an extra
3730      * EXTRA_USER_HANDLE that has the userHandle of the new user.  It is sent to
3731      * all running users.  You must hold
3732      * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3733      * @hide
3734      */
3735     @SystemApi
3736     public static final String ACTION_USER_ADDED =
3737             "android.intent.action.USER_ADDED";
3738 
3739     /**
3740      * Broadcast sent by the system when a user is started. Carries an extra
3741      * {@link EXTRA_USER_HANDLE} that has the userHandle of the user.  This is only sent to
3742      * registered receivers, not manifest receivers.  It is sent to the user
3743      * that has been started.  This is sent as a foreground
3744      * broadcast, since it is part of a visible user interaction; be as quick
3745      * as possible when handling it.
3746      * @hide
3747      */
3748     public static final String ACTION_USER_STARTED =
3749             "android.intent.action.USER_STARTED";
3750 
3751     /**
3752      * Broadcast sent when a user is in the process of starting.  Carries an extra
3753      * {@link EXTRA_USER_HANDLE} that has the userHandle of the user.  This is only
3754      * sent to registered receivers, not manifest receivers.  It is sent to all
3755      * users (including the one that is being started).  You must hold
3756      * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3757      * this broadcast.  This is sent as a background broadcast, since
3758      * its result is not part of the primary UX flow; to safely keep track of
3759      * started/stopped state of a user you can use this in conjunction with
3760      * {@link #ACTION_USER_STOPPING}.  It is <b>not</b> generally safe to use with
3761      * other user state broadcasts since those are foreground broadcasts so can
3762      * execute in a different order.
3763      * @hide
3764      */
3765     public static final String ACTION_USER_STARTING =
3766             "android.intent.action.USER_STARTING";
3767 
3768     /**
3769      * Broadcast sent when a user is going to be stopped.  Carries an extra
3770      * {@link EXTRA_USER_HANDLE} that has the userHandle of the user.  This is only
3771      * sent to registered receivers, not manifest receivers.  It is sent to all
3772      * users (including the one that is being stopped).  You must hold
3773      * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3774      * this broadcast.  The user will not stop until all receivers have
3775      * handled the broadcast.  This is sent as a background broadcast, since
3776      * its result is not part of the primary UX flow; to safely keep track of
3777      * started/stopped state of a user you can use this in conjunction with
3778      * {@link #ACTION_USER_STARTING}.  It is <b>not</b> generally safe to use with
3779      * other user state broadcasts since those are foreground broadcasts so can
3780      * execute in a different order.
3781      * @hide
3782      */
3783     public static final String ACTION_USER_STOPPING =
3784             "android.intent.action.USER_STOPPING";
3785 
3786     /**
3787      * Broadcast sent to the system when a user is stopped. Carries an extra
3788      * {@link EXTRA_USER_HANDLE} that has the userHandle of the user.  This is similar to
3789      * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3790      * specific package.  This is only sent to registered receivers, not manifest
3791      * receivers.  It is sent to all running users <em>except</em> the one that
3792      * has just been stopped (which is no longer running).
3793      * @hide
3794      */
3795     @TestApi
3796     public static final String ACTION_USER_STOPPED =
3797             "android.intent.action.USER_STOPPED";
3798 
3799     /**
3800      * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
3801      * the userHandle of the user.  It is sent to all running users except the
3802      * one that has been removed. The user will not be completely removed until all receivers have
3803      * handled the broadcast. You must hold
3804      * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3805      * @hide
3806      */
3807     @SystemApi
3808     public static final String ACTION_USER_REMOVED =
3809             "android.intent.action.USER_REMOVED";
3810 
3811     /**
3812      * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
3813      * the userHandle of the user to become the current one. This is only sent to
3814      * registered receivers, not manifest receivers.  It is sent to all running users.
3815      * You must hold
3816      * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3817      * @hide
3818      */
3819     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
3820     public static final String ACTION_USER_SWITCHED =
3821             "android.intent.action.USER_SWITCHED";
3822 
3823     /**
3824      * Broadcast Action: Sent when the credential-encrypted private storage has
3825      * become unlocked for the target user. This is only sent to registered
3826      * receivers, not manifest receivers.
3827      */
3828     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3829     public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3830 
3831     /**
3832      * Broadcast sent to the system when a user's information changes. Carries an extra
3833      * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
3834      * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
3835      * @hide
3836      */
3837     public static final String ACTION_USER_INFO_CHANGED =
3838             "android.intent.action.USER_INFO_CHANGED";
3839 
3840     /**
3841      * Broadcast sent to the primary user when an associated managed profile is added (the profile
3842      * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
3843      * the UserHandle of the profile that was added. Only applications (for example Launchers)
3844      * that need to display merged content across both primary and managed profiles need to
3845      * worry about this broadcast. This is only sent to registered receivers,
3846      * not manifest receivers.
3847      */
3848     public static final String ACTION_MANAGED_PROFILE_ADDED =
3849             "android.intent.action.MANAGED_PROFILE_ADDED";
3850 
3851     /**
3852      * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
3853      * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3854      * Only applications (for example Launchers) that need to display merged content across both
3855      * primary and managed profiles need to worry about this broadcast. This is only sent to
3856      * registered receivers, not manifest receivers.
3857      */
3858     public static final String ACTION_MANAGED_PROFILE_REMOVED =
3859             "android.intent.action.MANAGED_PROFILE_REMOVED";
3860 
3861     /**
3862      * Broadcast sent to the primary user when the credential-encrypted private storage for
3863      * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3864      * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3865      * Launchers) that need to display merged content across both primary and managed profiles
3866      * need to worry about this broadcast. This is only sent to registered receivers,
3867      * not manifest receivers.
3868      */
3869     public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3870             "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3871 
3872     /**
3873      * Broadcast sent to the primary user when an associated managed profile has become available.
3874      * Currently this includes when the user disables quiet mode for the profile. Carries an extra
3875      * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3876      * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3877      * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3878      */
3879     public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3880             "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3881 
3882     /**
3883      * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3884      * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3885      * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3886      * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3887      * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3888      */
3889     public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3890             "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
3891 
3892     /**
3893      * Broadcast sent to the parent user when an associated profile has been started and unlocked.
3894      * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile.
3895      * This is only sent to registered receivers, not manifest receivers.
3896      */
3897     public static final String ACTION_PROFILE_ACCESSIBLE =
3898             "android.intent.action.PROFILE_ACCESSIBLE";
3899 
3900     /**
3901      * Broadcast sent to the parent user when an associated profile has stopped.
3902      * Carries an extra {@link #EXTRA_USER} that specifies the {@link UserHandle} of the profile.
3903      * This is only sent to registered receivers, not manifest receivers.
3904      */
3905     public static final String ACTION_PROFILE_INACCESSIBLE =
3906             "android.intent.action.PROFILE_INACCESSIBLE";
3907 
3908     /**
3909      * Broadcast sent to the system user when the 'device locked' state changes for any user.
3910      * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3911      * the device was locked or unlocked.
3912      *
3913      * This is only sent to registered receivers.
3914      *
3915      * @hide
3916      */
3917     public static final String ACTION_DEVICE_LOCKED_CHANGED =
3918             "android.intent.action.DEVICE_LOCKED_CHANGED";
3919 
3920     /**
3921      * Sent when the user taps on the clock widget in the system's "quick settings" area.
3922      */
3923     public static final String ACTION_QUICK_CLOCK =
3924             "android.intent.action.QUICK_CLOCK";
3925 
3926     /**
3927      * Activity Action: Shows the brightness setting dialog.
3928      * @hide
3929      */
3930     public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3931             "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3932 
3933     /**
3934      * Broadcast Action:  A global button was pressed.  Includes a single
3935      * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3936      * caused the broadcast.
3937      * @hide
3938      */
3939     @SystemApi
3940     public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3941 
3942     /**
3943      * Broadcast Action: Sent when media resource is granted.
3944      * <p>
3945      * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3946      * granted.
3947      * </p>
3948      * <p class="note">
3949      * This is a protected intent that can only be sent by the system.
3950      * </p>
3951      * <p class="note">
3952      * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
3953      * </p>
3954      *
3955      * @hide
3956      */
3957     public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3958             "android.intent.action.MEDIA_RESOURCE_GRANTED";
3959 
3960     /**
3961      * Broadcast Action: An overlay package has changed. The data contains the
3962      * name of the overlay package which has changed. This is broadcast on all
3963      * changes to the OverlayInfo returned by {@link
3964      * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3965      * most common change is a state change that will change whether the
3966      * overlay is enabled or not.
3967      * @hide
3968      */
3969     public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3970 
3971     /**
3972      * Activity Action: Allow the user to select and return one or more existing
3973      * documents. When invoked, the system will display the various
3974      * {@link DocumentsProvider} instances installed on the device, letting the
3975      * user interactively navigate through them. These documents include local
3976      * media, such as photos and video, and documents provided by installed
3977      * cloud storage providers.
3978      * <p>
3979      * Each document is represented as a {@code content://} URI backed by a
3980      * {@link DocumentsProvider}, which can be opened as a stream with
3981      * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3982      * {@link android.provider.DocumentsContract.Document} metadata.
3983      * <p>
3984      * All selected documents are returned to the calling application with
3985      * persistable read and write permission grants. If you want to maintain
3986      * access to the documents across device reboots, you need to explicitly
3987      * take the persistable permissions using
3988      * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3989      * <p>
3990      * Callers must indicate the acceptable document MIME types through
3991      * {@link #setType(String)}. For example, to select photos, use
3992      * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3993      * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3994      * {@literal *}/*.
3995      * <p>
3996      * If the caller can handle multiple returned items (the user performing
3997      * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3998      * to indicate this.
3999      * <p>
4000      * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
4001      * URIs that can be opened with
4002      * {@link ContentResolver#openFileDescriptor(Uri, String)}.
4003      * <p>
4004      * Callers can set a document URI through
4005      * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
4006      * location of documents navigator. System will do its best to launch the
4007      * navigator in the specified document if it's a folder, or the folder that
4008      * contains the specified document if not.
4009      * <p>
4010      * Output: The URI of the item that was picked, returned in
4011      * {@link #getData()}. This must be a {@code content://} URI so that any
4012      * receiver can access it. If multiple documents were selected, they are
4013      * returned in {@link #getClipData()}.
4014      *
4015      * @see DocumentsContract
4016      * @see #ACTION_OPEN_DOCUMENT_TREE
4017      * @see #ACTION_CREATE_DOCUMENT
4018      * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4019      */
4020     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4021     public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
4022 
4023     /**
4024      * Activity Action: Allow the user to create a new document. When invoked,
4025      * the system will display the various {@link DocumentsProvider} instances
4026      * installed on the device, letting the user navigate through them. The
4027      * returned document may be a newly created document with no content, or it
4028      * may be an existing document with the requested MIME type.
4029      * <p>
4030      * Each document is represented as a {@code content://} URI backed by a
4031      * {@link DocumentsProvider}, which can be opened as a stream with
4032      * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
4033      * {@link android.provider.DocumentsContract.Document} metadata.
4034      * <p>
4035      * Callers must indicate the concrete MIME type of the document being
4036      * created by setting {@link #setType(String)}. This MIME type cannot be
4037      * changed after the document is created.
4038      * <p>
4039      * Callers can provide an initial display name through {@link #EXTRA_TITLE},
4040      * but the user may change this value before creating the file.
4041      * <p>
4042      * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
4043      * URIs that can be opened with
4044      * {@link ContentResolver#openFileDescriptor(Uri, String)}.
4045      * <p>
4046      * Callers can set a document URI through
4047      * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
4048      * location of documents navigator. System will do its best to launch the
4049      * navigator in the specified document if it's a folder, or the folder that
4050      * contains the specified document if not.
4051      * <p>
4052      * Output: The URI of the item that was created. This must be a
4053      * {@code content://} URI so that any receiver can access it.
4054      *
4055      * @see DocumentsContract
4056      * @see #ACTION_OPEN_DOCUMENT
4057      * @see #ACTION_OPEN_DOCUMENT_TREE
4058      * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
4059      */
4060     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4061     public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
4062 
4063     /**
4064      * Activity Action: Allow the user to pick a directory subtree. When
4065      * invoked, the system will display the various {@link DocumentsProvider}
4066      * instances installed on the device, letting the user navigate through
4067      * them. Apps can fully manage documents within the returned directory.
4068      * <p>
4069      * To gain access to descendant (child, grandchild, etc) documents, use
4070      * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
4071      * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
4072      * with the returned URI.
4073      * <p>
4074      * Callers can set a document URI through
4075      * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
4076      * location of documents navigator. System will do its best to launch the
4077      * navigator in the specified document if it's a folder, or the folder that
4078      * contains the specified document if not.
4079      * <p>
4080      * Output: The URI representing the selected directory tree.
4081      *
4082      * @see DocumentsContract
4083      */
4084     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4085     public static final String
4086             ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
4087 
4088 
4089     /**
4090      * Activity Action: Perform text translation.
4091      * <p>
4092      * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate.
4093      * <p>
4094      * Output: nothing.
4095      */
4096     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4097     public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE";
4098 
4099     /**
4100      * Activity Action: Define the meaning of the selected word(s).
4101      * <p>
4102      * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define.
4103      * <p>
4104      * Output: nothing.
4105      */
4106     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4107     public static final String ACTION_DEFINE = "android.intent.action.DEFINE";
4108 
4109     /**
4110      * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
4111      * exisiting sensor being disconnected.
4112      *
4113      * <p class="note">This is a protected intent that can only be sent by the system.</p>
4114      *
4115      * {@hide}
4116      */
4117     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4118     public static final String
4119             ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
4120 
4121     /**
4122      * Deprecated - use ACTION_FACTORY_RESET instead.
4123      * @hide
4124      * @removed
4125      */
4126     @Deprecated
4127     @SystemApi
4128     public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
4129 
4130     /**
4131      * Broadcast intent sent by the RecoverySystem to inform listeners that a global clear (wipe)
4132      * is about to be performed.
4133      * @hide
4134      */
4135     @SystemApi
4136     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4137     public static final String ACTION_MASTER_CLEAR_NOTIFICATION
4138             = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
4139 
4140     /**
4141      * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
4142      * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
4143      *
4144      * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
4145      *
4146      * @hide
4147      */
4148     @Deprecated
4149     public static final String EXTRA_FORCE_MASTER_CLEAR =
4150             "android.intent.extra.FORCE_MASTER_CLEAR";
4151 
4152     /**
4153      * A broadcast action to trigger a factory reset.
4154      *
4155      * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
4156      * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
4157      *
4158      * <p>Not for use by third-party applications.
4159      *
4160      * @see #EXTRA_FORCE_FACTORY_RESET
4161      *
4162      * {@hide}
4163      */
4164     @SystemApi
4165     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4166     public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
4167 
4168     /**
4169      * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
4170      * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
4171      *
4172      * <p>Not for use by third-party applications.
4173      *
4174      * @hide
4175      */
4176     @SystemApi
4177     public static final String EXTRA_FORCE_FACTORY_RESET =
4178             "android.intent.extra.FORCE_FACTORY_RESET";
4179 
4180     /**
4181      * Broadcast action: report that a settings element is being restored from backup. The intent
4182      * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
4183      * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
4184      * is the value of that settings entry prior to the restore operation, and
4185      * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
4186      * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
4187      * values are represented as strings, the fourth one as int.
4188      *
4189      * <p>This broadcast is sent only for settings provider entries known to require special handling
4190      * around restore time.  These entries are found in the BROADCAST_ON_RESTORE table within
4191      * the provider's backup agent implementation.
4192      *
4193      * @see #EXTRA_SETTING_NAME
4194      * @see #EXTRA_SETTING_PREVIOUS_VALUE
4195      * @see #EXTRA_SETTING_NEW_VALUE
4196      * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
4197      * {@hide}
4198      */
4199     public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
4200 
4201     /** {@hide} */
4202     public static final String EXTRA_SETTING_NAME = "setting_name";
4203     /** {@hide} */
4204     public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
4205     /** {@hide} */
4206     public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
4207     /** {@hide} */
4208     public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
4209 
4210     /**
4211      * Activity Action: Process a piece of text.
4212      * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
4213      * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
4214      * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
4215      */
4216     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4217     public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
4218 
4219     /**
4220      * Broadcast Action: The sim card state has changed.
4221      * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
4222      * because TelephonyIntents is an internal class.
4223      * The intent will have following extras.</p>
4224      * <p>
4225      * @see #EXTRA_SIM_STATE
4226      * @see #EXTRA_SIM_LOCKED_REASON
4227      * @see #EXTRA_REBROADCAST_ON_UNLOCK
4228      *
4229      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
4230      * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4231      *
4232      * @hide
4233      */
4234     @Deprecated
4235     @SystemApi
4236     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4237     public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
4238 
4239     /**
4240      * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE.
4241      * This will have one of the following intent values.
4242      * @see #SIM_STATE_UNKNOWN
4243      * @see #SIM_STATE_NOT_READY
4244      * @see #SIM_STATE_ABSENT
4245      * @see #SIM_STATE_PRESENT
4246      * @see #SIM_STATE_CARD_IO_ERROR
4247      * @see #SIM_STATE_CARD_RESTRICTED
4248      * @see #SIM_STATE_LOCKED
4249      * @see #SIM_STATE_READY
4250      * @see #SIM_STATE_IMSI
4251      * @see #SIM_STATE_LOADED
4252      * @hide
4253      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4254      */
4255     public static final String EXTRA_SIM_STATE = "ss";
4256 
4257     /**
4258      * The intent value UNKNOWN represents the SIM state unknown
4259      * @hide
4260      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4261      */
4262     public static final String SIM_STATE_UNKNOWN = "UNKNOWN";
4263 
4264     /**
4265      * The intent value NOT_READY means that the SIM is not ready eg. radio is off or powering on
4266      * @hide
4267      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4268      */
4269     public static final String SIM_STATE_NOT_READY = "NOT_READY";
4270 
4271     /**
4272      * The intent value ABSENT means the SIM card is missing
4273      * @hide
4274      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4275      */
4276     public static final String SIM_STATE_ABSENT = "ABSENT";
4277 
4278     /**
4279      * The intent value PRESENT means the device has a SIM card inserted
4280      * @hide
4281      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4282      */
4283     public static final String SIM_STATE_PRESENT = "PRESENT";
4284 
4285     /**
4286      * The intent value CARD_IO_ERROR means for three consecutive times there was SIM IO error
4287      * @hide
4288      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4289      */
4290     static public final String SIM_STATE_CARD_IO_ERROR = "CARD_IO_ERROR";
4291 
4292     /**
4293      * The intent value CARD_RESTRICTED means card is present but not usable due to carrier
4294      * restrictions
4295      * @hide
4296      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4297      */
4298     static public final String SIM_STATE_CARD_RESTRICTED = "CARD_RESTRICTED";
4299 
4300     /**
4301      * The intent value LOCKED means the SIM is locked by PIN or by network
4302      * @hide
4303      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4304      */
4305     public static final String SIM_STATE_LOCKED = "LOCKED";
4306 
4307     /**
4308      * The intent value READY means the SIM is ready to be accessed
4309      * @hide
4310      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4311      */
4312     public static final String SIM_STATE_READY = "READY";
4313 
4314     /**
4315      * The intent value IMSI means the SIM IMSI is ready in property
4316      * @hide
4317      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4318      */
4319     public static final String SIM_STATE_IMSI = "IMSI";
4320 
4321     /**
4322      * The intent value LOADED means all SIM records, including IMSI, are loaded
4323      * @hide
4324      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED}
4325      */
4326     public static final String SIM_STATE_LOADED = "LOADED";
4327 
4328     /**
4329      * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for broadcasting SIM STATE.
4330      * This extra will have one of the following intent values.
4331      * <p>
4332      * @see #SIM_LOCKED_ON_PIN
4333      * @see #SIM_LOCKED_ON_PUK
4334      * @see #SIM_LOCKED_NETWORK
4335      * @see #SIM_ABSENT_ON_PERM_DISABLED
4336      *
4337      * @hide
4338      * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4339      */
4340     public static final String EXTRA_SIM_LOCKED_REASON = "reason";
4341 
4342     /**
4343      * The intent value PIN means the SIM is locked on PIN1
4344      * @hide
4345      * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4346      */
4347     public static final String SIM_LOCKED_ON_PIN = "PIN";
4348 
4349     /**
4350      * The intent value PUK means the SIM is locked on PUK1
4351      * @hide
4352      * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4353      */
4354     /* PUK means ICC is locked on PUK1 */
4355     public static final String SIM_LOCKED_ON_PUK = "PUK";
4356 
4357     /**
4358      * The intent value NETWORK means the SIM is locked on NETWORK PERSONALIZATION
4359      * @hide
4360      * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4361      */
4362     public static final String SIM_LOCKED_NETWORK = "NETWORK";
4363 
4364     /**
4365      * The intent value PERM_DISABLED means SIM is permanently disabled due to puk fails
4366      * @hide
4367      * @deprecated Use {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4368      */
4369     public static final String SIM_ABSENT_ON_PERM_DISABLED = "PERM_DISABLED";
4370 
4371     /**
4372      * The extra used with {@link #ACTION_SIM_STATE_CHANGED} for indicating whether this broadcast
4373      * is a rebroadcast on unlock. Defaults to {@code false} if not specified.
4374      *
4375      * @hide
4376      * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
4377      * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
4378      */
4379     public static final String EXTRA_REBROADCAST_ON_UNLOCK = "rebroadcastOnUnlock";
4380 
4381     /**
4382      * Broadcast Action: indicate that the phone service state has changed.
4383      * The intent will have the following extra values:</p>
4384      * <p>
4385      * @see #EXTRA_VOICE_REG_STATE
4386      * @see #EXTRA_DATA_REG_STATE
4387      * @see #EXTRA_VOICE_ROAMING_TYPE
4388      * @see #EXTRA_DATA_ROAMING_TYPE
4389      * @see #EXTRA_OPERATOR_ALPHA_LONG
4390      * @see #EXTRA_OPERATOR_ALPHA_SHORT
4391      * @see #EXTRA_OPERATOR_NUMERIC
4392      * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
4393      * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
4394      * @see #EXTRA_DATA_OPERATOR_NUMERIC
4395      * @see #EXTRA_MANUAL
4396      * @see #EXTRA_VOICE_RADIO_TECH
4397      * @see #EXTRA_DATA_RADIO_TECH
4398      * @see #EXTRA_CSS_INDICATOR
4399      * @see #EXTRA_NETWORK_ID
4400      * @see #EXTRA_SYSTEM_ID
4401      * @see #EXTRA_CDMA_ROAMING_INDICATOR
4402      * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
4403      * @see #EXTRA_EMERGENCY_ONLY
4404      * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
4405      * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
4406      * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
4407      *
4408      * <p class="note">
4409      * Requires the READ_PHONE_STATE permission.
4410      *
4411      * <p class="note">This is a protected intent that can only be sent by the system.
4412      * @hide
4413      * @removed
4414      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
4415      * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
4416      * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
4417      * for a given subscription id and field with a ContentObserver or using JobScheduler.
4418      */
4419     @Deprecated
4420     @SystemApi
4421     @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
4422     public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
4423 
4424     /**
4425      * Used by {@link services.core.java.com.android.server.pm.DataLoaderManagerService}
4426      * for querying Data Loader Service providers. Data loader service providers register this
4427      * intent filter in their manifests, so that they can be looked up and bound to by
4428      * {@code DataLoaderManagerService}.
4429      *
4430      * <p class="note">This is a protected intent that can only be sent by the system.
4431      *
4432      * Data loader service providers must be privileged apps.
4433      * See {@link com.android.server.pm.PackageManagerShellCommandDataLoader} as an example of such
4434      * data loader service provider.
4435      *
4436      * @hide
4437      */
4438     @SystemApi
4439     @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
4440     public static final String ACTION_LOAD_DATA = "android.intent.action.LOAD_DATA";
4441 
4442     /**
4443      * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
4444      * state.
4445      * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4446      * @see android.telephony.ServiceState#STATE_IN_SERVICE
4447      * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4448      * @see android.telephony.ServiceState#STATE_POWER_OFF
4449      * @hide
4450      * @removed
4451      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
4452      */
4453     @Deprecated
4454     @SystemApi
4455     public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
4456 
4457     /**
4458      * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
4459      * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4460      * @see android.telephony.ServiceState#STATE_IN_SERVICE
4461      * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4462      * @see android.telephony.ServiceState#STATE_POWER_OFF
4463      * @hide
4464      * @removed
4465      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
4466      */
4467     @Deprecated
4468     @SystemApi
4469     public static final String EXTRA_DATA_REG_STATE = "dataRegState";
4470 
4471     /**
4472      * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
4473      * type.
4474      * @hide
4475      * @removed
4476      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
4477      */
4478     @Deprecated
4479     @SystemApi
4480     public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
4481 
4482     /**
4483      * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
4484      * type.
4485      * @hide
4486      * @removed
4487      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
4488      */
4489     @Deprecated
4490     @SystemApi
4491     public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
4492 
4493     /**
4494      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4495      * registered voice operator name in long alphanumeric format.
4496      * {@code null} if the operator name is not known or unregistered.
4497      * @hide
4498      * @removed
4499      * @deprecated Use
4500      * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
4501      */
4502     @Deprecated
4503     @SystemApi
4504     public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
4505 
4506     /**
4507      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4508      * registered voice operator name in short alphanumeric format.
4509      * {@code null} if the operator name is not known or unregistered.
4510      * @hide
4511      * @removed
4512      * @deprecated Use
4513      * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
4514      */
4515     @Deprecated
4516     @SystemApi
4517     public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
4518 
4519     /**
4520      * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4521      * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
4522      * network.
4523      * @hide
4524      * @removed
4525      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
4526      */
4527     @Deprecated
4528     @SystemApi
4529     public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
4530 
4531     /**
4532      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4533      * registered data operator name in long alphanumeric format.
4534      * {@code null} if the operator name is not known or unregistered.
4535      * @hide
4536      * @removed
4537      * @deprecated Use
4538      * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
4539      */
4540     @Deprecated
4541     @SystemApi
4542     public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
4543 
4544     /**
4545      * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4546      * registered data operator name in short alphanumeric format.
4547      * {@code null} if the operator name is not known or unregistered.
4548      * @hide
4549      * @removed
4550      * @deprecated Use
4551      * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
4552      */
4553     @Deprecated
4554     @SystemApi
4555     public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
4556 
4557     /**
4558      * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4559      * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
4560      * data operator.
4561      * @hide
4562      * @removed
4563      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
4564      */
4565     @Deprecated
4566     @SystemApi
4567     public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
4568 
4569     /**
4570      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
4571      * network selection mode is manual.
4572      * Will be {@code true} if manual mode, {@code false} if automatic mode.
4573      * @hide
4574      * @removed
4575      * @deprecated Use
4576      * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
4577      */
4578     @Deprecated
4579     @SystemApi
4580     public static final String EXTRA_MANUAL = "manual";
4581 
4582     /**
4583      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
4584      * radio technology.
4585      * @hide
4586      * @removed
4587      * @deprecated Use
4588      * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
4589      */
4590     @Deprecated
4591     @SystemApi
4592     public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
4593 
4594     /**
4595      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
4596      * radio technology.
4597      * @hide
4598      * @removed
4599      * @deprecated Use
4600      * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
4601      */
4602     @Deprecated
4603     @SystemApi
4604     public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
4605 
4606     /**
4607      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
4608      * support on CDMA network.
4609      * Will be {@code true} if support, {@code false} otherwise.
4610      * @hide
4611      * @removed
4612      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
4613      */
4614     @Deprecated
4615     @SystemApi
4616     public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
4617 
4618     /**
4619      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
4620      * id. {@code Integer.MAX_VALUE} if unknown.
4621      * @hide
4622      * @removed
4623      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
4624      */
4625     @Deprecated
4626     @SystemApi
4627     public static final String EXTRA_NETWORK_ID = "networkId";
4628 
4629     /**
4630      * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
4631      * {@code Integer.MAX_VALUE} if unknown.
4632      * @hide
4633      * @removed
4634      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
4635      */
4636     @Deprecated
4637     @SystemApi
4638     public static final String EXTRA_SYSTEM_ID = "systemId";
4639 
4640     /**
4641      * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
4642      * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
4643      * @hide
4644      * @removed
4645      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
4646      */
4647     @Deprecated
4648     @SystemApi
4649     public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
4650 
4651     /**
4652      * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
4653      * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
4654      * @hide
4655      * @removed
4656      * @deprecated Use
4657      * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
4658      */
4659     @Deprecated
4660     @SystemApi
4661     public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
4662 
4663     /**
4664      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
4665      * only mode.
4666      * {@code true} if in emergency only mode, {@code false} otherwise.
4667      * @hide
4668      * @removed
4669      * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
4670      */
4671     @Deprecated
4672     @SystemApi
4673     public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
4674 
4675     /**
4676      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
4677      * registration state is roaming.
4678      * {@code true} if registration indicates roaming, {@code false} otherwise
4679      * @hide
4680      * @removed
4681      * @deprecated Use
4682      * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
4683      */
4684     @Deprecated
4685     @SystemApi
4686     public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
4687             "isDataRoamingFromRegistration";
4688 
4689     /**
4690      * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
4691      * aggregation is in use.
4692      * {@code true} if carrier aggregation is in use, {@code false} otherwise.
4693      * @hide
4694      * @removed
4695      * @deprecated Use
4696      * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
4697      */
4698     @Deprecated
4699     @SystemApi
4700     public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
4701 
4702     /**
4703      * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
4704      * is reduced from the rsrp threshold while calculating signal strength level.
4705      * @hide
4706      * @removed
4707      */
4708     @Deprecated
4709     @SystemApi
4710     public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
4711 
4712     /**
4713      * The name of the extra used to define the text to be processed, as a
4714      * CharSequence. Note that this may be a styled CharSequence, so you must use
4715      * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
4716      */
4717     public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
4718     /**
4719      * The name of the boolean extra used to define if the processed text will be used as read-only.
4720      */
4721     public static final String EXTRA_PROCESS_TEXT_READONLY =
4722             "android.intent.extra.PROCESS_TEXT_READONLY";
4723 
4724     /**
4725      * Broadcast action: reports when a new thermal event has been reached. When the device
4726      * is reaching its maximum temperatue, the thermal level reported
4727      * {@hide}
4728      */
4729     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4730     public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
4731 
4732     /** {@hide} */
4733     public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
4734 
4735     /**
4736      * Thermal state when the device is normal. This state is sent in the
4737      * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4738      * {@hide}
4739      */
4740     public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
4741 
4742     /**
4743      * Thermal state where the device is approaching its maximum threshold. This state is sent in
4744      * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4745      * {@hide}
4746      */
4747     public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4748 
4749     /**
4750      * Thermal state where the device has reached its maximum threshold. This state is sent in the
4751      * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4752      * {@hide}
4753      */
4754     public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4755 
4756     /**
4757      * Broadcast Action: Indicates the dock in idle state while device is docked.
4758      *
4759      * <p class="note">This is a protected intent that can only be sent
4760      * by the system.
4761      *
4762      * @hide
4763      */
4764     public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4765 
4766     /**
4767      * Broadcast Action: Indicates the dock in active state while device is docked.
4768      *
4769      * <p class="note">This is a protected intent that can only be sent
4770      * by the system.
4771      *
4772      * @hide
4773      */
4774     public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4775 
4776     /**
4777      * Broadcast Action: Indicates that a new device customization has been
4778      * downloaded and applied (packages installed, runtime resource overlays
4779      * enabled, xml files copied, ...), and that it is time for components that
4780      * need to for example clear their caches to do so now.
4781      *
4782      * @hide
4783      */
4784     @SystemApi
4785     public static final String ACTION_DEVICE_CUSTOMIZATION_READY =
4786             "android.intent.action.DEVICE_CUSTOMIZATION_READY";
4787 
4788 
4789     /**
4790      * Activity Action: Display an activity state associated with an unique {@link LocusId}.
4791      *
4792      * <p>For example, a chat app could use the context to resume a conversation between 2 users.
4793      *
4794      * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the
4795      * app domain. Should be stable across reboots and backup / restore.
4796      * <p>Output: nothing.
4797      */
4798     @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4799     public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS";
4800 
4801     /**
4802      * Broadcast Action: Sent to the integrity component when a package
4803      * needs to be verified. The data contains the package URI along with other relevant
4804      * information.
4805      *
4806      * <p class="note">
4807      * This is a protected intent that can only be sent by the system.
4808      * </p>
4809      *
4810      * @hide
4811      */
4812     @SystemApi
4813     @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4814     public static final String ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION =
4815             "android.intent.action.PACKAGE_NEEDS_INTEGRITY_VERIFICATION";
4816 
4817 
4818     // ---------------------------------------------------------------------
4819     // ---------------------------------------------------------------------
4820     // Standard intent categories (see addCategory()).
4821 
4822     /**
4823      * Set if the activity should be an option for the default action
4824      * (center press) to perform on a piece of data.  Setting this will
4825      * hide from the user any activities without it set when performing an
4826      * action on some data.  Note that this is normally -not- set in the
4827      * Intent when initiating an action -- it is for use in intent filters
4828      * specified in packages.
4829      */
4830     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4831     public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4832     /**
4833      * Activities that can be safely invoked from a browser must support this
4834      * category.  For example, if the user is viewing a web page or an e-mail
4835      * and clicks on a link in the text, the Intent generated execute that
4836      * link will require the BROWSABLE category, so that only activities
4837      * supporting this category will be considered as possible actions.  By
4838      * supporting this category, you are promising that there is nothing
4839      * damaging (without user intervention) that can happen by invoking any
4840      * matching Intent.
4841      */
4842     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4843     public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4844     /**
4845      * Categories for activities that can participate in voice interaction.
4846      * An activity that supports this category must be prepared to run with
4847      * no UI shown at all (though in some case it may have a UI shown), and
4848      * rely on {@link android.app.VoiceInteractor} to interact with the user.
4849      */
4850     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4851     public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4852     /**
4853      * Set if the activity should be considered as an alternative action to
4854      * the data the user is currently viewing.  See also
4855      * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4856      * applies to the selection in a list of items.
4857      *
4858      * <p>Supporting this category means that you would like your activity to be
4859      * displayed in the set of alternative things the user can do, usually as
4860      * part of the current activity's options menu.  You will usually want to
4861      * include a specific label in the &lt;intent-filter&gt; of this action
4862      * describing to the user what it does.
4863      *
4864      * <p>The action of IntentFilter with this category is important in that it
4865      * describes the specific action the target will perform.  This generally
4866      * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4867      * a specific name such as "com.android.camera.action.CROP.  Only one
4868      * alternative of any particular action will be shown to the user, so using
4869      * a specific action like this makes sure that your alternative will be
4870      * displayed while also allowing other applications to provide their own
4871      * overrides of that particular action.
4872      */
4873     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4874     public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4875     /**
4876      * Set if the activity should be considered as an alternative selection
4877      * action to the data the user has currently selected.  This is like
4878      * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4879      * of items from which the user can select, giving them alternatives to the
4880      * default action that will be performed on it.
4881      */
4882     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4883     public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4884     /**
4885      * Intended to be used as a tab inside of a containing TabActivity.
4886      */
4887     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4888     public static final String CATEGORY_TAB = "android.intent.category.TAB";
4889     /**
4890      * Should be displayed in the top-level launcher.
4891      */
4892     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4893     public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4894     /**
4895      * Indicates an activity optimized for Leanback mode, and that should
4896      * be displayed in the Leanback launcher.
4897      */
4898     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4899     public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4900     /**
4901      * Indicates the preferred entry-point activity when an application is launched from a Car
4902      * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4903      * fallback, or exclude the application entirely.
4904      * @hide
4905      */
4906     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4907     public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4908     /**
4909      * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4910      * @hide
4911      */
4912     @SystemApi
4913     public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4914     /**
4915      * Provides information about the package it is in; typically used if
4916      * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4917      * a front-door to the user without having to be shown in the all apps list.
4918      */
4919     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4920     public static final String CATEGORY_INFO = "android.intent.category.INFO";
4921     /**
4922      * This is the home activity, that is the first activity that is displayed
4923      * when the device boots.
4924      */
4925     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4926     public static final String CATEGORY_HOME = "android.intent.category.HOME";
4927     /**
4928      * This is the home activity that is displayed when the device is finished setting up and ready
4929      * for use.
4930      * @hide
4931      */
4932     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4933     public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4934     /**
4935      * The home activity shown on secondary displays that support showing home activities.
4936      */
4937     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4938     public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME";
4939     /**
4940      * This is the setup wizard activity, that is the first activity that is displayed
4941      * when the user sets up the device for the first time.
4942      * @hide
4943      */
4944     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4945     public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4946     /**
4947      * This is the home activity, that is the activity that serves as the launcher app
4948      * from there the user can start other apps. Often components with lower/higher
4949      * priority intent filters handle the home intent, for example SetupWizard, to
4950      * setup the device and we need to be able to distinguish the home app from these
4951      * setup helpers.
4952      * @hide
4953      */
4954     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4955     public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4956     /**
4957      * This activity is a preference panel.
4958      */
4959     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4960     public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4961     /**
4962      * This activity is a development preference panel.
4963      */
4964     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4965     public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4966     /**
4967      * Capable of running inside a parent activity container.
4968      */
4969     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4970     public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4971     /**
4972      * This activity allows the user to browse and download new applications.
4973      */
4974     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4975     public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4976     /**
4977      * This activity may be exercised by the monkey or other automated test tools.
4978      */
4979     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4980     public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4981     /**
4982      * To be used as a test (not part of the normal user experience).
4983      */
4984     public static final String CATEGORY_TEST = "android.intent.category.TEST";
4985     /**
4986      * To be used as a unit test (run through the Test Harness).
4987      */
4988     public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4989     /**
4990      * To be used as a sample code example (not part of the normal user
4991      * experience).
4992      */
4993     public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
4994 
4995     /**
4996      * Used to indicate that an intent only wants URIs that can be opened with
4997      * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4998      * must support at least the columns defined in {@link OpenableColumns} when
4999      * queried.
5000      *
5001      * @see #ACTION_GET_CONTENT
5002      * @see #ACTION_OPEN_DOCUMENT
5003      * @see #ACTION_CREATE_DOCUMENT
5004      */
5005     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5006     public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
5007 
5008     /**
5009      * Used to indicate that an intent filter can accept files which are not necessarily
5010      * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
5011      * at least streamable via
5012      * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
5013      * using one of the stream types exposed via
5014      * {@link ContentResolver#getStreamTypes(Uri, String)}.
5015      *
5016      * @see #ACTION_SEND
5017      * @see #ACTION_SEND_MULTIPLE
5018      */
5019     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5020     public static final String CATEGORY_TYPED_OPENABLE  =
5021             "android.intent.category.TYPED_OPENABLE";
5022 
5023     /**
5024      * To be used as code under test for framework instrumentation tests.
5025      */
5026     public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
5027             "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
5028     /**
5029      * An activity to run when device is inserted into a car dock.
5030      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
5031      * information, see {@link android.app.UiModeManager}.
5032      */
5033     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5034     public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
5035     /**
5036      * An activity to run when device is inserted into a car dock.
5037      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
5038      * information, see {@link android.app.UiModeManager}.
5039      */
5040     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5041     public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
5042     /**
5043      * An activity to run when device is inserted into a analog (low end) dock.
5044      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
5045      * information, see {@link android.app.UiModeManager}.
5046      */
5047     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5048     public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
5049 
5050     /**
5051      * An activity to run when device is inserted into a digital (high end) dock.
5052      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
5053      * information, see {@link android.app.UiModeManager}.
5054      */
5055     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5056     public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
5057 
5058     /**
5059      * Used to indicate that the activity can be used in a car environment.
5060      */
5061     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5062     public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
5063 
5064     /**
5065      * An activity to use for the launcher when the device is placed in a VR Headset viewer.
5066      * Used with {@link #ACTION_MAIN} to launch an activity.  For more
5067      * information, see {@link android.app.UiModeManager}.
5068      */
5069     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5070     public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
5071 
5072     /**
5073      * The accessibility shortcut is a global gesture for users with disabilities to trigger an
5074      * important for them accessibility feature to help developers determine whether they want to
5075      * make their activity a shortcut target.
5076      * <p>
5077      * An activity of interest to users with accessibility needs may request to be the target of
5078      * the accessibility shortcut. It handles intent {@link #ACTION_MAIN} with this category,
5079      * which will be dispatched by the system when the user activates the shortcut when it is
5080      * configured to point at this target.
5081      * </p>
5082      * <p>
5083      * An activity declared itself to be a target of the shortcut in AndroidManifest.xml. It must
5084      * also do two things:
5085      * <ul>
5086      *     <ol>
5087      *         Specify that it handles the <code>android.intent.action.MAIN</code>
5088      *         {@link android.content.Intent}
5089      *         with category <code>android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET</code>.
5090      *     </ol>
5091      *     <ol>
5092      *         Provide a meta-data entry <code>android.accessibilityshortcut.target</code> in the
5093      *         manifest when declaring the activity.
5094      *     </ol>
5095      * </ul>
5096      * If either of these items is missing, the system will ignore the accessibility shortcut
5097      * target. Following is an example declaration:
5098      * </p>
5099      * <pre>
5100      * &lt;activity android:name=".MainActivity"
5101      * . . .
5102      *   &lt;intent-filter&gt;
5103      *       &lt;action android:name="android.intent.action.MAIN" /&gt;
5104      *       &lt;category android:name="android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET" /&gt;
5105      *   &lt;/intent-filter&gt;
5106      *   &lt;meta-data android:name="android.accessibilityshortcut.target"
5107      *                   android:resource="@xml/accessibilityshortcut" /&gt;
5108      * &lt;/activity&gt;
5109      * </pre>
5110      * <p> This is a sample XML file configuring a accessibility shortcut target: </p>
5111      * <pre>
5112      * &lt;accessibility-shortcut-target
5113      *     android:description="@string/shortcut_target_description"
5114      *     android:summary="@string/shortcut_target_summary"
5115      *     android:animatedImageDrawable="@drawable/shortcut_target_animated_image"
5116      *     android:htmlDescription="@string/shortcut_target_html_description"
5117      *     android:settingsActivity="com.example.android.shortcut.target.SettingsActivity" /&gt;
5118      * </pre>
5119      * <p>
5120      * Both description and summary are necessary. The system will ignore the accessibility
5121      * shortcut target if they are missing. The animated image and html description are supported
5122      * to help users understand how to use the shortcut target. The settings activity is a
5123      * component name that allows the user to modify the settings for this accessibility shortcut
5124      * target.
5125      * </p>
5126      */
5127     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5128     public static final String CATEGORY_ACCESSIBILITY_SHORTCUT_TARGET =
5129             "android.intent.category.ACCESSIBILITY_SHORTCUT_TARGET";
5130     // ---------------------------------------------------------------------
5131     // ---------------------------------------------------------------------
5132     // Application launch intent categories (see addCategory()).
5133 
5134     /**
5135      * Used with {@link #ACTION_MAIN} to launch the browser application.
5136      * The activity should be able to browse the Internet.
5137      * <p>NOTE: This should not be used as the primary key of an Intent,
5138      * since it will not result in the app launching with the correct
5139      * action and category.  Instead, use this with
5140      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5141      * Intent with this category in the selector.</p>
5142      */
5143     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5144     public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
5145 
5146     /**
5147      * Used with {@link #ACTION_MAIN} to launch the calculator application.
5148      * The activity should be able to perform standard arithmetic operations.
5149      * <p>NOTE: This should not be used as the primary key of an Intent,
5150      * since it will not result in the app launching with the correct
5151      * action and category.  Instead, use this with
5152      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5153      * Intent with this category in the selector.</p>
5154      */
5155     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5156     public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
5157 
5158     /**
5159      * Used with {@link #ACTION_MAIN} to launch the calendar application.
5160      * The activity should be able to view and manipulate calendar entries.
5161      * <p>NOTE: This should not be used as the primary key of an Intent,
5162      * since it will not result in the app launching with the correct
5163      * action and category.  Instead, use this with
5164      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5165      * Intent with this category in the selector.</p>
5166      */
5167     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5168     public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
5169 
5170     /**
5171      * Used with {@link #ACTION_MAIN} to launch the contacts application.
5172      * The activity should be able to view and manipulate address book entries.
5173      * <p>NOTE: This should not be used as the primary key of an Intent,
5174      * since it will not result in the app launching with the correct
5175      * action and category.  Instead, use this with
5176      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5177      * Intent with this category in the selector.</p>
5178      */
5179     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5180     public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
5181 
5182     /**
5183      * Used with {@link #ACTION_MAIN} to launch the email application.
5184      * The activity should be able to send and receive email.
5185      * <p>NOTE: This should not be used as the primary key of an Intent,
5186      * since it will not result in the app launching with the correct
5187      * action and category.  Instead, use this with
5188      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5189      * Intent with this category in the selector.</p>
5190      */
5191     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5192     public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
5193 
5194     /**
5195      * Used with {@link #ACTION_MAIN} to launch the gallery application.
5196      * The activity should be able to view and manipulate image and video files
5197      * stored on the device.
5198      * <p>NOTE: This should not be used as the primary key of an Intent,
5199      * since it will not result in the app launching with the correct
5200      * action and category.  Instead, use this with
5201      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5202      * Intent with this category in the selector.</p>
5203      */
5204     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5205     public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
5206 
5207     /**
5208      * Used with {@link #ACTION_MAIN} to launch the maps application.
5209      * The activity should be able to show the user's current location and surroundings.
5210      * <p>NOTE: This should not be used as the primary key of an Intent,
5211      * since it will not result in the app launching with the correct
5212      * action and category.  Instead, use this with
5213      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5214      * Intent with this category in the selector.</p>
5215      */
5216     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5217     public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
5218 
5219     /**
5220      * Used with {@link #ACTION_MAIN} to launch the messaging application.
5221      * The activity should be able to send and receive text messages.
5222      * <p>NOTE: This should not be used as the primary key of an Intent,
5223      * since it will not result in the app launching with the correct
5224      * action and category.  Instead, use this with
5225      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5226      * Intent with this category in the selector.</p>
5227      */
5228     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5229     public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
5230 
5231     /**
5232      * Used with {@link #ACTION_MAIN} to launch the music application.
5233      * The activity should be able to play, browse, or manipulate music files
5234      * stored on the device.
5235      * <p>NOTE: This should not be used as the primary key of an Intent,
5236      * since it will not result in the app launching with the correct
5237      * action and category.  Instead, use this with
5238      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5239      * Intent with this category in the selector.</p>
5240      */
5241     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5242     public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
5243 
5244     /**
5245      * Used with {@link #ACTION_MAIN} to launch the files application.
5246      * The activity should be able to browse and manage files stored on the device.
5247      * <p>NOTE: This should not be used as the primary key of an Intent,
5248      * since it will not result in the app launching with the correct
5249      * action and category.  Instead, use this with
5250      * {@link #makeMainSelectorActivity(String, String)} to generate a main
5251      * Intent with this category in the selector.</p>
5252      */
5253     @SdkConstant(SdkConstantType.INTENT_CATEGORY)
5254     public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES";
5255 
5256     // ---------------------------------------------------------------------
5257     // ---------------------------------------------------------------------
5258     // Standard extra data keys.
5259 
5260     /**
5261      * The initial data to place in a newly created record.  Use with
5262      * {@link #ACTION_INSERT}.  The data here is a Map containing the same
5263      * fields as would be given to the underlying ContentProvider.insert()
5264      * call.
5265      */
5266     public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
5267 
5268     /**
5269      * A constant CharSequence that is associated with the Intent, used with
5270      * {@link #ACTION_SEND} to supply the literal data to be sent.  Note that
5271      * this may be a styled CharSequence, so you must use
5272      * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
5273      * retrieve it.
5274      */
5275     public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
5276 
5277     /**
5278      * A constant String that is associated with the Intent, used with
5279      * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
5280      * as HTML formatted text.  Note that you <em>must</em> also supply
5281      * {@link #EXTRA_TEXT}.
5282      */
5283     public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
5284 
5285     /**
5286      * A content: URI holding a stream of data associated with the Intent,
5287      * used with {@link #ACTION_SEND} to supply the data being sent.
5288      */
5289     public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
5290 
5291     /**
5292      * A String[] holding e-mail addresses that should be delivered to.
5293      */
5294     public static final String EXTRA_EMAIL       = "android.intent.extra.EMAIL";
5295 
5296     /**
5297      * A String[] holding e-mail addresses that should be carbon copied.
5298      */
5299     public static final String EXTRA_CC       = "android.intent.extra.CC";
5300 
5301     /**
5302      * A String[] holding e-mail addresses that should be blind carbon copied.
5303      */
5304     public static final String EXTRA_BCC      = "android.intent.extra.BCC";
5305 
5306     /**
5307      * A constant string holding the desired subject line of a message.
5308      */
5309     public static final String EXTRA_SUBJECT  = "android.intent.extra.SUBJECT";
5310 
5311     /**
5312      * An Intent describing the choices you would like shown with
5313      * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
5314      */
5315     public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
5316 
5317     /**
5318      * An int representing the user id to be used.
5319      *
5320      * @hide
5321      */
5322     public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
5323 
5324     /**
5325      * An int representing the task id to be retrieved. This is used when a launch from recents is
5326      * intercepted by another action such as credentials confirmation to remember which task should
5327      * be resumed when complete.
5328      *
5329      * @hide
5330      */
5331     public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
5332 
5333     /**
5334      * A String[] holding attribution tags when used with
5335      * {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
5336      *
5337      * E.g. an attribution tag could be location_provider, com.google.android.gms.*, etc.
5338      */
5339     public static final String EXTRA_ATTRIBUTION_TAGS = "android.intent.extra.ATTRIBUTION_TAGS";
5340 
5341     /**
5342      * A long representing the start timestamp (epoch time in millis) of the permission usage
5343      * when used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
5344      */
5345     public static final String EXTRA_START_TIME = "android.intent.extra.START_TIME";
5346 
5347     /**
5348      * A long representing the end timestamp (epoch time in millis) of the permission usage when
5349      * used with {@link #ACTION_VIEW_PERMISSION_USAGE_FOR_PERIOD}
5350      */
5351     public static final String EXTRA_END_TIME = "android.intent.extra.END_TIME";
5352 
5353     /**
5354      * An Intent[] describing additional, alternate choices you would like shown with
5355      * {@link #ACTION_CHOOSER}.
5356      *
5357      * <p>An app may be capable of providing several different payload types to complete a
5358      * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
5359      * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
5360      * several different supported sending mechanisms for sharing, such as the actual "image/*"
5361      * photo data or a hosted link where the photos can be viewed.</p>
5362      *
5363      * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
5364      * first/primary/preferred intent in the set. Additional intents specified in
5365      * this extra are ordered; by default intents that appear earlier in the array will be
5366      * preferred over intents that appear later in the array as matches for the same
5367      * target component. To alter this preference, a calling app may also supply
5368      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
5369      */
5370     public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
5371 
5372     /**
5373      * A {@link ComponentName ComponentName[]} describing components that should be filtered out
5374      * and omitted from a list of components presented to the user.
5375      *
5376      * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
5377      * in this array if it otherwise would have shown them. Useful for omitting specific targets
5378      * from your own package or other apps from your organization if the idea of sending to those
5379      * targets would be redundant with other app functionality. Filtered components will not
5380      * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
5381      */
5382     public static final String EXTRA_EXCLUDE_COMPONENTS
5383             = "android.intent.extra.EXCLUDE_COMPONENTS";
5384 
5385     /**
5386      * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
5387      * describing additional high-priority deep-link targets for the chooser to present to the user.
5388      *
5389      * <p>Targets provided in this way will be presented inline with all other targets provided
5390      * by services from other apps. They will be prioritized before other service targets, but
5391      * after those targets provided by sources that the user has manually pinned to the front.</p>
5392      *
5393      * @see #ACTION_CHOOSER
5394      */
5395     public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
5396 
5397     /**
5398      * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
5399      * from the chooser activity presented by {@link #ACTION_CHOOSER}.
5400      *
5401      * <p>An app preparing an action for another app to complete may wish to allow the user to
5402      * disambiguate between several options for completing the action based on the chosen target
5403      * or otherwise refine the action before it is invoked.
5404      * </p>
5405      *
5406      * <p>When sent, this IntentSender may be filled in with the following extras:</p>
5407      * <ul>
5408      *     <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
5409      *     <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
5410      *     chosen target beyond the first</li>
5411      *     <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
5412      *     should fill in and send once the disambiguation is complete</li>
5413      * </ul>
5414      */
5415     public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
5416             = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
5417 
5418     /**
5419      * An {@code ArrayList} of {@code String} annotations describing content for
5420      * {@link #ACTION_CHOOSER}.
5421      *
5422      * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
5423      * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
5424      *
5425      * <p>Annotations should describe the major components or topics of the content. It is up to
5426      * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
5427      * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
5428      * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
5429      * character. Performance on customized annotations can suffer, if they are rarely used for
5430      * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
5431      * following annotations when applicable.</p>
5432      * <ul>
5433      *     <li>"product" represents that the topic of the content is mainly about products, e.g.,
5434      *     health & beauty, and office supplies.</li>
5435      *     <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
5436      *     happy, and sad.</li>
5437      *     <li>"person" represents that the topic of the content is mainly about persons, e.g.,
5438      *     face, finger, standing, and walking.</li>
5439      *     <li>"child" represents that the topic of the content is mainly about children, e.g.,
5440      *     child, and baby.</li>
5441      *     <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
5442      *     <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
5443      *     <li>"party" represents that the topic of the content is mainly about parties.</li>
5444      *     <li>"animal" represent that the topic of the content is mainly about animals.</li>
5445      *     <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
5446      *     flowers.</li>
5447      *     <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
5448      *     <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
5449      *     sunglasses, jewelry, handbags and clothing.</li>
5450      *     <li>"material" represents that the topic of the content is mainly about materials, e.g.,
5451      *     paper, and silk.</li>
5452      *     <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
5453      *     cars, and boats.</li>
5454      *     <li>"document" represents that the topic of the content is mainly about documents, e.g.
5455      *     posters.</li>
5456      *     <li>"design" represents that the topic of the content is mainly about design, e.g. arts
5457      *     and designs of houses.</li>
5458      *     <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
5459      *     Christmas and Thanksgiving.</li>
5460      * </ul>
5461      */
5462     public static final String EXTRA_CONTENT_ANNOTATIONS
5463             = "android.intent.extra.CONTENT_ANNOTATIONS";
5464 
5465     /**
5466      * A {@link ResultReceiver} used to return data back to the sender.
5467      *
5468      * <p>Used to complete an app-specific
5469      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
5470      *
5471      * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
5472      * used to start a {@link #ACTION_CHOOSER} activity this extra will be
5473      * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
5474      * when the user selects a target component from the chooser. It is up to the recipient
5475      * to send a result to this ResultReceiver to signal that disambiguation is complete
5476      * and that the chooser should invoke the user's choice.</p>
5477      *
5478      * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
5479      * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
5480      * to match and fill in the final Intent or ChooserTarget before starting it.
5481      * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
5482      * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
5483      * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
5484      *
5485      * <p>The result code passed to the ResultReceiver should be
5486      * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
5487      * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
5488      * the chooser should finish without starting a target.</p>
5489      */
5490     public static final String EXTRA_RESULT_RECEIVER
5491             = "android.intent.extra.RESULT_RECEIVER";
5492 
5493     /**
5494      * A CharSequence dialog title to provide to the user when used with a
5495      * {@link #ACTION_CHOOSER}.
5496      */
5497     public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
5498 
5499     /**
5500      * A Parcelable[] of {@link Intent} or
5501      * {@link android.content.pm.LabeledIntent} objects as set with
5502      * {@link #putExtra(String, Parcelable[])} of additional activities to place
5503      * a the front of the list of choices, when shown to the user with a
5504      * {@link #ACTION_CHOOSER}.
5505      */
5506     public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
5507 
5508     /**
5509      * A {@link IntentSender} to start after instant app installation success.
5510      * @hide
5511      */
5512     @SystemApi
5513     public static final String EXTRA_INSTANT_APP_SUCCESS =
5514             "android.intent.extra.INSTANT_APP_SUCCESS";
5515 
5516     /**
5517      * A {@link IntentSender} to start after instant app installation failure.
5518      * @hide
5519      */
5520     @SystemApi
5521     public static final String EXTRA_INSTANT_APP_FAILURE =
5522             "android.intent.extra.INSTANT_APP_FAILURE";
5523 
5524     /**
5525      * The host name that triggered an instant app resolution.
5526      * @hide
5527      */
5528     @SystemApi
5529     public static final String EXTRA_INSTANT_APP_HOSTNAME =
5530             "android.intent.extra.INSTANT_APP_HOSTNAME";
5531 
5532     /**
5533      * An opaque token to track instant app resolution.
5534      * @hide
5535      */
5536     @SystemApi
5537     public static final String EXTRA_INSTANT_APP_TOKEN =
5538             "android.intent.extra.INSTANT_APP_TOKEN";
5539 
5540     /**
5541      * The action that triggered an instant application resolution.
5542      * @hide
5543      */
5544     @SystemApi
5545     public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
5546 
5547     /**
5548      * An array of {@link Bundle}s containing details about resolved instant apps..
5549      * @hide
5550      */
5551     @SystemApi
5552     public static final String EXTRA_INSTANT_APP_BUNDLES =
5553             "android.intent.extra.INSTANT_APP_BUNDLES";
5554 
5555     /**
5556      * A {@link Bundle} of metadata that describes the instant application that needs to be
5557      * installed. This data is populated from the response to
5558      * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
5559      * instant application resolver.
5560      * @hide
5561      */
5562     @SystemApi
5563     public static final String EXTRA_INSTANT_APP_EXTRAS =
5564             "android.intent.extra.INSTANT_APP_EXTRAS";
5565 
5566     /**
5567      * A boolean value indicating that the instant app resolver was unable to state with certainty
5568      * that it did or did not have an app for the sanitized {@link Intent} defined at
5569      * {@link #EXTRA_INTENT}.
5570      * @hide
5571      */
5572     @SystemApi
5573     public static final String EXTRA_UNKNOWN_INSTANT_APP =
5574             "android.intent.extra.UNKNOWN_INSTANT_APP";
5575 
5576     /**
5577      * The version code of the app to install components from.
5578      * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
5579      * @hide
5580      */
5581     @Deprecated
5582     public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
5583 
5584     /**
5585      * The version code of the app to install components from.
5586      * @hide
5587      */
5588     @SystemApi
5589     public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
5590 
5591     /**
5592      * The app that triggered the instant app installation.
5593      * @hide
5594      */
5595     @SystemApi
5596     public static final String EXTRA_CALLING_PACKAGE
5597             = "android.intent.extra.CALLING_PACKAGE";
5598 
5599     /**
5600      * Optional calling app provided bundle containing additional launch information the
5601      * installer may use.
5602      * @hide
5603      */
5604     @SystemApi
5605     public static final String EXTRA_VERIFICATION_BUNDLE
5606             = "android.intent.extra.VERIFICATION_BUNDLE";
5607 
5608     /**
5609      * A Bundle forming a mapping of potential target package names to different extras Bundles
5610      * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
5611      * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
5612      * be currently installed on the device.
5613      *
5614      * <p>An application may choose to provide alternate extras for the case where a user
5615      * selects an activity from a predetermined set of target packages. If the activity
5616      * the user selects from the chooser belongs to a package with its package name as
5617      * a key in this bundle, the corresponding extras for that package will be merged with
5618      * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
5619      * extra has the same key as an extra already present in the intent it will overwrite
5620      * the extra from the intent.</p>
5621      *
5622      * <p><em>Examples:</em>
5623      * <ul>
5624      *     <li>An application may offer different {@link #EXTRA_TEXT} to an application
5625      *     when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
5626      *     parameters for that target.</li>
5627      *     <li>An application may offer additional metadata for known targets of a given intent
5628      *     to pass along information only relevant to that target such as account or content
5629      *     identifiers already known to that application.</li>
5630      * </ul></p>
5631      */
5632     public static final String EXTRA_REPLACEMENT_EXTRAS =
5633             "android.intent.extra.REPLACEMENT_EXTRAS";
5634 
5635     /**
5636      * An {@link IntentSender} that will be notified if a user successfully chooses a target
5637      * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
5638      * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
5639      * {@link ComponentName} of the chosen component.
5640      *
5641      * <p>In some situations this callback may never come, for example if the user abandons
5642      * the chooser, switches to another task or any number of other reasons. Apps should not
5643      * be written assuming that this callback will always occur.</p>
5644      */
5645     public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
5646             "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
5647 
5648     /**
5649      * The {@link ComponentName} chosen by the user to complete an action.
5650      *
5651      * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
5652      */
5653     public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
5654 
5655     /**
5656      * A {@link android.view.KeyEvent} object containing the event that
5657      * triggered the creation of the Intent it is in.
5658      */
5659     public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
5660 
5661     /**
5662      * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
5663      * before shutting down.
5664      *
5665      * {@hide}
5666      */
5667     public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
5668 
5669     /**
5670      * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
5671      * requested by the user.
5672      *
5673      * {@hide}
5674      */
5675     public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
5676             "android.intent.extra.USER_REQUESTED_SHUTDOWN";
5677 
5678     /**
5679      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5680      * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
5681      * of restarting the application.
5682      */
5683     public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
5684 
5685     /**
5686      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5687      * intents to signal that the application was removed with the user-initiated action.
5688      */
5689     public static final String EXTRA_USER_INITIATED = "android.intent.extra.USER_INITIATED";
5690 
5691     /**
5692      * A String holding the phone number originally entered in
5693      * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
5694      * number to call in a {@link android.content.Intent#ACTION_CALL}.
5695      */
5696     public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
5697 
5698     /**
5699      * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
5700      * intents to supply the uid the package had been assigned.  Also an optional
5701      * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5702      * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
5703      * purpose.
5704      */
5705     public static final String EXTRA_UID = "android.intent.extra.UID";
5706 
5707     /**
5708      * @hide String array of package names.
5709      */
5710     @SystemApi
5711     public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
5712 
5713     /**
5714      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5715      * intents to indicate whether this represents a full uninstall (removing
5716      * both the code and its data) or a partial uninstall (leaving its data,
5717      * implying that this is an update).
5718      */
5719     public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
5720 
5721     /**
5722      * @hide
5723      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5724      * intents to indicate that at this point the package has been removed for
5725      * all users on the device.
5726      */
5727     public static final String EXTRA_REMOVED_FOR_ALL_USERS
5728             = "android.intent.extra.REMOVED_FOR_ALL_USERS";
5729 
5730     /**
5731      * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5732      * intents to indicate that this is a replacement of the package, so this
5733      * broadcast will immediately be followed by an add broadcast for a
5734      * different version of the same package.
5735      */
5736     public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
5737 
5738     /**
5739      * Used as an int extra field in {@link android.app.AlarmManager} pending intents
5740      * to tell the application being invoked how many pending alarms are being
5741      * delivered with the intent.  For one-shot alarms this will always be 1.
5742      * For recurring alarms, this might be greater than 1 if the device was
5743      * asleep or powered off at the time an earlier alarm would have been
5744      * delivered.
5745      *
5746      * <p>Note: You must supply a <b>mutable</b> {@link android.app.PendingIntent} to
5747      * {@code AlarmManager} while setting your alarms to be able to read this value on receiving
5748      * them. <em>Mutability of pending intents must be explicitly specified by apps targeting
5749      * {@link Build.VERSION_CODES#S} or higher</em>.
5750      *
5751      * @see android.app.PendingIntent#FLAG_MUTABLE
5752      *
5753      */
5754     public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
5755 
5756     /**
5757      * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
5758      * intents to request the dock state.  Possible values are
5759      * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
5760      * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
5761      * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
5762      * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
5763      * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
5764      */
5765     public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
5766 
5767     /**
5768      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5769      * to represent that the phone is not in any dock.
5770      */
5771     public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
5772 
5773     /**
5774      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5775      * to represent that the phone is in a desk dock.
5776      */
5777     public static final int EXTRA_DOCK_STATE_DESK = 1;
5778 
5779     /**
5780      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5781      * to represent that the phone is in a car dock.
5782      */
5783     public static final int EXTRA_DOCK_STATE_CAR = 2;
5784 
5785     /**
5786      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5787      * to represent that the phone is in a analog (low end) dock.
5788      */
5789     public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
5790 
5791     /**
5792      * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5793      * to represent that the phone is in a digital (high end) dock.
5794      */
5795     public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
5796 
5797     /**
5798      * Boolean that can be supplied as meta-data with a dock activity, to
5799      * indicate that the dock should take over the home key when it is active.
5800      */
5801     public static final String METADATA_DOCK_HOME = "android.dock_home";
5802 
5803     /**
5804      * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
5805      * the bug report.
5806      */
5807     public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
5808 
5809     /**
5810      * Used in the extra field in the remote intent. It's a string token passed with the
5811      * remote intent.
5812      */
5813     public static final String EXTRA_REMOTE_INTENT_TOKEN =
5814             "android.intent.extra.remote_intent_token";
5815 
5816     /**
5817      * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
5818      * will contain only the first name in the list.
5819      */
5820     @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
5821             "android.intent.extra.changed_component_name";
5822 
5823     /**
5824      * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
5825      * and contains a string array of all of the components that have changed.  If
5826      * the state of the overall package has changed, then it will contain an entry
5827      * with the package name itself.
5828      */
5829     public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
5830             "android.intent.extra.changed_component_name_list";
5831 
5832     /**
5833      * This field is part of
5834      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5835      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
5836      * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
5837      * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
5838      * and contains a string array of all of the components that have changed.
5839      */
5840     public static final String EXTRA_CHANGED_PACKAGE_LIST =
5841             "android.intent.extra.changed_package_list";
5842 
5843     /**
5844      * This field is part of
5845      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5846      * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
5847      * and contains an integer array of uids of all of the components
5848      * that have changed.
5849      */
5850     public static final String EXTRA_CHANGED_UID_LIST =
5851             "android.intent.extra.changed_uid_list";
5852 
5853     /**
5854      * An integer denoting a bitwise combination of restrictions set on distracting packages via
5855      * {@link PackageManager#setDistractingPackageRestrictions(String[], int)}
5856      *
5857      * @hide
5858      * @see PackageManager.DistractionRestriction
5859      * @see PackageManager#setDistractingPackageRestrictions(String[], int)
5860      */
5861     public static final String EXTRA_DISTRACTION_RESTRICTIONS =
5862             "android.intent.extra.distraction_restrictions";
5863 
5864     /**
5865      * @hide
5866      * Magic extra system code can use when binding, to give a label for
5867      * who it is that has bound to a service.  This is an integer giving
5868      * a framework string resource that can be displayed to the user.
5869      */
5870     public static final String EXTRA_CLIENT_LABEL =
5871             "android.intent.extra.client_label";
5872 
5873     /**
5874      * @hide
5875      * Magic extra system code can use when binding, to give a PendingIntent object
5876      * that can be launched for the user to disable the system's use of this
5877      * service.
5878      */
5879     public static final String EXTRA_CLIENT_INTENT =
5880             "android.intent.extra.client_intent";
5881 
5882     /**
5883      * Extra used to indicate that an intent should only return data that is on
5884      * the local device. This is a boolean extra; the default is false. If true,
5885      * an implementation should only allow the user to select data that is
5886      * already on the device, not requiring it be downloaded from a remote
5887      * service when opened.
5888      *
5889      * @see #ACTION_GET_CONTENT
5890      * @see #ACTION_OPEN_DOCUMENT
5891      * @see #ACTION_OPEN_DOCUMENT_TREE
5892      * @see #ACTION_CREATE_DOCUMENT
5893      */
5894     public static final String EXTRA_LOCAL_ONLY =
5895             "android.intent.extra.LOCAL_ONLY";
5896 
5897     /**
5898      * Extra used to indicate that an intent can allow the user to select and
5899      * return multiple items. This is a boolean extra; the default is false. If
5900      * true, an implementation is allowed to present the user with a UI where
5901      * they can pick multiple items that are all returned to the caller. When
5902      * this happens, they should be returned as the {@link #getClipData()} part
5903      * of the result Intent.
5904      *
5905      * @see #ACTION_GET_CONTENT
5906      * @see #ACTION_OPEN_DOCUMENT
5907      */
5908     public static final String EXTRA_ALLOW_MULTIPLE =
5909             "android.intent.extra.ALLOW_MULTIPLE";
5910 
5911     /**
5912      * The integer userHandle (i.e. userId) carried with broadcast intents related to addition,
5913      * removal and switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5914      * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5915      *
5916      * @hide
5917      */
5918     public static final String EXTRA_USER_HANDLE =
5919             "android.intent.extra.user_handle";
5920 
5921     /**
5922      * The UserHandle carried with intents.
5923      */
5924     public static final String EXTRA_USER =
5925             "android.intent.extra.USER";
5926 
5927     /**
5928      * Extra used in the response from a BroadcastReceiver that handles
5929      * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5930      * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
5931      */
5932     public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5933 
5934     /**
5935      * Extra sent in the intent to the BroadcastReceiver that handles
5936      * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5937      * the restrictions as key/value pairs.
5938      */
5939     public static final String EXTRA_RESTRICTIONS_BUNDLE =
5940             "android.intent.extra.restrictions_bundle";
5941 
5942     /**
5943      * Extra used in the response from a BroadcastReceiver that handles
5944      * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5945      */
5946     public static final String EXTRA_RESTRICTIONS_INTENT =
5947             "android.intent.extra.restrictions_intent";
5948 
5949     /**
5950      * Extra used to communicate a set of acceptable MIME types. The type of the
5951      * extra is {@code String[]}. Values may be a combination of concrete MIME
5952      * types (such as "image/png") and/or partial MIME types (such as
5953      * "audio/*").
5954      *
5955      * @see #ACTION_GET_CONTENT
5956      * @see #ACTION_OPEN_DOCUMENT
5957      */
5958     public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5959 
5960     /**
5961      * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5962      * this shutdown is only for the user space of the system, not a complete shutdown.
5963      * When this is true, hardware devices can use this information to determine that
5964      * they shouldn't do a complete shutdown of their device since this is not a
5965      * complete shutdown down to the kernel, but only user space restarting.
5966      * The default if not supplied is false.
5967      */
5968     public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5969             = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5970 
5971     /**
5972      * Optional extra specifying a time in milliseconds since the Epoch. The value must be
5973      * non-negative.
5974      * <p>
5975      * Type: long
5976      * </p>
5977      */
5978     public static final String EXTRA_TIME = "android.intent.extra.TIME";
5979 
5980     /**
5981      * Extra sent with {@link #ACTION_TIMEZONE_CHANGED} specifying the new time zone of the device.
5982      *
5983      * <p>Type: String, the same as returned by {@link TimeZone#getID()} to identify time zones.
5984      */
5985     @SuppressLint("ActionValue")
5986     public static final String EXTRA_TIMEZONE = "time-zone";
5987 
5988     /**
5989      * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5990      * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5991      * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5992      * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
5993      *
5994      * @hide for internal use only.
5995      */
5996     public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5997             "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
5998     /** @hide */
5999     public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
6000     /** @hide */
6001     public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
6002     /** @hide */
6003     public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
6004 
6005     /**
6006      * Intent extra: the reason that the operation associated with this intent is being performed.
6007      *
6008      * <p>Type: String
6009      * @hide
6010      */
6011     @SystemApi
6012     public static final String EXTRA_REASON = "android.intent.extra.REASON";
6013 
6014     /**
6015      * {@hide}
6016      * This extra will be send together with {@link #ACTION_FACTORY_RESET}
6017      */
6018     public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
6019 
6020     /**
6021      * {@hide}
6022      * This extra will be set to true when the user choose to wipe the data on eSIM during factory
6023      * reset for the device with eSIM. This extra will be sent together with
6024      * {@link #ACTION_FACTORY_RESET}
6025      */
6026     public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
6027 
6028     /**
6029      * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
6030      * activation request.
6031      * TODO: Add information about the structure and response data used with the pending intent.
6032      * @hide
6033      */
6034     public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
6035             "android.intent.extra.SIM_ACTIVATION_RESPONSE";
6036 
6037     /**
6038      * Optional index with semantics depending on the intent action.
6039      *
6040      * <p>The value must be an integer greater or equal to 0.
6041      * @see #ACTION_QUICK_VIEW
6042      */
6043     public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
6044 
6045     /**
6046      * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
6047      * such as opening in other apps, sharing, opening, editing, printing, deleting,
6048      * casting, etc.
6049      *
6050      * <p>The value is boolean. By default false.
6051      * @see #ACTION_QUICK_VIEW
6052      * @removed
6053      */
6054     @Deprecated
6055     public static final String EXTRA_QUICK_VIEW_ADVANCED =
6056             "android.intent.extra.QUICK_VIEW_ADVANCED";
6057 
6058     /**
6059      * An optional extra of {@code String[]} indicating which quick view features should be made
6060      * available to the user in the quick view UI while handing a
6061      * {@link Intent#ACTION_QUICK_VIEW} intent.
6062      * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
6063      * Quick viewer can implement features not listed below.
6064      * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
6065      * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
6066      * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
6067      * {@link QuickViewConstants#FEATURE_PRINT}.
6068      * <p>
6069      * Requirements:
6070      * <li>Quick viewer shouldn't show a feature if the feature is absent in
6071      * {@link #EXTRA_QUICK_VIEW_FEATURES}.
6072      * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
6073      * internal policies.
6074      * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
6075      * requirement that the feature be shown. Quick viewer may, according to its own policies,
6076      * disable or hide features.
6077      *
6078      * @see #ACTION_QUICK_VIEW
6079      */
6080     public static final String EXTRA_QUICK_VIEW_FEATURES =
6081             "android.intent.extra.QUICK_VIEW_FEATURES";
6082 
6083     /**
6084      * Optional boolean extra indicating whether quiet mode has been switched on or off.
6085      * When a profile goes into quiet mode, all apps in the profile are killed and the
6086      * profile user is stopped. Widgets originating from the profile are masked, and app
6087      * launcher icons are grayed out.
6088      */
6089     public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
6090 
6091     /**
6092      * Optional CharSequence extra to provide a search query.
6093      * The format of this query is dependent on the receiving application.
6094      *
6095      * <p>Applicable to {@link Intent} with actions:
6096      * <ul>
6097      *      <li>{@link Intent#ACTION_GET_CONTENT}</li>
6098      *      <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li>
6099      * </ul>
6100      */
6101     public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY";
6102 
6103     /**
6104      * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
6105      * intents to specify the resource type granted. Possible values are
6106      * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
6107      * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
6108      *
6109      * @hide
6110      */
6111     public static final String EXTRA_MEDIA_RESOURCE_TYPE =
6112             "android.intent.extra.MEDIA_RESOURCE_TYPE";
6113 
6114     /**
6115      * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
6116      * whether to show the chooser or not when there is only one application available
6117      * to choose from.
6118      */
6119     public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
6120             "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
6121 
6122     /**
6123      * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
6124      * to represent that a video codec is allowed to use.
6125      *
6126      * @hide
6127      */
6128     public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
6129 
6130     /**
6131      * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
6132      * to represent that a audio codec is allowed to use.
6133      *
6134      * @hide
6135      */
6136     public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
6137 
6138     /**
6139      * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}.
6140      *
6141      * <p>
6142      * Type: {@link LocusId}
6143      * </p>
6144      */
6145     public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID";
6146 
6147     /**
6148      * Used as an int array extra field in
6149      * {@link android.content.Intent#ACTION_PACKAGE_REMOVED_INTERNAL}
6150      * intents to indicate that visibility allow list of this removed package.
6151      *
6152      * @hide
6153      */
6154     public static final String EXTRA_VISIBILITY_ALLOW_LIST =
6155             "android.intent.extra.VISIBILITY_ALLOW_LIST";
6156 
6157     // ---------------------------------------------------------------------
6158     // ---------------------------------------------------------------------
6159     // Intent flags (see mFlags variable).
6160 
6161     /** @hide */
6162     @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
6163             FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
6164             FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
6165     @Retention(RetentionPolicy.SOURCE)
6166     public @interface GrantUriMode {}
6167 
6168     /** @hide */
6169     @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
6170             FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
6171     @Retention(RetentionPolicy.SOURCE)
6172     public @interface AccessUriMode {}
6173 
6174     /**
6175      * Test if given mode flags specify an access mode, which must be at least
6176      * read and/or write.
6177      *
6178      * @hide
6179      */
isAccessUriMode(int modeFlags)6180     public static boolean isAccessUriMode(int modeFlags) {
6181         return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
6182                 | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
6183     }
6184 
6185     /** @hide */
6186     @IntDef(flag = true, prefix = { "FLAG_" }, value = {
6187             FLAG_GRANT_READ_URI_PERMISSION,
6188             FLAG_GRANT_WRITE_URI_PERMISSION,
6189             FLAG_FROM_BACKGROUND,
6190             FLAG_DEBUG_LOG_RESOLUTION,
6191             FLAG_EXCLUDE_STOPPED_PACKAGES,
6192             FLAG_INCLUDE_STOPPED_PACKAGES,
6193             FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
6194             FLAG_GRANT_PREFIX_URI_PERMISSION,
6195             FLAG_DEBUG_TRIAGED_MISSING,
6196             FLAG_IGNORE_EPHEMERAL,
6197             FLAG_ACTIVITY_MATCH_EXTERNAL,
6198             FLAG_ACTIVITY_NO_HISTORY,
6199             FLAG_ACTIVITY_SINGLE_TOP,
6200             FLAG_ACTIVITY_NEW_TASK,
6201             FLAG_ACTIVITY_MULTIPLE_TASK,
6202             FLAG_ACTIVITY_CLEAR_TOP,
6203             FLAG_ACTIVITY_FORWARD_RESULT,
6204             FLAG_ACTIVITY_PREVIOUS_IS_TOP,
6205             FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
6206             FLAG_ACTIVITY_BROUGHT_TO_FRONT,
6207             FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
6208             FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
6209             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6210             FLAG_ACTIVITY_NEW_DOCUMENT,
6211             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6212             FLAG_ACTIVITY_NO_USER_ACTION,
6213             FLAG_ACTIVITY_REORDER_TO_FRONT,
6214             FLAG_ACTIVITY_NO_ANIMATION,
6215             FLAG_ACTIVITY_CLEAR_TASK,
6216             FLAG_ACTIVITY_TASK_ON_HOME,
6217             FLAG_ACTIVITY_RETAIN_IN_RECENTS,
6218             FLAG_ACTIVITY_LAUNCH_ADJACENT,
6219             FLAG_ACTIVITY_REQUIRE_NON_BROWSER,
6220             FLAG_ACTIVITY_REQUIRE_DEFAULT,
6221             FLAG_RECEIVER_REGISTERED_ONLY,
6222             FLAG_RECEIVER_REPLACE_PENDING,
6223             FLAG_RECEIVER_FOREGROUND,
6224             FLAG_RECEIVER_NO_ABORT,
6225             FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
6226             FLAG_RECEIVER_BOOT_UPGRADE,
6227             FLAG_RECEIVER_INCLUDE_BACKGROUND,
6228             FLAG_RECEIVER_EXCLUDE_BACKGROUND,
6229             FLAG_RECEIVER_FROM_SHELL,
6230             FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
6231             FLAG_RECEIVER_OFFLOAD,
6232     })
6233     @Retention(RetentionPolicy.SOURCE)
6234     public @interface Flags {}
6235 
6236     /** @hide */
6237     @IntDef(flag = true, prefix = { "FLAG_" }, value = {
6238             FLAG_FROM_BACKGROUND,
6239             FLAG_DEBUG_LOG_RESOLUTION,
6240             FLAG_EXCLUDE_STOPPED_PACKAGES,
6241             FLAG_INCLUDE_STOPPED_PACKAGES,
6242             FLAG_DEBUG_TRIAGED_MISSING,
6243             FLAG_IGNORE_EPHEMERAL,
6244             FLAG_ACTIVITY_MATCH_EXTERNAL,
6245             FLAG_ACTIVITY_NO_HISTORY,
6246             FLAG_ACTIVITY_SINGLE_TOP,
6247             FLAG_ACTIVITY_NEW_TASK,
6248             FLAG_ACTIVITY_MULTIPLE_TASK,
6249             FLAG_ACTIVITY_CLEAR_TOP,
6250             FLAG_ACTIVITY_FORWARD_RESULT,
6251             FLAG_ACTIVITY_PREVIOUS_IS_TOP,
6252             FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
6253             FLAG_ACTIVITY_BROUGHT_TO_FRONT,
6254             FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
6255             FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
6256             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6257             FLAG_ACTIVITY_NEW_DOCUMENT,
6258             FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
6259             FLAG_ACTIVITY_NO_USER_ACTION,
6260             FLAG_ACTIVITY_REORDER_TO_FRONT,
6261             FLAG_ACTIVITY_NO_ANIMATION,
6262             FLAG_ACTIVITY_CLEAR_TASK,
6263             FLAG_ACTIVITY_TASK_ON_HOME,
6264             FLAG_ACTIVITY_RETAIN_IN_RECENTS,
6265             FLAG_ACTIVITY_LAUNCH_ADJACENT,
6266             FLAG_RECEIVER_REGISTERED_ONLY,
6267             FLAG_RECEIVER_REPLACE_PENDING,
6268             FLAG_RECEIVER_FOREGROUND,
6269             FLAG_RECEIVER_NO_ABORT,
6270             FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
6271             FLAG_RECEIVER_BOOT_UPGRADE,
6272             FLAG_RECEIVER_INCLUDE_BACKGROUND,
6273             FLAG_RECEIVER_EXCLUDE_BACKGROUND,
6274             FLAG_RECEIVER_FROM_SHELL,
6275             FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
6276             FLAG_RECEIVER_OFFLOAD,
6277     })
6278     @Retention(RetentionPolicy.SOURCE)
6279     public @interface MutableFlags {}
6280 
6281     /**
6282      * If set, the recipient of this Intent will be granted permission to
6283      * perform read operations on the URI in the Intent's data and any URIs
6284      * specified in its ClipData.  When applying to an Intent's ClipData,
6285      * all URIs as well as recursive traversals through data or other ClipData
6286      * in Intent items will be granted; only the grant flags of the top-level
6287      * Intent are used.
6288      */
6289     public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
6290     /**
6291      * If set, the recipient of this Intent will be granted permission to
6292      * perform write operations on the URI in the Intent's data and any URIs
6293      * specified in its ClipData.  When applying to an Intent's ClipData,
6294      * all URIs as well as recursive traversals through data or other ClipData
6295      * in Intent items will be granted; only the grant flags of the top-level
6296      * Intent are used.
6297      */
6298     public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
6299     /**
6300      * Can be set by the caller to indicate that this Intent is coming from
6301      * a background operation, not from direct user interaction.
6302      */
6303     public static final int FLAG_FROM_BACKGROUND = 0x00000004;
6304     /**
6305      * A flag you can enable for debugging: when set, log messages will be
6306      * printed during the resolution of this intent to show you what has
6307      * been found to create the final resolved list.
6308      */
6309     public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
6310     /**
6311      * If set, this intent will not match any components in packages that
6312      * are currently stopped.  If this is not set, then the default behavior
6313      * is to include such applications in the result.
6314      */
6315     public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
6316     /**
6317      * If set, this intent will always match any components in packages that
6318      * are currently stopped.  This is the default behavior when
6319      * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set.  If both of these
6320      * flags are set, this one wins (it allows overriding of exclude for
6321      * places where the framework may automatically set the exclude flag).
6322      */
6323     public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
6324 
6325     /**
6326      * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
6327      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
6328      * persisted across device reboots until explicitly revoked with
6329      * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
6330      * grant for possible persisting; the receiving application must call
6331      * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
6332      * actually persist.
6333      *
6334      * @see ContentResolver#takePersistableUriPermission(Uri, int)
6335      * @see ContentResolver#releasePersistableUriPermission(Uri, int)
6336      * @see ContentResolver#getPersistedUriPermissions()
6337      * @see ContentResolver#getOutgoingPersistedUriPermissions()
6338      */
6339     public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
6340 
6341     /**
6342      * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
6343      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
6344      * applies to any URI that is a prefix match against the original granted
6345      * URI. (Without this flag, the URI must match exactly for access to be
6346      * granted.) Another URI is considered a prefix match only when scheme,
6347      * authority, and all path segments defined by the prefix are an exact
6348      * match.
6349      */
6350     public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
6351 
6352     /**
6353      * Flag used to automatically match intents based on their Direct Boot
6354      * awareness and the current user state.
6355      * <p>
6356      * Since the default behavior is to automatically apply the current user
6357      * state, this is effectively a sentinel value that doesn't change the
6358      * output of any queries based on its presence or absence.
6359      * <p>
6360      * Instead, this value can be useful in conjunction with
6361      * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
6362      * to detect when a caller is relying on implicit automatic matching,
6363      * instead of confirming the explicit behavior they want.
6364      */
6365     public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
6366 
6367     /** {@hide} */
6368     @Deprecated
6369     public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
6370 
6371     /**
6372      * Internal flag used to indicate ephemeral applications should not be
6373      * considered when resolving the intent.
6374      *
6375      * @hide
6376      */
6377     public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
6378 
6379     /**
6380      * If set, the new activity is not kept in the history stack.  As soon as
6381      * the user navigates away from it, the activity is finished.  This may also
6382      * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
6383      * noHistory} attribute.
6384      *
6385      * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
6386      * is never invoked when the current activity starts a new activity which
6387      * sets a result and finishes.
6388      */
6389     public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
6390     /**
6391      * If set, the activity will not be launched if it is already running
6392      * at the top of the history stack.  See
6393      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html#TaskLaunchModes">
6394      * Tasks and Back Stack</a> for more information.
6395      */
6396     public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
6397     /**
6398      * If set, this activity will become the start of a new task on this
6399      * history stack.  A task (from the activity that started it to the
6400      * next task activity) defines an atomic group of activities that the
6401      * user can move to.  Tasks can be moved to the foreground and background;
6402      * all of the activities inside of a particular task always remain in
6403      * the same order.  See
6404      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6405      * Stack</a> for more information about tasks.
6406      *
6407      * <p>This flag is generally used by activities that want
6408      * to present a "launcher" style behavior: they give the user a list of
6409      * separate things that can be done, which otherwise run completely
6410      * independently of the activity launching them.
6411      *
6412      * <p>When using this flag, if a task is already running for the activity
6413      * you are now starting, then a new activity will not be started; instead,
6414      * the current task will simply be brought to the front of the screen with
6415      * the state it was last in.  See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
6416      * to disable this behavior.
6417      *
6418      * <p>This flag can not be used when the caller is requesting a result from
6419      * the activity being launched.
6420      */
6421     public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
6422     /**
6423      * This flag is used to create a new task and launch an activity into it.
6424      * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
6425      * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
6426      * search through existing tasks for ones matching this Intent. Only if no such
6427      * task is found would a new task be created. When paired with
6428      * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
6429      * the search for a matching task and unconditionally start a new task.
6430      *
6431      * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
6432      * flag unless you are implementing your own
6433      * top-level application launcher.</strong>  Used in conjunction with
6434      * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
6435      * behavior of bringing an existing task to the foreground.  When set,
6436      * a new task is <em>always</em> started to host the Activity for the
6437      * Intent, regardless of whether there is already an existing task running
6438      * the same thing.
6439      *
6440      * <p><strong>Because the default system does not include graphical task management,
6441      * you should not use this flag unless you provide some way for a user to
6442      * return back to the tasks you have launched.</strong>
6443      *
6444      * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
6445      * creating new document tasks.
6446      *
6447      * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
6448      * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
6449      *
6450      * <p>See
6451      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6452      * Stack</a> for more information about tasks.
6453      *
6454      * @see #FLAG_ACTIVITY_NEW_DOCUMENT
6455      * @see #FLAG_ACTIVITY_NEW_TASK
6456      */
6457     public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
6458     /**
6459      * If set, and the activity being launched is already running in the
6460      * current task, then instead of launching a new instance of that activity,
6461      * all of the other activities on top of it will be closed and this Intent
6462      * will be delivered to the (now on top) old activity as a new Intent.
6463      *
6464      * <p>For example, consider a task consisting of the activities: A, B, C, D.
6465      * If D calls startActivity() with an Intent that resolves to the component
6466      * of activity B, then C and D will be finished and B receive the given
6467      * Intent, resulting in the stack now being: A, B.
6468      *
6469      * <p>The currently running instance of activity B in the above example will
6470      * either receive the new intent you are starting here in its
6471      * onNewIntent() method, or be itself finished and restarted with the
6472      * new intent.  If it has declared its launch mode to be "multiple" (the
6473      * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
6474      * the same intent, then it will be finished and re-created; for all other
6475      * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
6476      * Intent will be delivered to the current instance's onNewIntent().
6477      *
6478      * <p>This launch mode can also be used to good effect in conjunction with
6479      * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
6480      * of a task, it will bring any currently running instance of that task
6481      * to the foreground, and then clear it to its root state.  This is
6482      * especially useful, for example, when launching an activity from the
6483      * notification manager.
6484      *
6485      * <p>See
6486      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
6487      * Stack</a> for more information about tasks.
6488      */
6489     public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
6490     /**
6491      * If set and this intent is being used to launch a new activity from an
6492      * existing one, then the reply target of the existing activity will be
6493      * transferred to the new activity.  This way, the new activity can call
6494      * {@link android.app.Activity#setResult} and have that result sent back to
6495      * the reply target of the original activity.
6496      */
6497     public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
6498     /**
6499      * If set and this intent is being used to launch a new activity from an
6500      * existing one, the current activity will not be counted as the top
6501      * activity for deciding whether the new intent should be delivered to
6502      * the top instead of starting a new one.  The previous activity will
6503      * be used as the top, with the assumption being that the current activity
6504      * will finish itself immediately.
6505      */
6506     public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
6507     /**
6508      * If set, the new activity is not kept in the list of recently launched
6509      * activities.
6510      */
6511     public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
6512     /**
6513      * This flag is not normally set by application code, but set for you by
6514      * the system as described in the
6515      * {@link android.R.styleable#AndroidManifestActivity_launchMode
6516      * launchMode} documentation for the singleTask mode.
6517      */
6518     public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
6519     /**
6520      * If set, and this activity is either being started in a new task or
6521      * bringing to the top an existing task, then it will be launched as
6522      * the front door of the task.  This will result in the application of
6523      * any affinities needed to have that task in the proper state (either
6524      * moving activities to or from it), or simply resetting that task to
6525      * its initial state if needed.
6526      *
6527      * @see android.R.attr#allowTaskReparenting
6528      * @see android.R.attr#clearTaskOnLaunch
6529      * @see android.R.attr#finishOnTaskLaunch
6530      */
6531     public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
6532     /**
6533      * This flag is not normally set by application code, but set for you by
6534      * the system if this activity is being launched from history.
6535      */
6536     public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
6537     /**
6538      * @deprecated As of API 21 this performs identically to
6539      * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
6540      */
6541     @Deprecated
6542     public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
6543     /**
6544      * This flag is used to open a document into a new task rooted at the activity launched
6545      * by this Intent. Through the use of this flag, or its equivalent attribute,
6546      * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
6547      * containing different documents will appear in the recent tasks list.
6548      *
6549      * <p>The use of the activity attribute form of this,
6550      * {@link android.R.attr#documentLaunchMode}, is
6551      * preferred over the Intent flag described here. The attribute form allows the
6552      * Activity to specify multiple document behavior for all launchers of the Activity
6553      * whereas using this flag requires each Intent that launches the Activity to specify it.
6554      *
6555      * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
6556      * it is kept after the activity is finished is different than the use of
6557      * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
6558      * this flag is being used to create a new recents entry, then by default that entry
6559      * will be removed once the activity is finished.  You can modify this behavior with
6560      * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
6561      *
6562      * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
6563      * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
6564      * equivalent of the Activity manifest specifying {@link
6565      * android.R.attr#documentLaunchMode}="intoExisting". When used with
6566      * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
6567      * {@link android.R.attr#documentLaunchMode}="always". The flag is ignored even in
6568      * conjunction with {@link #FLAG_ACTIVITY_MULTIPLE_TASK} when the Activity manifest specifies
6569      * {@link android.R.attr#documentLaunchMode}="never".
6570      *
6571      * Refer to {@link android.R.attr#documentLaunchMode} for more information.
6572      *
6573      * @see android.R.attr#documentLaunchMode
6574      * @see #FLAG_ACTIVITY_MULTIPLE_TASK
6575      */
6576     public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
6577     /**
6578      * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
6579      * callback from occurring on the current frontmost activity before it is
6580      * paused as the newly-started activity is brought to the front.
6581      *
6582      * <p>Typically, an activity can rely on that callback to indicate that an
6583      * explicit user action has caused their activity to be moved out of the
6584      * foreground. The callback marks an appropriate point in the activity's
6585      * lifecycle for it to dismiss any notifications that it intends to display
6586      * "until the user has seen them," such as a blinking LED.
6587      *
6588      * <p>If an activity is ever started via any non-user-driven events such as
6589      * phone-call receipt or an alarm handler, this flag should be passed to {@link
6590      * Context#startActivity Context.startActivity}, ensuring that the pausing
6591      * activity does not think the user has acknowledged its notification.
6592      */
6593     public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
6594     /**
6595      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6596      * this flag will cause the launched activity to be brought to the front of its
6597      * task's history stack if it is already running.
6598      *
6599      * <p>For example, consider a task consisting of four activities: A, B, C, D.
6600      * If D calls startActivity() with an Intent that resolves to the component
6601      * of activity B, then B will be brought to the front of the history stack,
6602      * with this resulting order:  A, C, D, B.
6603      *
6604      * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
6605      * specified.
6606      */
6607     public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
6608     /**
6609      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6610      * this flag will prevent the system from applying an activity transition
6611      * animation to go to the next activity state.  This doesn't mean an
6612      * animation will never run -- if another activity change happens that doesn't
6613      * specify this flag before the activity started here is displayed, then
6614      * that transition will be used.  This flag can be put to good use
6615      * when you are going to do a series of activity operations but the
6616      * animation seen by the user shouldn't be driven by the first activity
6617      * change but rather a later one.
6618      */
6619     public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
6620     /**
6621      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6622      * this flag will cause any existing task that would be associated with the
6623      * activity to be cleared before the activity is started.  That is, the activity
6624      * becomes the new root of an otherwise empty task, and any old activities
6625      * are finished.  This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6626      */
6627     public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
6628     /**
6629      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6630      * this flag will cause a newly launching task to be placed on top of the current
6631      * home activity task (if there is one).  That is, pressing back from the task
6632      * will always return the user to home even if that was not the last activity they
6633      * saw.   This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6634      */
6635     public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
6636     /**
6637      * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
6638      * have its entry in recent tasks removed when the user closes it (with back
6639      * or however else it may finish()). If you would like to instead allow the
6640      * document to be kept in recents so that it can be re-launched, you can use
6641      * this flag. When set and the task's activity is finished, the recents
6642      * entry will remain in the interface for the user to re-launch it, like a
6643      * recents entry for a top-level application.
6644      * <p>
6645      * The receiving activity can override this request with
6646      * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
6647      * {@link android.app.Activity#finishAndRemoveTask()
6648      * Activity.finishAndRemoveTask()}.
6649      */
6650     public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
6651 
6652     /**
6653      * This flag is only used for split-screen multi-window mode. The new activity will be displayed
6654      * adjacent to the one launching it. This can only be used in conjunction with
6655      * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
6656      * required if you want a new instance of an existing activity to be created.
6657      */
6658     public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
6659 
6660 
6661     /**
6662      * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6663      * this flag will attempt to launch an instant app if no full app on the device can already
6664      * handle the intent.
6665      * <p>
6666      * When attempting to resolve instant apps externally, the following {@link Intent} properties
6667      * are supported:
6668      * <ul>
6669      *     <li>{@link Intent#setAction(String)}</li>
6670      *     <li>{@link Intent#addCategory(String)}</li>
6671      *     <li>{@link Intent#setData(Uri)}</li>
6672      *     <li>{@link Intent#setType(String)}</li>
6673      *     <li>{@link Intent#setPackage(String)}</li>
6674      *     <li>{@link Intent#addFlags(int)}</li>
6675      * </ul>
6676      * <p>
6677      * In the case that no instant app can be found, the installer will be launched to notify the
6678      * user that the intent could not be resolved. On devices that do not support instant apps,
6679      * the flag will be ignored.
6680      */
6681     public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
6682 
6683     /**
6684      * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this
6685      * flag will only launch the intent if it resolves to a result that is not a browser. If no such
6686      * result exists, an {@link ActivityNotFoundException} will be thrown.
6687      */
6688     public static final int FLAG_ACTIVITY_REQUIRE_NON_BROWSER = 0x00000400;
6689 
6690     /**
6691      * If set in an intent passed to {@link Context#startActivity Context.startActivity()}, this
6692      * flag will only launch the intent if it resolves to a single result. If no such result exists
6693      * or if the system chooser would otherwise be displayed, an {@link ActivityNotFoundException}
6694      * will be thrown.
6695      */
6696     public static final int FLAG_ACTIVITY_REQUIRE_DEFAULT = 0x00000200;
6697 
6698     /**
6699      * If set, when sending a broadcast only registered receivers will be
6700      * called -- no BroadcastReceiver components will be launched.
6701      */
6702     public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
6703     /**
6704      * If set, when sending a broadcast the new broadcast will replace
6705      * any existing pending broadcast that matches it.  Matching is defined
6706      * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
6707      * true for the intents of the two broadcasts.  When a match is found,
6708      * the new broadcast (and receivers associated with it) will replace the
6709      * existing one in the pending broadcast list, remaining at the same
6710      * position in the list.
6711      *
6712      * <p>This flag is most typically used with sticky broadcasts, which
6713      * only care about delivering the most recent values of the broadcast
6714      * to their receivers.
6715      */
6716     public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
6717     /**
6718      * If set, when sending a broadcast the recipient is allowed to run at
6719      * foreground priority, with a shorter timeout interval.  During normal
6720      * broadcasts the receivers are not automatically hoisted out of the
6721      * background priority class.
6722      */
6723     public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
6724     /**
6725      * If set, when sending a broadcast the recipient will be run on the offload queue.
6726      *
6727      * @hide
6728      */
6729     public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000;
6730     /**
6731      * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
6732      * They can still propagate results through to later receivers, but they can not prevent
6733      * later receivers from seeing the broadcast.
6734      */
6735     public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
6736     /**
6737      * If set, when sending a broadcast <i>before the system has fully booted up
6738      * (which is even before {@link #ACTION_LOCKED_BOOT_COMPLETED} has been sent)"</i> only
6739      * registered receivers will be called -- no BroadcastReceiver components
6740      * will be launched.  Sticky intent state will be recorded properly even
6741      * if no receivers wind up being called.  If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
6742      * is specified in the broadcast intent, this flag is unnecessary.
6743      *
6744      * <p>This flag is only for use by system services (even services from mainline modules) as a
6745      * convenience to avoid having to implement a more complex mechanism around detection
6746      * of boot completion.
6747      *
6748      * <p>This is useful to system server mainline modules
6749      *
6750      * @hide
6751      */
6752     @SystemApi
6753     public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
6754     /**
6755      * Set when this broadcast is for a boot upgrade, a special mode that
6756      * allows the broadcast to be sent before the system is ready and launches
6757      * the app process with no providers running in it.
6758      * @hide
6759      */
6760     public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
6761     /**
6762      * If set, the broadcast will always go to manifest receivers in background (cached
6763      * or not running) apps, regardless of whether that would be done by default.  By
6764      * default they will only receive broadcasts if the broadcast has specified an
6765      * explicit component or package name.
6766      *
6767      * NOTE: dumpstate uses this flag numerically, so when its value is changed
6768      * the broadcast code there must also be changed to match.
6769      *
6770      * @hide
6771      */
6772     public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
6773     /**
6774      * If set, the broadcast will never go to manifest receivers in background (cached
6775      * or not running) apps, regardless of whether that would be done by default.  By
6776      * default they will receive broadcasts if the broadcast has specified an
6777      * explicit component or package name.
6778      * @hide
6779      */
6780     public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
6781     /**
6782      * If set, this broadcast is being sent from the shell.
6783      * @hide
6784      */
6785     public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
6786 
6787     /**
6788      * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
6789      * will not receive broadcasts.
6790      *
6791      * <em>This flag has no effect when used by an Instant App.</em>
6792      */
6793     public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
6794 
6795     /**
6796      * @hide Flags that can't be changed with PendingIntent.
6797      */
6798     public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
6799             | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6800             | FLAG_GRANT_PREFIX_URI_PERMISSION;
6801 
6802     /**
6803      * Local flag indicating this instance was created by copy constructor.
6804      */
6805     private static final int LOCAL_FLAG_FROM_COPY = 1 << 0;
6806 
6807     /**
6808      * Local flag indicating this instance was created from a {@link Parcel}.
6809      */
6810     private static final int LOCAL_FLAG_FROM_PARCEL = 1 << 1;
6811 
6812     /**
6813      * Local flag indicating this instance was delivered through a protected
6814      * component, such as an activity that requires a signature permission, or a
6815      * protected broadcast. Note that this flag <em>cannot</em> be recursively
6816      * applied to any contained instances, since a malicious app may have
6817      * controlled them via {@link #fillIn(Intent, int)}.
6818      */
6819     private static final int LOCAL_FLAG_FROM_PROTECTED_COMPONENT = 1 << 2;
6820 
6821     /**
6822      * Local flag indicating this instance had unfiltered extras copied into it. This could be
6823      * from either {@link #putExtras(Intent)} when an unparceled Intent is provided or {@link
6824      * #putExtras(Bundle)} when the provided Bundle has not been unparceled.
6825      */
6826     private static final int LOCAL_FLAG_UNFILTERED_EXTRAS = 1 << 3;
6827 
6828     /**
6829      * Local flag indicating this instance was created from a {@link Uri}.
6830      */
6831     private static final int LOCAL_FLAG_FROM_URI = 1 << 4;
6832 
6833     // ---------------------------------------------------------------------
6834     // ---------------------------------------------------------------------
6835     // toUri() and parseUri() options.
6836 
6837     /** @hide */
6838     @IntDef(flag = true, prefix = { "URI_" }, value = {
6839             URI_ALLOW_UNSAFE,
6840             URI_ANDROID_APP_SCHEME,
6841             URI_INTENT_SCHEME,
6842     })
6843     @Retention(RetentionPolicy.SOURCE)
6844     public @interface UriFlags {}
6845 
6846     /**
6847      * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6848      * always has the "intent:" scheme.  This syntax can be used when you want
6849      * to later disambiguate between URIs that are intended to describe an
6850      * Intent vs. all others that should be treated as raw URIs.  When used
6851      * with {@link #parseUri}, any other scheme will result in a generic
6852      * VIEW action for that raw URI.
6853      */
6854     public static final int URI_INTENT_SCHEME = 1<<0;
6855 
6856     /**
6857      * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6858      * always has the "android-app:" scheme.  This is a variation of
6859      * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
6860      * http/https URI being delivered to a specific package name.  The format
6861      * is:
6862      *
6863      * <pre class="prettyprint">
6864      * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
6865      *
6866      * <p>In this scheme, only the <code>package_id</code> is required.  If you include a host,
6867      * you must also include a scheme; including a path also requires both a host and a scheme.
6868      * The final #Intent; fragment can be used without a scheme, host, or path.
6869      * Note that this can not be
6870      * used with intents that have a {@link #setSelector}, since the base intent
6871      * will always have an explicit package name.</p>
6872      *
6873      * <p>Some examples of how this scheme maps to Intent objects:</p>
6874      * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
6875      *     <colgroup align="left" />
6876      *     <colgroup align="left" />
6877      *     <thead>
6878      *     <tr><th>URI</th> <th>Intent</th></tr>
6879      *     </thead>
6880      *
6881      *     <tbody>
6882      *     <tr><td><code>android-app://com.example.app</code></td>
6883      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6884      *             <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
6885      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6886      *         </table></td>
6887      *     </tr>
6888      *     <tr><td><code>android-app://com.example.app/http/example.com</code></td>
6889      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6890      *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6891      *             <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
6892      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6893      *         </table></td>
6894      *     </tr>
6895      *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
6896      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6897      *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6898      *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6899      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6900      *         </table></td>
6901      *     </tr>
6902      *     <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6903      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6904      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6905      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6906      *         </table></td>
6907      *     </tr>
6908      *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6909      *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6910      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6911      *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6912      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6913      *         </table></td>
6914      *     </tr>
6915      *     <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>
6916      *         <td><table border="" style="margin:0" >
6917      *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6918      *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6919      *             <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
6920      *         </table></td>
6921      *     </tr>
6922      *     </tbody>
6923      * </table>
6924      */
6925     public static final int URI_ANDROID_APP_SCHEME = 1<<1;
6926 
6927     /**
6928      * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
6929      * of unsafe information.  In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
6930      * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
6931      * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
6932      * generated Intent can not cause unexpected data access to happen.
6933      *
6934      * <p>If you do not trust the source of the URI being parsed, you should still do further
6935      * processing to protect yourself from it.  In particular, when using it to start an
6936      * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
6937      * that can handle it.</p>
6938      */
6939     public static final int URI_ALLOW_UNSAFE = 1<<2;
6940 
6941     // ---------------------------------------------------------------------
6942 
6943     private String mAction;
6944     private Uri mData;
6945     private String mType;
6946     private String mIdentifier;
6947     private String mPackage;
6948     private ComponentName mComponent;
6949     private int mFlags;
6950     /** Set of in-process flags which are never parceled */
6951     private int mLocalFlags;
6952     private ArraySet<String> mCategories;
6953     @UnsupportedAppUsage
6954     private Bundle mExtras;
6955     private Rect mSourceBounds;
6956     private Intent mSelector;
6957     private ClipData mClipData;
6958     private int mContentUserHint = UserHandle.USER_CURRENT;
6959     /** Token to track instant app launches. Local only; do not copy cross-process. */
6960     private String mLaunchToken;
6961 
6962     // ---------------------------------------------------------------------
6963 
6964     private static final int COPY_MODE_ALL = 0;
6965     private static final int COPY_MODE_FILTER = 1;
6966     private static final int COPY_MODE_HISTORY = 2;
6967 
6968     /** @hide */
6969     @IntDef(prefix = { "COPY_MODE_" }, value = {
6970             COPY_MODE_ALL,
6971             COPY_MODE_FILTER,
6972             COPY_MODE_HISTORY
6973     })
6974     @Retention(RetentionPolicy.SOURCE)
6975     public @interface CopyMode {}
6976 
6977     /**
6978      * Create an empty intent.
6979      */
Intent()6980     public Intent() {
6981     }
6982 
6983     /**
6984      * Copy constructor.
6985      */
Intent(Intent o)6986     public Intent(Intent o) {
6987         this(o, COPY_MODE_ALL);
6988     }
6989 
Intent(Intent o, @CopyMode int copyMode)6990     private Intent(Intent o, @CopyMode int copyMode) {
6991         this.mAction = o.mAction;
6992         this.mData = o.mData;
6993         this.mType = o.mType;
6994         this.mIdentifier = o.mIdentifier;
6995         this.mPackage = o.mPackage;
6996         this.mComponent = o.mComponent;
6997 
6998         if (o.mCategories != null) {
6999             this.mCategories = new ArraySet<>(o.mCategories);
7000         }
7001 
7002         // Inherit flags from the original, plus mark that we were
7003         // created by this copy constructor
7004         this.mLocalFlags = o.mLocalFlags;
7005         this.mLocalFlags |= LOCAL_FLAG_FROM_COPY;
7006 
7007         if (copyMode != COPY_MODE_FILTER) {
7008             this.mFlags = o.mFlags;
7009             this.mContentUserHint = o.mContentUserHint;
7010             this.mLaunchToken = o.mLaunchToken;
7011             if (o.mSourceBounds != null) {
7012                 this.mSourceBounds = new Rect(o.mSourceBounds);
7013             }
7014             if (o.mSelector != null) {
7015                 this.mSelector = new Intent(o.mSelector);
7016             }
7017 
7018             if (copyMode != COPY_MODE_HISTORY) {
7019                 if (o.mExtras != null) {
7020                     this.mExtras = new Bundle(o.mExtras);
7021                 }
7022                 if (o.mClipData != null) {
7023                     this.mClipData = new ClipData(o.mClipData);
7024                 }
7025             } else {
7026                 if (o.mExtras != null && !o.mExtras.isDefinitelyEmpty()) {
7027                     this.mExtras = Bundle.STRIPPED;
7028                 }
7029 
7030                 // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
7031                 // history.
7032             }
7033         }
7034     }
7035 
7036     @Override
clone()7037     public Object clone() {
7038         return new Intent(this);
7039     }
7040 
7041     /**
7042      * Make a clone of only the parts of the Intent that are relevant for
7043      * filter matching: the action, data, type, component, and categories.
7044      */
cloneFilter()7045     public @NonNull Intent cloneFilter() {
7046         return new Intent(this, COPY_MODE_FILTER);
7047     }
7048 
7049     /**
7050      * Create an intent with a given action.  All other fields (data, type,
7051      * class) are null.  Note that the action <em>must</em> be in a
7052      * namespace because Intents are used globally in the system -- for
7053      * example the system VIEW action is android.intent.action.VIEW; an
7054      * application's custom action would be something like
7055      * com.google.app.myapp.CUSTOM_ACTION.
7056      *
7057      * @param action The Intent action, such as ACTION_VIEW.
7058      */
Intent(String action)7059     public Intent(String action) {
7060         setAction(action);
7061     }
7062 
7063     /**
7064      * Create an intent with a given action and for a given data url.  Note
7065      * that the action <em>must</em> be in a namespace because Intents are
7066      * used globally in the system -- for example the system VIEW action is
7067      * android.intent.action.VIEW; an application's custom action would be
7068      * something like com.google.app.myapp.CUSTOM_ACTION.
7069      *
7070      * <p><em>Note: scheme and host name matching in the Android framework is
7071      * case-sensitive, unlike the formal RFC.  As a result,
7072      * you should always ensure that you write your Uri with these elements
7073      * using lower case letters, and normalize any Uris you receive from
7074      * outside of Android to ensure the scheme and host is lower case.</em></p>
7075      *
7076      * @param action The Intent action, such as ACTION_VIEW.
7077      * @param uri The Intent data URI.
7078      */
Intent(String action, Uri uri)7079     public Intent(String action, Uri uri) {
7080         setAction(action);
7081         mData = uri;
7082     }
7083 
7084     /**
7085      * Create an intent for a specific component.  All other fields (action, data,
7086      * type, class) are null, though they can be modified later with explicit
7087      * calls.  This provides a convenient way to create an intent that is
7088      * intended to execute a hard-coded class name, rather than relying on the
7089      * system to find an appropriate class for you; see {@link #setComponent}
7090      * for more information on the repercussions of this.
7091      *
7092      * @param packageContext A Context of the application package implementing
7093      * this class.
7094      * @param cls The component class that is to be used for the intent.
7095      *
7096      * @see #setClass
7097      * @see #setComponent
7098      * @see #Intent(String, android.net.Uri , Context, Class)
7099      */
Intent(Context packageContext, Class<?> cls)7100     public Intent(Context packageContext, Class<?> cls) {
7101         mComponent = new ComponentName(packageContext, cls);
7102     }
7103 
7104     /**
7105      * Create an intent for a specific component with a specified action and data.
7106      * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
7107      * construct the Intent and then calling {@link #setClass} to set its
7108      * class.
7109      *
7110      * <p><em>Note: scheme and host name matching in the Android framework is
7111      * case-sensitive, unlike the formal RFC.  As a result,
7112      * you should always ensure that you write your Uri with these elements
7113      * using lower case letters, and normalize any Uris you receive from
7114      * outside of Android to ensure the scheme and host is lower case.</em></p>
7115      *
7116      * @param action The Intent action, such as ACTION_VIEW.
7117      * @param uri The Intent data URI.
7118      * @param packageContext A Context of the application package implementing
7119      * this class.
7120      * @param cls The component class that is to be used for the intent.
7121      *
7122      * @see #Intent(String, android.net.Uri)
7123      * @see #Intent(Context, Class)
7124      * @see #setClass
7125      * @see #setComponent
7126      */
Intent(String action, Uri uri, Context packageContext, Class<?> cls)7127     public Intent(String action, Uri uri,
7128             Context packageContext, Class<?> cls) {
7129         setAction(action);
7130         mData = uri;
7131         mComponent = new ComponentName(packageContext, cls);
7132     }
7133 
7134     /**
7135      * Create an intent to launch the main (root) activity of a task.  This
7136      * is the Intent that is started when the application's is launched from
7137      * Home.  For anything else that wants to launch an application in the
7138      * same way, it is important that they use an Intent structured the same
7139      * way, and can use this function to ensure this is the case.
7140      *
7141      * <p>The returned Intent has the given Activity component as its explicit
7142      * component, {@link #ACTION_MAIN} as its action, and includes the
7143      * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
7144      * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
7145      * to do that through {@link #addFlags(int)} on the returned Intent.
7146      *
7147      * @param mainActivity The main activity component that this Intent will
7148      * launch.
7149      * @return Returns a newly created Intent that can be used to launch the
7150      * activity as a main application entry.
7151      *
7152      * @see #setClass
7153      * @see #setComponent
7154      */
makeMainActivity(ComponentName mainActivity)7155     public static Intent makeMainActivity(ComponentName mainActivity) {
7156         Intent intent = new Intent(ACTION_MAIN);
7157         intent.setComponent(mainActivity);
7158         intent.addCategory(CATEGORY_LAUNCHER);
7159         return intent;
7160     }
7161 
7162     /**
7163      * Make an Intent for the main activity of an application, without
7164      * specifying a specific activity to run but giving a selector to find
7165      * the activity.  This results in a final Intent that is structured
7166      * the same as when the application is launched from
7167      * Home.  For anything else that wants to launch an application in the
7168      * same way, it is important that they use an Intent structured the same
7169      * way, and can use this function to ensure this is the case.
7170      *
7171      * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
7172      * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
7173      * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
7174      * to do that through {@link #addFlags(int)} on the returned Intent.
7175      *
7176      * @param selectorAction The action name of the Intent's selector.
7177      * @param selectorCategory The name of a category to add to the Intent's
7178      * selector.
7179      * @return Returns a newly created Intent that can be used to launch the
7180      * activity as a main application entry.
7181      *
7182      * @see #setSelector(Intent)
7183      */
makeMainSelectorActivity(String selectorAction, String selectorCategory)7184     public static Intent makeMainSelectorActivity(String selectorAction,
7185             String selectorCategory) {
7186         Intent intent = new Intent(ACTION_MAIN);
7187         intent.addCategory(CATEGORY_LAUNCHER);
7188         Intent selector = new Intent();
7189         selector.setAction(selectorAction);
7190         selector.addCategory(selectorCategory);
7191         intent.setSelector(selector);
7192         return intent;
7193     }
7194 
7195     /**
7196      * Make an Intent that can be used to re-launch an application's task
7197      * in its base state.  This is like {@link #makeMainActivity(ComponentName)},
7198      * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
7199      * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
7200      *
7201      * @param mainActivity The activity component that is the root of the
7202      * task; this is the activity that has been published in the application's
7203      * manifest as the main launcher icon.
7204      *
7205      * @return Returns a newly created Intent that can be used to relaunch the
7206      * activity's task in its root state.
7207      */
makeRestartActivityTask(ComponentName mainActivity)7208     public static Intent makeRestartActivityTask(ComponentName mainActivity) {
7209         Intent intent = makeMainActivity(mainActivity);
7210         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
7211                 | Intent.FLAG_ACTIVITY_CLEAR_TASK);
7212         return intent;
7213     }
7214 
7215     /**
7216      * Call {@link #parseUri} with 0 flags.
7217      * @deprecated Use {@link #parseUri} instead.
7218      */
7219     @Deprecated
getIntent(String uri)7220     public static Intent getIntent(String uri) throws URISyntaxException {
7221         return parseUri(uri, 0);
7222     }
7223 
7224     /**
7225      * Create an intent from a URI.  This URI may encode the action,
7226      * category, and other intent fields, if it was returned by
7227      * {@link #toUri}.  If the Intent was not generate by toUri(), its data
7228      * will be the entire URI and its action will be ACTION_VIEW.
7229      *
7230      * <p>The URI given here must not be relative -- that is, it must include
7231      * the scheme and full path.
7232      *
7233      * @param uri The URI to turn into an Intent.
7234      * @param flags Additional processing flags.
7235      *
7236      * @return Intent The newly created Intent object.
7237      *
7238      * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
7239      * it bad (as parsed by the Uri class) or the Intent data within the
7240      * URI is invalid.
7241      *
7242      * @see #toUri
7243      */
parseUri(String uri, @UriFlags int flags)7244     public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
7245         Intent intent = parseUriInternal(uri, flags);
7246         intent.mLocalFlags |= LOCAL_FLAG_FROM_URI;
7247         return intent;
7248     }
7249 
7250     /**
7251      * @see #parseUri(String, int)
7252      */
parseUriInternal(String uri, @UriFlags int flags)7253     private static Intent parseUriInternal(String uri, @UriFlags int flags)
7254             throws URISyntaxException {
7255         int i = 0;
7256         try {
7257             final boolean androidApp = uri.startsWith("android-app:");
7258 
7259             // Validate intent scheme if requested.
7260             if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
7261                 if (!uri.startsWith("intent:") && !androidApp) {
7262                     Intent intent = new Intent(ACTION_VIEW);
7263                     try {
7264                         intent.setData(Uri.parse(uri));
7265                     } catch (IllegalArgumentException e) {
7266                         throw new URISyntaxException(uri, e.getMessage());
7267                     }
7268                     return intent;
7269                 }
7270             }
7271 
7272             i = uri.lastIndexOf("#");
7273             // simple case
7274             if (i == -1) {
7275                 if (!androidApp) {
7276                     return new Intent(ACTION_VIEW, Uri.parse(uri));
7277                 }
7278 
7279             // old format Intent URI
7280             } else if (!uri.startsWith("#Intent;", i)) {
7281                 if (!androidApp) {
7282                     return getIntentOld(uri, flags);
7283                 } else {
7284                     i = -1;
7285                 }
7286             }
7287 
7288             // new format
7289             Intent intent = new Intent(ACTION_VIEW);
7290             Intent baseIntent = intent;
7291             boolean explicitAction = false;
7292             boolean inSelector = false;
7293 
7294             // fetch data part, if present
7295             String scheme = null;
7296             String data;
7297             if (i >= 0) {
7298                 data = uri.substring(0, i);
7299                 i += 8; // length of "#Intent;"
7300             } else {
7301                 data = uri;
7302             }
7303 
7304             // loop over contents of Intent, all name=value;
7305             while (i >= 0 && !uri.startsWith("end", i)) {
7306                 int eq = uri.indexOf('=', i);
7307                 if (eq < 0) eq = i-1;
7308                 int semi = uri.indexOf(';', i);
7309                 String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
7310 
7311                 // action
7312                 if (uri.startsWith("action=", i)) {
7313                     intent.setAction(value);
7314                     if (!inSelector) {
7315                         explicitAction = true;
7316                     }
7317                 }
7318 
7319                 // categories
7320                 else if (uri.startsWith("category=", i)) {
7321                     intent.addCategory(value);
7322                 }
7323 
7324                 // type
7325                 else if (uri.startsWith("type=", i)) {
7326                     intent.mType = value;
7327                 }
7328 
7329                 // identifier
7330                 else if (uri.startsWith("identifier=", i)) {
7331                     intent.mIdentifier = value;
7332                 }
7333 
7334                 // launch flags
7335                 else if (uri.startsWith("launchFlags=", i)) {
7336                     intent.mFlags = Integer.decode(value).intValue();
7337                     if ((flags& URI_ALLOW_UNSAFE) == 0) {
7338                         intent.mFlags &= ~IMMUTABLE_FLAGS;
7339                     }
7340                 }
7341 
7342                 // package
7343                 else if (uri.startsWith("package=", i)) {
7344                     intent.mPackage = value;
7345                 }
7346 
7347                 // component
7348                 else if (uri.startsWith("component=", i)) {
7349                     intent.mComponent = ComponentName.unflattenFromString(value);
7350                 }
7351 
7352                 // scheme
7353                 else if (uri.startsWith("scheme=", i)) {
7354                     if (inSelector) {
7355                         intent.mData = Uri.parse(value + ":");
7356                     } else {
7357                         scheme = value;
7358                     }
7359                 }
7360 
7361                 // source bounds
7362                 else if (uri.startsWith("sourceBounds=", i)) {
7363                     intent.mSourceBounds = Rect.unflattenFromString(value);
7364                 }
7365 
7366                 // selector
7367                 else if (semi == (i+3) && uri.startsWith("SEL", i)) {
7368                     intent = new Intent();
7369                     inSelector = true;
7370                 }
7371 
7372                 // extra
7373                 else {
7374                     String key = Uri.decode(uri.substring(i + 2, eq));
7375                     // create Bundle if it doesn't already exist
7376                     if (intent.mExtras == null) intent.mExtras = new Bundle();
7377                     Bundle b = intent.mExtras;
7378                     // add EXTRA
7379                     if      (uri.startsWith("S.", i)) b.putString(key, value);
7380                     else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
7381                     else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
7382                     else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
7383                     else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
7384                     else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
7385                     else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
7386                     else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
7387                     else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
7388                     else throw new URISyntaxException(uri, "unknown EXTRA type", i);
7389                 }
7390 
7391                 // move to the next item
7392                 i = semi + 1;
7393             }
7394 
7395             if (inSelector) {
7396                 // The Intent had a selector; fix it up.
7397                 if (baseIntent.mPackage == null) {
7398                     baseIntent.setSelector(intent);
7399                 }
7400                 intent = baseIntent;
7401             }
7402 
7403             if (data != null) {
7404                 if (data.startsWith("intent:")) {
7405                     data = data.substring(7);
7406                     if (scheme != null) {
7407                         data = scheme + ':' + data;
7408                     }
7409                 } else if (data.startsWith("android-app:")) {
7410                     if (data.charAt(12) == '/' && data.charAt(13) == '/') {
7411                         // Correctly formed android-app, first part is package name.
7412                         int end = data.indexOf('/', 14);
7413                         if (end < 0) {
7414                             // All we have is a package name.
7415                             intent.mPackage = data.substring(14);
7416                             if (!explicitAction) {
7417                                 intent.setAction(ACTION_MAIN);
7418                             }
7419                             data = "";
7420                         } else {
7421                             // Target the Intent at the given package name always.
7422                             String authority = null;
7423                             intent.mPackage = data.substring(14, end);
7424                             int newEnd;
7425                             if ((end+1) < data.length()) {
7426                                 if ((newEnd=data.indexOf('/', end+1)) >= 0) {
7427                                     // Found a scheme, remember it.
7428                                     scheme = data.substring(end+1, newEnd);
7429                                     end = newEnd;
7430                                     if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
7431                                         // Found a authority, remember it.
7432                                         authority = data.substring(end+1, newEnd);
7433                                         end = newEnd;
7434                                     }
7435                                 } else {
7436                                     // All we have is a scheme.
7437                                     scheme = data.substring(end+1);
7438                                 }
7439                             }
7440                             if (scheme == null) {
7441                                 // If there was no scheme, then this just targets the package.
7442                                 if (!explicitAction) {
7443                                     intent.setAction(ACTION_MAIN);
7444                                 }
7445                                 data = "";
7446                             } else if (authority == null) {
7447                                 data = scheme + ":";
7448                             } else {
7449                                 data = scheme + "://" + authority + data.substring(end);
7450                             }
7451                         }
7452                     } else {
7453                         data = "";
7454                     }
7455                 }
7456 
7457                 if (data.length() > 0) {
7458                     try {
7459                         intent.mData = Uri.parse(data);
7460                     } catch (IllegalArgumentException e) {
7461                         throw new URISyntaxException(uri, e.getMessage());
7462                     }
7463                 }
7464             }
7465 
7466             return intent;
7467 
7468         } catch (IndexOutOfBoundsException e) {
7469             throw new URISyntaxException(uri, "illegal Intent URI format", i);
7470         }
7471     }
7472 
7473     public static Intent getIntentOld(String uri) throws URISyntaxException {
7474         Intent intent = getIntentOld(uri, 0);
7475         intent.mLocalFlags |= LOCAL_FLAG_FROM_URI;
7476         return intent;
7477     }
7478 
7479     private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
7480         Intent intent;
7481 
7482         int i = uri.lastIndexOf('#');
7483         if (i >= 0) {
7484             String action = null;
7485             final int intentFragmentStart = i;
7486             boolean isIntentFragment = false;
7487 
7488             i++;
7489 
7490             if (uri.regionMatches(i, "action(", 0, 7)) {
7491                 isIntentFragment = true;
7492                 i += 7;
7493                 int j = uri.indexOf(')', i);
7494                 action = uri.substring(i, j);
7495                 i = j + 1;
7496             }
7497 
7498             intent = new Intent(action);
7499 
7500             if (uri.regionMatches(i, "categories(", 0, 11)) {
7501                 isIntentFragment = true;
7502                 i += 11;
7503                 int j = uri.indexOf(')', i);
7504                 while (i < j) {
7505                     int sep = uri.indexOf('!', i);
7506                     if (sep < 0 || sep > j) sep = j;
7507                     if (i < sep) {
7508                         intent.addCategory(uri.substring(i, sep));
7509                     }
7510                     i = sep + 1;
7511                 }
7512                 i = j + 1;
7513             }
7514 
7515             if (uri.regionMatches(i, "type(", 0, 5)) {
7516                 isIntentFragment = true;
7517                 i += 5;
7518                 int j = uri.indexOf(')', i);
7519                 intent.mType = uri.substring(i, j);
7520                 i = j + 1;
7521             }
7522 
7523             if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
7524                 isIntentFragment = true;
7525                 i += 12;
7526                 int j = uri.indexOf(')', i);
7527                 intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
7528                 if ((flags& URI_ALLOW_UNSAFE) == 0) {
7529                     intent.mFlags &= ~IMMUTABLE_FLAGS;
7530                 }
7531                 i = j + 1;
7532             }
7533 
7534             if (uri.regionMatches(i, "component(", 0, 10)) {
7535                 isIntentFragment = true;
7536                 i += 10;
7537                 int j = uri.indexOf(')', i);
7538                 int sep = uri.indexOf('!', i);
7539                 if (sep >= 0 && sep < j) {
7540                     String pkg = uri.substring(i, sep);
7541                     String cls = uri.substring(sep + 1, j);
7542                     intent.mComponent = new ComponentName(pkg, cls);
7543                 }
7544                 i = j + 1;
7545             }
7546 
7547             if (uri.regionMatches(i, "extras(", 0, 7)) {
7548                 isIntentFragment = true;
7549                 i += 7;
7550 
7551                 final int closeParen = uri.indexOf(')', i);
7552                 if (closeParen == -1) throw new URISyntaxException(uri,
7553                         "EXTRA missing trailing ')'", i);
7554 
7555                 while (i < closeParen) {
7556                     // fetch the key value
7557                     int j = uri.indexOf('=', i);
7558                     if (j <= i + 1 || i >= closeParen) {
7559                         throw new URISyntaxException(uri, "EXTRA missing '='", i);
7560                     }
7561                     char type = uri.charAt(i);
7562                     i++;
7563                     String key = uri.substring(i, j);
7564                     i = j + 1;
7565 
7566                     // get type-value
7567                     j = uri.indexOf('!', i);
7568                     if (j == -1 || j >= closeParen) j = closeParen;
7569                     if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
7570                     String value = uri.substring(i, j);
7571                     i = j;
7572 
7573                     // create Bundle if it doesn't already exist
7574                     if (intent.mExtras == null) intent.mExtras = new Bundle();
7575 
7576                     // add item to bundle
7577                     try {
7578                         switch (type) {
7579                             case 'S':
7580                                 intent.mExtras.putString(key, Uri.decode(value));
7581                                 break;
7582                             case 'B':
7583                                 intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
7584                                 break;
7585                             case 'b':
7586                                 intent.mExtras.putByte(key, Byte.parseByte(value));
7587                                 break;
7588                             case 'c':
7589                                 intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
7590                                 break;
7591                             case 'd':
7592                                 intent.mExtras.putDouble(key, Double.parseDouble(value));
7593                                 break;
7594                             case 'f':
7595                                 intent.mExtras.putFloat(key, Float.parseFloat(value));
7596                                 break;
7597                             case 'i':
7598                                 intent.mExtras.putInt(key, Integer.parseInt(value));
7599                                 break;
7600                             case 'l':
7601                                 intent.mExtras.putLong(key, Long.parseLong(value));
7602                                 break;
7603                             case 's':
7604                                 intent.mExtras.putShort(key, Short.parseShort(value));
7605                                 break;
7606                             default:
7607                                 throw new URISyntaxException(uri, "EXTRA has unknown type", i);
7608                         }
7609                     } catch (NumberFormatException e) {
7610                         throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
7611                     }
7612 
7613                     char ch = uri.charAt(i);
7614                     if (ch == ')') break;
7615                     if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
7616                     i++;
7617                 }
7618             }
7619 
7620             if (isIntentFragment) {
7621                 intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
7622             } else {
7623                 intent.mData = Uri.parse(uri);
7624             }
7625 
7626             if (intent.mAction == null) {
7627                 // By default, if no action is specified, then use VIEW.
7628                 intent.mAction = ACTION_VIEW;
7629             }
7630 
7631         } else {
7632             intent = new Intent(ACTION_VIEW, Uri.parse(uri));
7633         }
7634 
7635         return intent;
7636     }
7637 
7638     /** @hide */
7639     public interface CommandOptionHandler {
7640         boolean handleOption(String opt, ShellCommand cmd);
7641     }
7642 
7643     /** @hide */
7644     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
7645     @SuppressWarnings("AndroidFrameworkEfficientCollections")
parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)7646     public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
7647             throws URISyntaxException {
7648         Intent intent = new Intent();
7649         Intent baseIntent = intent;
7650         boolean hasIntentInfo = false;
7651 
7652         Uri data = null;
7653         String type = null;
7654 
7655         String opt;
7656         while ((opt=cmd.getNextOption()) != null) {
7657             switch (opt) {
7658                 case "-a":
7659                     intent.setAction(cmd.getNextArgRequired());
7660                     if (intent == baseIntent) {
7661                         hasIntentInfo = true;
7662                     }
7663                     break;
7664                 case "-d":
7665                     data = Uri.parse(cmd.getNextArgRequired());
7666                     if (intent == baseIntent) {
7667                         hasIntentInfo = true;
7668                     }
7669                     break;
7670                 case "-t":
7671                     type = cmd.getNextArgRequired();
7672                     if (intent == baseIntent) {
7673                         hasIntentInfo = true;
7674                     }
7675                     break;
7676                 case "-i":
7677                     intent.setIdentifier(cmd.getNextArgRequired());
7678                     if (intent == baseIntent) {
7679                         hasIntentInfo = true;
7680                     }
7681                     break;
7682                 case "-c":
7683                     intent.addCategory(cmd.getNextArgRequired());
7684                     if (intent == baseIntent) {
7685                         hasIntentInfo = true;
7686                     }
7687                     break;
7688                 case "-e":
7689                 case "--es": {
7690                     String key = cmd.getNextArgRequired();
7691                     String value = cmd.getNextArgRequired();
7692                     intent.putExtra(key, value);
7693                 }
7694                 break;
7695                 case "--esn": {
7696                     String key = cmd.getNextArgRequired();
7697                     intent.putExtra(key, (String) null);
7698                 }
7699                 break;
7700                 case "--ei": {
7701                     String key = cmd.getNextArgRequired();
7702                     String value = cmd.getNextArgRequired();
7703                     intent.putExtra(key, Integer.decode(value));
7704                 }
7705                 break;
7706                 case "--eu": {
7707                     String key = cmd.getNextArgRequired();
7708                     String value = cmd.getNextArgRequired();
7709                     intent.putExtra(key, Uri.parse(value));
7710                 }
7711                 break;
7712                 case "--ecn": {
7713                     String key = cmd.getNextArgRequired();
7714                     String value = cmd.getNextArgRequired();
7715                     ComponentName cn = ComponentName.unflattenFromString(value);
7716                     if (cn == null)
7717                         throw new IllegalArgumentException("Bad component name: " + value);
7718                     intent.putExtra(key, cn);
7719                 }
7720                 break;
7721                 case "--eia": {
7722                     String key = cmd.getNextArgRequired();
7723                     String value = cmd.getNextArgRequired();
7724                     String[] strings = value.split(",");
7725                     int[] list = new int[strings.length];
7726                     for (int i = 0; i < strings.length; i++) {
7727                         list[i] = Integer.decode(strings[i]);
7728                     }
7729                     intent.putExtra(key, list);
7730                 }
7731                 break;
7732                 case "--eial": {
7733                     String key = cmd.getNextArgRequired();
7734                     String value = cmd.getNextArgRequired();
7735                     String[] strings = value.split(",");
7736                     ArrayList<Integer> list = new ArrayList<>(strings.length);
7737                     for (int i = 0; i < strings.length; i++) {
7738                         list.add(Integer.decode(strings[i]));
7739                     }
7740                     intent.putExtra(key, list);
7741                 }
7742                 break;
7743                 case "--el": {
7744                     String key = cmd.getNextArgRequired();
7745                     String value = cmd.getNextArgRequired();
7746                     intent.putExtra(key, Long.valueOf(value));
7747                 }
7748                 break;
7749                 case "--ela": {
7750                     String key = cmd.getNextArgRequired();
7751                     String value = cmd.getNextArgRequired();
7752                     String[] strings = value.split(",");
7753                     long[] list = new long[strings.length];
7754                     for (int i = 0; i < strings.length; i++) {
7755                         list[i] = Long.valueOf(strings[i]);
7756                     }
7757                     intent.putExtra(key, list);
7758                     hasIntentInfo = true;
7759                 }
7760                 break;
7761                 case "--elal": {
7762                     String key = cmd.getNextArgRequired();
7763                     String value = cmd.getNextArgRequired();
7764                     String[] strings = value.split(",");
7765                     ArrayList<Long> list = new ArrayList<>(strings.length);
7766                     for (int i = 0; i < strings.length; i++) {
7767                         list.add(Long.valueOf(strings[i]));
7768                     }
7769                     intent.putExtra(key, list);
7770                     hasIntentInfo = true;
7771                 }
7772                 break;
7773                 case "--ef": {
7774                     String key = cmd.getNextArgRequired();
7775                     String value = cmd.getNextArgRequired();
7776                     intent.putExtra(key, Float.valueOf(value));
7777                     hasIntentInfo = true;
7778                 }
7779                 break;
7780                 case "--efa": {
7781                     String key = cmd.getNextArgRequired();
7782                     String value = cmd.getNextArgRequired();
7783                     String[] strings = value.split(",");
7784                     float[] list = new float[strings.length];
7785                     for (int i = 0; i < strings.length; i++) {
7786                         list[i] = Float.valueOf(strings[i]);
7787                     }
7788                     intent.putExtra(key, list);
7789                     hasIntentInfo = true;
7790                 }
7791                 break;
7792                 case "--efal": {
7793                     String key = cmd.getNextArgRequired();
7794                     String value = cmd.getNextArgRequired();
7795                     String[] strings = value.split(",");
7796                     ArrayList<Float> list = new ArrayList<>(strings.length);
7797                     for (int i = 0; i < strings.length; i++) {
7798                         list.add(Float.valueOf(strings[i]));
7799                     }
7800                     intent.putExtra(key, list);
7801                     hasIntentInfo = true;
7802                 }
7803                 break;
7804                 case "--esa": {
7805                     String key = cmd.getNextArgRequired();
7806                     String value = cmd.getNextArgRequired();
7807                     // Split on commas unless they are preceeded by an escape.
7808                     // The escape character must be escaped for the string and
7809                     // again for the regex, thus four escape characters become one.
7810                     String[] strings = value.split("(?<!\\\\),");
7811                     intent.putExtra(key, strings);
7812                     hasIntentInfo = true;
7813                 }
7814                 break;
7815                 case "--esal": {
7816                     String key = cmd.getNextArgRequired();
7817                     String value = cmd.getNextArgRequired();
7818                     // Split on commas unless they are preceeded by an escape.
7819                     // The escape character must be escaped for the string and
7820                     // again for the regex, thus four escape characters become one.
7821                     String[] strings = value.split("(?<!\\\\),");
7822                     ArrayList<String> list = new ArrayList<>(strings.length);
7823                     for (int i = 0; i < strings.length; i++) {
7824                         list.add(strings[i]);
7825                     }
7826                     intent.putExtra(key, list);
7827                     hasIntentInfo = true;
7828                 }
7829                 break;
7830                 case "--ez": {
7831                     String key = cmd.getNextArgRequired();
7832                     String value = cmd.getNextArgRequired().toLowerCase();
7833                     // Boolean.valueOf() results in false for anything that is not "true", which is
7834                     // error-prone in shell commands
7835                     boolean arg;
7836                     if ("true".equals(value) || "t".equals(value)) {
7837                         arg = true;
7838                     } else if ("false".equals(value) || "f".equals(value)) {
7839                         arg = false;
7840                     } else {
7841                         try {
7842                             arg = Integer.decode(value) != 0;
7843                         } catch (NumberFormatException ex) {
7844                             throw new IllegalArgumentException("Invalid boolean value: " + value);
7845                         }
7846                     }
7847 
7848                     intent.putExtra(key, arg);
7849                 }
7850                 break;
7851                 case "-n": {
7852                     String str = cmd.getNextArgRequired();
7853                     ComponentName cn = ComponentName.unflattenFromString(str);
7854                     if (cn == null)
7855                         throw new IllegalArgumentException("Bad component name: " + str);
7856                     intent.setComponent(cn);
7857                     if (intent == baseIntent) {
7858                         hasIntentInfo = true;
7859                     }
7860                 }
7861                 break;
7862                 case "-p": {
7863                     String str = cmd.getNextArgRequired();
7864                     intent.setPackage(str);
7865                     if (intent == baseIntent) {
7866                         hasIntentInfo = true;
7867                     }
7868                 }
7869                 break;
7870                 case "-f":
7871                     String str = cmd.getNextArgRequired();
7872                     intent.setFlags(Integer.decode(str).intValue());
7873                     break;
7874                 case "--grant-read-uri-permission":
7875                     intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
7876                     break;
7877                 case "--grant-write-uri-permission":
7878                     intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
7879                     break;
7880                 case "--grant-persistable-uri-permission":
7881                     intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
7882                     break;
7883                 case "--grant-prefix-uri-permission":
7884                     intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
7885                     break;
7886                 case "--exclude-stopped-packages":
7887                     intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
7888                     break;
7889                 case "--include-stopped-packages":
7890                     intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
7891                     break;
7892                 case "--debug-log-resolution":
7893                     intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
7894                     break;
7895                 case "--activity-brought-to-front":
7896                     intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
7897                     break;
7898                 case "--activity-clear-top":
7899                     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
7900                     break;
7901                 case "--activity-clear-when-task-reset":
7902                     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
7903                     break;
7904                 case "--activity-exclude-from-recents":
7905                     intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
7906                     break;
7907                 case "--activity-launched-from-history":
7908                     intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
7909                     break;
7910                 case "--activity-multiple-task":
7911                     intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
7912                     break;
7913                 case "--activity-no-animation":
7914                     intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
7915                     break;
7916                 case "--activity-no-history":
7917                     intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
7918                     break;
7919                 case "--activity-no-user-action":
7920                     intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
7921                     break;
7922                 case "--activity-previous-is-top":
7923                     intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
7924                     break;
7925                 case "--activity-reorder-to-front":
7926                     intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
7927                     break;
7928                 case "--activity-reset-task-if-needed":
7929                     intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
7930                     break;
7931                 case "--activity-single-top":
7932                     intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
7933                     break;
7934                 case "--activity-clear-task":
7935                     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
7936                     break;
7937                 case "--activity-task-on-home":
7938                     intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
7939                     break;
7940                 case "--activity-match-external":
7941                     intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
7942                     break;
7943                 case "--receiver-registered-only":
7944                     intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
7945                     break;
7946                 case "--receiver-replace-pending":
7947                     intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
7948                     break;
7949                 case "--receiver-foreground":
7950                     intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
7951                     break;
7952                 case "--receiver-no-abort":
7953                     intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
7954                     break;
7955                 case "--receiver-include-background":
7956                     intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
7957                     break;
7958                 case "--selector":
7959                     intent.setDataAndType(data, type);
7960                     intent = new Intent();
7961                     break;
7962                 default:
7963                     if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
7964                         // Okay, caller handled this option.
7965                     } else {
7966                         throw new IllegalArgumentException("Unknown option: " + opt);
7967                     }
7968                     break;
7969             }
7970         }
7971         intent.setDataAndType(data, type);
7972 
7973         final boolean hasSelector = intent != baseIntent;
7974         if (hasSelector) {
7975             // A selector was specified; fix up.
7976             baseIntent.setSelector(intent);
7977             intent = baseIntent;
7978         }
7979 
7980         String arg = cmd.getNextArg();
7981         baseIntent = null;
7982         if (arg == null) {
7983             if (hasSelector) {
7984                 // If a selector has been specified, and no arguments
7985                 // have been supplied for the main Intent, then we can
7986                 // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
7987                 // need to have a component name specified yet, the
7988                 // selector will take care of that.
7989                 baseIntent = new Intent(Intent.ACTION_MAIN);
7990                 baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7991             }
7992         } else if (arg.indexOf(':') >= 0) {
7993             // The argument is a URI.  Fully parse it, and use that result
7994             // to fill in any data not specified so far.
7995             baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
7996                     | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
7997         } else if (arg.indexOf('/') >= 0) {
7998             // The argument is a component name.  Build an Intent to launch
7999             // it.
8000             baseIntent = new Intent(Intent.ACTION_MAIN);
8001             baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
8002             baseIntent.setComponent(ComponentName.unflattenFromString(arg));
8003         } else {
8004             // Assume the argument is a package name.
8005             baseIntent = new Intent(Intent.ACTION_MAIN);
8006             baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
8007             baseIntent.setPackage(arg);
8008         }
8009         if (baseIntent != null) {
8010             Bundle extras = intent.getExtras();
8011             intent.replaceExtras((Bundle)null);
8012             Bundle uriExtras = baseIntent.getExtras();
8013             baseIntent.replaceExtras((Bundle)null);
8014             if (intent.getAction() != null && baseIntent.getCategories() != null) {
8015                 HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
8016                 for (String c : cats) {
8017                     baseIntent.removeCategory(c);
8018                 }
8019             }
8020             intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
8021             if (extras == null) {
8022                 extras = uriExtras;
8023             } else if (uriExtras != null) {
8024                 uriExtras.putAll(extras);
8025                 extras = uriExtras;
8026             }
8027             intent.replaceExtras(extras);
8028             hasIntentInfo = true;
8029         }
8030 
8031         if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
8032         return intent;
8033     }
8034 
8035     /** @hide */
8036     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
printIntentArgsHelp(PrintWriter pw, String prefix)8037     public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
8038         final String[] lines = new String[] {
8039                 "<INTENT> specifications include these flags and arguments:",
8040                 "    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]",
8041                 "    [-c <CATEGORY> [-c <CATEGORY>] ...]",
8042                 "    [-n <COMPONENT_NAME>]",
8043                 "    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
8044                 "    [--esn <EXTRA_KEY> ...]",
8045                 "    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
8046                 "    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
8047                 "    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
8048                 "    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
8049                 "    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
8050                 "    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
8051                 "    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
8052                 "        (mutiple extras passed as Integer[])",
8053                 "    [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
8054                 "        (mutiple extras passed as List<Integer>)",
8055                 "    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
8056                 "        (mutiple extras passed as Long[])",
8057                 "    [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
8058                 "        (mutiple extras passed as List<Long>)",
8059                 "    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
8060                 "        (mutiple extras passed as Float[])",
8061                 "    [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
8062                 "        (mutiple extras passed as List<Float>)",
8063                 "    [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
8064                 "        (mutiple extras passed as String[]; to embed a comma into a string,",
8065                 "         escape it using \"\\,\")",
8066                 "    [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
8067                 "        (mutiple extras passed as List<String>; to embed a comma into a string,",
8068                 "         escape it using \"\\,\")",
8069                 "    [-f <FLAG>]",
8070                 "    [--grant-read-uri-permission] [--grant-write-uri-permission]",
8071                 "    [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
8072                 "    [--debug-log-resolution] [--exclude-stopped-packages]",
8073                 "    [--include-stopped-packages]",
8074                 "    [--activity-brought-to-front] [--activity-clear-top]",
8075                 "    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
8076                 "    [--activity-launched-from-history] [--activity-multiple-task]",
8077                 "    [--activity-no-animation] [--activity-no-history]",
8078                 "    [--activity-no-user-action] [--activity-previous-is-top]",
8079                 "    [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
8080                 "    [--activity-single-top] [--activity-clear-task]",
8081                 "    [--activity-task-on-home] [--activity-match-external]",
8082                 "    [--receiver-registered-only] [--receiver-replace-pending]",
8083                 "    [--receiver-foreground] [--receiver-no-abort]",
8084                 "    [--receiver-include-background]",
8085                 "    [--selector]",
8086                 "    [<URI> | <PACKAGE> | <COMPONENT>]"
8087         };
8088         for (String line : lines) {
8089             pw.print(prefix);
8090             pw.println(line);
8091         }
8092     }
8093 
8094     /**
8095      * Retrieve the general action to be performed, such as
8096      * {@link #ACTION_VIEW}.  The action describes the general way the rest of
8097      * the information in the intent should be interpreted -- most importantly,
8098      * what to do with the data returned by {@link #getData}.
8099      *
8100      * @return The action of this intent or null if none is specified.
8101      *
8102      * @see #setAction
8103      */
getAction()8104     public @Nullable String getAction() {
8105         return mAction;
8106     }
8107 
8108     /**
8109      * Retrieve data this intent is operating on.  This URI specifies the name
8110      * of the data; often it uses the content: scheme, specifying data in a
8111      * content provider.  Other schemes may be handled by specific activities,
8112      * such as http: by the web browser.
8113      *
8114      * @return The URI of the data this intent is targeting or null.
8115      *
8116      * @see #getScheme
8117      * @see #setData
8118      */
getData()8119     public @Nullable Uri getData() {
8120         return mData;
8121     }
8122 
8123     /**
8124      * The same as {@link #getData()}, but returns the URI as an encoded
8125      * String.
8126      */
getDataString()8127     public @Nullable String getDataString() {
8128         return mData != null ? mData.toString() : null;
8129     }
8130 
8131     /**
8132      * Return the scheme portion of the intent's data.  If the data is null or
8133      * does not include a scheme, null is returned.  Otherwise, the scheme
8134      * prefix without the final ':' is returned, i.e. "http".
8135      *
8136      * <p>This is the same as calling getData().getScheme() (and checking for
8137      * null data).
8138      *
8139      * @return The scheme of this intent.
8140      *
8141      * @see #getData
8142      */
getScheme()8143     public @Nullable String getScheme() {
8144         return mData != null ? mData.getScheme() : null;
8145     }
8146 
8147     /**
8148      * Retrieve any explicit MIME type included in the intent.  This is usually
8149      * null, as the type is determined by the intent data.
8150      *
8151      * @return If a type was manually set, it is returned; else null is
8152      *         returned.
8153      *
8154      * @see #resolveType(ContentResolver)
8155      * @see #setType
8156      */
getType()8157     public @Nullable String getType() {
8158         return mType;
8159     }
8160 
8161     /**
8162      * Return the MIME data type of this intent.  If the type field is
8163      * explicitly set, that is simply returned.  Otherwise, if the data is set,
8164      * the type of that data is returned.  If neither fields are set, a null is
8165      * returned.
8166      *
8167      * @return The MIME type of this intent.
8168      *
8169      * @see #getType
8170      * @see #resolveType(ContentResolver)
8171      */
resolveType(@onNull Context context)8172     public @Nullable String resolveType(@NonNull Context context) {
8173         return resolveType(context.getContentResolver());
8174     }
8175 
8176     /**
8177      * Return the MIME data type of this intent.  If the type field is
8178      * explicitly set, that is simply returned.  Otherwise, if the data is set,
8179      * the type of that data is returned.  If neither fields are set, a null is
8180      * returned.
8181      *
8182      * @param resolver A ContentResolver that can be used to determine the MIME
8183      *                 type of the intent's data.
8184      *
8185      * @return The MIME type of this intent.
8186      *
8187      * @see #getType
8188      * @see #resolveType(Context)
8189      */
resolveType(@onNull ContentResolver resolver)8190     public @Nullable String resolveType(@NonNull ContentResolver resolver) {
8191         if (mType != null) {
8192             return mType;
8193         }
8194         if (mData != null) {
8195             if ("content".equals(mData.getScheme())) {
8196                 return resolver.getType(mData);
8197             }
8198         }
8199         return null;
8200     }
8201 
8202     /**
8203      * Return the MIME data type of this intent, only if it will be needed for
8204      * intent resolution.  This is not generally useful for application code;
8205      * it is used by the frameworks for communicating with back-end system
8206      * services.
8207      *
8208      * @param resolver A ContentResolver that can be used to determine the MIME
8209      *                 type of the intent's data.
8210      *
8211      * @return The MIME type of this intent, or null if it is unknown or not
8212      *         needed.
8213      */
resolveTypeIfNeeded(@onNull ContentResolver resolver)8214     public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
8215         if (mComponent != null) {
8216             return mType;
8217         }
8218         return resolveType(resolver);
8219     }
8220 
8221     /**
8222      * Retrieve the identifier for this Intent.  If non-null, this is an arbitrary identity
8223      * of the Intent to distinguish it from other Intents.
8224      *
8225      * @return The identifier of this intent or null if none is specified.
8226      *
8227      * @see #setIdentifier
8228      */
getIdentifier()8229     public @Nullable String getIdentifier() {
8230         return mIdentifier;
8231     }
8232 
8233     /**
8234      * Check if a category exists in the intent.
8235      *
8236      * @param category The category to check.
8237      *
8238      * @return boolean True if the intent contains the category, else false.
8239      *
8240      * @see #getCategories
8241      * @see #addCategory
8242      */
hasCategory(String category)8243     public boolean hasCategory(String category) {
8244         return mCategories != null && mCategories.contains(category);
8245     }
8246 
8247     /**
8248      * Return the set of all categories in the intent.  If there are no categories,
8249      * returns NULL.
8250      *
8251      * @return The set of categories you can examine.  Do not modify!
8252      *
8253      * @see #hasCategory
8254      * @see #addCategory
8255      */
getCategories()8256     public Set<String> getCategories() {
8257         return mCategories;
8258     }
8259 
8260     /**
8261      * Return the specific selector associated with this Intent.  If there is
8262      * none, returns null.  See {@link #setSelector} for more information.
8263      *
8264      * @see #setSelector
8265      */
getSelector()8266     public @Nullable Intent getSelector() {
8267         return mSelector;
8268     }
8269 
8270     /**
8271      * Return the {@link ClipData} associated with this Intent.  If there is
8272      * none, returns null.  See {@link #setClipData} for more information.
8273      *
8274      * @see #setClipData
8275      */
getClipData()8276     public @Nullable ClipData getClipData() {
8277         return mClipData;
8278     }
8279 
8280     /** @hide */
getContentUserHint()8281     public int getContentUserHint() {
8282         return mContentUserHint;
8283     }
8284 
8285     /** @hide */
getLaunchToken()8286     public String getLaunchToken() {
8287         return mLaunchToken;
8288     }
8289 
8290     /** @hide */
setLaunchToken(String launchToken)8291     public void setLaunchToken(String launchToken) {
8292         mLaunchToken = launchToken;
8293     }
8294 
8295     /**
8296      * Sets the ClassLoader that will be used when unmarshalling
8297      * any Parcelable values from the extras of this Intent.
8298      *
8299      * @param loader a ClassLoader, or null to use the default loader
8300      * at the time of unmarshalling.
8301      */
setExtrasClassLoader(@ullable ClassLoader loader)8302     public void setExtrasClassLoader(@Nullable ClassLoader loader) {
8303         if (mExtras != null) {
8304             mExtras.setClassLoader(loader);
8305         }
8306     }
8307 
8308     /**
8309      * Returns true if an extra value is associated with the given name.
8310      * @param name the extra's name
8311      * @return true if the given extra is present.
8312      */
hasExtra(String name)8313     public boolean hasExtra(String name) {
8314         return mExtras != null && mExtras.containsKey(name);
8315     }
8316 
8317     /**
8318      * Returns true if the Intent's extras contain a parcelled file descriptor.
8319      * @return true if the Intent contains a parcelled file descriptor.
8320      */
hasFileDescriptors()8321     public boolean hasFileDescriptors() {
8322         return mExtras != null && mExtras.hasFileDescriptors();
8323     }
8324 
8325     /** {@hide} */
8326     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
setAllowFds(boolean allowFds)8327     public void setAllowFds(boolean allowFds) {
8328         if (mExtras != null) {
8329             mExtras.setAllowFds(allowFds);
8330         }
8331     }
8332 
8333     /** {@hide} */
setDefusable(boolean defusable)8334     public void setDefusable(boolean defusable) {
8335         if (mExtras != null) {
8336             mExtras.setDefusable(defusable);
8337         }
8338     }
8339 
8340     /**
8341      * Retrieve extended data from the intent.
8342      *
8343      * @param name The name of the desired item.
8344      *
8345      * @return the value of an item previously added with putExtra(),
8346      * or null if none was found.
8347      *
8348      * @deprecated
8349      * @hide
8350      */
8351     @Deprecated
8352     @UnsupportedAppUsage
getExtra(String name)8353     public Object getExtra(String name) {
8354         return getExtra(name, null);
8355     }
8356 
8357     /**
8358      * Retrieve extended data from the intent.
8359      *
8360      * @param name The name of the desired item.
8361      * @param defaultValue the value to be returned if no value of the desired
8362      * type is stored with the given name.
8363      *
8364      * @return the value of an item previously added with putExtra(),
8365      * or the default value if none was found.
8366      *
8367      * @see #putExtra(String, boolean)
8368      */
getBooleanExtra(String name, boolean defaultValue)8369     public boolean getBooleanExtra(String name, boolean defaultValue) {
8370         return mExtras == null ? defaultValue :
8371             mExtras.getBoolean(name, defaultValue);
8372     }
8373 
8374     /**
8375      * Retrieve extended data from the intent.
8376      *
8377      * @param name The name of the desired item.
8378      * @param defaultValue the value to be returned if no value of the desired
8379      * type is stored with the given name.
8380      *
8381      * @return the value of an item previously added with putExtra(),
8382      * or the default value if none was found.
8383      *
8384      * @see #putExtra(String, byte)
8385      */
getByteExtra(String name, byte defaultValue)8386     public byte getByteExtra(String name, byte defaultValue) {
8387         return mExtras == null ? defaultValue :
8388             mExtras.getByte(name, defaultValue);
8389     }
8390 
8391     /**
8392      * Retrieve extended data from the intent.
8393      *
8394      * @param name The name of the desired item.
8395      * @param defaultValue the value to be returned if no value of the desired
8396      * type is stored with the given name.
8397      *
8398      * @return the value of an item previously added with putExtra(),
8399      * or the default value if none was found.
8400      *
8401      * @see #putExtra(String, short)
8402      */
getShortExtra(String name, short defaultValue)8403     public short getShortExtra(String name, short defaultValue) {
8404         return mExtras == null ? defaultValue :
8405             mExtras.getShort(name, defaultValue);
8406     }
8407 
8408     /**
8409      * Retrieve extended data from the intent.
8410      *
8411      * @param name The name of the desired item.
8412      * @param defaultValue the value to be returned if no value of the desired
8413      * type is stored with the given name.
8414      *
8415      * @return the value of an item previously added with putExtra(),
8416      * or the default value if none was found.
8417      *
8418      * @see #putExtra(String, char)
8419      */
getCharExtra(String name, char defaultValue)8420     public char getCharExtra(String name, char defaultValue) {
8421         return mExtras == null ? defaultValue :
8422             mExtras.getChar(name, defaultValue);
8423     }
8424 
8425     /**
8426      * Retrieve extended data from the intent.
8427      *
8428      * @param name The name of the desired item.
8429      * @param defaultValue the value to be returned if no value of the desired
8430      * type is stored with the given name.
8431      *
8432      * @return the value of an item previously added with putExtra(),
8433      * or the default value if none was found.
8434      *
8435      * @see #putExtra(String, int)
8436      */
getIntExtra(String name, int defaultValue)8437     public int getIntExtra(String name, int defaultValue) {
8438         return mExtras == null ? defaultValue :
8439             mExtras.getInt(name, defaultValue);
8440     }
8441 
8442     /**
8443      * Retrieve extended data from the intent.
8444      *
8445      * @param name The name of the desired item.
8446      * @param defaultValue the value to be returned if no value of the desired
8447      * type is stored with the given name.
8448      *
8449      * @return the value of an item previously added with putExtra(),
8450      * or the default value if none was found.
8451      *
8452      * @see #putExtra(String, long)
8453      */
getLongExtra(String name, long defaultValue)8454     public long getLongExtra(String name, long defaultValue) {
8455         return mExtras == null ? defaultValue :
8456             mExtras.getLong(name, defaultValue);
8457     }
8458 
8459     /**
8460      * Retrieve extended data from the intent.
8461      *
8462      * @param name The name of the desired item.
8463      * @param defaultValue the value to be returned if no value of the desired
8464      * type is stored with the given name.
8465      *
8466      * @return the value of an item previously added with putExtra(),
8467      * or the default value if no such item is present
8468      *
8469      * @see #putExtra(String, float)
8470      */
getFloatExtra(String name, float defaultValue)8471     public float getFloatExtra(String name, float defaultValue) {
8472         return mExtras == null ? defaultValue :
8473             mExtras.getFloat(name, defaultValue);
8474     }
8475 
8476     /**
8477      * Retrieve extended data from the intent.
8478      *
8479      * @param name The name of the desired item.
8480      * @param defaultValue the value to be returned if no value of the desired
8481      * type is stored with the given name.
8482      *
8483      * @return the value of an item previously added with putExtra(),
8484      * or the default value if none was found.
8485      *
8486      * @see #putExtra(String, double)
8487      */
getDoubleExtra(String name, double defaultValue)8488     public double getDoubleExtra(String name, double defaultValue) {
8489         return mExtras == null ? defaultValue :
8490             mExtras.getDouble(name, defaultValue);
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 String value was found.
8500      *
8501      * @see #putExtra(String, String)
8502      */
getStringExtra(String name)8503     public @Nullable String getStringExtra(String name) {
8504         return mExtras == null ? null : mExtras.getString(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 CharSequence value was found.
8514      *
8515      * @see #putExtra(String, CharSequence)
8516      */
getCharSequenceExtra(String name)8517     public @Nullable CharSequence getCharSequenceExtra(String name) {
8518         return mExtras == null ? null : mExtras.getCharSequence(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 Parcelable value was found.
8528      *
8529      * @see #putExtra(String, Parcelable)
8530      */
getParcelableExtra(String name)8531     public @Nullable <T extends Parcelable> T getParcelableExtra(String name) {
8532         return mExtras == null ? null : mExtras.<T>getParcelable(name);
8533     }
8534 
8535     /**
8536      * Retrieve extended data from the intent.
8537      *
8538      * @param name The name of the desired item.
8539      *
8540      * @return the value of an item previously added with putExtra(),
8541      * or null if no Parcelable[] value was found.
8542      *
8543      * @see #putExtra(String, Parcelable[])
8544      */
getParcelableArrayExtra(String name)8545     public @Nullable Parcelable[] getParcelableArrayExtra(String name) {
8546         return mExtras == null ? null : mExtras.getParcelableArray(name);
8547     }
8548 
8549     /**
8550      * Retrieve extended data from the intent.
8551      *
8552      * @param name The name of the desired item.
8553      *
8554      * @return the value of an item previously added with
8555      * putParcelableArrayListExtra(), or null if no
8556      * ArrayList<Parcelable> value was found.
8557      *
8558      * @see #putParcelableArrayListExtra(String, ArrayList)
8559      */
getParcelableArrayListExtra(String name)8560     public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
8561         return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
8562     }
8563 
8564     /**
8565      * Retrieve extended data from the intent.
8566      *
8567      * @param name The name of the desired item.
8568      *
8569      * @return the value of an item previously added with putExtra(),
8570      * or null if no Serializable value was found.
8571      *
8572      * @see #putExtra(String, Serializable)
8573      */
getSerializableExtra(String name)8574     public @Nullable Serializable getSerializableExtra(String name) {
8575         return mExtras == null ? null : mExtras.getSerializable(name);
8576     }
8577 
8578     /**
8579      * Retrieve extended data from the intent.
8580      *
8581      * @param name The name of the desired item.
8582      *
8583      * @return the value of an item previously added with
8584      * putIntegerArrayListExtra(), or null if no
8585      * ArrayList<Integer> value was found.
8586      *
8587      * @see #putIntegerArrayListExtra(String, ArrayList)
8588      */
getIntegerArrayListExtra(String name)8589     public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) {
8590         return mExtras == null ? null : mExtras.getIntegerArrayList(name);
8591     }
8592 
8593     /**
8594      * Retrieve extended data from the intent.
8595      *
8596      * @param name The name of the desired item.
8597      *
8598      * @return the value of an item previously added with
8599      * putStringArrayListExtra(), or null if no
8600      * ArrayList<String> value was found.
8601      *
8602      * @see #putStringArrayListExtra(String, ArrayList)
8603      */
getStringArrayListExtra(String name)8604     public @Nullable ArrayList<String> getStringArrayListExtra(String name) {
8605         return mExtras == null ? null : mExtras.getStringArrayList(name);
8606     }
8607 
8608     /**
8609      * Retrieve extended data from the intent.
8610      *
8611      * @param name The name of the desired item.
8612      *
8613      * @return the value of an item previously added with
8614      * putCharSequenceArrayListExtra, or null if no
8615      * ArrayList<CharSequence> value was found.
8616      *
8617      * @see #putCharSequenceArrayListExtra(String, ArrayList)
8618      */
getCharSequenceArrayListExtra(String name)8619     public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
8620         return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
8621     }
8622 
8623     /**
8624      * Retrieve extended data from the intent.
8625      *
8626      * @param name The name of the desired item.
8627      *
8628      * @return the value of an item previously added with putExtra(),
8629      * or null if no boolean array value was found.
8630      *
8631      * @see #putExtra(String, boolean[])
8632      */
getBooleanArrayExtra(String name)8633     public @Nullable boolean[] getBooleanArrayExtra(String name) {
8634         return mExtras == null ? null : mExtras.getBooleanArray(name);
8635     }
8636 
8637     /**
8638      * Retrieve extended data from the intent.
8639      *
8640      * @param name The name of the desired item.
8641      *
8642      * @return the value of an item previously added with putExtra(),
8643      * or null if no byte array value was found.
8644      *
8645      * @see #putExtra(String, byte[])
8646      */
getByteArrayExtra(String name)8647     public @Nullable byte[] getByteArrayExtra(String name) {
8648         return mExtras == null ? null : mExtras.getByteArray(name);
8649     }
8650 
8651     /**
8652      * Retrieve extended data from the intent.
8653      *
8654      * @param name The name of the desired item.
8655      *
8656      * @return the value of an item previously added with putExtra(),
8657      * or null if no short array value was found.
8658      *
8659      * @see #putExtra(String, short[])
8660      */
getShortArrayExtra(String name)8661     public @Nullable short[] getShortArrayExtra(String name) {
8662         return mExtras == null ? null : mExtras.getShortArray(name);
8663     }
8664 
8665     /**
8666      * Retrieve extended data from the intent.
8667      *
8668      * @param name The name of the desired item.
8669      *
8670      * @return the value of an item previously added with putExtra(),
8671      * or null if no char array value was found.
8672      *
8673      * @see #putExtra(String, char[])
8674      */
getCharArrayExtra(String name)8675     public @Nullable char[] getCharArrayExtra(String name) {
8676         return mExtras == null ? null : mExtras.getCharArray(name);
8677     }
8678 
8679     /**
8680      * Retrieve extended data from the intent.
8681      *
8682      * @param name The name of the desired item.
8683      *
8684      * @return the value of an item previously added with putExtra(),
8685      * or null if no int array value was found.
8686      *
8687      * @see #putExtra(String, int[])
8688      */
getIntArrayExtra(String name)8689     public @Nullable int[] getIntArrayExtra(String name) {
8690         return mExtras == null ? null : mExtras.getIntArray(name);
8691     }
8692 
8693     /**
8694      * Retrieve extended data from the intent.
8695      *
8696      * @param name The name of the desired item.
8697      *
8698      * @return the value of an item previously added with putExtra(),
8699      * or null if no long array value was found.
8700      *
8701      * @see #putExtra(String, long[])
8702      */
getLongArrayExtra(String name)8703     public @Nullable long[] getLongArrayExtra(String name) {
8704         return mExtras == null ? null : mExtras.getLongArray(name);
8705     }
8706 
8707     /**
8708      * Retrieve extended data from the intent.
8709      *
8710      * @param name The name of the desired item.
8711      *
8712      * @return the value of an item previously added with putExtra(),
8713      * or null if no float array value was found.
8714      *
8715      * @see #putExtra(String, float[])
8716      */
getFloatArrayExtra(String name)8717     public @Nullable float[] getFloatArrayExtra(String name) {
8718         return mExtras == null ? null : mExtras.getFloatArray(name);
8719     }
8720 
8721     /**
8722      * Retrieve extended data from the intent.
8723      *
8724      * @param name The name of the desired item.
8725      *
8726      * @return the value of an item previously added with putExtra(),
8727      * or null if no double array value was found.
8728      *
8729      * @see #putExtra(String, double[])
8730      */
getDoubleArrayExtra(String name)8731     public @Nullable double[] getDoubleArrayExtra(String name) {
8732         return mExtras == null ? null : mExtras.getDoubleArray(name);
8733     }
8734 
8735     /**
8736      * Retrieve extended data from the intent.
8737      *
8738      * @param name The name of the desired item.
8739      *
8740      * @return the value of an item previously added with putExtra(),
8741      * or null if no String array value was found.
8742      *
8743      * @see #putExtra(String, String[])
8744      */
getStringArrayExtra(String name)8745     public @Nullable String[] getStringArrayExtra(String name) {
8746         return mExtras == null ? null : mExtras.getStringArray(name);
8747     }
8748 
8749     /**
8750      * Retrieve extended data from the intent.
8751      *
8752      * @param name The name of the desired item.
8753      *
8754      * @return the value of an item previously added with putExtra(),
8755      * or null if no CharSequence array value was found.
8756      *
8757      * @see #putExtra(String, CharSequence[])
8758      */
getCharSequenceArrayExtra(String name)8759     public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) {
8760         return mExtras == null ? null : mExtras.getCharSequenceArray(name);
8761     }
8762 
8763     /**
8764      * Retrieve extended data from the intent.
8765      *
8766      * @param name The name of the desired item.
8767      *
8768      * @return the value of an item previously added with putExtra(),
8769      * or null if no Bundle value was found.
8770      *
8771      * @see #putExtra(String, Bundle)
8772      */
getBundleExtra(String name)8773     public @Nullable Bundle getBundleExtra(String name) {
8774         return mExtras == null ? null : mExtras.getBundle(name);
8775     }
8776 
8777     /**
8778      * Retrieve extended data from the intent.
8779      *
8780      * @param name The name of the desired item.
8781      *
8782      * @return the value of an item previously added with putExtra(),
8783      * or null if no IBinder value was found.
8784      *
8785      * @see #putExtra(String, IBinder)
8786      *
8787      * @deprecated
8788      * @hide
8789      */
8790     @Deprecated
8791     @UnsupportedAppUsage
getIBinderExtra(String name)8792     public IBinder getIBinderExtra(String name) {
8793         return mExtras == null ? null : mExtras.getIBinder(name);
8794     }
8795 
8796     /**
8797      * Retrieve extended data from the intent.
8798      *
8799      * @param name The name of the desired item.
8800      * @param defaultValue The default value to return in case no item is
8801      * associated with the key 'name'
8802      *
8803      * @return the value of an item previously added with putExtra(),
8804      * or defaultValue if none was found.
8805      *
8806      * @see #putExtra
8807      *
8808      * @deprecated
8809      * @hide
8810      */
8811     @Deprecated
8812     @UnsupportedAppUsage
getExtra(String name, Object defaultValue)8813     public Object getExtra(String name, Object defaultValue) {
8814         Object result = defaultValue;
8815         if (mExtras != null) {
8816             Object result2 = mExtras.get(name);
8817             if (result2 != null) {
8818                 result = result2;
8819             }
8820         }
8821 
8822         return result;
8823     }
8824 
8825     /**
8826      * Retrieves a map of extended data from the intent.
8827      *
8828      * @return the map of all extras previously added with putExtra(),
8829      * or null if none have been added.
8830      */
getExtras()8831     public @Nullable Bundle getExtras() {
8832         return (mExtras != null)
8833                 ? new Bundle(mExtras)
8834                 : null;
8835     }
8836 
8837     /**
8838      * Filter extras to only basic types.
8839      * @hide
8840      */
removeUnsafeExtras()8841     public void removeUnsafeExtras() {
8842         if (mExtras != null) {
8843             mExtras = mExtras.filterValues();
8844         }
8845     }
8846 
8847     /**
8848      * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
8849      * return itself as-is.
8850      * @hide
8851      */
canStripForHistory()8852     public boolean canStripForHistory() {
8853         return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
8854     }
8855 
8856     /**
8857      * Call it when the system needs to keep an intent for logging purposes to remove fields
8858      * that are not needed for logging.
8859      * @hide
8860      */
maybeStripForHistory()8861     public Intent maybeStripForHistory() {
8862         // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
8863 
8864         if (!canStripForHistory()) {
8865             return this;
8866         }
8867         return new Intent(this, COPY_MODE_HISTORY);
8868     }
8869 
8870     /**
8871      * Retrieve any special flags associated with this intent.  You will
8872      * normally just set them with {@link #setFlags} and let the system
8873      * take the appropriate action with them.
8874      *
8875      * @return The currently set flags.
8876      * @see #setFlags
8877      * @see #addFlags
8878      * @see #removeFlags
8879      */
getFlags()8880     public @Flags int getFlags() {
8881         return mFlags;
8882     }
8883 
8884     /** @hide */
8885     @UnsupportedAppUsage
isExcludingStopped()8886     public boolean isExcludingStopped() {
8887         return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
8888                 == FLAG_EXCLUDE_STOPPED_PACKAGES;
8889     }
8890 
8891     /**
8892      * Retrieve the application package name this Intent is limited to.  When
8893      * resolving an Intent, if non-null this limits the resolution to only
8894      * components in the given application package.
8895      *
8896      * @return The name of the application package for the Intent.
8897      *
8898      * @see #resolveActivity
8899      * @see #setPackage
8900      */
getPackage()8901     public @Nullable String getPackage() {
8902         return mPackage;
8903     }
8904 
8905     /**
8906      * Retrieve the concrete component associated with the intent.  When receiving
8907      * an intent, this is the component that was found to best handle it (that is,
8908      * yourself) and will always be non-null; in all other cases it will be
8909      * null unless explicitly set.
8910      *
8911      * @return The name of the application component to handle the intent.
8912      *
8913      * @see #resolveActivity
8914      * @see #setComponent
8915      */
getComponent()8916     public @Nullable ComponentName getComponent() {
8917         return mComponent;
8918     }
8919 
8920     /**
8921      * Get the bounds of the sender of this intent, in screen coordinates.  This can be
8922      * used as a hint to the receiver for animations and the like.  Null means that there
8923      * is no source bounds.
8924      */
getSourceBounds()8925     public @Nullable Rect getSourceBounds() {
8926         return mSourceBounds;
8927     }
8928 
8929     /**
8930      * Return the Activity component that should be used to handle this intent.
8931      * The appropriate component is determined based on the information in the
8932      * intent, evaluated as follows:
8933      *
8934      * <p>If {@link #getComponent} returns an explicit class, that is returned
8935      * without any further consideration.
8936      *
8937      * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
8938      * category to be considered.
8939      *
8940      * <p>If {@link #getAction} is non-NULL, the activity must handle this
8941      * action.
8942      *
8943      * <p>If {@link #resolveType} returns non-NULL, the activity must handle
8944      * this type.
8945      *
8946      * <p>If {@link #addCategory} has added any categories, the activity must
8947      * handle ALL of the categories specified.
8948      *
8949      * <p>If {@link #getPackage} is non-NULL, only activity components in
8950      * that application package will be considered.
8951      *
8952      * <p>If there are no activities that satisfy all of these conditions, a
8953      * null string is returned.
8954      *
8955      * <p>If multiple activities are found to satisfy the intent, the one with
8956      * the highest priority will be used.  If there are multiple activities
8957      * with the same priority, the system will either pick the best activity
8958      * based on user preference, or resolve to a system class that will allow
8959      * the user to pick an activity and forward from there.
8960      *
8961      * <p>This method is implemented simply by calling
8962      * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
8963      * true.</p>
8964      * <p> This API is called for you as part of starting an activity from an
8965      * intent.  You do not normally need to call it yourself.</p>
8966      *
8967      * @param pm The package manager with which to resolve the Intent.
8968      *
8969      * @return Name of the component implementing an activity that can
8970      *         display the intent.
8971      *
8972      * @see #setComponent
8973      * @see #getComponent
8974      * @see #resolveActivityInfo
8975      */
resolveActivity(@onNull PackageManager pm)8976     public ComponentName resolveActivity(@NonNull PackageManager pm) {
8977         if (mComponent != null) {
8978             return mComponent;
8979         }
8980 
8981         ResolveInfo info = pm.resolveActivity(
8982             this, PackageManager.MATCH_DEFAULT_ONLY);
8983         if (info != null) {
8984             return new ComponentName(
8985                     info.activityInfo.applicationInfo.packageName,
8986                     info.activityInfo.name);
8987         }
8988 
8989         return null;
8990     }
8991 
8992     /**
8993      * Resolve the Intent into an {@link ActivityInfo}
8994      * describing the activity that should execute the intent.  Resolution
8995      * follows the same rules as described for {@link #resolveActivity}, but
8996      * you get back the completely information about the resolved activity
8997      * instead of just its class name.
8998      *
8999      * @param pm The package manager with which to resolve the Intent.
9000      * @param flags Addition information to retrieve as per
9001      * {@link PackageManager#getActivityInfo(ComponentName, int)
9002      * PackageManager.getActivityInfo()}.
9003      *
9004      * @return PackageManager.ActivityInfo
9005      *
9006      * @see #resolveActivity
9007      */
resolveActivityInfo(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)9008     public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
9009             @PackageManager.ComponentInfoFlags int flags) {
9010         ActivityInfo ai = null;
9011         if (mComponent != null) {
9012             try {
9013                 ai = pm.getActivityInfo(mComponent, flags);
9014             } catch (PackageManager.NameNotFoundException e) {
9015                 // ignore
9016             }
9017         } else {
9018             ResolveInfo info = pm.resolveActivity(
9019                 this, PackageManager.MATCH_DEFAULT_ONLY | flags);
9020             if (info != null) {
9021                 ai = info.activityInfo;
9022             }
9023         }
9024 
9025         return ai;
9026     }
9027 
9028     /**
9029      * Special function for use by the system to resolve service
9030      * intents to system apps.  Throws an exception if there are
9031      * multiple potential matches to the Intent.  Returns null if
9032      * there are no matches.
9033      * @hide
9034      */
9035     @UnsupportedAppUsage
resolveSystemService(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)9036     public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
9037             @PackageManager.ComponentInfoFlags int flags) {
9038         if (mComponent != null) {
9039             return mComponent;
9040         }
9041 
9042         List<ResolveInfo> results = pm.queryIntentServices(this, flags);
9043         if (results == null) {
9044             return null;
9045         }
9046         ComponentName comp = null;
9047         for (int i=0; i<results.size(); i++) {
9048             ResolveInfo ri = results.get(i);
9049             if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
9050                 continue;
9051             }
9052             ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
9053                     ri.serviceInfo.name);
9054             if (comp != null) {
9055                 throw new IllegalStateException("Multiple system services handle " + this
9056                         + ": " + comp + ", " + foundComp);
9057             }
9058             comp = foundComp;
9059         }
9060         return comp;
9061     }
9062 
9063     /**
9064      * Set the general action to be performed.
9065      *
9066      * @param action An action name, such as ACTION_VIEW.  Application-specific
9067      *               actions should be prefixed with the vendor's package name.
9068      *
9069      * @return Returns the same Intent object, for chaining multiple calls
9070      * into a single statement.
9071      *
9072      * @see #getAction
9073      */
setAction(@ullable String action)9074     public @NonNull Intent setAction(@Nullable String action) {
9075         mAction = action != null ? action.intern() : null;
9076         return this;
9077     }
9078 
9079     /**
9080      * Set the data this intent is operating on.  This method automatically
9081      * clears any type that was previously set by {@link #setType} or
9082      * {@link #setTypeAndNormalize}.
9083      *
9084      * <p><em>Note: scheme matching in the Android framework is
9085      * case-sensitive, unlike the formal RFC. As a result,
9086      * you should always write your Uri with a lower case scheme,
9087      * or use {@link Uri#normalizeScheme} or
9088      * {@link #setDataAndNormalize}
9089      * to ensure that the scheme is converted to lower case.</em>
9090      *
9091      * @param data The Uri of the data this intent is now targeting.
9092      *
9093      * @return Returns the same Intent object, for chaining multiple calls
9094      * into a single statement.
9095      *
9096      * @see #getData
9097      * @see #setDataAndNormalize
9098      * @see android.net.Uri#normalizeScheme()
9099      */
setData(@ullable Uri data)9100     public @NonNull Intent setData(@Nullable Uri data) {
9101         mData = data;
9102         mType = null;
9103         return this;
9104     }
9105 
9106     /**
9107      * Normalize and set the data this intent is operating on.
9108      *
9109      * <p>This method automatically clears any type that was
9110      * previously set (for example, by {@link #setType}).
9111      *
9112      * <p>The data Uri is normalized using
9113      * {@link android.net.Uri#normalizeScheme} before it is set,
9114      * so really this is just a convenience method for
9115      * <pre>
9116      * setData(data.normalize())
9117      * </pre>
9118      *
9119      * @param data The Uri of the data this intent is now targeting.
9120      *
9121      * @return Returns the same Intent object, for chaining multiple calls
9122      * into a single statement.
9123      *
9124      * @see #getData
9125      * @see #setType
9126      * @see android.net.Uri#normalizeScheme
9127      */
setDataAndNormalize(@onNull Uri data)9128     public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
9129         return setData(data.normalizeScheme());
9130     }
9131 
9132     /**
9133      * Set an explicit MIME data type.
9134      *
9135      * <p>This is used to create intents that only specify a type and not data,
9136      * for example to indicate the type of data to return.
9137      *
9138      * <p>This method automatically clears any data that was
9139      * previously set (for example by {@link #setData}).
9140      *
9141      * <p><em>Note: MIME type matching in the Android framework is
9142      * case-sensitive, unlike formal RFC MIME types.  As a result,
9143      * you should always write your MIME types with lower case letters,
9144      * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
9145      * to ensure that it is converted to lower case.</em>
9146      *
9147      * @param type The MIME type of the data being handled by this intent.
9148      *
9149      * @return Returns the same Intent object, for chaining multiple calls
9150      * into a single statement.
9151      *
9152      * @see #getType
9153      * @see #setTypeAndNormalize
9154      * @see #setDataAndType
9155      * @see #normalizeMimeType
9156      */
setType(@ullable String type)9157     public @NonNull Intent setType(@Nullable String type) {
9158         mData = null;
9159         mType = type;
9160         return this;
9161     }
9162 
9163     /**
9164      * Normalize and set an explicit MIME data type.
9165      *
9166      * <p>This is used to create intents that only specify a type and not data,
9167      * for example to indicate the type of data to return.
9168      *
9169      * <p>This method automatically clears any data that was
9170      * previously set (for example by {@link #setData}).
9171      *
9172      * <p>The MIME type is normalized using
9173      * {@link #normalizeMimeType} before it is set,
9174      * so really this is just a convenience method for
9175      * <pre>
9176      * setType(Intent.normalizeMimeType(type))
9177      * </pre>
9178      *
9179      * @param type The MIME type of the data being handled by this intent.
9180      *
9181      * @return Returns the same Intent object, for chaining multiple calls
9182      * into a single statement.
9183      *
9184      * @see #getType
9185      * @see #setData
9186      * @see #normalizeMimeType
9187      */
setTypeAndNormalize(@ullable String type)9188     public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
9189         return setType(normalizeMimeType(type));
9190     }
9191 
9192     /**
9193      * (Usually optional) Set the data for the intent along with an explicit
9194      * MIME data type.  This method should very rarely be used -- it allows you
9195      * to override the MIME type that would ordinarily be inferred from the
9196      * data with your own type given here.
9197      *
9198      * <p><em>Note: MIME type and Uri scheme matching in the
9199      * Android framework is case-sensitive, unlike the formal RFC definitions.
9200      * As a result, you should always write these elements with lower case letters,
9201      * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
9202      * {@link #setDataAndTypeAndNormalize}
9203      * to ensure that they are converted to lower case.</em>
9204      *
9205      * @param data The Uri of the data this intent is now targeting.
9206      * @param type The MIME type of the data being handled by this intent.
9207      *
9208      * @return Returns the same Intent object, for chaining multiple calls
9209      * into a single statement.
9210      *
9211      * @see #setType
9212      * @see #setData
9213      * @see #normalizeMimeType
9214      * @see android.net.Uri#normalizeScheme
9215      * @see #setDataAndTypeAndNormalize
9216      */
setDataAndType(@ullable Uri data, @Nullable String type)9217     public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
9218         mData = data;
9219         mType = type;
9220         return this;
9221     }
9222 
9223     /**
9224      * (Usually optional) Normalize and set both the data Uri and an explicit
9225      * MIME data type.  This method should very rarely be used -- it allows you
9226      * to override the MIME type that would ordinarily be inferred from the
9227      * data with your own type given here.
9228      *
9229      * <p>The data Uri and the MIME type are normalize using
9230      * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
9231      * before they are set, so really this is just a convenience method for
9232      * <pre>
9233      * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
9234      * </pre>
9235      *
9236      * @param data The Uri of the data this intent is now targeting.
9237      * @param type The MIME type of the data being handled by this intent.
9238      *
9239      * @return Returns the same Intent object, for chaining multiple calls
9240      * into a single statement.
9241      *
9242      * @see #setType
9243      * @see #setData
9244      * @see #setDataAndType
9245      * @see #normalizeMimeType
9246      * @see android.net.Uri#normalizeScheme
9247      */
setDataAndTypeAndNormalize(@onNull Uri data, @Nullable String type)9248     public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
9249         return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
9250     }
9251 
9252     /**
9253      * Set an identifier for this Intent.  If set, this provides a unique identity for this Intent,
9254      * allowing it to be unique from other Intents that would otherwise look the same.  In
9255      * particular, this will be used by {@link #filterEquals(Intent)} to determine if two
9256      * Intents are the same as with other fields like {@link #setAction}.  However, unlike those
9257      * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter};
9258      * it is as if the identifier has not been set on the Intent.
9259      *
9260      * <p>This can be used, for example, to make this Intent unique from other Intents that
9261      * are otherwise the same, for use in creating a {@link android.app.PendingIntent}.  (Be aware
9262      * however that the receiver of the PendingIntent will see whatever you put in here.)  The
9263      * structure of this string is completely undefined by the platform, however if you are going
9264      * to be exposing identifier strings across different applications you may need to define
9265      * your own structure if there is no central party defining the contents of this field.</p>
9266      *
9267      * @param identifier The identifier for this Intent.  The contents of the string have no
9268      *                   meaning to the system, except whether they are exactly the same as
9269      *                   another identifier.
9270      *
9271      * @return Returns the same Intent object, for chaining multiple calls
9272      * into a single statement.
9273      *
9274      * @see #getIdentifier
9275      */
setIdentifier(@ullable String identifier)9276     public @NonNull Intent setIdentifier(@Nullable String identifier) {
9277         mIdentifier = identifier;
9278         return this;
9279     }
9280 
9281     /**
9282      * Add a new category to the intent.  Categories provide additional detail
9283      * about the action the intent performs.  When resolving an intent, only
9284      * activities that provide <em>all</em> of the requested categories will be
9285      * used.
9286      *
9287      * @param category The desired category.  This can be either one of the
9288      *               predefined Intent categories, or a custom category in your own
9289      *               namespace.
9290      *
9291      * @return Returns the same Intent object, for chaining multiple calls
9292      * into a single statement.
9293      *
9294      * @see #hasCategory
9295      * @see #removeCategory
9296      */
addCategory(String category)9297     public @NonNull Intent addCategory(String category) {
9298         if (mCategories == null) {
9299             mCategories = new ArraySet<String>();
9300         }
9301         mCategories.add(category.intern());
9302         return this;
9303     }
9304 
9305     /**
9306      * Remove a category from an intent.
9307      *
9308      * @param category The category to remove.
9309      *
9310      * @see #addCategory
9311      */
removeCategory(String category)9312     public void removeCategory(String category) {
9313         if (mCategories != null) {
9314             mCategories.remove(category);
9315             if (mCategories.size() == 0) {
9316                 mCategories = null;
9317             }
9318         }
9319     }
9320 
9321     /**
9322      * Set a selector for this Intent.  This is a modification to the kinds of
9323      * things the Intent will match.  If the selector is set, it will be used
9324      * when trying to find entities that can handle the Intent, instead of the
9325      * main contents of the Intent.  This allows you build an Intent containing
9326      * a generic protocol while targeting it more specifically.
9327      *
9328      * <p>An example of where this may be used is with things like
9329      * {@link #CATEGORY_APP_BROWSER}.  This category allows you to build an
9330      * Intent that will launch the Browser application.  However, the correct
9331      * main entry point of an application is actually {@link #ACTION_MAIN}
9332      * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
9333      * used to specify the actual Activity to launch.  If you launch the browser
9334      * with something different, undesired behavior may happen if the user has
9335      * previously or later launches it the normal way, since they do not match.
9336      * Instead, you can build an Intent with the MAIN action (but no ComponentName
9337      * yet specified) and set a selector with {@link #ACTION_MAIN} and
9338      * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
9339      *
9340      * <p>Setting a selector does not impact the behavior of
9341      * {@link #filterEquals(Intent)} and {@link #filterHashCode()}.  This is part of the
9342      * desired behavior of a selector -- it does not impact the base meaning
9343      * of the Intent, just what kinds of things will be matched against it
9344      * when determining who can handle it.</p>
9345      *
9346      * <p>You can not use both a selector and {@link #setPackage(String)} on
9347      * the same base Intent.</p>
9348      *
9349      * @param selector The desired selector Intent; set to null to not use
9350      * a special selector.
9351      */
setSelector(@ullable Intent selector)9352     public void setSelector(@Nullable Intent selector) {
9353         if (selector == this) {
9354             throw new IllegalArgumentException(
9355                     "Intent being set as a selector of itself");
9356         }
9357         if (selector != null && mPackage != null) {
9358             throw new IllegalArgumentException(
9359                     "Can't set selector when package name is already set");
9360         }
9361         mSelector = selector;
9362     }
9363 
9364     /**
9365      * Set a {@link ClipData} associated with this Intent.  This replaces any
9366      * previously set ClipData.
9367      *
9368      * <p>The ClipData in an intent is not used for Intent matching or other
9369      * such operations.  Semantically it is like extras, used to transmit
9370      * additional data with the Intent.  The main feature of using this over
9371      * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
9372      * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
9373      * items included in the clip data.  This is useful, in particular, if
9374      * you want to transmit an Intent containing multiple <code>content:</code>
9375      * URIs for which the recipient may not have global permission to access the
9376      * content provider.
9377      *
9378      * <p>If the ClipData contains items that are themselves Intents, any
9379      * grant flags in those Intents will be ignored.  Only the top-level flags
9380      * of the main Intent are respected, and will be applied to all Uri or
9381      * Intent items in the clip (or sub-items of the clip).
9382      *
9383      * <p>The MIME type, label, and icon in the ClipData object are not
9384      * directly used by Intent.  Applications should generally rely on the
9385      * MIME type of the Intent itself, not what it may find in the ClipData.
9386      * A common practice is to construct a ClipData for use with an Intent
9387      * with a MIME type of "*&#47;*".
9388      *
9389      * @param clip The new clip to set.  May be null to clear the current clip.
9390      */
setClipData(@ullable ClipData clip)9391     public void setClipData(@Nullable ClipData clip) {
9392         mClipData = clip;
9393     }
9394 
9395     /**
9396      * This is NOT a secure mechanism to identify the user who sent the intent.
9397      * When the intent is sent to a different user, it is used to fix uris by adding the userId
9398      * who sent the intent.
9399      * @hide
9400      */
prepareToLeaveUser(int userId)9401     public void prepareToLeaveUser(int userId) {
9402         // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
9403         // We want mContentUserHint to refer to the original user, so don't do anything.
9404         if (mContentUserHint == UserHandle.USER_CURRENT) {
9405             mContentUserHint = userId;
9406         }
9407     }
9408 
9409     /**
9410      * Add extended data to the intent.  The name must include a package
9411      * prefix, for example the app com.android.contacts would use names
9412      * like "com.android.contacts.ShowAll".
9413      *
9414      * @param name The name of the extra data, with package prefix.
9415      * @param value The boolean data value.
9416      *
9417      * @return Returns the same Intent object, for chaining multiple calls
9418      * into a single statement.
9419      *
9420      * @see #putExtras
9421      * @see #removeExtra
9422      * @see #getBooleanExtra(String, boolean)
9423      */
putExtra(String name, boolean value)9424     public @NonNull Intent putExtra(String name, boolean value) {
9425         if (mExtras == null) {
9426             mExtras = new Bundle();
9427         }
9428         mExtras.putBoolean(name, value);
9429         return this;
9430     }
9431 
9432     /**
9433      * Add extended data to the intent.  The name must include a package
9434      * prefix, for example the app com.android.contacts would use names
9435      * like "com.android.contacts.ShowAll".
9436      *
9437      * @param name The name of the extra data, with package prefix.
9438      * @param value The byte data value.
9439      *
9440      * @return Returns the same Intent object, for chaining multiple calls
9441      * into a single statement.
9442      *
9443      * @see #putExtras
9444      * @see #removeExtra
9445      * @see #getByteExtra(String, byte)
9446      */
putExtra(String name, byte value)9447     public @NonNull Intent putExtra(String name, byte value) {
9448         if (mExtras == null) {
9449             mExtras = new Bundle();
9450         }
9451         mExtras.putByte(name, value);
9452         return this;
9453     }
9454 
9455     /**
9456      * Add extended data to the intent.  The name must include a package
9457      * prefix, for example the app com.android.contacts would use names
9458      * like "com.android.contacts.ShowAll".
9459      *
9460      * @param name The name of the extra data, with package prefix.
9461      * @param value The char data value.
9462      *
9463      * @return Returns the same Intent object, for chaining multiple calls
9464      * into a single statement.
9465      *
9466      * @see #putExtras
9467      * @see #removeExtra
9468      * @see #getCharExtra(String, char)
9469      */
putExtra(String name, char value)9470     public @NonNull Intent putExtra(String name, char value) {
9471         if (mExtras == null) {
9472             mExtras = new Bundle();
9473         }
9474         mExtras.putChar(name, value);
9475         return this;
9476     }
9477 
9478     /**
9479      * Add extended data to the intent.  The name must include a package
9480      * prefix, for example the app com.android.contacts would use names
9481      * like "com.android.contacts.ShowAll".
9482      *
9483      * @param name The name of the extra data, with package prefix.
9484      * @param value The short data value.
9485      *
9486      * @return Returns the same Intent object, for chaining multiple calls
9487      * into a single statement.
9488      *
9489      * @see #putExtras
9490      * @see #removeExtra
9491      * @see #getShortExtra(String, short)
9492      */
putExtra(String name, short value)9493     public @NonNull Intent putExtra(String name, short value) {
9494         if (mExtras == null) {
9495             mExtras = new Bundle();
9496         }
9497         mExtras.putShort(name, value);
9498         return this;
9499     }
9500 
9501     /**
9502      * Add extended data to the intent.  The name must include a package
9503      * prefix, for example the app com.android.contacts would use names
9504      * like "com.android.contacts.ShowAll".
9505      *
9506      * @param name The name of the extra data, with package prefix.
9507      * @param value The integer data value.
9508      *
9509      * @return Returns the same Intent object, for chaining multiple calls
9510      * into a single statement.
9511      *
9512      * @see #putExtras
9513      * @see #removeExtra
9514      * @see #getIntExtra(String, int)
9515      */
putExtra(String name, int value)9516     public @NonNull Intent putExtra(String name, int value) {
9517         if (mExtras == null) {
9518             mExtras = new Bundle();
9519         }
9520         mExtras.putInt(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 long 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 #getLongExtra(String, long)
9538      */
putExtra(String name, long value)9539     public @NonNull Intent putExtra(String name, long value) {
9540         if (mExtras == null) {
9541             mExtras = new Bundle();
9542         }
9543         mExtras.putLong(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 float 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 #getFloatExtra(String, float)
9561      */
putExtra(String name, float value)9562     public @NonNull Intent putExtra(String name, float value) {
9563         if (mExtras == null) {
9564             mExtras = new Bundle();
9565         }
9566         mExtras.putFloat(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 double 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 #getDoubleExtra(String, double)
9584      */
putExtra(String name, double value)9585     public @NonNull Intent putExtra(String name, double value) {
9586         if (mExtras == null) {
9587             mExtras = new Bundle();
9588         }
9589         mExtras.putDouble(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 String 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 #getStringExtra(String)
9607      */
putExtra(String name, @Nullable String value)9608     public @NonNull Intent putExtra(String name, @Nullable String value) {
9609         if (mExtras == null) {
9610             mExtras = new Bundle();
9611         }
9612         mExtras.putString(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 CharSequence 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 #getCharSequenceExtra(String)
9630      */
putExtra(String name, @Nullable CharSequence value)9631     public @NonNull Intent putExtra(String name, @Nullable CharSequence value) {
9632         if (mExtras == null) {
9633             mExtras = new Bundle();
9634         }
9635         mExtras.putCharSequence(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 Parcelable 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 #getParcelableExtra(String)
9653      */
putExtra(String name, @Nullable Parcelable value)9654     public @NonNull Intent putExtra(String name, @Nullable Parcelable value) {
9655         if (mExtras == null) {
9656             mExtras = new Bundle();
9657         }
9658         mExtras.putParcelable(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 Parcelable[] 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 #getParcelableArrayExtra(String)
9676      */
putExtra(String name, @Nullable Parcelable[] value)9677     public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) {
9678         if (mExtras == null) {
9679             mExtras = new Bundle();
9680         }
9681         mExtras.putParcelableArray(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 ArrayList<Parcelable> 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 #getParcelableArrayListExtra(String)
9699      */
putParcelableArrayListExtra(String name, @Nullable ArrayList<? extends Parcelable> value)9700     public @NonNull Intent putParcelableArrayListExtra(String name,
9701             @Nullable ArrayList<? extends Parcelable> value) {
9702         if (mExtras == null) {
9703             mExtras = new Bundle();
9704         }
9705         mExtras.putParcelableArrayList(name, value);
9706         return this;
9707     }
9708 
9709     /**
9710      * Add extended data to the intent.  The name must include a package
9711      * prefix, for example the app com.android.contacts would use names
9712      * like "com.android.contacts.ShowAll".
9713      *
9714      * @param name The name of the extra data, with package prefix.
9715      * @param value The ArrayList<Integer> data value.
9716      *
9717      * @return Returns the same Intent object, for chaining multiple calls
9718      * into a single statement.
9719      *
9720      * @see #putExtras
9721      * @see #removeExtra
9722      * @see #getIntegerArrayListExtra(String)
9723      */
putIntegerArrayListExtra(String name, @Nullable ArrayList<Integer> value)9724     public @NonNull Intent putIntegerArrayListExtra(String name,
9725             @Nullable ArrayList<Integer> value) {
9726         if (mExtras == null) {
9727             mExtras = new Bundle();
9728         }
9729         mExtras.putIntegerArrayList(name, value);
9730         return this;
9731     }
9732 
9733     /**
9734      * Add extended data to the intent.  The name must include a package
9735      * prefix, for example the app com.android.contacts would use names
9736      * like "com.android.contacts.ShowAll".
9737      *
9738      * @param name The name of the extra data, with package prefix.
9739      * @param value The ArrayList<String> data value.
9740      *
9741      * @return Returns the same Intent object, for chaining multiple calls
9742      * into a single statement.
9743      *
9744      * @see #putExtras
9745      * @see #removeExtra
9746      * @see #getStringArrayListExtra(String)
9747      */
putStringArrayListExtra(String name, @Nullable ArrayList<String> value)9748     public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) {
9749         if (mExtras == null) {
9750             mExtras = new Bundle();
9751         }
9752         mExtras.putStringArrayList(name, value);
9753         return this;
9754     }
9755 
9756     /**
9757      * Add extended data to the intent.  The name must include a package
9758      * prefix, for example the app com.android.contacts would use names
9759      * like "com.android.contacts.ShowAll".
9760      *
9761      * @param name The name of the extra data, with package prefix.
9762      * @param value The ArrayList<CharSequence> data value.
9763      *
9764      * @return Returns the same Intent object, for chaining multiple calls
9765      * into a single statement.
9766      *
9767      * @see #putExtras
9768      * @see #removeExtra
9769      * @see #getCharSequenceArrayListExtra(String)
9770      */
putCharSequenceArrayListExtra(String name, @Nullable ArrayList<CharSequence> value)9771     public @NonNull Intent putCharSequenceArrayListExtra(String name,
9772             @Nullable ArrayList<CharSequence> value) {
9773         if (mExtras == null) {
9774             mExtras = new Bundle();
9775         }
9776         mExtras.putCharSequenceArrayList(name, value);
9777         return this;
9778     }
9779 
9780     /**
9781      * Add extended data to the intent.  The name must include a package
9782      * prefix, for example the app com.android.contacts would use names
9783      * like "com.android.contacts.ShowAll".
9784      *
9785      * @param name The name of the extra data, with package prefix.
9786      * @param value The Serializable data value.
9787      *
9788      * @return Returns the same Intent object, for chaining multiple calls
9789      * into a single statement.
9790      *
9791      * @see #putExtras
9792      * @see #removeExtra
9793      * @see #getSerializableExtra(String)
9794      */
putExtra(String name, @Nullable Serializable value)9795     public @NonNull Intent putExtra(String name, @Nullable Serializable value) {
9796         if (mExtras == null) {
9797             mExtras = new Bundle();
9798         }
9799         mExtras.putSerializable(name, value);
9800         return this;
9801     }
9802 
9803     /**
9804      * Add extended data to the intent.  The name must include a package
9805      * prefix, for example the app com.android.contacts would use names
9806      * like "com.android.contacts.ShowAll".
9807      *
9808      * @param name The name of the extra data, with package prefix.
9809      * @param value The boolean array data value.
9810      *
9811      * @return Returns the same Intent object, for chaining multiple calls
9812      * into a single statement.
9813      *
9814      * @see #putExtras
9815      * @see #removeExtra
9816      * @see #getBooleanArrayExtra(String)
9817      */
putExtra(String name, @Nullable boolean[] value)9818     public @NonNull Intent putExtra(String name, @Nullable boolean[] value) {
9819         if (mExtras == null) {
9820             mExtras = new Bundle();
9821         }
9822         mExtras.putBooleanArray(name, value);
9823         return this;
9824     }
9825 
9826     /**
9827      * Add extended data to the intent.  The name must include a package
9828      * prefix, for example the app com.android.contacts would use names
9829      * like "com.android.contacts.ShowAll".
9830      *
9831      * @param name The name of the extra data, with package prefix.
9832      * @param value The byte array data value.
9833      *
9834      * @return Returns the same Intent object, for chaining multiple calls
9835      * into a single statement.
9836      *
9837      * @see #putExtras
9838      * @see #removeExtra
9839      * @see #getByteArrayExtra(String)
9840      */
putExtra(String name, @Nullable byte[] value)9841     public @NonNull Intent putExtra(String name, @Nullable byte[] value) {
9842         if (mExtras == null) {
9843             mExtras = new Bundle();
9844         }
9845         mExtras.putByteArray(name, value);
9846         return this;
9847     }
9848 
9849     /**
9850      * Add extended data to the intent.  The name must include a package
9851      * prefix, for example the app com.android.contacts would use names
9852      * like "com.android.contacts.ShowAll".
9853      *
9854      * @param name The name of the extra data, with package prefix.
9855      * @param value The short array data value.
9856      *
9857      * @return Returns the same Intent object, for chaining multiple calls
9858      * into a single statement.
9859      *
9860      * @see #putExtras
9861      * @see #removeExtra
9862      * @see #getShortArrayExtra(String)
9863      */
putExtra(String name, @Nullable short[] value)9864     public @NonNull Intent putExtra(String name, @Nullable short[] value) {
9865         if (mExtras == null) {
9866             mExtras = new Bundle();
9867         }
9868         mExtras.putShortArray(name, value);
9869         return this;
9870     }
9871 
9872     /**
9873      * Add extended data to the intent.  The name must include a package
9874      * prefix, for example the app com.android.contacts would use names
9875      * like "com.android.contacts.ShowAll".
9876      *
9877      * @param name The name of the extra data, with package prefix.
9878      * @param value The char array data value.
9879      *
9880      * @return Returns the same Intent object, for chaining multiple calls
9881      * into a single statement.
9882      *
9883      * @see #putExtras
9884      * @see #removeExtra
9885      * @see #getCharArrayExtra(String)
9886      */
putExtra(String name, @Nullable char[] value)9887     public @NonNull Intent putExtra(String name, @Nullable char[] value) {
9888         if (mExtras == null) {
9889             mExtras = new Bundle();
9890         }
9891         mExtras.putCharArray(name, value);
9892         return this;
9893     }
9894 
9895     /**
9896      * Add extended data to the intent.  The name must include a package
9897      * prefix, for example the app com.android.contacts would use names
9898      * like "com.android.contacts.ShowAll".
9899      *
9900      * @param name The name of the extra data, with package prefix.
9901      * @param value The int array data value.
9902      *
9903      * @return Returns the same Intent object, for chaining multiple calls
9904      * into a single statement.
9905      *
9906      * @see #putExtras
9907      * @see #removeExtra
9908      * @see #getIntArrayExtra(String)
9909      */
putExtra(String name, @Nullable int[] value)9910     public @NonNull Intent putExtra(String name, @Nullable int[] value) {
9911         if (mExtras == null) {
9912             mExtras = new Bundle();
9913         }
9914         mExtras.putIntArray(name, value);
9915         return this;
9916     }
9917 
9918     /**
9919      * Add extended data to the intent.  The name must include a package
9920      * prefix, for example the app com.android.contacts would use names
9921      * like "com.android.contacts.ShowAll".
9922      *
9923      * @param name The name of the extra data, with package prefix.
9924      * @param value The byte array data value.
9925      *
9926      * @return Returns the same Intent object, for chaining multiple calls
9927      * into a single statement.
9928      *
9929      * @see #putExtras
9930      * @see #removeExtra
9931      * @see #getLongArrayExtra(String)
9932      */
putExtra(String name, @Nullable long[] value)9933     public @NonNull Intent putExtra(String name, @Nullable long[] value) {
9934         if (mExtras == null) {
9935             mExtras = new Bundle();
9936         }
9937         mExtras.putLongArray(name, value);
9938         return this;
9939     }
9940 
9941     /**
9942      * Add extended data to the intent.  The name must include a package
9943      * prefix, for example the app com.android.contacts would use names
9944      * like "com.android.contacts.ShowAll".
9945      *
9946      * @param name The name of the extra data, with package prefix.
9947      * @param value The float array data value.
9948      *
9949      * @return Returns the same Intent object, for chaining multiple calls
9950      * into a single statement.
9951      *
9952      * @see #putExtras
9953      * @see #removeExtra
9954      * @see #getFloatArrayExtra(String)
9955      */
putExtra(String name, @Nullable float[] value)9956     public @NonNull Intent putExtra(String name, @Nullable float[] value) {
9957         if (mExtras == null) {
9958             mExtras = new Bundle();
9959         }
9960         mExtras.putFloatArray(name, value);
9961         return this;
9962     }
9963 
9964     /**
9965      * Add extended data to the intent.  The name must include a package
9966      * prefix, for example the app com.android.contacts would use names
9967      * like "com.android.contacts.ShowAll".
9968      *
9969      * @param name The name of the extra data, with package prefix.
9970      * @param value The double array data value.
9971      *
9972      * @return Returns the same Intent object, for chaining multiple calls
9973      * into a single statement.
9974      *
9975      * @see #putExtras
9976      * @see #removeExtra
9977      * @see #getDoubleArrayExtra(String)
9978      */
putExtra(String name, @Nullable double[] value)9979     public @NonNull Intent putExtra(String name, @Nullable double[] value) {
9980         if (mExtras == null) {
9981             mExtras = new Bundle();
9982         }
9983         mExtras.putDoubleArray(name, value);
9984         return this;
9985     }
9986 
9987     /**
9988      * Add extended data to the intent.  The name must include a package
9989      * prefix, for example the app com.android.contacts would use names
9990      * like "com.android.contacts.ShowAll".
9991      *
9992      * @param name The name of the extra data, with package prefix.
9993      * @param value The String array data value.
9994      *
9995      * @return Returns the same Intent object, for chaining multiple calls
9996      * into a single statement.
9997      *
9998      * @see #putExtras
9999      * @see #removeExtra
10000      * @see #getStringArrayExtra(String)
10001      */
putExtra(String name, @Nullable String[] value)10002     public @NonNull Intent putExtra(String name, @Nullable String[] value) {
10003         if (mExtras == null) {
10004             mExtras = new Bundle();
10005         }
10006         mExtras.putStringArray(name, value);
10007         return this;
10008     }
10009 
10010     /**
10011      * Add extended data to the intent.  The name must include a package
10012      * prefix, for example the app com.android.contacts would use names
10013      * like "com.android.contacts.ShowAll".
10014      *
10015      * @param name The name of the extra data, with package prefix.
10016      * @param value The CharSequence array data value.
10017      *
10018      * @return Returns the same Intent object, for chaining multiple calls
10019      * into a single statement.
10020      *
10021      * @see #putExtras
10022      * @see #removeExtra
10023      * @see #getCharSequenceArrayExtra(String)
10024      */
putExtra(String name, @Nullable CharSequence[] value)10025     public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) {
10026         if (mExtras == null) {
10027             mExtras = new Bundle();
10028         }
10029         mExtras.putCharSequenceArray(name, value);
10030         return this;
10031     }
10032 
10033     /**
10034      * Add extended data to the intent.  The name must include a package
10035      * prefix, for example the app com.android.contacts would use names
10036      * like "com.android.contacts.ShowAll".
10037      *
10038      * @param name The name of the extra data, with package prefix.
10039      * @param value The Bundle data value.
10040      *
10041      * @return Returns the same Intent object, for chaining multiple calls
10042      * into a single statement.
10043      *
10044      * @see #putExtras
10045      * @see #removeExtra
10046      * @see #getBundleExtra(String)
10047      */
putExtra(String name, @Nullable Bundle value)10048     public @NonNull Intent putExtra(String name, @Nullable Bundle value) {
10049         if (mExtras == null) {
10050             mExtras = new Bundle();
10051         }
10052         mExtras.putBundle(name, value);
10053         return this;
10054     }
10055 
10056     /**
10057      * Add extended data to the intent.  The name must include a package
10058      * prefix, for example the app com.android.contacts would use names
10059      * like "com.android.contacts.ShowAll".
10060      *
10061      * @param name The name of the extra data, with package prefix.
10062      * @param value The IBinder data value.
10063      *
10064      * @return Returns the same Intent object, for chaining multiple calls
10065      * into a single statement.
10066      *
10067      * @see #putExtras
10068      * @see #removeExtra
10069      * @see #getIBinderExtra(String)
10070      *
10071      * @deprecated
10072      * @hide
10073      */
10074     @Deprecated
10075     @UnsupportedAppUsage
putExtra(String name, IBinder value)10076     public @NonNull Intent putExtra(String name, IBinder value) {
10077         if (mExtras == null) {
10078             mExtras = new Bundle();
10079         }
10080         mExtras.putIBinder(name, value);
10081         return this;
10082     }
10083 
10084     /**
10085      * Copy all extras in 'src' in to this intent.
10086      *
10087      * @param src Contains the extras to copy.
10088      *
10089      * @see #putExtra
10090      */
putExtras(@onNull Intent src)10091     public @NonNull Intent putExtras(@NonNull Intent src) {
10092         if (src.mExtras != null) {
10093             if (mExtras == null) {
10094                 mExtras = new Bundle(src.mExtras);
10095             } else {
10096                 mExtras.putAll(src.mExtras);
10097             }
10098         }
10099         // If the provided Intent was unparceled and this is not an Intent delivered to a protected
10100         // component then mark the extras as unfiltered. An Intent delivered to a protected
10101         // component had to come from a trusted component, and if unfiltered data was copied to the
10102         // delivered Intent then it would have been reported when that Intent left the sending
10103         // process.
10104         if ((src.mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0
10105                 && (src.mLocalFlags & LOCAL_FLAG_FROM_PROTECTED_COMPONENT) == 0) {
10106             mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS;
10107         }
10108         return this;
10109     }
10110 
10111     /**
10112      * Add a set of extended data to the intent.  The keys must include a package
10113      * prefix, for example the app com.android.contacts would use names
10114      * like "com.android.contacts.ShowAll".
10115      *
10116      * @param extras The Bundle of extras to add to this intent.
10117      *
10118      * @see #putExtra
10119      * @see #removeExtra
10120      */
putExtras(@onNull Bundle extras)10121     public @NonNull Intent putExtras(@NonNull Bundle extras) {
10122         // If the provided Bundle has not yet been unparceled then treat this as unfiltered extras.
10123         if (extras.isParcelled()) {
10124             mLocalFlags |= LOCAL_FLAG_UNFILTERED_EXTRAS;
10125         }
10126         if (mExtras == null) {
10127             mExtras = new Bundle();
10128         }
10129         mExtras.putAll(extras);
10130         return this;
10131     }
10132 
10133     /**
10134      * Completely replace the extras in the Intent with the extras in the
10135      * given Intent.
10136      *
10137      * @param src The exact extras contained in this Intent are copied
10138      * into the target intent, replacing any that were previously there.
10139      */
replaceExtras(@onNull Intent src)10140     public @NonNull Intent replaceExtras(@NonNull Intent src) {
10141         mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
10142         return this;
10143     }
10144 
10145     /**
10146      * Completely replace the extras in the Intent with the given Bundle of
10147      * extras.
10148      *
10149      * @param extras The new set of extras in the Intent, or null to erase
10150      * all extras.
10151      */
replaceExtras(@ullable Bundle extras)10152     public @NonNull Intent replaceExtras(@Nullable Bundle extras) {
10153         mExtras = extras != null ? new Bundle(extras) : null;
10154         return this;
10155     }
10156 
10157     /**
10158      * Remove extended data from the intent.
10159      *
10160      * @see #putExtra
10161      */
removeExtra(String name)10162     public void removeExtra(String name) {
10163         if (mExtras != null) {
10164             mExtras.remove(name);
10165             if (mExtras.size() == 0) {
10166                 mExtras = null;
10167             }
10168         }
10169     }
10170 
10171     /**
10172      * Set special flags controlling how this intent is handled.  Most values
10173      * here depend on the type of component being executed by the Intent,
10174      * specifically the FLAG_ACTIVITY_* flags are all for use with
10175      * {@link Context#startActivity Context.startActivity()} and the
10176      * FLAG_RECEIVER_* flags are all for use with
10177      * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
10178      *
10179      * <p>See the
10180      * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
10181      * Stack</a> documentation for important information on how some of these options impact
10182      * the behavior of your application.
10183      *
10184      * @param flags The desired flags.
10185      * @return Returns the same Intent object, for chaining multiple calls
10186      * into a single statement.
10187      * @see #getFlags
10188      * @see #addFlags
10189      * @see #removeFlags
10190      */
setFlags(@lags int flags)10191     public @NonNull Intent setFlags(@Flags int flags) {
10192         mFlags = flags;
10193         return this;
10194     }
10195 
10196     /**
10197      * Add additional flags to the intent (or with existing flags value).
10198      *
10199      * @param flags The new flags to set.
10200      * @return Returns the same Intent object, for chaining multiple calls into
10201      *         a single statement.
10202      * @see #setFlags
10203      * @see #getFlags
10204      * @see #removeFlags
10205      */
addFlags(@lags int flags)10206     public @NonNull Intent addFlags(@Flags int flags) {
10207         mFlags |= flags;
10208         return this;
10209     }
10210 
10211     /**
10212      * Remove these flags from the intent.
10213      *
10214      * @param flags The flags to remove.
10215      * @see #setFlags
10216      * @see #getFlags
10217      * @see #addFlags
10218      */
removeFlags(@lags int flags)10219     public void removeFlags(@Flags int flags) {
10220         mFlags &= ~flags;
10221     }
10222 
10223     /**
10224      * (Usually optional) Set an explicit application package name that limits
10225      * the components this Intent will resolve to.  If left to the default
10226      * value of null, all components in all applications will considered.
10227      * If non-null, the Intent can only match the components in the given
10228      * application package.
10229      *
10230      * @param packageName The name of the application package to handle the
10231      * intent, or null to allow any application package.
10232      *
10233      * @return Returns the same Intent object, for chaining multiple calls
10234      * into a single statement.
10235      *
10236      * @see #getPackage
10237      * @see #resolveActivity
10238      */
setPackage(@ullable String packageName)10239     public @NonNull Intent setPackage(@Nullable String packageName) {
10240         if (packageName != null && mSelector != null) {
10241             throw new IllegalArgumentException(
10242                     "Can't set package name when selector is already set");
10243         }
10244         mPackage = packageName;
10245         return this;
10246     }
10247 
10248     /**
10249      * (Usually optional) Explicitly set the component to handle the intent.
10250      * If left with the default value of null, the system will determine the
10251      * appropriate class to use based on the other fields (action, data,
10252      * type, categories) in the Intent.  If this class is defined, the
10253      * specified class will always be used regardless of the other fields.  You
10254      * should only set this value when you know you absolutely want a specific
10255      * class to be used; otherwise it is better to let the system find the
10256      * appropriate class so that you will respect the installed applications
10257      * and user preferences.
10258      *
10259      * @param component The name of the application component to handle the
10260      * intent, or null to let the system find one for you.
10261      *
10262      * @return Returns the same Intent object, for chaining multiple calls
10263      * into a single statement.
10264      *
10265      * @see #setClass
10266      * @see #setClassName(Context, String)
10267      * @see #setClassName(String, String)
10268      * @see #getComponent
10269      * @see #resolveActivity
10270      */
setComponent(@ullable ComponentName component)10271     public @NonNull Intent setComponent(@Nullable ComponentName component) {
10272         mComponent = component;
10273         return this;
10274     }
10275 
10276     /**
10277      * Convenience for calling {@link #setComponent} with an
10278      * explicit class name.
10279      *
10280      * @param packageContext A Context of the application package implementing
10281      * this class.
10282      * @param className The name of a class inside of the application package
10283      * that will be used as the component for this Intent.
10284      *
10285      * @return Returns the same Intent object, for chaining multiple calls
10286      * into a single statement.
10287      *
10288      * @see #setComponent
10289      * @see #setClass
10290      */
setClassName(@onNull Context packageContext, @NonNull String className)10291     public @NonNull Intent setClassName(@NonNull Context packageContext,
10292             @NonNull String className) {
10293         mComponent = new ComponentName(packageContext, className);
10294         return this;
10295     }
10296 
10297     /**
10298      * Convenience for calling {@link #setComponent} with an
10299      * explicit application package name and class name.
10300      *
10301      * @param packageName The name of the package implementing the desired
10302      * component.
10303      * @param className The name of a class inside of the application package
10304      * that will be used as the component for this Intent.
10305      *
10306      * @return Returns the same Intent object, for chaining multiple calls
10307      * into a single statement.
10308      *
10309      * @see #setComponent
10310      * @see #setClass
10311      */
setClassName(@onNull String packageName, @NonNull String className)10312     public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
10313         mComponent = new ComponentName(packageName, className);
10314         return this;
10315     }
10316 
10317     /**
10318      * Convenience for calling {@link #setComponent(ComponentName)} with the
10319      * name returned by a {@link Class} object.
10320      *
10321      * @param packageContext A Context of the application package implementing
10322      * this class.
10323      * @param cls The class name to set, equivalent to
10324      *            <code>setClassName(context, cls.getName())</code>.
10325      *
10326      * @return Returns the same Intent object, for chaining multiple calls
10327      * into a single statement.
10328      *
10329      * @see #setComponent
10330      */
setClass(@onNull Context packageContext, @NonNull Class<?> cls)10331     public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
10332         mComponent = new ComponentName(packageContext, cls);
10333         return this;
10334     }
10335 
10336     /**
10337      * Set the bounds of the sender of this intent, in screen coordinates.  This can be
10338      * used as a hint to the receiver for animations and the like.  Null means that there
10339      * is no source bounds.
10340      */
setSourceBounds(@ullable Rect r)10341     public void setSourceBounds(@Nullable Rect r) {
10342         if (r != null) {
10343             mSourceBounds = new Rect(r);
10344         } else {
10345             mSourceBounds = null;
10346         }
10347     }
10348 
10349     /** @hide */
10350     @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
10351             FILL_IN_ACTION,
10352             FILL_IN_DATA,
10353             FILL_IN_CATEGORIES,
10354             FILL_IN_COMPONENT,
10355             FILL_IN_PACKAGE,
10356             FILL_IN_SOURCE_BOUNDS,
10357             FILL_IN_SELECTOR,
10358             FILL_IN_CLIP_DATA
10359     })
10360     @Retention(RetentionPolicy.SOURCE)
10361     public @interface FillInFlags {}
10362 
10363     /**
10364      * Use with {@link #fillIn} to allow the current action value to be
10365      * overwritten, even if it is already set.
10366      */
10367     public static final int FILL_IN_ACTION = 1<<0;
10368 
10369     /**
10370      * Use with {@link #fillIn} to allow the current data or type value
10371      * overwritten, even if it is already set.
10372      */
10373     public static final int FILL_IN_DATA = 1<<1;
10374 
10375     /**
10376      * Use with {@link #fillIn} to allow the current categories to be
10377      * overwritten, even if they are already set.
10378      */
10379     public static final int FILL_IN_CATEGORIES = 1<<2;
10380 
10381     /**
10382      * Use with {@link #fillIn} to allow the current component value to be
10383      * overwritten, even if it is already set.
10384      */
10385     public static final int FILL_IN_COMPONENT = 1<<3;
10386 
10387     /**
10388      * Use with {@link #fillIn} to allow the current package value to be
10389      * overwritten, even if it is already set.
10390      */
10391     public static final int FILL_IN_PACKAGE = 1<<4;
10392 
10393     /**
10394      * Use with {@link #fillIn} to allow the current bounds rectangle to be
10395      * overwritten, even if it is already set.
10396      */
10397     public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
10398 
10399     /**
10400      * Use with {@link #fillIn} to allow the current selector to be
10401      * overwritten, even if it is already set.
10402      */
10403     public static final int FILL_IN_SELECTOR = 1<<6;
10404 
10405     /**
10406      * Use with {@link #fillIn} to allow the current ClipData to be
10407      * overwritten, even if it is already set.
10408      */
10409     public static final int FILL_IN_CLIP_DATA = 1<<7;
10410 
10411     /**
10412      * Use with {@link #fillIn} to allow the current identifier value to be
10413      * overwritten, even if it is already set.
10414      */
10415     public static final int FILL_IN_IDENTIFIER = 1<<8;
10416 
10417     /**
10418      * Copy the contents of <var>other</var> in to this object, but only
10419      * where fields are not defined by this object.  For purposes of a field
10420      * being defined, the following pieces of data in the Intent are
10421      * considered to be separate fields:
10422      *
10423      * <ul>
10424      * <li> action, as set by {@link #setAction}.
10425      * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
10426      * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
10427      * <li> identifier, as set by {@link #setIdentifier}.
10428      * <li> categories, as set by {@link #addCategory}.
10429      * <li> package, as set by {@link #setPackage}.
10430      * <li> component, as set by {@link #setComponent(ComponentName)} or
10431      * related methods.
10432      * <li> source bounds, as set by {@link #setSourceBounds}.
10433      * <li> selector, as set by {@link #setSelector(Intent)}.
10434      * <li> clip data, as set by {@link #setClipData(ClipData)}.
10435      * <li> each top-level name in the associated extras.
10436      * </ul>
10437      *
10438      * <p>In addition, you can use the {@link #FILL_IN_ACTION},
10439      * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES},
10440      * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
10441      * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
10442      * the restriction where the corresponding field will not be replaced if
10443      * it is already set.
10444      *
10445      * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
10446      * is explicitly specified.  The selector will only be copied if
10447      * {@link #FILL_IN_SELECTOR} is explicitly specified.
10448      *
10449      * <p>For example, consider Intent A with {data="foo", categories="bar"}
10450      * and Intent B with {action="gotit", data-type="some/thing",
10451      * categories="one","two"}.
10452      *
10453      * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
10454      * containing: {action="gotit", data-type="some/thing",
10455      * categories="bar"}.
10456      *
10457      * @param other Another Intent whose values are to be used to fill in
10458      * the current one.
10459      * @param flags Options to control which fields can be filled in.
10460      *
10461      * @return Returns a bit mask of {@link #FILL_IN_ACTION},
10462      * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
10463      * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
10464      * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
10465      * changed.
10466      */
10467     @FillInFlags
fillIn(@onNull Intent other, @FillInFlags int flags)10468     public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
10469         int changes = 0;
10470         boolean mayHaveCopiedUris = false;
10471         if (other.mAction != null
10472                 && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
10473             mAction = other.mAction;
10474             changes |= FILL_IN_ACTION;
10475         }
10476         if ((other.mData != null || other.mType != null)
10477                 && ((mData == null && mType == null)
10478                         || (flags&FILL_IN_DATA) != 0)) {
10479             mData = other.mData;
10480             mType = other.mType;
10481             changes |= FILL_IN_DATA;
10482             mayHaveCopiedUris = true;
10483         }
10484         if (other.mIdentifier != null
10485                 && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) {
10486             mIdentifier = other.mIdentifier;
10487             changes |= FILL_IN_IDENTIFIER;
10488         }
10489         if (other.mCategories != null
10490                 && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
10491             if (other.mCategories != null) {
10492                 mCategories = new ArraySet<String>(other.mCategories);
10493             }
10494             changes |= FILL_IN_CATEGORIES;
10495         }
10496         if (other.mPackage != null
10497                 && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
10498             // Only do this if mSelector is not set.
10499             if (mSelector == null) {
10500                 mPackage = other.mPackage;
10501                 changes |= FILL_IN_PACKAGE;
10502             }
10503         }
10504         // Selector is special: it can only be set if explicitly allowed,
10505         // for the same reason as the component name.
10506         if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
10507             if (mPackage == null) {
10508                 mSelector = new Intent(other.mSelector);
10509                 mPackage = null;
10510                 changes |= FILL_IN_SELECTOR;
10511             }
10512         }
10513         if (other.mClipData != null
10514                 && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
10515             mClipData = other.mClipData;
10516             changes |= FILL_IN_CLIP_DATA;
10517             mayHaveCopiedUris = true;
10518         }
10519         // Component is special: it can -only- be set if explicitly allowed,
10520         // since otherwise the sender could force the intent somewhere the
10521         // originator didn't intend.
10522         if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
10523             mComponent = other.mComponent;
10524             changes |= FILL_IN_COMPONENT;
10525         }
10526         mFlags |= other.mFlags;
10527         if (other.mSourceBounds != null
10528                 && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
10529             mSourceBounds = new Rect(other.mSourceBounds);
10530             changes |= FILL_IN_SOURCE_BOUNDS;
10531         }
10532         if (mExtras == null) {
10533             if (other.mExtras != null) {
10534                 mExtras = new Bundle(other.mExtras);
10535                 mayHaveCopiedUris = true;
10536             }
10537         } else if (other.mExtras != null) {
10538             try {
10539                 Bundle newb = new Bundle(other.mExtras);
10540                 newb.putAll(mExtras);
10541                 mExtras = newb;
10542                 mayHaveCopiedUris = true;
10543             } catch (RuntimeException e) {
10544                 // Modifying the extras can cause us to unparcel the contents
10545                 // of the bundle, and if we do this in the system process that
10546                 // may fail.  We really should handle this (i.e., the Bundle
10547                 // impl shouldn't be on top of a plain map), but for now just
10548                 // ignore it and keep the original contents. :(
10549                 Log.w(TAG, "Failure filling in extras", e);
10550             }
10551         }
10552         if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
10553                 && other.mContentUserHint != UserHandle.USER_CURRENT) {
10554             mContentUserHint = other.mContentUserHint;
10555         }
10556         return changes;
10557     }
10558 
10559     /**
10560      * Wrapper class holding an Intent and implementing comparisons on it for
10561      * the purpose of filtering.  The class implements its
10562      * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
10563      * simple calls to {@link Intent#filterEquals(Intent)}  filterEquals()} and
10564      * {@link android.content.Intent#filterHashCode()}  filterHashCode()}
10565      * on the wrapped Intent.
10566      */
10567     public static final class FilterComparison {
10568         private final Intent mIntent;
10569         private final int mHashCode;
10570 
FilterComparison(Intent intent)10571         public FilterComparison(Intent intent) {
10572             mIntent = intent;
10573             mHashCode = intent.filterHashCode();
10574         }
10575 
10576         /**
10577          * Return the Intent that this FilterComparison represents.
10578          * @return Returns the Intent held by the FilterComparison.  Do
10579          * not modify!
10580          */
getIntent()10581         public Intent getIntent() {
10582             return mIntent;
10583         }
10584 
10585         @Override
equals(@ullable Object obj)10586         public boolean equals(@Nullable Object obj) {
10587             if (obj instanceof FilterComparison) {
10588                 Intent other = ((FilterComparison)obj).mIntent;
10589                 return mIntent.filterEquals(other);
10590             }
10591             return false;
10592         }
10593 
10594         @Override
hashCode()10595         public int hashCode() {
10596             return mHashCode;
10597         }
10598     }
10599 
10600     /**
10601      * Determine if two intents are the same for the purposes of intent
10602      * resolution (filtering). That is, if their action, data, type, identity,
10603      * class, and categories are the same.  This does <em>not</em> compare
10604      * any extra data included in the intents.  Note that technically when actually
10605      * matching against an {@link IntentFilter} the identifier is ignored, while here
10606      * it is directly compared for equality like the other fields.
10607      *
10608      * @param other The other Intent to compare against.
10609      *
10610      * @return Returns true if action, data, type, class, and categories
10611      *         are the same.
10612      */
filterEquals(Intent other)10613     public boolean filterEquals(Intent other) {
10614         if (other == null) {
10615             return false;
10616         }
10617         if (!Objects.equals(this.mAction, other.mAction)) return false;
10618         if (!Objects.equals(this.mData, other.mData)) return false;
10619         if (!Objects.equals(this.mType, other.mType)) return false;
10620         if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false;
10621         if (!(this.hasPackageEquivalentComponent() && other.hasPackageEquivalentComponent())
10622                 && !Objects.equals(this.mPackage, other.mPackage)) {
10623             return false;
10624         }
10625         if (!Objects.equals(this.mComponent, other.mComponent)) return false;
10626         if (!Objects.equals(this.mCategories, other.mCategories)) return false;
10627 
10628         return true;
10629     }
10630 
10631     /**
10632      * Return {@code true} if the component name is not null and is in the same package that this
10633      * intent limited to. otherwise return {@code false}.
10634      */
hasPackageEquivalentComponent()10635     private boolean hasPackageEquivalentComponent() {
10636         return mComponent != null
10637             && (mPackage == null || mPackage.equals(mComponent.getPackageName()));
10638     }
10639 
10640     /**
10641      * Generate hash code that matches semantics of filterEquals().
10642      *
10643      * @return Returns the hash value of the action, data, type, class, and
10644      *         categories.
10645      *
10646      * @see #filterEquals
10647      */
filterHashCode()10648     public int filterHashCode() {
10649         int code = 0;
10650         if (mAction != null) {
10651             code += mAction.hashCode();
10652         }
10653         if (mData != null) {
10654             code += mData.hashCode();
10655         }
10656         if (mType != null) {
10657             code += mType.hashCode();
10658         }
10659         if (mIdentifier != null) {
10660             code += mIdentifier.hashCode();
10661         }
10662         if (mPackage != null) {
10663             code += mPackage.hashCode();
10664         }
10665         if (mComponent != null) {
10666             code += mComponent.hashCode();
10667         }
10668         if (mCategories != null) {
10669             code += mCategories.hashCode();
10670         }
10671         return code;
10672     }
10673 
10674     @Override
toString()10675     public String toString() {
10676         StringBuilder b = new StringBuilder(128);
10677 
10678         b.append("Intent { ");
10679         toShortString(b, true, true, true, false);
10680         b.append(" }");
10681 
10682         return b.toString();
10683     }
10684 
10685     /** @hide */
10686     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
toInsecureString()10687     public String toInsecureString() {
10688         StringBuilder b = new StringBuilder(128);
10689 
10690         b.append("Intent { ");
10691         toShortString(b, false, true, true, false);
10692         b.append(" }");
10693 
10694         return b.toString();
10695     }
10696 
10697     /** @hide */
toShortString(boolean secure, boolean comp, boolean extras, boolean clip)10698     public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
10699         StringBuilder b = new StringBuilder(128);
10700         toShortString(b, secure, comp, extras, clip);
10701         return b.toString();
10702     }
10703 
10704     /** @hide */
toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, boolean clip)10705     public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
10706             boolean clip) {
10707         boolean first = true;
10708         if (mAction != null) {
10709             b.append("act=").append(mAction);
10710             first = false;
10711         }
10712         if (mCategories != null) {
10713             if (!first) {
10714                 b.append(' ');
10715             }
10716             first = false;
10717             b.append("cat=[");
10718             for (int i=0; i<mCategories.size(); i++) {
10719                 if (i > 0) b.append(',');
10720                 b.append(mCategories.valueAt(i));
10721             }
10722             b.append("]");
10723         }
10724         if (mData != null) {
10725             if (!first) {
10726                 b.append(' ');
10727             }
10728             first = false;
10729             b.append("dat=");
10730             if (secure) {
10731                 b.append(mData.toSafeString());
10732             } else {
10733                 b.append(mData);
10734             }
10735         }
10736         if (mType != null) {
10737             if (!first) {
10738                 b.append(' ');
10739             }
10740             first = false;
10741             b.append("typ=").append(mType);
10742         }
10743         if (mIdentifier != null) {
10744             if (!first) {
10745                 b.append(' ');
10746             }
10747             first = false;
10748             b.append("id=").append(mIdentifier);
10749         }
10750         if (mFlags != 0) {
10751             if (!first) {
10752                 b.append(' ');
10753             }
10754             first = false;
10755             b.append("flg=0x").append(Integer.toHexString(mFlags));
10756         }
10757         if (mPackage != null) {
10758             if (!first) {
10759                 b.append(' ');
10760             }
10761             first = false;
10762             b.append("pkg=").append(mPackage);
10763         }
10764         if (comp && mComponent != null) {
10765             if (!first) {
10766                 b.append(' ');
10767             }
10768             first = false;
10769             b.append("cmp=").append(mComponent.flattenToShortString());
10770         }
10771         if (mSourceBounds != null) {
10772             if (!first) {
10773                 b.append(' ');
10774             }
10775             first = false;
10776             b.append("bnds=").append(mSourceBounds.toShortString());
10777         }
10778         if (mClipData != null) {
10779             if (!first) {
10780                 b.append(' ');
10781             }
10782             b.append("clip={");
10783             mClipData.toShortString(b, !clip || secure);
10784             first = false;
10785             b.append('}');
10786         }
10787         if (extras && mExtras != null) {
10788             if (!first) {
10789                 b.append(' ');
10790             }
10791             first = false;
10792             b.append("(has extras)");
10793         }
10794         if (mContentUserHint != UserHandle.USER_CURRENT) {
10795             if (!first) {
10796                 b.append(' ');
10797             }
10798             first = false;
10799             b.append("u=").append(mContentUserHint);
10800         }
10801         if (mSelector != null) {
10802             b.append(" sel=");
10803             mSelector.toShortString(b, secure, comp, extras, clip);
10804             b.append("}");
10805         }
10806     }
10807 
10808     /** @hide */
dumpDebug(ProtoOutputStream proto, long fieldId)10809     public void dumpDebug(ProtoOutputStream proto, long fieldId) {
10810         // Same input parameters that toString() gives to toShortString().
10811         dumpDebug(proto, fieldId, true, true, true, false);
10812     }
10813 
10814     /** @hide */
dumpDebug(ProtoOutputStream proto)10815     public void dumpDebug(ProtoOutputStream proto) {
10816         // Same input parameters that toString() gives to toShortString().
10817         dumpDebugWithoutFieldId(proto, true, true, true, false);
10818     }
10819 
10820     /** @hide */
dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, boolean extras, boolean clip)10821     public void dumpDebug(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
10822             boolean extras, boolean clip) {
10823         long token = proto.start(fieldId);
10824         dumpDebugWithoutFieldId(proto, secure, comp, extras, clip);
10825         proto.end(token);
10826     }
10827 
dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, boolean extras, boolean clip)10828     private void dumpDebugWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp,
10829             boolean extras, boolean clip) {
10830         if (mAction != null) {
10831             proto.write(IntentProto.ACTION, mAction);
10832         }
10833         if (mCategories != null)  {
10834             for (String category : mCategories) {
10835                 proto.write(IntentProto.CATEGORIES, category);
10836             }
10837         }
10838         if (mData != null) {
10839             proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
10840         }
10841         if (mType != null) {
10842             proto.write(IntentProto.TYPE, mType);
10843         }
10844         if (mIdentifier != null) {
10845             proto.write(IntentProto.IDENTIFIER, mIdentifier);
10846         }
10847         if (mFlags != 0) {
10848             proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
10849         }
10850         if (mPackage != null) {
10851             proto.write(IntentProto.PACKAGE, mPackage);
10852         }
10853         if (comp && mComponent != null) {
10854             mComponent.dumpDebug(proto, IntentProto.COMPONENT);
10855         }
10856         if (mSourceBounds != null) {
10857             proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
10858         }
10859         if (mClipData != null) {
10860             StringBuilder b = new StringBuilder();
10861             mClipData.toShortString(b, !clip || secure);
10862             proto.write(IntentProto.CLIP_DATA, b.toString());
10863         }
10864         if (extras && mExtras != null) {
10865             proto.write(IntentProto.EXTRAS, mExtras.toShortString());
10866         }
10867         if (mContentUserHint != 0) {
10868             proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
10869         }
10870         if (mSelector != null) {
10871             proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
10872         }
10873     }
10874 
10875     /**
10876      * Call {@link #toUri} with 0 flags.
10877      * @deprecated Use {@link #toUri} instead.
10878      */
10879     @Deprecated
toURI()10880     public String toURI() {
10881         return toUri(0);
10882     }
10883 
10884     /**
10885      * Convert this Intent into a String holding a URI representation of it.
10886      * The returned URI string has been properly URI encoded, so it can be
10887      * used with {@link Uri#parse Uri.parse(String)}.  The URI contains the
10888      * Intent's data as the base URI, with an additional fragment describing
10889      * the action, categories, type, flags, package, component, and extras.
10890      *
10891      * <p>You can convert the returned string back to an Intent with
10892      * {@link #getIntent}.
10893      *
10894      * @param flags Additional operating flags.
10895      *
10896      * @return Returns a URI encoding URI string describing the entire contents
10897      * of the Intent.
10898      */
toUri(@riFlags int flags)10899     public String toUri(@UriFlags int flags) {
10900         StringBuilder uri = new StringBuilder(128);
10901         if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
10902             if (mPackage == null) {
10903                 throw new IllegalArgumentException(
10904                         "Intent must include an explicit package name to build an android-app: "
10905                         + this);
10906             }
10907             uri.append("android-app://");
10908             uri.append(mPackage);
10909             String scheme = null;
10910             if (mData != null) {
10911                 scheme = mData.getScheme();
10912                 if (scheme != null) {
10913                     uri.append('/');
10914                     uri.append(scheme);
10915                     String authority = mData.getEncodedAuthority();
10916                     if (authority != null) {
10917                         uri.append('/');
10918                         uri.append(authority);
10919                         String path = mData.getEncodedPath();
10920                         if (path != null) {
10921                             uri.append(path);
10922                         }
10923                         String queryParams = mData.getEncodedQuery();
10924                         if (queryParams != null) {
10925                             uri.append('?');
10926                             uri.append(queryParams);
10927                         }
10928                         String fragment = mData.getEncodedFragment();
10929                         if (fragment != null) {
10930                             uri.append('#');
10931                             uri.append(fragment);
10932                         }
10933                     }
10934                 }
10935             }
10936             toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
10937                     mPackage, flags);
10938             return uri.toString();
10939         }
10940         String scheme = null;
10941         if (mData != null) {
10942             String data = mData.toString();
10943             if ((flags&URI_INTENT_SCHEME) != 0) {
10944                 final int N = data.length();
10945                 for (int i=0; i<N; i++) {
10946                     char c = data.charAt(i);
10947                     if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
10948                             || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
10949                         continue;
10950                     }
10951                     if (c == ':' && i > 0) {
10952                         // Valid scheme.
10953                         scheme = data.substring(0, i);
10954                         uri.append("intent:");
10955                         data = data.substring(i+1);
10956                         break;
10957                     }
10958 
10959                     // No scheme.
10960                     break;
10961                 }
10962             }
10963             uri.append(data);
10964 
10965         } else if ((flags&URI_INTENT_SCHEME) != 0) {
10966             uri.append("intent:");
10967         }
10968 
10969         toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
10970 
10971         return uri.toString();
10972     }
10973 
toUriFragment(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)10974     private void toUriFragment(StringBuilder uri, String scheme, String defAction,
10975             String defPackage, int flags) {
10976         StringBuilder frag = new StringBuilder(128);
10977 
10978         toUriInner(frag, scheme, defAction, defPackage, flags);
10979         if (mSelector != null) {
10980             frag.append("SEL;");
10981             // Note that for now we are not going to try to handle the
10982             // data part; not clear how to represent this as a URI, and
10983             // not much utility in it.
10984             mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
10985                     null, null, flags);
10986         }
10987 
10988         if (frag.length() > 0) {
10989             uri.append("#Intent;");
10990             uri.append(frag);
10991             uri.append("end");
10992         }
10993     }
10994 
toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)10995     private void toUriInner(StringBuilder uri, String scheme, String defAction,
10996             String defPackage, int flags) {
10997         if (scheme != null) {
10998             uri.append("scheme=").append(scheme).append(';');
10999         }
11000         if (mAction != null && !mAction.equals(defAction)) {
11001             uri.append("action=").append(Uri.encode(mAction)).append(';');
11002         }
11003         if (mCategories != null) {
11004             for (int i=0; i<mCategories.size(); i++) {
11005                 uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
11006             }
11007         }
11008         if (mType != null) {
11009             uri.append("type=").append(Uri.encode(mType, "/")).append(';');
11010         }
11011         if (mIdentifier != null) {
11012             uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';');
11013         }
11014         if (mFlags != 0) {
11015             uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
11016         }
11017         if (mPackage != null && !mPackage.equals(defPackage)) {
11018             uri.append("package=").append(Uri.encode(mPackage)).append(';');
11019         }
11020         if (mComponent != null) {
11021             uri.append("component=").append(Uri.encode(
11022                     mComponent.flattenToShortString(), "/")).append(';');
11023         }
11024         if (mSourceBounds != null) {
11025             uri.append("sourceBounds=")
11026                     .append(Uri.encode(mSourceBounds.flattenToString()))
11027                     .append(';');
11028         }
11029         if (mExtras != null) {
11030             for (String key : mExtras.keySet()) {
11031                 final Object value = mExtras.get(key);
11032                 char entryType =
11033                         value instanceof String    ? 'S' :
11034                         value instanceof Boolean   ? 'B' :
11035                         value instanceof Byte      ? 'b' :
11036                         value instanceof Character ? 'c' :
11037                         value instanceof Double    ? 'd' :
11038                         value instanceof Float     ? 'f' :
11039                         value instanceof Integer   ? 'i' :
11040                         value instanceof Long      ? 'l' :
11041                         value instanceof Short     ? 's' :
11042                         '\0';
11043 
11044                 if (entryType != '\0') {
11045                     uri.append(entryType);
11046                     uri.append('.');
11047                     uri.append(Uri.encode(key));
11048                     uri.append('=');
11049                     uri.append(Uri.encode(value.toString()));
11050                     uri.append(';');
11051                 }
11052             }
11053         }
11054     }
11055 
describeContents()11056     public int describeContents() {
11057         return (mExtras != null) ? mExtras.describeContents() : 0;
11058     }
11059 
writeToParcel(Parcel out, int flags)11060     public void writeToParcel(Parcel out, int flags) {
11061         out.writeString8(mAction);
11062         Uri.writeToParcel(out, mData);
11063         out.writeString8(mType);
11064         out.writeString8(mIdentifier);
11065         out.writeInt(mFlags);
11066         out.writeString8(mPackage);
11067         ComponentName.writeToParcel(mComponent, out);
11068 
11069         if (mSourceBounds != null) {
11070             out.writeInt(1);
11071             mSourceBounds.writeToParcel(out, flags);
11072         } else {
11073             out.writeInt(0);
11074         }
11075 
11076         if (mCategories != null) {
11077             final int N = mCategories.size();
11078             out.writeInt(N);
11079             for (int i=0; i<N; i++) {
11080                 out.writeString8(mCategories.valueAt(i));
11081             }
11082         } else {
11083             out.writeInt(0);
11084         }
11085 
11086         if (mSelector != null) {
11087             out.writeInt(1);
11088             mSelector.writeToParcel(out, flags);
11089         } else {
11090             out.writeInt(0);
11091         }
11092 
11093         if (mClipData != null) {
11094             out.writeInt(1);
11095             mClipData.writeToParcel(out, flags);
11096         } else {
11097             out.writeInt(0);
11098         }
11099         out.writeInt(mContentUserHint);
11100         out.writeBundle(mExtras);
11101     }
11102 
11103     public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR
11104             = new Parcelable.Creator<Intent>() {
11105         public Intent createFromParcel(Parcel in) {
11106             return new Intent(in);
11107         }
11108         public Intent[] newArray(int size) {
11109             return new Intent[size];
11110         }
11111     };
11112 
11113     /** @hide */
Intent(Parcel in)11114     protected Intent(Parcel in) {
11115         // Remember that we came from a remote process to help detect security
11116         // issues caused by later unsafe launches
11117         mLocalFlags = LOCAL_FLAG_FROM_PARCEL;
11118         readFromParcel(in);
11119     }
11120 
readFromParcel(Parcel in)11121     public void readFromParcel(Parcel in) {
11122         setAction(in.readString8());
11123         mData = Uri.CREATOR.createFromParcel(in);
11124         mType = in.readString8();
11125         mIdentifier = in.readString8();
11126         mFlags = in.readInt();
11127         mPackage = in.readString8();
11128         mComponent = ComponentName.readFromParcel(in);
11129 
11130         if (in.readInt() != 0) {
11131             mSourceBounds = Rect.CREATOR.createFromParcel(in);
11132         }
11133 
11134         int N = in.readInt();
11135         if (N > 0) {
11136             mCategories = new ArraySet<String>();
11137             int i;
11138             for (i=0; i<N; i++) {
11139                 mCategories.add(in.readString8().intern());
11140             }
11141         } else {
11142             mCategories = null;
11143         }
11144 
11145         if (in.readInt() != 0) {
11146             mSelector = new Intent(in);
11147         }
11148 
11149         if (in.readInt() != 0) {
11150             mClipData = new ClipData(in);
11151         }
11152         mContentUserHint = in.readInt();
11153         mExtras = in.readBundle();
11154     }
11155 
11156     /**
11157      * Parses the "intent" element (and its children) from XML and instantiates
11158      * an Intent object.  The given XML parser should be located at the tag
11159      * where parsing should start (often named "intent"), from which the
11160      * basic action, data, type, and package and class name will be
11161      * retrieved.  The function will then parse in to any child elements,
11162      * looking for <category android:name="xxx"> tags to add categories and
11163      * <extra android:name="xxx" android:value="yyy"> to attach extra data
11164      * to the intent.
11165      *
11166      * @param resources The Resources to use when inflating resources.
11167      * @param parser The XML parser pointing at an "intent" tag.
11168      * @param attrs The AttributeSet interface for retrieving extended
11169      * attribute data at the current <var>parser</var> location.
11170      * @return An Intent object matching the XML data.
11171      * @throws XmlPullParserException If there was an XML parsing error.
11172      * @throws IOException If there was an I/O error.
11173      */
parseIntent(@onNull Resources resources, @NonNull XmlPullParser parser, AttributeSet attrs)11174     public static @NonNull Intent parseIntent(@NonNull Resources resources,
11175             @NonNull XmlPullParser parser, AttributeSet attrs)
11176             throws XmlPullParserException, IOException {
11177         Intent intent = new Intent();
11178 
11179         TypedArray sa = resources.obtainAttributes(attrs,
11180                 com.android.internal.R.styleable.Intent);
11181 
11182         intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
11183 
11184         String data = sa.getString(com.android.internal.R.styleable.Intent_data);
11185         String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
11186         intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
11187 
11188         intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier));
11189 
11190         String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
11191         String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
11192         if (packageName != null && className != null) {
11193             intent.setComponent(new ComponentName(packageName, className));
11194         }
11195 
11196         sa.recycle();
11197 
11198         int outerDepth = parser.getDepth();
11199         int type;
11200         while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
11201                && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
11202             if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
11203                 continue;
11204             }
11205 
11206             String nodeName = parser.getName();
11207             if (nodeName.equals(TAG_CATEGORIES)) {
11208                 sa = resources.obtainAttributes(attrs,
11209                         com.android.internal.R.styleable.IntentCategory);
11210                 String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
11211                 sa.recycle();
11212 
11213                 if (cat != null) {
11214                     intent.addCategory(cat);
11215                 }
11216                 XmlUtils.skipCurrentTag(parser);
11217 
11218             } else if (nodeName.equals(TAG_EXTRA)) {
11219                 if (intent.mExtras == null) {
11220                     intent.mExtras = new Bundle();
11221                 }
11222                 resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
11223                 XmlUtils.skipCurrentTag(parser);
11224 
11225             } else {
11226                 XmlUtils.skipCurrentTag(parser);
11227             }
11228         }
11229 
11230         return intent;
11231     }
11232 
11233     /** @hide */
saveToXml(XmlSerializer out)11234     public void saveToXml(XmlSerializer out) throws IOException {
11235         if (mAction != null) {
11236             out.attribute(null, ATTR_ACTION, mAction);
11237         }
11238         if (mData != null) {
11239             out.attribute(null, ATTR_DATA, mData.toString());
11240         }
11241         if (mType != null) {
11242             out.attribute(null, ATTR_TYPE, mType);
11243         }
11244         if (mIdentifier != null) {
11245             out.attribute(null, ATTR_IDENTIFIER, mIdentifier);
11246         }
11247         if (mComponent != null) {
11248             out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
11249         }
11250         out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
11251 
11252         if (mCategories != null) {
11253             out.startTag(null, TAG_CATEGORIES);
11254             for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
11255                 out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
11256             }
11257             out.endTag(null, TAG_CATEGORIES);
11258         }
11259     }
11260 
11261     /** @hide */
restoreFromXml(XmlPullParser in)11262     public static Intent restoreFromXml(XmlPullParser in) throws IOException,
11263             XmlPullParserException {
11264         Intent intent = new Intent();
11265         final int outerDepth = in.getDepth();
11266 
11267         int attrCount = in.getAttributeCount();
11268         for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
11269             final String attrName = in.getAttributeName(attrNdx);
11270             final String attrValue = in.getAttributeValue(attrNdx);
11271             if (ATTR_ACTION.equals(attrName)) {
11272                 intent.setAction(attrValue);
11273             } else if (ATTR_DATA.equals(attrName)) {
11274                 intent.setData(Uri.parse(attrValue));
11275             } else if (ATTR_TYPE.equals(attrName)) {
11276                 intent.setType(attrValue);
11277             } else if (ATTR_IDENTIFIER.equals(attrName)) {
11278                 intent.setIdentifier(attrValue);
11279             } else if (ATTR_COMPONENT.equals(attrName)) {
11280                 intent.setComponent(ComponentName.unflattenFromString(attrValue));
11281             } else if (ATTR_FLAGS.equals(attrName)) {
11282                 intent.setFlags(Integer.parseInt(attrValue, 16));
11283             } else {
11284                 Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName);
11285             }
11286         }
11287 
11288         int event;
11289         String name;
11290         while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
11291                 (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
11292             if (event == XmlPullParser.START_TAG) {
11293                 name = in.getName();
11294                 if (TAG_CATEGORIES.equals(name)) {
11295                     attrCount = in.getAttributeCount();
11296                     for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
11297                         intent.addCategory(in.getAttributeValue(attrNdx));
11298                     }
11299                 } else {
11300                     Log.w(TAG, "restoreFromXml: unknown name=" + name);
11301                     XmlUtils.skipCurrentTag(in);
11302                 }
11303             }
11304         }
11305 
11306         return intent;
11307     }
11308 
11309     /**
11310      * Normalize a MIME data type.
11311      *
11312      * <p>A normalized MIME type has white-space trimmed,
11313      * content-type parameters removed, and is lower-case.
11314      * This aligns the type with Android best practices for
11315      * intent filtering.
11316      *
11317      * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
11318      * "text/x-vCard" becomes "text/x-vcard".
11319      *
11320      * <p>All MIME types received from outside Android (such as user input,
11321      * or external sources like Bluetooth, NFC, or the Internet) should
11322      * be normalized before they are used to create an Intent.
11323      *
11324      * @param type MIME data type to normalize
11325      * @return normalized MIME data type, or null if the input was null
11326      * @see #setType
11327      * @see #setTypeAndNormalize
11328      */
normalizeMimeType(@ullable String type)11329     public static @Nullable String normalizeMimeType(@Nullable String type) {
11330         if (type == null) {
11331             return null;
11332         }
11333 
11334         type = type.trim().toLowerCase(Locale.ROOT);
11335 
11336         final int semicolonIndex = type.indexOf(';');
11337         if (semicolonIndex != -1) {
11338             type = type.substring(0, semicolonIndex);
11339         }
11340         return type;
11341     }
11342 
11343     /**
11344      * Prepare this {@link Intent} to leave an app process.
11345      *
11346      * @hide
11347      */
11348     @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
prepareToLeaveProcess(Context context)11349     public void prepareToLeaveProcess(Context context) {
11350         final boolean leavingPackage = (mComponent == null)
11351                 || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
11352         prepareToLeaveProcess(leavingPackage);
11353     }
11354 
11355     /**
11356      * Prepare this {@link Intent} to leave an app process.
11357      *
11358      * @hide
11359      */
prepareToLeaveProcess(boolean leavingPackage)11360     public void prepareToLeaveProcess(boolean leavingPackage) {
11361         setAllowFds(false);
11362 
11363         if (mSelector != null) {
11364             mSelector.prepareToLeaveProcess(leavingPackage);
11365         }
11366         if (mClipData != null) {
11367             mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
11368         }
11369 
11370         if (mExtras != null && !mExtras.isParcelled()) {
11371             final Object intent = mExtras.get(Intent.EXTRA_INTENT);
11372             if (intent instanceof Intent) {
11373                 ((Intent) intent).prepareToLeaveProcess(leavingPackage);
11374             }
11375         }
11376 
11377         if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
11378                 && leavingPackage) {
11379             switch (mAction) {
11380                 case ACTION_MEDIA_REMOVED:
11381                 case ACTION_MEDIA_UNMOUNTED:
11382                 case ACTION_MEDIA_CHECKING:
11383                 case ACTION_MEDIA_NOFS:
11384                 case ACTION_MEDIA_MOUNTED:
11385                 case ACTION_MEDIA_SHARED:
11386                 case ACTION_MEDIA_UNSHARED:
11387                 case ACTION_MEDIA_BAD_REMOVAL:
11388                 case ACTION_MEDIA_UNMOUNTABLE:
11389                 case ACTION_MEDIA_EJECT:
11390                 case ACTION_MEDIA_SCANNER_STARTED:
11391                 case ACTION_MEDIA_SCANNER_FINISHED:
11392                 case ACTION_MEDIA_SCANNER_SCAN_FILE:
11393                 case ACTION_PACKAGE_NEEDS_VERIFICATION:
11394                 case ACTION_PACKAGE_NEEDS_INTEGRITY_VERIFICATION:
11395                 case ACTION_PACKAGE_VERIFIED:
11396                 case ACTION_PACKAGE_ENABLE_ROLLBACK:
11397                     // Ignore legacy actions
11398                     break;
11399                 default:
11400                     mData.checkFileUriExposed("Intent.getData()");
11401             }
11402         }
11403 
11404         if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
11405                 && leavingPackage) {
11406             switch (mAction) {
11407                 case ACTION_PROVIDER_CHANGED:
11408                 case QuickContact.ACTION_QUICK_CONTACT:
11409                     // Ignore actions that don't need to grant
11410                     break;
11411                 default:
11412                     mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
11413             }
11414         }
11415 
11416         // Translate raw filesystem paths out of storage sandbox
11417         if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null
11418                 && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) {
11419             final StorageManager sm = AppGlobals.getInitialApplication()
11420                     .getSystemService(StorageManager.class);
11421             final File before = new File(mData.getPath());
11422             final File after = sm.translateAppToSystem(before,
11423                     android.os.Process.myPid(), android.os.Process.myUid());
11424             if (!Objects.equals(before, after)) {
11425                 Log.v(TAG, "Translated " + before + " to " + after);
11426                 mData = Uri.fromFile(after);
11427             }
11428         }
11429 
11430         // Detect cases where we're about to launch a potentially unsafe intent
11431         if (StrictMode.vmUnsafeIntentLaunchEnabled()) {
11432             if ((mLocalFlags & LOCAL_FLAG_FROM_PARCEL) != 0
11433                     && (mLocalFlags & LOCAL_FLAG_FROM_PROTECTED_COMPONENT) == 0) {
11434                 StrictMode.onUnsafeIntentLaunch(this);
11435             } else if ((mLocalFlags & LOCAL_FLAG_UNFILTERED_EXTRAS) != 0) {
11436                 StrictMode.onUnsafeIntentLaunch(this);
11437             } else if ((mLocalFlags & LOCAL_FLAG_FROM_URI) != 0
11438                     && !(mCategories != null && mCategories.contains(CATEGORY_BROWSABLE)
11439                         && mComponent == null)) {
11440                 // Since the docs for #URI_ALLOW_UNSAFE recommend setting the category to browsable
11441                 // for an implicit Intent parsed from a URI a violation should be reported if these
11442                 // conditions are not met.
11443                 StrictMode.onUnsafeIntentLaunch(this);
11444             }
11445         }
11446     }
11447 
11448     /**
11449      * @hide
11450      */
prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source)11451     public void prepareToEnterProcess(boolean fromProtectedComponent, AttributionSource source) {
11452         // We just entered destination process, so we should be able to read all
11453         // parcelables inside.
11454         setDefusable(true);
11455 
11456         if (mSelector != null) {
11457             // We can't recursively claim that this data is from a protected
11458             // component, since it may have been filled in by a malicious app
11459             mSelector.prepareToEnterProcess(false, source);
11460         }
11461         if (mClipData != null) {
11462             mClipData.prepareToEnterProcess(source);
11463         }
11464 
11465         if (mContentUserHint != UserHandle.USER_CURRENT) {
11466             if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
11467                 fixUris(mContentUserHint);
11468                 mContentUserHint = UserHandle.USER_CURRENT;
11469             }
11470         }
11471 
11472         if (fromProtectedComponent) {
11473             mLocalFlags |= LOCAL_FLAG_FROM_PROTECTED_COMPONENT;
11474         }
11475 
11476         // Special attribution fix-up logic for any BluetoothDevice extras
11477         // passed via Bluetooth intents
11478         if (mAction != null && mAction.startsWith("android.bluetooth.")
11479                 && hasExtra(BluetoothDevice.EXTRA_DEVICE)) {
11480             final BluetoothDevice device = getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
11481             if (device != null) {
11482                 device.prepareToEnterProcess(source);
11483             }
11484         }
11485     }
11486 
11487     /** @hide */
hasWebURI()11488     public boolean hasWebURI() {
11489         if (getData() == null) {
11490             return false;
11491         }
11492         final String scheme = getScheme();
11493         if (TextUtils.isEmpty(scheme)) {
11494             return false;
11495         }
11496         return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
11497     }
11498 
11499     /** @hide */
isWebIntent()11500     public boolean isWebIntent() {
11501         return ACTION_VIEW.equals(mAction)
11502                 && hasWebURI();
11503     }
11504 
isImageCaptureIntent()11505     private boolean isImageCaptureIntent() {
11506         return (MediaStore.ACTION_IMAGE_CAPTURE.equals(mAction)
11507                 || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(mAction)
11508                 || MediaStore.ACTION_VIDEO_CAPTURE.equals(mAction));
11509     }
11510 
11511     /** @hide */
isImplicitImageCaptureIntent()11512     public boolean isImplicitImageCaptureIntent() {
11513         return mPackage == null && mComponent == null && isImageCaptureIntent();
11514     }
11515 
11516     /**
11517      * @hide
11518      */
fixUris(int contentUserHint)11519      public void fixUris(int contentUserHint) {
11520         Uri data = getData();
11521         if (data != null) {
11522             mData = maybeAddUserId(data, contentUserHint);
11523         }
11524         if (mClipData != null) {
11525             mClipData.fixUris(contentUserHint);
11526         }
11527         String action = getAction();
11528         if (ACTION_SEND.equals(action)) {
11529             final Uri stream = getParcelableExtra(EXTRA_STREAM);
11530             if (stream != null) {
11531                 putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
11532             }
11533         } else if (ACTION_SEND_MULTIPLE.equals(action)) {
11534             final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
11535             if (streams != null) {
11536                 ArrayList<Uri> newStreams = new ArrayList<Uri>();
11537                 for (int i = 0; i < streams.size(); i++) {
11538                     newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
11539                 }
11540                 putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
11541             }
11542         } else if (isImageCaptureIntent()) {
11543             final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
11544             if (output != null) {
11545                 putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
11546             }
11547         }
11548      }
11549 
11550     /**
11551      * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
11552      * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
11553      * intents in {@link #ACTION_CHOOSER}.
11554      *
11555      * @return Whether any contents were migrated.
11556      * @hide
11557      */
migrateExtraStreamToClipData()11558     public boolean migrateExtraStreamToClipData() {
11559         return migrateExtraStreamToClipData(AppGlobals.getInitialApplication());
11560     }
11561 
11562     /**
11563      * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
11564      * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
11565      * intents in {@link #ACTION_CHOOSER}.
11566      *
11567      * @param context app context
11568      * @return Whether any contents were migrated.
11569      * @hide
11570      */
migrateExtraStreamToClipData(Context context)11571     public boolean migrateExtraStreamToClipData(Context context) {
11572         // Refuse to touch if extras already parcelled
11573         if (mExtras != null && mExtras.isParcelled()) return false;
11574 
11575         // Bail when someone already gave us ClipData
11576         if (getClipData() != null) return false;
11577 
11578         final String action = getAction();
11579         if (ACTION_CHOOSER.equals(action)) {
11580             // Inspect contained intents to see if we need to migrate extras. We
11581             // don't promote ClipData to the parent, since ChooserActivity will
11582             // already start the picked item as the caller, and we can't combine
11583             // the flags in a safe way.
11584 
11585             boolean migrated = false;
11586             try {
11587                 final Intent intent = getParcelableExtra(EXTRA_INTENT);
11588                 if (intent != null) {
11589                     migrated |= intent.migrateExtraStreamToClipData(context);
11590                 }
11591             } catch (ClassCastException e) {
11592             }
11593             try {
11594                 final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
11595                 if (intents != null) {
11596                     for (int i = 0; i < intents.length; i++) {
11597                         final Intent intent = (Intent) intents[i];
11598                         if (intent != null) {
11599                             migrated |= intent.migrateExtraStreamToClipData(context);
11600                         }
11601                     }
11602                 }
11603             } catch (ClassCastException e) {
11604             }
11605             return migrated;
11606 
11607         } else if (ACTION_SEND.equals(action)) {
11608             try {
11609                 final Uri stream = getParcelableExtra(EXTRA_STREAM);
11610                 final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
11611                 final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
11612                 if (stream != null || text != null || htmlText != null) {
11613                     final ClipData clipData = new ClipData(
11614                             null, new String[] { getType() },
11615                             new ClipData.Item(text, htmlText, null, stream));
11616                     setClipData(clipData);
11617                     addFlags(FLAG_GRANT_READ_URI_PERMISSION);
11618                     return true;
11619                 }
11620             } catch (ClassCastException e) {
11621             }
11622 
11623         } else if (ACTION_SEND_MULTIPLE.equals(action)) {
11624             try {
11625                 final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
11626                 final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
11627                 final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
11628                 int num = -1;
11629                 if (streams != null) {
11630                     num = streams.size();
11631                 }
11632                 if (texts != null) {
11633                     if (num >= 0 && num != texts.size()) {
11634                         // Wha...!  F- you.
11635                         return false;
11636                     }
11637                     num = texts.size();
11638                 }
11639                 if (htmlTexts != null) {
11640                     if (num >= 0 && num != htmlTexts.size()) {
11641                         // Wha...!  F- you.
11642                         return false;
11643                     }
11644                     num = htmlTexts.size();
11645                 }
11646                 if (num > 0) {
11647                     final ClipData clipData = new ClipData(
11648                             null, new String[] { getType() },
11649                             makeClipItem(streams, texts, htmlTexts, 0));
11650 
11651                     for (int i = 1; i < num; i++) {
11652                         clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
11653                     }
11654 
11655                     setClipData(clipData);
11656                     addFlags(FLAG_GRANT_READ_URI_PERMISSION);
11657                     return true;
11658                 }
11659             } catch (ClassCastException e) {
11660             }
11661         } else if (isImageCaptureIntent()) {
11662             Uri output;
11663             try {
11664                 output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
11665             } catch (ClassCastException e) {
11666                 return false;
11667             }
11668 
11669             if (output != null) {
11670                 output = maybeConvertFileToContentUri(context, output);
11671                 putExtra(MediaStore.EXTRA_OUTPUT, output);
11672 
11673                 setClipData(ClipData.newRawUri("", output));
11674                 addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
11675                 return true;
11676             }
11677         }
11678 
11679         return false;
11680     }
11681 
maybeConvertFileToContentUri(Context context, Uri uri)11682     private Uri maybeConvertFileToContentUri(Context context, Uri uri) {
11683         if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())
11684                 && context.getApplicationInfo().targetSdkVersion < Build.VERSION_CODES.R) {
11685             File file = new File(uri.getPath());
11686             try {
11687                 if (!file.exists()) file.createNewFile();
11688                 uri = MediaStore.scanFile(context.getContentResolver(), new File(uri.getPath()));
11689                 if (uri != null) {
11690                     return uri;
11691                 }
11692             } catch (IOException e) {
11693                 Log.e(TAG, "Ignoring failure to create file " + file, e);
11694             }
11695         }
11696         return uri;
11697     }
11698 
11699     /**
11700      * Convert the dock state to a human readable format.
11701      * @hide
11702      */
dockStateToString(int dock)11703     public static String dockStateToString(int dock) {
11704         switch (dock) {
11705             case EXTRA_DOCK_STATE_HE_DESK:
11706                 return "EXTRA_DOCK_STATE_HE_DESK";
11707             case EXTRA_DOCK_STATE_LE_DESK:
11708                 return "EXTRA_DOCK_STATE_LE_DESK";
11709             case EXTRA_DOCK_STATE_CAR:
11710                 return "EXTRA_DOCK_STATE_CAR";
11711             case EXTRA_DOCK_STATE_DESK:
11712                 return "EXTRA_DOCK_STATE_DESK";
11713             case EXTRA_DOCK_STATE_UNDOCKED:
11714                 return "EXTRA_DOCK_STATE_UNDOCKED";
11715             default:
11716                 return Integer.toString(dock);
11717         }
11718     }
11719 
makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, ArrayList<String> htmlTexts, int which)11720     private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
11721             ArrayList<String> htmlTexts, int which) {
11722         Uri uri = streams != null ? streams.get(which) : null;
11723         CharSequence text = texts != null ? texts.get(which) : null;
11724         String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
11725         return new ClipData.Item(text, htmlText, null, uri);
11726     }
11727 
11728     /** @hide */
isDocument()11729     public boolean isDocument() {
11730         return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
11731     }
11732 }
11733