• Home
  • History
  • Annotate
  • 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.annotation.AnyRes;
22  import android.annotation.BroadcastBehavior;
23  import android.annotation.IntDef;
24  import android.annotation.NonNull;
25  import android.annotation.Nullable;
26  import android.annotation.RequiresPermission;
27  import android.annotation.SdkConstant;
28  import android.annotation.SdkConstant.SdkConstantType;
29  import android.annotation.SystemApi;
30  import android.annotation.TestApi;
31  import android.annotation.UnsupportedAppUsage;
32  import android.app.AppGlobals;
33  import android.content.pm.ActivityInfo;
34  import android.content.pm.ApplicationInfo;
35  import android.content.pm.ComponentInfo;
36  import android.content.pm.PackageManager;
37  import android.content.pm.ResolveInfo;
38  import android.content.pm.ShortcutInfo;
39  import android.content.res.Resources;
40  import android.content.res.TypedArray;
41  import android.graphics.Rect;
42  import android.net.Uri;
43  import android.os.Build;
44  import android.os.Bundle;
45  import android.os.IBinder;
46  import android.os.IncidentManager;
47  import android.os.Parcel;
48  import android.os.Parcelable;
49  import android.os.PersistableBundle;
50  import android.os.Process;
51  import android.os.ResultReceiver;
52  import android.os.ShellCommand;
53  import android.os.StrictMode;
54  import android.os.UserHandle;
55  import android.os.storage.StorageManager;
56  import android.provider.ContactsContract.QuickContact;
57  import android.provider.DocumentsContract;
58  import android.provider.DocumentsProvider;
59  import android.provider.MediaStore;
60  import android.provider.OpenableColumns;
61  import android.telecom.PhoneAccount;
62  import android.telecom.TelecomManager;
63  import android.text.TextUtils;
64  import android.util.ArraySet;
65  import android.util.AttributeSet;
66  import android.util.Log;
67  import android.util.proto.ProtoOutputStream;
68  
69  import com.android.internal.util.XmlUtils;
70  
71  import org.xmlpull.v1.XmlPullParser;
72  import org.xmlpull.v1.XmlPullParserException;
73  import org.xmlpull.v1.XmlSerializer;
74  
75  import java.io.File;
76  import java.io.IOException;
77  import java.io.PrintWriter;
78  import java.io.Serializable;
79  import java.lang.annotation.Retention;
80  import java.lang.annotation.RetentionPolicy;
81  import java.net.URISyntaxException;
82  import java.util.ArrayList;
83  import java.util.HashSet;
84  import java.util.List;
85  import java.util.Locale;
86  import java.util.Objects;
87  import java.util.Set;
88  
89  /**
90   * An intent is an abstract description of an operation to be performed.  It
91   * can be used with {@link Context#startActivity(Intent) startActivity} to
92   * launch an {@link android.app.Activity},
93   * {@link android.content.Context#sendBroadcast(Intent) broadcastIntent} to
94   * send it to any interested {@link BroadcastReceiver BroadcastReceiver} components,
95   * and {@link android.content.Context#startService} or
96   * {@link android.content.Context#bindService} to communicate with a
97   * background {@link android.app.Service}.
98   *
99   * <p>An Intent provides a facility for performing late runtime binding between the code in
100   * different applications. Its most significant use is in the launching of activities, where it
101   * can be thought of as the glue between activities. It is basically a passive data structure
102   * holding an abstract description of an action to be performed.</p>
103   *
104   * <div class="special reference">
105   * <h3>Developer Guides</h3>
106   * <p>For information about how to create and resolve intents, read the
107   * <a href="{@docRoot}guide/topics/intents/intents-filters.html">Intents and Intent Filters</a>
108   * developer guide.</p>
109   * </div>
110   *
111   * <a name="IntentStructure"></a>
112   * <h3>Intent Structure</h3>
113   * <p>The primary pieces of information in an intent are:</p>
114   *
115   * <ul>
116   *   <li> <p><b>action</b> -- The general action to be performed, such as
117   *     {@link #ACTION_VIEW}, {@link #ACTION_EDIT}, {@link #ACTION_MAIN},
118   *     etc.</p>
119   *   </li>
120   *   <li> <p><b>data</b> -- The data to operate on, such as a person record
121   *     in the contacts database, expressed as a {@link android.net.Uri}.</p>
122   *   </li>
123   * </ul>
124   *
125   *
126   * <p>Some examples of action/data pairs are:</p>
127   *
128   * <ul>
129   *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/1</i></b> -- Display
130   *     information about the person whose identifier is "1".</p>
131   *   </li>
132   *   <li> <p><b>{@link #ACTION_DIAL} <i>content://contacts/people/1</i></b> -- Display
133   *     the phone dialer with the person filled in.</p>
134   *   </li>
135   *   <li> <p><b>{@link #ACTION_VIEW} <i>tel:123</i></b> -- Display
136   *     the phone dialer with the given number filled in.  Note how the
137   *     VIEW action does what is considered the most reasonable thing for
138   *     a particular URI.</p>
139   *   </li>
140   *   <li> <p><b>{@link #ACTION_DIAL} <i>tel:123</i></b> -- Display
141   *     the phone dialer with the given number filled in.</p>
142   *   </li>
143   *   <li> <p><b>{@link #ACTION_EDIT} <i>content://contacts/people/1</i></b> -- Edit
144   *     information about the person whose identifier is "1".</p>
145   *   </li>
146   *   <li> <p><b>{@link #ACTION_VIEW} <i>content://contacts/people/</i></b> -- Display
147   *     a list of people, which the user can browse through.  This example is a
148   *     typical top-level entry into the Contacts application, showing you the
149   *     list of people. Selecting a particular person to view would result in a
150   *     new intent { <b>{@link #ACTION_VIEW} <i>content://contacts/people/N</i></b> }
151   *     being used to start an activity to display that person.</p>
152   *   </li>
153   * </ul>
154   *
155   * <p>In addition to these primary attributes, there are a number of secondary
156   * attributes that you can also include with an intent:</p>
157   *
158   * <ul>
159   *     <li> <p><b>category</b> -- Gives additional information about the action
160   *         to execute.  For example, {@link #CATEGORY_LAUNCHER} means it should
161   *         appear in the Launcher as a top-level application, while
162   *         {@link #CATEGORY_ALTERNATIVE} means it should be included in a list
163   *         of alternative actions the user can perform on a piece of data.</p>
164   *     <li> <p><b>type</b> -- Specifies an explicit type (a MIME type) of the
165   *         intent data.  Normally the type is inferred from the data itself.
166   *         By setting this attribute, you disable that evaluation and force
167   *         an explicit type.</p>
168   *     <li> <p><b>component</b> -- Specifies an explicit name of a component
169   *         class to use for the intent.  Normally this is determined by looking
170   *         at the other information in the intent (the action, data/type, and
171   *         categories) and matching that with a component that can handle it.
172   *         If this attribute is set then none of the evaluation is performed,
173   *         and this component is used exactly as is.  By specifying this attribute,
174   *         all of the other Intent attributes become optional.</p>
175   *     <li> <p><b>extras</b> -- This is a {@link Bundle} of any additional information.
176   *         This can be used to provide extended information to the component.
177   *         For example, if we have a action to send an e-mail message, we could
178   *         also include extra pieces of data here to supply a subject, body,
179   *         etc.</p>
180   * </ul>
181   *
182   * <p>Here are some examples of other operations you can specify as intents
183   * using these additional parameters:</p>
184   *
185   * <ul>
186   *   <li> <p><b>{@link #ACTION_MAIN} with category {@link #CATEGORY_HOME}</b> --
187   *     Launch the home screen.</p>
188   *   </li>
189   *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
190   *     <i>{@link android.provider.Contacts.Phones#CONTENT_URI
191   *     vnd.android.cursor.item/phone}</i></b>
192   *     -- Display the list of people's phone numbers, allowing the user to
193   *     browse through them and pick one and return it to the parent activity.</p>
194   *   </li>
195   *   <li> <p><b>{@link #ACTION_GET_CONTENT} with MIME type
196   *     <i>*{@literal /}*</i> and category {@link #CATEGORY_OPENABLE}</b>
197   *     -- Display all pickers for data that can be opened with
198   *     {@link ContentResolver#openInputStream(Uri) ContentResolver.openInputStream()},
199   *     allowing the user to pick one of them and then some data inside of it
200   *     and returning the resulting URI to the caller.  This can be used,
201   *     for example, in an e-mail application to allow the user to pick some
202   *     data to include as an attachment.</p>
203   *   </li>
204   * </ul>
205   *
206   * <p>There are a variety of standard Intent action and category constants
207   * defined in the Intent class, but applications can also define their own.
208   * These strings use Java-style scoping, to ensure they are unique -- for
209   * example, the standard {@link #ACTION_VIEW} is called
210   * "android.intent.action.VIEW".</p>
211   *
212   * <p>Put together, the set of actions, data types, categories, and extra data
213   * defines a language for the system allowing for the expression of phrases
214   * such as "call john smith's cell".  As applications are added to the system,
215   * they can extend this language by adding new actions, types, and categories, or
216   * they can modify the behavior of existing phrases by supplying their own
217   * activities that handle them.</p>
218   *
219   * <a name="IntentResolution"></a>
220   * <h3>Intent Resolution</h3>
221   *
222   * <p>There are two primary forms of intents you will use.
223   *
224   * <ul>
225   *     <li> <p><b>Explicit Intents</b> have specified a component (via
226   *     {@link #setComponent} or {@link #setClass}), which provides the exact
227   *     class to be run.  Often these will not include any other information,
228   *     simply being a way for an application to launch various internal
229   *     activities it has as the user interacts with the application.
230   *
231   *     <li> <p><b>Implicit Intents</b> have not specified a component;
232   *     instead, they must include enough information for the system to
233   *     determine which of the available components is best to run for that
234   *     intent.
235   * </ul>
236   *
237   * <p>When using implicit intents, given such an arbitrary intent we need to
238   * know what to do with it. This is handled by the process of <em>Intent
239   * resolution</em>, which maps an Intent to an {@link android.app.Activity},
240   * {@link BroadcastReceiver}, or {@link android.app.Service} (or sometimes two or
241   * more activities/receivers) that can handle it.</p>
242   *
243   * <p>The intent resolution mechanism basically revolves around matching an
244   * Intent against all of the &lt;intent-filter&gt; descriptions in the
245   * installed application packages.  (Plus, in the case of broadcasts, any {@link BroadcastReceiver}
246   * objects explicitly registered with {@link Context#registerReceiver}.)  More
247   * details on this can be found in the documentation on the {@link
248   * IntentFilter} class.</p>
249   *
250   * <p>There are three pieces of information in the Intent that are used for
251   * resolution: the action, type, and category.  Using this information, a query
252   * is done on the {@link PackageManager} for a component that can handle the
253   * intent. The appropriate component is determined based on the intent
254   * information supplied in the <code>AndroidManifest.xml</code> file as
255   * follows:</p>
256   *
257   * <ul>
258   *     <li> <p>The <b>action</b>, if given, must be listed by the component as
259   *         one it handles.</p>
260   *     <li> <p>The <b>type</b> is retrieved from the Intent's data, if not
261   *         already supplied in the Intent.  Like the action, if a type is
262   *         included in the intent (either explicitly or implicitly in its
263   *         data), then this must be listed by the component as one it handles.</p>
264   *     <li> For data that is not a <code>content:</code> URI and where no explicit
265   *         type is included in the Intent, instead the <b>scheme</b> of the
266   *         intent data (such as <code>http:</code> or <code>mailto:</code>) is
267   *         considered. Again like the action, if we are matching a scheme it
268   *         must be listed by the component as one it can handle.
269   *     <li> <p>The <b>categories</b>, if supplied, must <em>all</em> be listed
270   *         by the activity as categories it handles.  That is, if you include
271   *         the categories {@link #CATEGORY_LAUNCHER} and
272   *         {@link #CATEGORY_ALTERNATIVE}, then you will only resolve to components
273   *         with an intent that lists <em>both</em> of those categories.
274   *         Activities will very often need to support the
275   *         {@link #CATEGORY_DEFAULT} so that they can be found by
276   *         {@link Context#startActivity Context.startActivity()}.</p>
277   * </ul>
278   *
279   * <p>For example, consider the Note Pad sample application that
280   * allows a user to browse through a list of notes data and view details about
281   * individual items.  Text in italics indicates places where you would replace a
282   * name with one specific to your own package.</p>
283   *
284   * <pre> &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
285   *       package="<i>com.android.notepad</i>"&gt;
286   *     &lt;application android:icon="@drawable/app_notes"
287   *             android:label="@string/app_name"&gt;
288   *
289   *         &lt;provider class=".NotePadProvider"
290   *                 android:authorities="<i>com.google.provider.NotePad</i>" /&gt;
291   *
292   *         &lt;activity class=".NotesList" android:label="@string/title_notes_list"&gt;
293   *             &lt;intent-filter&gt;
294   *                 &lt;action android:name="android.intent.action.MAIN" /&gt;
295   *                 &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
296   *             &lt;/intent-filter&gt;
297   *             &lt;intent-filter&gt;
298   *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
299   *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
300   *                 &lt;action android:name="android.intent.action.PICK" /&gt;
301   *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
302   *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
303   *             &lt;/intent-filter&gt;
304   *             &lt;intent-filter&gt;
305   *                 &lt;action android:name="android.intent.action.GET_CONTENT" /&gt;
306   *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
307   *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
308   *             &lt;/intent-filter&gt;
309   *         &lt;/activity&gt;
310   *
311   *         &lt;activity class=".NoteEditor" android:label="@string/title_note"&gt;
312   *             &lt;intent-filter android:label="@string/resolve_edit"&gt;
313   *                 &lt;action android:name="android.intent.action.VIEW" /&gt;
314   *                 &lt;action android:name="android.intent.action.EDIT" /&gt;
315   *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
316   *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
317   *             &lt;/intent-filter&gt;
318   *
319   *             &lt;intent-filter&gt;
320   *                 &lt;action android:name="android.intent.action.INSERT" /&gt;
321   *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
322   *                 &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
323   *             &lt;/intent-filter&gt;
324   *
325   *         &lt;/activity&gt;
326   *
327   *         &lt;activity class=".TitleEditor" android:label="@string/title_edit_title"
328   *                 android:theme="@android:style/Theme.Dialog"&gt;
329   *             &lt;intent-filter android:label="@string/resolve_title"&gt;
330   *                 &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
331   *                 &lt;category android:name="android.intent.category.DEFAULT" /&gt;
332   *                 &lt;category android:name="android.intent.category.ALTERNATIVE" /&gt;
333   *                 &lt;category android:name="android.intent.category.SELECTED_ALTERNATIVE" /&gt;
334   *                 &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
335   *             &lt;/intent-filter&gt;
336   *         &lt;/activity&gt;
337   *
338   *     &lt;/application&gt;
339   * &lt;/manifest&gt;</pre>
340   *
341   * <p>The first activity,
342   * <code>com.android.notepad.NotesList</code>, serves as our main
343   * entry into the app.  It can do three things as described by its three intent
344   * templates:
345   * <ol>
346   * <li><pre>
347   * &lt;intent-filter&gt;
348   *     &lt;action android:name="{@link #ACTION_MAIN android.intent.action.MAIN}" /&gt;
349   *     &lt;category android:name="{@link #CATEGORY_LAUNCHER android.intent.category.LAUNCHER}" /&gt;
350   * &lt;/intent-filter&gt;</pre>
351   * <p>This provides a top-level entry into the NotePad application: the standard
352   * MAIN action is a main entry point (not requiring any other information in
353   * the Intent), and the LAUNCHER category says that this entry point should be
354   * listed in the application launcher.</p>
355   * <li><pre>
356   * &lt;intent-filter&gt;
357   *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
358   *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
359   *     &lt;action android:name="{@link #ACTION_PICK android.intent.action.PICK}" /&gt;
360   *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
361   *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
362   * &lt;/intent-filter&gt;</pre>
363   * <p>This declares the things that the activity can do on a directory of
364   * notes.  The type being supported is given with the &lt;type&gt; tag, where
365   * <code>vnd.android.cursor.dir/vnd.google.note</code> is a URI from which
366   * a Cursor of zero or more items (<code>vnd.android.cursor.dir</code>) can
367   * be retrieved which holds our note pad data (<code>vnd.google.note</code>).
368   * The activity allows the user to view or edit the directory of data (via
369   * the VIEW and EDIT actions), or to pick a particular note and return it
370   * to the caller (via the PICK action).  Note also the DEFAULT category
371   * supplied here: this is <em>required</em> for the
372   * {@link Context#startActivity Context.startActivity} method to resolve your
373   * activity when its component name is not explicitly specified.</p>
374   * <li><pre>
375   * &lt;intent-filter&gt;
376   *     &lt;action android:name="{@link #ACTION_GET_CONTENT android.intent.action.GET_CONTENT}" /&gt;
377   *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
378   *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
379   * &lt;/intent-filter&gt;</pre>
380   * <p>This filter describes the ability to return to the caller a note selected by
381   * the user without needing to know where it came from.  The data type
382   * <code>vnd.android.cursor.item/vnd.google.note</code> is a URI from which
383   * a Cursor of exactly one (<code>vnd.android.cursor.item</code>) item can
384   * be retrieved which contains our note pad data (<code>vnd.google.note</code>).
385   * The GET_CONTENT action is similar to the PICK action, where the activity
386   * will return to its caller a piece of data selected by the user.  Here,
387   * however, the caller specifies the type of data they desire instead of
388   * the type of data the user will be picking from.</p>
389   * </ol>
390   *
391   * <p>Given these capabilities, the following intents will resolve to the
392   * NotesList activity:</p>
393   *
394   * <ul>
395   *     <li> <p><b>{ action=android.app.action.MAIN }</b> matches all of the
396   *         activities that can be used as top-level entry points into an
397   *         application.</p>
398   *     <li> <p><b>{ action=android.app.action.MAIN,
399   *         category=android.app.category.LAUNCHER }</b> is the actual intent
400   *         used by the Launcher to populate its top-level list.</p>
401   *     <li> <p><b>{ action=android.intent.action.VIEW
402   *          data=content://com.google.provider.NotePad/notes }</b>
403   *         displays a list of all the notes under
404   *         "content://com.google.provider.NotePad/notes", which
405   *         the user can browse through and see the details on.</p>
406   *     <li> <p><b>{ action=android.app.action.PICK
407   *          data=content://com.google.provider.NotePad/notes }</b>
408   *         provides a list of the notes under
409   *         "content://com.google.provider.NotePad/notes", from which
410   *         the user can pick a note whose data URL is returned back to the caller.</p>
411   *     <li> <p><b>{ action=android.app.action.GET_CONTENT
412   *          type=vnd.android.cursor.item/vnd.google.note }</b>
413   *         is similar to the pick action, but allows the caller to specify the
414   *         kind of data they want back so that the system can find the appropriate
415   *         activity to pick something of that data type.</p>
416   * </ul>
417   *
418   * <p>The second activity,
419   * <code>com.android.notepad.NoteEditor</code>, shows the user a single
420   * note entry and allows them to edit it.  It can do two things as described
421   * by its two intent templates:
422   * <ol>
423   * <li><pre>
424   * &lt;intent-filter android:label="@string/resolve_edit"&gt;
425   *     &lt;action android:name="{@link #ACTION_VIEW android.intent.action.VIEW}" /&gt;
426   *     &lt;action android:name="{@link #ACTION_EDIT android.intent.action.EDIT}" /&gt;
427   *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
428   *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
429   * &lt;/intent-filter&gt;</pre>
430   * <p>The first, primary, purpose of this activity is to let the user interact
431   * with a single note, as decribed by the MIME type
432   * <code>vnd.android.cursor.item/vnd.google.note</code>.  The activity can
433   * either VIEW a note or allow the user to EDIT it.  Again we support the
434   * DEFAULT category to allow the activity to be launched without explicitly
435   * specifying its component.</p>
436   * <li><pre>
437   * &lt;intent-filter&gt;
438   *     &lt;action android:name="{@link #ACTION_INSERT android.intent.action.INSERT}" /&gt;
439   *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
440   *     &lt;data android:mimeType="vnd.android.cursor.dir/<i>vnd.google.note</i>" /&gt;
441   * &lt;/intent-filter&gt;</pre>
442   * <p>The secondary use of this activity is to insert a new note entry into
443   * an existing directory of notes.  This is used when the user creates a new
444   * note: the INSERT action is executed on the directory of notes, causing
445   * this activity to run and have the user create the new note data which
446   * it then adds to the content provider.</p>
447   * </ol>
448   *
449   * <p>Given these capabilities, the following intents will resolve to the
450   * NoteEditor activity:</p>
451   *
452   * <ul>
453   *     <li> <p><b>{ action=android.intent.action.VIEW
454   *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
455   *         shows the user the content of note <var>{ID}</var>.</p>
456   *     <li> <p><b>{ action=android.app.action.EDIT
457   *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
458   *         allows the user to edit the content of note <var>{ID}</var>.</p>
459   *     <li> <p><b>{ action=android.app.action.INSERT
460   *          data=content://com.google.provider.NotePad/notes }</b>
461   *         creates a new, empty note in the notes list at
462   *         "content://com.google.provider.NotePad/notes"
463   *         and allows the user to edit it.  If they keep their changes, the URI
464   *         of the newly created note is returned to the caller.</p>
465   * </ul>
466   *
467   * <p>The last activity,
468   * <code>com.android.notepad.TitleEditor</code>, allows the user to
469   * edit the title of a note.  This could be implemented as a class that the
470   * application directly invokes (by explicitly setting its component in
471   * the Intent), but here we show a way you can publish alternative
472   * operations on existing data:</p>
473   *
474   * <pre>
475   * &lt;intent-filter android:label="@string/resolve_title"&gt;
476   *     &lt;action android:name="<i>com.android.notepad.action.EDIT_TITLE</i>" /&gt;
477   *     &lt;category android:name="{@link #CATEGORY_DEFAULT android.intent.category.DEFAULT}" /&gt;
478   *     &lt;category android:name="{@link #CATEGORY_ALTERNATIVE android.intent.category.ALTERNATIVE}" /&gt;
479   *     &lt;category android:name="{@link #CATEGORY_SELECTED_ALTERNATIVE android.intent.category.SELECTED_ALTERNATIVE}" /&gt;
480   *     &lt;data android:mimeType="vnd.android.cursor.item/<i>vnd.google.note</i>" /&gt;
481   * &lt;/intent-filter&gt;</pre>
482   *
483   * <p>In the single intent template here, we
484   * have created our own private action called
485   * <code>com.android.notepad.action.EDIT_TITLE</code> which means to
486   * edit the title of a note.  It must be invoked on a specific note
487   * (data type <code>vnd.android.cursor.item/vnd.google.note</code>) like the previous
488   * view and edit actions, but here displays and edits the title contained
489   * in the note data.
490   *
491   * <p>In addition to supporting the default category as usual, our title editor
492   * also supports two other standard categories: ALTERNATIVE and
493   * SELECTED_ALTERNATIVE.  Implementing
494   * these categories allows others to find the special action it provides
495   * without directly knowing about it, through the
496   * {@link android.content.pm.PackageManager#queryIntentActivityOptions} method, or
497   * more often to build dynamic menu items with
498   * {@link android.view.Menu#addIntentOptions}.  Note that in the intent
499   * template here was also supply an explicit name for the template
500   * (via <code>android:label="@string/resolve_title"</code>) to better control
501   * what the user sees when presented with this activity as an alternative
502   * action to the data they are viewing.
503   *
504   * <p>Given these capabilities, the following intent will resolve to the
505   * TitleEditor activity:</p>
506   *
507   * <ul>
508   *     <li> <p><b>{ action=com.android.notepad.action.EDIT_TITLE
509   *          data=content://com.google.provider.NotePad/notes/<var>{ID}</var> }</b>
510   *         displays and allows the user to edit the title associated
511   *         with note <var>{ID}</var>.</p>
512   * </ul>
513   *
514   * <h3>Standard Activity Actions</h3>
515   *
516   * <p>These are the current standard actions that Intent defines for launching
517   * activities (usually through {@link Context#startActivity}.  The most
518   * important, and by far most frequently used, are {@link #ACTION_MAIN} and
519   * {@link #ACTION_EDIT}.
520   *
521   * <ul>
522   *     <li> {@link #ACTION_MAIN}
523   *     <li> {@link #ACTION_VIEW}
524   *     <li> {@link #ACTION_ATTACH_DATA}
525   *     <li> {@link #ACTION_EDIT}
526   *     <li> {@link #ACTION_PICK}
527   *     <li> {@link #ACTION_CHOOSER}
528   *     <li> {@link #ACTION_GET_CONTENT}
529   *     <li> {@link #ACTION_DIAL}
530   *     <li> {@link #ACTION_CALL}
531   *     <li> {@link #ACTION_SEND}
532   *     <li> {@link #ACTION_SENDTO}
533   *     <li> {@link #ACTION_ANSWER}
534   *     <li> {@link #ACTION_INSERT}
535   *     <li> {@link #ACTION_DELETE}
536   *     <li> {@link #ACTION_RUN}
537   *     <li> {@link #ACTION_SYNC}
538   *     <li> {@link #ACTION_PICK_ACTIVITY}
539   *     <li> {@link #ACTION_SEARCH}
540   *     <li> {@link #ACTION_WEB_SEARCH}
541   *     <li> {@link #ACTION_FACTORY_TEST}
542   * </ul>
543   *
544   * <h3>Standard Broadcast Actions</h3>
545   *
546   * <p>These are the current standard actions that Intent defines for receiving
547   * broadcasts (usually through {@link Context#registerReceiver} or a
548   * &lt;receiver&gt; tag in a manifest).
549   *
550   * <ul>
551   *     <li> {@link #ACTION_TIME_TICK}
552   *     <li> {@link #ACTION_TIME_CHANGED}
553   *     <li> {@link #ACTION_TIMEZONE_CHANGED}
554   *     <li> {@link #ACTION_BOOT_COMPLETED}
555   *     <li> {@link #ACTION_PACKAGE_ADDED}
556   *     <li> {@link #ACTION_PACKAGE_CHANGED}
557   *     <li> {@link #ACTION_PACKAGE_REMOVED}
558   *     <li> {@link #ACTION_PACKAGE_RESTARTED}
559   *     <li> {@link #ACTION_PACKAGE_DATA_CLEARED}
560   *     <li> {@link #ACTION_PACKAGES_SUSPENDED}
561   *     <li> {@link #ACTION_PACKAGES_UNSUSPENDED}
562   *     <li> {@link #ACTION_UID_REMOVED}
563   *     <li> {@link #ACTION_BATTERY_CHANGED}
564   *     <li> {@link #ACTION_POWER_CONNECTED}
565   *     <li> {@link #ACTION_POWER_DISCONNECTED}
566   *     <li> {@link #ACTION_SHUTDOWN}
567   * </ul>
568   *
569   * <h3>Standard Categories</h3>
570   *
571   * <p>These are the current standard categories that can be used to further
572   * clarify an Intent via {@link #addCategory}.
573   *
574   * <ul>
575   *     <li> {@link #CATEGORY_DEFAULT}
576   *     <li> {@link #CATEGORY_BROWSABLE}
577   *     <li> {@link #CATEGORY_TAB}
578   *     <li> {@link #CATEGORY_ALTERNATIVE}
579   *     <li> {@link #CATEGORY_SELECTED_ALTERNATIVE}
580   *     <li> {@link #CATEGORY_LAUNCHER}
581   *     <li> {@link #CATEGORY_INFO}
582   *     <li> {@link #CATEGORY_HOME}
583   *     <li> {@link #CATEGORY_PREFERENCE}
584   *     <li> {@link #CATEGORY_TEST}
585   *     <li> {@link #CATEGORY_CAR_DOCK}
586   *     <li> {@link #CATEGORY_DESK_DOCK}
587   *     <li> {@link #CATEGORY_LE_DESK_DOCK}
588   *     <li> {@link #CATEGORY_HE_DESK_DOCK}
589   *     <li> {@link #CATEGORY_CAR_MODE}
590   *     <li> {@link #CATEGORY_APP_MARKET}
591   *     <li> {@link #CATEGORY_VR_HOME}
592   * </ul>
593   *
594   * <h3>Standard Extra Data</h3>
595   *
596   * <p>These are the current standard fields that can be used as extra data via
597   * {@link #putExtra}.
598   *
599   * <ul>
600   *     <li> {@link #EXTRA_ALARM_COUNT}
601   *     <li> {@link #EXTRA_BCC}
602   *     <li> {@link #EXTRA_CC}
603   *     <li> {@link #EXTRA_CHANGED_COMPONENT_NAME}
604   *     <li> {@link #EXTRA_DATA_REMOVED}
605   *     <li> {@link #EXTRA_DOCK_STATE}
606   *     <li> {@link #EXTRA_DOCK_STATE_HE_DESK}
607   *     <li> {@link #EXTRA_DOCK_STATE_LE_DESK}
608   *     <li> {@link #EXTRA_DOCK_STATE_CAR}
609   *     <li> {@link #EXTRA_DOCK_STATE_DESK}
610   *     <li> {@link #EXTRA_DOCK_STATE_UNDOCKED}
611   *     <li> {@link #EXTRA_DONT_KILL_APP}
612   *     <li> {@link #EXTRA_EMAIL}
613   *     <li> {@link #EXTRA_INITIAL_INTENTS}
614   *     <li> {@link #EXTRA_INTENT}
615   *     <li> {@link #EXTRA_KEY_EVENT}
616   *     <li> {@link #EXTRA_ORIGINATING_URI}
617   *     <li> {@link #EXTRA_PHONE_NUMBER}
618   *     <li> {@link #EXTRA_REFERRER}
619   *     <li> {@link #EXTRA_REMOTE_INTENT_TOKEN}
620   *     <li> {@link #EXTRA_REPLACING}
621   *     <li> {@link #EXTRA_SHORTCUT_ICON}
622   *     <li> {@link #EXTRA_SHORTCUT_ICON_RESOURCE}
623   *     <li> {@link #EXTRA_SHORTCUT_INTENT}
624   *     <li> {@link #EXTRA_STREAM}
625   *     <li> {@link #EXTRA_SHORTCUT_NAME}
626   *     <li> {@link #EXTRA_SUBJECT}
627   *     <li> {@link #EXTRA_TEMPLATE}
628   *     <li> {@link #EXTRA_TEXT}
629   *     <li> {@link #EXTRA_TITLE}
630   *     <li> {@link #EXTRA_UID}
631   * </ul>
632   *
633   * <h3>Flags</h3>
634   *
635   * <p>These are the possible flags that can be used in the Intent via
636   * {@link #setFlags} and {@link #addFlags}.  See {@link #setFlags} for a list
637   * of all possible flags.
638   */
639  public class Intent implements Parcelable, Cloneable {
640      private static final String TAG = "Intent";
641  
642      private static final String ATTR_ACTION = "action";
643      private static final String TAG_CATEGORIES = "categories";
644      private static final String ATTR_CATEGORY = "category";
645      private static final String TAG_EXTRA = "extra";
646      private static final String ATTR_TYPE = "type";
647      private static final String ATTR_IDENTIFIER = "ident";
648      private static final String ATTR_COMPONENT = "component";
649      private static final String ATTR_DATA = "data";
650      private static final String ATTR_FLAGS = "flags";
651  
652      // ---------------------------------------------------------------------
653      // ---------------------------------------------------------------------
654      // Standard intent activity actions (see action variable).
655  
656      /**
657       *  Activity Action: Start as a main entry point, does not expect to
658       *  receive data.
659       *  <p>Input: nothing
660       *  <p>Output: nothing
661       */
662      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
663      public static final String ACTION_MAIN = "android.intent.action.MAIN";
664  
665      /**
666       * Activity Action: Display the data to the user.  This is the most common
667       * action performed on data -- it is the generic action you can use on
668       * a piece of data to get the most reasonable thing to occur.  For example,
669       * when used on a contacts entry it will view the entry; when used on a
670       * mailto: URI it will bring up a compose window filled with the information
671       * supplied by the URI; when used with a tel: URI it will invoke the
672       * dialer.
673       * <p>Input: {@link #getData} is URI from which to retrieve data.
674       * <p>Output: nothing.
675       */
676      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
677      public static final String ACTION_VIEW = "android.intent.action.VIEW";
678  
679      /**
680       * Extra that can be included on activity intents coming from the storage UI
681       * when it launches sub-activities to manage various types of storage.  For example,
682       * it may use {@link #ACTION_VIEW} with a "image/*" MIME type to have an app show
683       * the images on the device, and in that case also include this extra to tell the
684       * app it is coming from the storage UI so should help the user manage storage of
685       * this type.
686       */
687      public static final String EXTRA_FROM_STORAGE = "android.intent.extra.FROM_STORAGE";
688  
689      /**
690       * A synonym for {@link #ACTION_VIEW}, the "standard" action that is
691       * performed on a piece of data.
692       */
693      public static final String ACTION_DEFAULT = ACTION_VIEW;
694  
695      /**
696       * Activity Action: Quick view the data. Launches a quick viewer for
697       * a URI or a list of URIs.
698       * <p>Activities handling this intent action should handle the vast majority of
699       * MIME types rather than only specific ones.
700       * <p>Quick viewers must render the quick view image locally, and must not send
701       * file content outside current device.
702       * <p>Input: {@link #getData} is a mandatory content URI of the item to
703       * preview. {@link #getClipData} contains an optional list of content URIs
704       * if there is more than one item to preview. {@link #EXTRA_INDEX} is an
705       * optional index of the URI in the clip data to show first.
706       * {@link #EXTRA_QUICK_VIEW_FEATURES} is an optional extra indicating the features
707       * that can be shown in the quick view UI.
708       * <p>Output: nothing.
709       * @see #EXTRA_INDEX
710       * @see #EXTRA_QUICK_VIEW_FEATURES
711       */
712      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
713      public static final String ACTION_QUICK_VIEW = "android.intent.action.QUICK_VIEW";
714  
715      /**
716       * Used to indicate that some piece of data should be attached to some other
717       * place.  For example, image data could be attached to a contact.  It is up
718       * to the recipient to decide where the data should be attached; the intent
719       * does not specify the ultimate destination.
720       * <p>Input: {@link #getData} is URI of data to be attached.
721       * <p>Output: nothing.
722       */
723      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
724      public static final String ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
725  
726      /**
727       * Activity Action: Provide explicit editable access to the given data.
728       * <p>Input: {@link #getData} is URI of data to be edited.
729       * <p>Output: nothing.
730       */
731      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
732      public static final String ACTION_EDIT = "android.intent.action.EDIT";
733  
734      /**
735       * Activity Action: Pick an existing item, or insert a new item, and then edit it.
736       * <p>Input: {@link #getType} is the desired MIME type of the item to create or edit.
737       * The extras can contain type specific data to pass through to the editing/creating
738       * activity.
739       * <p>Output: The URI of the item that was picked.  This must be a content:
740       * URI so that any receiver can access it.
741       */
742      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
743      public static final String ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
744  
745      /**
746       * Activity Action: Pick an item from the data, returning what was selected.
747       * <p>Input: {@link #getData} is URI containing a directory of data
748       * (vnd.android.cursor.dir/*) from which to pick an item.
749       * <p>Output: The URI of the item that was picked.
750       */
751      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
752      public static final String ACTION_PICK = "android.intent.action.PICK";
753  
754      /**
755       * Activity Action: Creates a shortcut.
756       * <p>Input: Nothing.</p>
757       * <p>Output: An Intent representing the {@link android.content.pm.ShortcutInfo} result.</p>
758       * <p>For compatibility with older versions of android the intent may also contain three
759       * extras: SHORTCUT_INTENT (value: Intent), SHORTCUT_NAME (value: String),
760       * and SHORTCUT_ICON (value: Bitmap) or SHORTCUT_ICON_RESOURCE
761       * (value: ShortcutIconResource).</p>
762       *
763       * @see android.content.pm.ShortcutManager#createShortcutResultIntent
764       * @see #EXTRA_SHORTCUT_INTENT
765       * @see #EXTRA_SHORTCUT_NAME
766       * @see #EXTRA_SHORTCUT_ICON
767       * @see #EXTRA_SHORTCUT_ICON_RESOURCE
768       * @see android.content.Intent.ShortcutIconResource
769       */
770      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
771      public static final String ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
772  
773      /**
774       * The name of the extra used to define the Intent of a shortcut.
775       *
776       * @see #ACTION_CREATE_SHORTCUT
777       * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
778       */
779      @Deprecated
780      public static final String EXTRA_SHORTCUT_INTENT = "android.intent.extra.shortcut.INTENT";
781      /**
782       * The name of the extra used to define the name of a shortcut.
783       *
784       * @see #ACTION_CREATE_SHORTCUT
785       * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
786       */
787      @Deprecated
788      public static final String EXTRA_SHORTCUT_NAME = "android.intent.extra.shortcut.NAME";
789      /**
790       * The name of the extra used to define the icon, as a Bitmap, of a shortcut.
791       *
792       * @see #ACTION_CREATE_SHORTCUT
793       * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
794       */
795      @Deprecated
796      public static final String EXTRA_SHORTCUT_ICON = "android.intent.extra.shortcut.ICON";
797      /**
798       * The name of the extra used to define the icon, as a ShortcutIconResource, of a shortcut.
799       *
800       * @see #ACTION_CREATE_SHORTCUT
801       * @see android.content.Intent.ShortcutIconResource
802       * @deprecated Replaced with {@link android.content.pm.ShortcutManager#createShortcutResultIntent}
803       */
804      @Deprecated
805      public static final String EXTRA_SHORTCUT_ICON_RESOURCE =
806              "android.intent.extra.shortcut.ICON_RESOURCE";
807  
808      /**
809       * An activity that provides a user interface for adjusting application preferences.
810       * Optional but recommended settings for all applications which have settings.
811       */
812      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
813      public static final String ACTION_APPLICATION_PREFERENCES
814              = "android.intent.action.APPLICATION_PREFERENCES";
815  
816      /**
817       * Activity Action: Launch an activity showing the app information.
818       * For applications which install other applications (such as app stores), it is recommended
819       * to handle this action for providing the app information to the user.
820       *
821       * <p>Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose information needs
822       * to be displayed.
823       * <p>Output: Nothing.
824       */
825      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
826      public static final String ACTION_SHOW_APP_INFO
827              = "android.intent.action.SHOW_APP_INFO";
828  
829      /**
830       * Represents a shortcut/live folder icon resource.
831       *
832       * @see Intent#ACTION_CREATE_SHORTCUT
833       * @see Intent#EXTRA_SHORTCUT_ICON_RESOURCE
834       * @see android.provider.LiveFolders#ACTION_CREATE_LIVE_FOLDER
835       * @see android.provider.LiveFolders#EXTRA_LIVE_FOLDER_ICON
836       */
837      public static class ShortcutIconResource implements Parcelable {
838          /**
839           * The package name of the application containing the icon.
840           */
841          public String packageName;
842  
843          /**
844           * The resource name of the icon, including package, name and type.
845           */
846          public String resourceName;
847  
848          /**
849           * Creates a new ShortcutIconResource for the specified context and resource
850           * identifier.
851           *
852           * @param context The context of the application.
853           * @param resourceId The resource identifier for the icon.
854           * @return A new ShortcutIconResource with the specified's context package name
855           *         and icon resource identifier.``
856           */
fromContext(Context context, @AnyRes int resourceId)857          public static ShortcutIconResource fromContext(Context context, @AnyRes int resourceId) {
858              ShortcutIconResource icon = new ShortcutIconResource();
859              icon.packageName = context.getPackageName();
860              icon.resourceName = context.getResources().getResourceName(resourceId);
861              return icon;
862          }
863  
864          /**
865           * Used to read a ShortcutIconResource from a Parcel.
866           */
867          public static final @android.annotation.NonNull Parcelable.Creator<ShortcutIconResource> CREATOR =
868              new Parcelable.Creator<ShortcutIconResource>() {
869  
870                  public ShortcutIconResource createFromParcel(Parcel source) {
871                      ShortcutIconResource icon = new ShortcutIconResource();
872                      icon.packageName = source.readString();
873                      icon.resourceName = source.readString();
874                      return icon;
875                  }
876  
877                  public ShortcutIconResource[] newArray(int size) {
878                      return new ShortcutIconResource[size];
879                  }
880              };
881  
882          /**
883           * No special parcel contents.
884           */
describeContents()885          public int describeContents() {
886              return 0;
887          }
888  
writeToParcel(Parcel dest, int flags)889          public void writeToParcel(Parcel dest, int flags) {
890              dest.writeString(packageName);
891              dest.writeString(resourceName);
892          }
893  
894          @Override
toString()895          public String toString() {
896              return resourceName;
897          }
898      }
899  
900      /**
901       * Activity Action: Display an activity chooser, allowing the user to pick
902       * what they want to before proceeding.  This can be used as an alternative
903       * to the standard activity picker that is displayed by the system when
904       * you try to start an activity with multiple possible matches, with these
905       * differences in behavior:
906       * <ul>
907       * <li>You can specify the title that will appear in the activity chooser.
908       * <li>The user does not have the option to make one of the matching
909       * activities a preferred activity, and all possible activities will
910       * always be shown even if one of them is currently marked as the
911       * preferred activity.
912       * </ul>
913       * <p>
914       * This action should be used when the user will naturally expect to
915       * select an activity in order to proceed.  An example if when not to use
916       * it is when the user clicks on a "mailto:" link.  They would naturally
917       * expect to go directly to their mail app, so startActivity() should be
918       * called directly: it will
919       * either launch the current preferred app, or put up a dialog allowing the
920       * user to pick an app to use and optionally marking that as preferred.
921       * <p>
922       * In contrast, if the user is selecting a menu item to send a picture
923       * they are viewing to someone else, there are many different things they
924       * may want to do at this point: send it through e-mail, upload it to a
925       * web service, etc.  In this case the CHOOSER action should be used, to
926       * always present to the user a list of the things they can do, with a
927       * nice title given by the caller such as "Send this photo with:".
928       * <p>
929       * If you need to grant URI permissions through a chooser, you must specify
930       * the permissions to be granted on the ACTION_CHOOSER Intent
931       * <em>in addition</em> to the EXTRA_INTENT inside.  This means using
932       * {@link #setClipData} to specify the URIs to be granted as well as
933       * {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
934       * {@link #FLAG_GRANT_WRITE_URI_PERMISSION} as appropriate.
935       * <p>
936       * As a convenience, an Intent of this form can be created with the
937       * {@link #createChooser} function.
938       * <p>
939       * Input: No data should be specified.  get*Extra must have
940       * a {@link #EXTRA_INTENT} field containing the Intent being executed,
941       * and can optionally have a {@link #EXTRA_TITLE} field containing the
942       * title text to display in the chooser.
943       * <p>
944       * Output: Depends on the protocol of {@link #EXTRA_INTENT}.
945       */
946      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
947      public static final String ACTION_CHOOSER = "android.intent.action.CHOOSER";
948  
949      /**
950       * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
951       *
952       * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
953       * target intent, also optionally supplying a title.  If the target
954       * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
955       * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
956       * set in the returned chooser intent, with its ClipData set appropriately:
957       * either a direct reflection of {@link #getClipData()} if that is non-null,
958       * or a new ClipData built from {@link #getData()}.
959       *
960       * @param target The Intent that the user will be selecting an activity
961       * to perform.
962       * @param title Optional title that will be displayed in the chooser,
963       * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
964       * @return Return a new Intent object that you can hand to
965       * {@link Context#startActivity(Intent) Context.startActivity()} and
966       * related methods.
967       */
createChooser(Intent target, CharSequence title)968      public static Intent createChooser(Intent target, CharSequence title) {
969          return createChooser(target, title, null);
970      }
971  
972      /**
973       * Convenience function for creating a {@link #ACTION_CHOOSER} Intent.
974       *
975       * <p>Builds a new {@link #ACTION_CHOOSER} Intent that wraps the given
976       * target intent, also optionally supplying a title.  If the target
977       * intent has specified {@link #FLAG_GRANT_READ_URI_PERMISSION} or
978       * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, then these flags will also be
979       * set in the returned chooser intent, with its ClipData set appropriately:
980       * either a direct reflection of {@link #getClipData()} if that is non-null,
981       * or a new ClipData built from {@link #getData()}.</p>
982       *
983       * <p>The caller may optionally supply an {@link IntentSender} to receive a callback
984       * when the user makes a choice. This can be useful if the calling application wants
985       * to remember the last chosen target and surface it as a more prominent or one-touch
986       * affordance elsewhere in the UI for next time.</p>
987       *
988       * @param target The Intent that the user will be selecting an activity
989       * to perform.
990       * @param title Optional title that will be displayed in the chooser,
991       * only when the target action is not ACTION_SEND or ACTION_SEND_MULTIPLE.
992       * @param sender Optional IntentSender to be called when a choice is made.
993       * @return Return a new Intent object that you can hand to
994       * {@link Context#startActivity(Intent) Context.startActivity()} and
995       * related methods.
996       */
createChooser(Intent target, CharSequence title, IntentSender sender)997      public static Intent createChooser(Intent target, CharSequence title, IntentSender sender) {
998          Intent intent = new Intent(ACTION_CHOOSER);
999          intent.putExtra(EXTRA_INTENT, target);
1000          if (title != null) {
1001              intent.putExtra(EXTRA_TITLE, title);
1002          }
1003  
1004          if (sender != null) {
1005              intent.putExtra(EXTRA_CHOSEN_COMPONENT_INTENT_SENDER, sender);
1006          }
1007  
1008          // Migrate any clip data and flags from target.
1009          int permFlags = target.getFlags() & (FLAG_GRANT_READ_URI_PERMISSION
1010                  | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
1011                  | FLAG_GRANT_PREFIX_URI_PERMISSION);
1012          if (permFlags != 0) {
1013              ClipData targetClipData = target.getClipData();
1014              if (targetClipData == null && target.getData() != null) {
1015                  ClipData.Item item = new ClipData.Item(target.getData());
1016                  String[] mimeTypes;
1017                  if (target.getType() != null) {
1018                      mimeTypes = new String[] { target.getType() };
1019                  } else {
1020                      mimeTypes = new String[] { };
1021                  }
1022                  targetClipData = new ClipData(null, mimeTypes, item);
1023              }
1024              if (targetClipData != null) {
1025                  intent.setClipData(targetClipData);
1026                  intent.addFlags(permFlags);
1027              }
1028          }
1029  
1030          return intent;
1031      }
1032  
1033      /**
1034       * Activity Action: Allow the user to select a particular kind of data and
1035       * return it.  This is different than {@link #ACTION_PICK} in that here we
1036       * just say what kind of data is desired, not a URI of existing data from
1037       * which the user can pick.  An ACTION_GET_CONTENT could allow the user to
1038       * create the data as it runs (for example taking a picture or recording a
1039       * sound), let them browse over the web and download the desired data,
1040       * etc.
1041       * <p>
1042       * There are two main ways to use this action: if you want a specific kind
1043       * of data, such as a person contact, you set the MIME type to the kind of
1044       * data you want and launch it with {@link Context#startActivity(Intent)}.
1045       * The system will then launch the best application to select that kind
1046       * of data for you.
1047       * <p>
1048       * You may also be interested in any of a set of types of content the user
1049       * can pick.  For example, an e-mail application that wants to allow the
1050       * user to add an attachment to an e-mail message can use this action to
1051       * bring up a list of all of the types of content the user can attach.
1052       * <p>
1053       * In this case, you should wrap the GET_CONTENT intent with a chooser
1054       * (through {@link #createChooser}), which will give the proper interface
1055       * for the user to pick how to send your data and allow you to specify
1056       * a prompt indicating what they are doing.  You will usually specify a
1057       * broad MIME type (such as image/* or {@literal *}/*), resulting in a
1058       * broad range of content types the user can select from.
1059       * <p>
1060       * When using such a broad GET_CONTENT action, it is often desirable to
1061       * only pick from data that can be represented as a stream.  This is
1062       * accomplished by requiring the {@link #CATEGORY_OPENABLE} in the Intent.
1063       * <p>
1064       * Callers can optionally specify {@link #EXTRA_LOCAL_ONLY} to request that
1065       * the launched content chooser only returns results representing data that
1066       * is locally available on the device.  For example, if this extra is set
1067       * to true then an image picker should not show any pictures that are available
1068       * from a remote server but not already on the local device (thus requiring
1069       * they be downloaded when opened).
1070       * <p>
1071       * If the caller can handle multiple returned items (the user performing
1072       * multiple selection), then it can specify {@link #EXTRA_ALLOW_MULTIPLE}
1073       * to indicate this.
1074       * <p>
1075       * Input: {@link #getType} is the desired MIME type to retrieve.  Note
1076       * that no URI is supplied in the intent, as there are no constraints on
1077       * where the returned data originally comes from.  You may also include the
1078       * {@link #CATEGORY_OPENABLE} if you can only accept data that can be
1079       * opened as a stream.  You may use {@link #EXTRA_LOCAL_ONLY} to limit content
1080       * selection to local data.  You may use {@link #EXTRA_ALLOW_MULTIPLE} to
1081       * allow the user to select multiple items.
1082       * <p>
1083       * Output: The URI of the item that was picked.  This must be a content:
1084       * URI so that any receiver can access it.
1085       */
1086      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1087      public static final String ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
1088      /**
1089       * Activity Action: Dial a number as specified by the data.  This shows a
1090       * UI with the number being dialed, allowing the user to explicitly
1091       * initiate the call.
1092       * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1093       * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1094       * number.
1095       * <p>Output: nothing.
1096       */
1097      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1098      public static final String ACTION_DIAL = "android.intent.action.DIAL";
1099      /**
1100       * Activity Action: Perform a call to someone specified by the data.
1101       * <p>Input: If nothing, an empty dialer is started; else {@link #getData}
1102       * is URI of a phone number to be dialed or a tel: URI of an explicit phone
1103       * number.
1104       * <p>Output: nothing.
1105       *
1106       * <p>Note: there will be restrictions on which applications can initiate a
1107       * call; most applications should use the {@link #ACTION_DIAL}.
1108       * <p>Note: this Intent <strong>cannot</strong> be used to call emergency
1109       * numbers.  Applications can <strong>dial</strong> emergency numbers using
1110       * {@link #ACTION_DIAL}, however.
1111       *
1112       * <p>Note: if you app targets {@link android.os.Build.VERSION_CODES#M M}
1113       * and above and declares as using the {@link android.Manifest.permission#CALL_PHONE}
1114       * permission which is not granted, then attempting to use this action will
1115       * result in a {@link java.lang.SecurityException}.
1116       */
1117      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1118      public static final String ACTION_CALL = "android.intent.action.CALL";
1119      /**
1120       * Activity Action: Perform a call to an emergency number specified by the
1121       * data.
1122       * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1123       * tel: URI of an explicit phone number.
1124       * <p>Output: nothing.
1125       *
1126       * <p class="note"><strong>Note:</strong> It is not guaranteed that the call will be placed on
1127       * the {@link PhoneAccount} provided in the {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE}
1128       * extra (if specified) and may be placed on another {@link PhoneAccount} with the
1129       * {@link PhoneAccount#CAPABILITY_PLACE_EMERGENCY_CALLS} capability, depending on external
1130       * factors, such as network conditions and Modem/SIM status.
1131       * @hide
1132       */
1133      @SystemApi
1134      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1135      public static final String ACTION_CALL_EMERGENCY = "android.intent.action.CALL_EMERGENCY";
1136      /**
1137       * Activity action: Perform a call to any number (emergency or not)
1138       * specified by the data.
1139       * <p>Input: {@link #getData} is URI of a phone number to be dialed or a
1140       * tel: URI of an explicit phone number.
1141       * <p>Output: nothing.
1142       * @hide
1143       */
1144      @SystemApi
1145      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1146      public static final String ACTION_CALL_PRIVILEGED = "android.intent.action.CALL_PRIVILEGED";
1147  
1148      /**
1149       * Activity Action: Main entry point for carrier setup apps.
1150       * <p>Carrier apps that provide an implementation for this action may be invoked to configure
1151       * carrier service and typically require
1152       * {@link android.telephony.TelephonyManager#hasCarrierPrivileges() carrier privileges} to
1153       * fulfill their duties.
1154       */
1155      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1156      public static final String ACTION_CARRIER_SETUP = "android.intent.action.CARRIER_SETUP";
1157      /**
1158       * Activity Action: Send a message to someone specified by the data.
1159       * <p>Input: {@link #getData} is URI describing the target.
1160       * <p>Output: nothing.
1161       */
1162      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1163      public static final String ACTION_SENDTO = "android.intent.action.SENDTO";
1164      /**
1165       * Activity Action: Deliver some data to someone else.  Who the data is
1166       * being delivered to is not specified; it is up to the receiver of this
1167       * action to ask the user where the data should be sent.
1168       * <p>
1169       * When launching a SEND intent, you should usually wrap it in a chooser
1170       * (through {@link #createChooser}), which will give the proper interface
1171       * for the user to pick how to send your data and allow you to specify
1172       * a prompt indicating what they are doing.
1173       * <p>
1174       * Input: {@link #getType} is the MIME type of the data being sent.
1175       * get*Extra can have either a {@link #EXTRA_TEXT}
1176       * or {@link #EXTRA_STREAM} field, containing the data to be sent.  If
1177       * using EXTRA_TEXT, the MIME type should be "text/plain"; otherwise it
1178       * should be the MIME type of the data in EXTRA_STREAM.  Use {@literal *}/*
1179       * if the MIME type is unknown (this will only allow senders that can
1180       * handle generic data streams).  If using {@link #EXTRA_TEXT}, you can
1181       * also optionally supply {@link #EXTRA_HTML_TEXT} for clients to retrieve
1182       * your text with HTML formatting.
1183       * <p>
1184       * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1185       * being sent can be supplied through {@link #setClipData(ClipData)}.  This
1186       * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1187       * content: URIs and other advanced features of {@link ClipData}.  If
1188       * using this approach, you still must supply the same data through the
1189       * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1190       * for compatibility with old applications.  If you don't set a ClipData,
1191       * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1192       * <p>
1193       * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1194       * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1195       * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1196       * be openable only as asset typed files using
1197       * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1198       * <p>
1199       * Optional standard extras, which may be interpreted by some recipients as
1200       * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1201       * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1202       * <p>
1203       * Output: nothing.
1204       */
1205      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1206      public static final String ACTION_SEND = "android.intent.action.SEND";
1207      /**
1208       * Activity Action: Deliver multiple data to someone else.
1209       * <p>
1210       * Like {@link #ACTION_SEND}, except the data is multiple.
1211       * <p>
1212       * Input: {@link #getType} is the MIME type of the data being sent.
1213       * get*ArrayListExtra can have either a {@link #EXTRA_TEXT} or {@link
1214       * #EXTRA_STREAM} field, containing the data to be sent.  If using
1215       * {@link #EXTRA_TEXT}, you can also optionally supply {@link #EXTRA_HTML_TEXT}
1216       * for clients to retrieve your text with HTML formatting.
1217       * <p>
1218       * Multiple types are supported, and receivers should handle mixed types
1219       * whenever possible. The right way for the receiver to check them is to
1220       * use the content resolver on each URI. The intent sender should try to
1221       * put the most concrete mime type in the intent type, but it can fall
1222       * back to {@literal <type>/*} or {@literal *}/* as needed.
1223       * <p>
1224       * e.g. if you are sending image/jpg and image/jpg, the intent's type can
1225       * be image/jpg, but if you are sending image/jpg and image/png, then the
1226       * intent's type should be image/*.
1227       * <p>
1228       * As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, the data
1229       * being sent can be supplied through {@link #setClipData(ClipData)}.  This
1230       * allows you to use {@link #FLAG_GRANT_READ_URI_PERMISSION} when sharing
1231       * content: URIs and other advanced features of {@link ClipData}.  If
1232       * using this approach, you still must supply the same data through the
1233       * {@link #EXTRA_TEXT} or {@link #EXTRA_STREAM} fields described below
1234       * for compatibility with old applications.  If you don't set a ClipData,
1235       * it will be copied there for you when calling {@link Context#startActivity(Intent)}.
1236       * <p>
1237       * Starting from {@link android.os.Build.VERSION_CODES#O}, if
1238       * {@link #CATEGORY_TYPED_OPENABLE} is passed, then the Uris passed in
1239       * either {@link #EXTRA_STREAM} or via {@link #setClipData(ClipData)} may
1240       * be openable only as asset typed files using
1241       * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}.
1242       * <p>
1243       * Optional standard extras, which may be interpreted by some recipients as
1244       * appropriate, are: {@link #EXTRA_EMAIL}, {@link #EXTRA_CC},
1245       * {@link #EXTRA_BCC}, {@link #EXTRA_SUBJECT}.
1246       * <p>
1247       * Output: nothing.
1248       */
1249      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1250      public static final String ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
1251      /**
1252       * Activity Action: Handle an incoming phone call.
1253       * <p>Input: nothing.
1254       * <p>Output: nothing.
1255       */
1256      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1257      public static final String ACTION_ANSWER = "android.intent.action.ANSWER";
1258      /**
1259       * Activity Action: Insert an empty item into the given container.
1260       * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1261       * in which to place the data.
1262       * <p>Output: URI of the new data that was created.
1263       */
1264      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1265      public static final String ACTION_INSERT = "android.intent.action.INSERT";
1266      /**
1267       * Activity Action: Create a new item in the given container, initializing it
1268       * from the current contents of the clipboard.
1269       * <p>Input: {@link #getData} is URI of the directory (vnd.android.cursor.dir/*)
1270       * in which to place the data.
1271       * <p>Output: URI of the new data that was created.
1272       */
1273      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1274      public static final String ACTION_PASTE = "android.intent.action.PASTE";
1275      /**
1276       * Activity Action: Delete the given data from its container.
1277       * <p>Input: {@link #getData} is URI of data to be deleted.
1278       * <p>Output: nothing.
1279       */
1280      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1281      public static final String ACTION_DELETE = "android.intent.action.DELETE";
1282      /**
1283       * Activity Action: Run the data, whatever that means.
1284       * <p>Input: ?  (Note: this is currently specific to the test harness.)
1285       * <p>Output: nothing.
1286       */
1287      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1288      public static final String ACTION_RUN = "android.intent.action.RUN";
1289      /**
1290       * Activity Action: Perform a data synchronization.
1291       * <p>Input: ?
1292       * <p>Output: ?
1293       */
1294      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1295      public static final String ACTION_SYNC = "android.intent.action.SYNC";
1296      /**
1297       * Activity Action: Pick an activity given an intent, returning the class
1298       * selected.
1299       * <p>Input: get*Extra field {@link #EXTRA_INTENT} is an Intent
1300       * used with {@link PackageManager#queryIntentActivities} to determine the
1301       * set of activities from which to pick.
1302       * <p>Output: Class name of the activity that was selected.
1303       */
1304      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1305      public static final String ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
1306      /**
1307       * Activity Action: Perform a search.
1308       * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1309       * is the text to search for.  If empty, simply
1310       * enter your search results Activity with the search UI activated.
1311       * <p>Output: nothing.
1312       */
1313      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1314      public static final String ACTION_SEARCH = "android.intent.action.SEARCH";
1315      /**
1316       * Activity Action: Start the platform-defined tutorial
1317       * <p>Input: {@link android.app.SearchManager#QUERY getStringExtra(SearchManager.QUERY)}
1318       * is the text to search for.  If empty, simply
1319       * enter your search results Activity with the search UI activated.
1320       * <p>Output: nothing.
1321       */
1322      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1323      public static final String ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
1324      /**
1325       * Activity Action: Perform a web search.
1326       * <p>
1327       * Input: {@link android.app.SearchManager#QUERY
1328       * getStringExtra(SearchManager.QUERY)} is the text to search for. If it is
1329       * a url starts with http or https, the site will be opened. If it is plain
1330       * text, Google search will be applied.
1331       * <p>
1332       * Output: nothing.
1333       */
1334      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1335      public static final String ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
1336  
1337      /**
1338       * Activity Action: Perform assist action.
1339       * <p>
1340       * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1341       * additional optional contextual information about where the user was when they
1342       * requested the assist; {@link #EXTRA_REFERRER} may be set with additional referrer
1343       * information.
1344       * Output: nothing.
1345       */
1346      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1347      public static final String ACTION_ASSIST = "android.intent.action.ASSIST";
1348  
1349      /**
1350       * Activity Action: Perform voice assist action.
1351       * <p>
1352       * Input: {@link #EXTRA_ASSIST_PACKAGE}, {@link #EXTRA_ASSIST_CONTEXT}, can provide
1353       * additional optional contextual information about where the user was when they
1354       * requested the voice assist.
1355       * Output: nothing.
1356       * @hide
1357       */
1358      @SystemApi
1359      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1360      public static final String ACTION_VOICE_ASSIST = "android.intent.action.VOICE_ASSIST";
1361  
1362      /**
1363       * An optional field on {@link #ACTION_ASSIST} containing the name of the current foreground
1364       * application package at the time the assist was invoked.
1365       */
1366      public static final String EXTRA_ASSIST_PACKAGE
1367              = "android.intent.extra.ASSIST_PACKAGE";
1368  
1369      /**
1370       * An optional field on {@link #ACTION_ASSIST} containing the uid of the current foreground
1371       * application package at the time the assist was invoked.
1372       */
1373      public static final String EXTRA_ASSIST_UID
1374              = "android.intent.extra.ASSIST_UID";
1375  
1376      /**
1377       * An optional field on {@link #ACTION_ASSIST} and containing additional contextual
1378       * information supplied by the current foreground app at the time of the assist request.
1379       * This is a {@link Bundle} of additional data.
1380       */
1381      public static final String EXTRA_ASSIST_CONTEXT
1382              = "android.intent.extra.ASSIST_CONTEXT";
1383  
1384      /**
1385       * An optional field on {@link #ACTION_ASSIST} suggesting that the user will likely use a
1386       * keyboard as the primary input device for assistance.
1387       */
1388      public static final String EXTRA_ASSIST_INPUT_HINT_KEYBOARD =
1389              "android.intent.extra.ASSIST_INPUT_HINT_KEYBOARD";
1390  
1391      /**
1392       * An optional field on {@link #ACTION_ASSIST} containing the InputDevice id
1393       * that was used to invoke the assist.
1394       */
1395      public static final String EXTRA_ASSIST_INPUT_DEVICE_ID =
1396              "android.intent.extra.ASSIST_INPUT_DEVICE_ID";
1397  
1398      /**
1399       * Activity Action: List all available applications.
1400       * <p>Input: Nothing.
1401       * <p>Output: nothing.
1402       */
1403      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1404      public static final String ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
1405      /**
1406       * Activity Action: Show settings for choosing wallpaper.
1407       * <p>Input: Nothing.
1408       * <p>Output: Nothing.
1409       */
1410      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1411      public static final String ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
1412  
1413      /**
1414       * Activity Action: Show activity for reporting a bug.
1415       * <p>Input: Nothing.
1416       * <p>Output: Nothing.
1417       */
1418      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1419      public static final String ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
1420  
1421      /**
1422       *  Activity Action: Main entry point for factory tests.  Only used when
1423       *  the device is booting in factory test node.  The implementing package
1424       *  must be installed in the system image.
1425       *  <p>Input: nothing
1426       *  <p>Output: nothing
1427       */
1428      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1429      public static final String ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
1430  
1431      /**
1432       * Activity Action: The user pressed the "call" button to go to the dialer
1433       * or other appropriate UI for placing a call.
1434       * <p>Input: Nothing.
1435       * <p>Output: Nothing.
1436       */
1437      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1438      public static final String ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
1439  
1440      /**
1441       * Activity Action: Start Voice Command.
1442       * <p>Input: Nothing.
1443       * <p>Output: Nothing.
1444       * <p class="note">
1445       * In some cases, a matching Activity may not exist, so ensure you
1446       * safeguard against this.
1447       */
1448      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1449      public static final String ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
1450  
1451      /**
1452       * Activity Action: Start action associated with long pressing on the
1453       * search key.
1454       * <p>Input: Nothing.
1455       * <p>Output: Nothing.
1456       */
1457      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1458      public static final String ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
1459  
1460      /**
1461       * Activity Action: The user pressed the "Report" button in the crash/ANR dialog.
1462       * This intent is delivered to the package which installed the application, usually
1463       * Google Play.
1464       * <p>Input: No data is specified. The bug report is passed in using
1465       * an {@link #EXTRA_BUG_REPORT} field.
1466       * <p>Output: Nothing.
1467       *
1468       * @see #EXTRA_BUG_REPORT
1469       */
1470      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1471      public static final String ACTION_APP_ERROR = "android.intent.action.APP_ERROR";
1472  
1473      /**
1474       * An incident or bug report has been taken, and a system app has requested it to be shared,
1475       * so trigger the confirmation screen.
1476       *
1477       * This will be sent directly to the registered receiver with the
1478       * android.permission.APPROVE_INCIDENT_REPORTS permission.
1479       * @hide
1480       */
1481      @SystemApi
1482      public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED =
1483              "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED";
1484  
1485      /**
1486       * An incident report has been taken, and the user has approved it for sharing.
1487       * <p>
1488       * This will be sent directly to the registered receiver, which must have
1489       * both the DUMP and USAGE_STATS permissions.
1490       * <p>
1491       * After receiving this, the application should wait until a suitable time
1492       * (e.g. network available), get the list of available reports with
1493       * {@link IncidentManager#getIncidentReportList IncidentManager.getIncidentReportList(String)}
1494       * and then when the reports have been successfully uploaded, call
1495       * {@link IncidentManager#deleteIncidentReport IncidentManager.deleteIncidentReport(Uri)}.
1496       *
1497       * @hide
1498       */
1499      @SystemApi
1500      public static final String ACTION_INCIDENT_REPORT_READY =
1501              "android.intent.action.INCIDENT_REPORT_READY";
1502  
1503      /**
1504       * Activity Action: Show power usage information to the user.
1505       * <p>Input: Nothing.
1506       * <p>Output: Nothing.
1507       */
1508      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1509      public static final String ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
1510  
1511      /**
1512       * Activity Action: Setup wizard action provided for OTA provisioning to determine if it needs
1513       * to run.
1514       * <p>Input: Nothing.
1515       * <p>Output: Nothing.
1516       * @deprecated As of {@link android.os.Build.VERSION_CODES#M}, setup wizard can be identified
1517       * using {@link #ACTION_MAIN} and {@link #CATEGORY_SETUP_WIZARD}
1518       * @hide
1519       * @removed
1520       */
1521      @Deprecated
1522      @SystemApi
1523      public static final String ACTION_DEVICE_INITIALIZATION_WIZARD =
1524              "android.intent.action.DEVICE_INITIALIZATION_WIZARD";
1525  
1526      /**
1527       * Activity Action: Setup wizard to launch after a platform update.  This
1528       * activity should have a string meta-data field associated with it,
1529       * {@link #METADATA_SETUP_VERSION}, which defines the current version of
1530       * the platform for setup.  The activity will be launched only if
1531       * {@link android.provider.Settings.Secure#LAST_SETUP_SHOWN} is not the
1532       * same value.
1533       * <p>Input: Nothing.
1534       * <p>Output: Nothing.
1535       * @hide
1536       */
1537      @SystemApi
1538      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1539      public static final String ACTION_UPGRADE_SETUP = "android.intent.action.UPGRADE_SETUP";
1540  
1541      /**
1542       * Activity Action: Start the Keyboard Shortcuts Helper screen.
1543       * <p>Input: Nothing.
1544       * <p>Output: Nothing.
1545       * @hide
1546       */
1547      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1548      public static final String ACTION_SHOW_KEYBOARD_SHORTCUTS =
1549              "com.android.intent.action.SHOW_KEYBOARD_SHORTCUTS";
1550  
1551      /**
1552       * Activity Action: Dismiss the Keyboard Shortcuts Helper screen.
1553       * <p>Input: Nothing.
1554       * <p>Output: Nothing.
1555       * @hide
1556       */
1557      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1558      public static final String ACTION_DISMISS_KEYBOARD_SHORTCUTS =
1559              "com.android.intent.action.DISMISS_KEYBOARD_SHORTCUTS";
1560  
1561      /**
1562       * Activity Action: Show settings for managing network data usage of a
1563       * specific application. Applications should define an activity that offers
1564       * options to control data usage.
1565       */
1566      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1567      public static final String ACTION_MANAGE_NETWORK_USAGE =
1568              "android.intent.action.MANAGE_NETWORK_USAGE";
1569  
1570      /**
1571       * Activity Action: Launch application installer.
1572       * <p>
1573       * Input: The data must be a content: URI at which the application
1574       * can be retrieved.  As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1},
1575       * you can also use "package:<package-name>" to install an application for the
1576       * current user that is already installed for another user. You can optionally supply
1577       * {@link #EXTRA_INSTALLER_PACKAGE_NAME}, {@link #EXTRA_NOT_UNKNOWN_SOURCE},
1578       * {@link #EXTRA_ALLOW_REPLACE}, and {@link #EXTRA_RETURN_RESULT}.
1579       * <p>
1580       * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1581       * succeeded.
1582       * <p>
1583       * <strong>Note:</strong>If your app is targeting API level higher than 25 you
1584       * need to hold {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES}
1585       * in order to launch the application installer.
1586       * </p>
1587       *
1588       * @see #EXTRA_INSTALLER_PACKAGE_NAME
1589       * @see #EXTRA_NOT_UNKNOWN_SOURCE
1590       * @see #EXTRA_RETURN_RESULT
1591       *
1592       * @deprecated use {@link android.content.pm.PackageInstaller} instead
1593       */
1594      @Deprecated
1595      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1596      public static final String ACTION_INSTALL_PACKAGE = "android.intent.action.INSTALL_PACKAGE";
1597  
1598      /**
1599       * Activity Action: Activity to handle split installation failures.
1600       * <p>Splits may be installed dynamically. This happens when an Activity is launched,
1601       * but the split that contains the application isn't installed. When a split is
1602       * installed in this manner, the containing package usually doesn't know this is
1603       * happening. However, if an error occurs during installation, the containing
1604       * package can define a single activity handling this action to deal with such
1605       * failures.
1606       * <p>The activity handling this action must be in the base package.
1607       * <p>
1608       * Input: {@link #EXTRA_INTENT} the original intent that started split installation.
1609       * {@link #EXTRA_SPLIT_NAME} the name of the split that failed to be installed.
1610       */
1611      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1612      public static final String ACTION_INSTALL_FAILURE = "android.intent.action.INSTALL_FAILURE";
1613  
1614      /**
1615       * Activity Action: Launch instant application installer.
1616       * <p class="note">
1617       * This is a protected intent that can only be sent by the system.
1618       * </p>
1619       *
1620       * @hide
1621       */
1622      @SystemApi
1623      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1624      public static final String ACTION_INSTALL_INSTANT_APP_PACKAGE
1625              = "android.intent.action.INSTALL_INSTANT_APP_PACKAGE";
1626  
1627      /**
1628       * Service Action: Resolve instant application.
1629       * <p>
1630       * The system will have a persistent connection to this service.
1631       * This is a protected intent that can only be sent by the system.
1632       * </p>
1633       *
1634       * @hide
1635       */
1636      @SystemApi
1637      @SdkConstant(SdkConstantType.SERVICE_ACTION)
1638      public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE
1639              = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE";
1640  
1641      /**
1642       * Activity Action: Launch instant app settings.
1643       *
1644       * <p class="note">
1645       * This is a protected intent that can only be sent by the system.
1646       * </p>
1647       *
1648       * @hide
1649       */
1650      @SystemApi
1651      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1652      public static final String ACTION_INSTANT_APP_RESOLVER_SETTINGS
1653              = "android.intent.action.INSTANT_APP_RESOLVER_SETTINGS";
1654  
1655      /**
1656       * Used as a string extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1657       * package.  Specifies the installer package name; this package will receive the
1658       * {@link #ACTION_APP_ERROR} intent.
1659       */
1660      public static final String EXTRA_INSTALLER_PACKAGE_NAME
1661              = "android.intent.extra.INSTALLER_PACKAGE_NAME";
1662  
1663      /**
1664       * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1665       * package.  Specifies that the application being installed should not be
1666       * treated as coming from an unknown source, but as coming from the app
1667       * invoking the Intent.  For this to work you must start the installer with
1668       * startActivityForResult().
1669       */
1670      public static final String EXTRA_NOT_UNKNOWN_SOURCE
1671              = "android.intent.extra.NOT_UNKNOWN_SOURCE";
1672  
1673      /**
1674       * Used as a URI extra field with {@link #ACTION_INSTALL_PACKAGE} and
1675       * {@link #ACTION_VIEW} to indicate the URI from which the local APK in the Intent
1676       * data field originated from.
1677       */
1678      public static final String EXTRA_ORIGINATING_URI
1679              = "android.intent.extra.ORIGINATING_URI";
1680  
1681      /**
1682       * This extra can be used with any Intent used to launch an activity, supplying information
1683       * about who is launching that activity.  This field contains a {@link android.net.Uri}
1684       * object, typically an http: or https: URI of the web site that the referral came from;
1685       * it can also use the {@link #URI_ANDROID_APP_SCHEME android-app:} scheme to identify
1686       * a native application that it came from.
1687       *
1688       * <p>To retrieve this value in a client, use {@link android.app.Activity#getReferrer}
1689       * instead of directly retrieving the extra.  It is also valid for applications to
1690       * instead supply {@link #EXTRA_REFERRER_NAME} for cases where they can only create
1691       * a string, not a Uri; the field here, if supplied, will always take precedence,
1692       * however.</p>
1693       *
1694       * @see #EXTRA_REFERRER_NAME
1695       */
1696      public static final String EXTRA_REFERRER
1697              = "android.intent.extra.REFERRER";
1698  
1699      /**
1700       * Alternate version of {@link #EXTRA_REFERRER} that supplies the URI as a String rather
1701       * than a {@link android.net.Uri} object.  Only for use in cases where Uri objects can
1702       * not be created, in particular when Intent extras are supplied through the
1703       * {@link #URI_INTENT_SCHEME intent:} or {@link #URI_ANDROID_APP_SCHEME android-app:}
1704       * schemes.
1705       *
1706       * @see #EXTRA_REFERRER
1707       */
1708      public static final String EXTRA_REFERRER_NAME
1709              = "android.intent.extra.REFERRER_NAME";
1710  
1711      /**
1712       * Used as an int extra field with {@link #ACTION_INSTALL_PACKAGE} and
1713       * {@link #ACTION_VIEW} to indicate the uid of the package that initiated the install
1714       * Currently only a system app that hosts the provider authority "downloads" or holds the
1715       * permission {@link android.Manifest.permission.MANAGE_DOCUMENTS} can use this.
1716       * @hide
1717       */
1718      @SystemApi
1719      public static final String EXTRA_ORIGINATING_UID
1720              = "android.intent.extra.ORIGINATING_UID";
1721  
1722      /**
1723       * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} to install a
1724       * package.  Tells the installer UI to skip the confirmation with the user
1725       * if the .apk is replacing an existing one.
1726       * @deprecated As of {@link android.os.Build.VERSION_CODES#JELLY_BEAN}, Android
1727       * will no longer show an interstitial message about updating existing
1728       * applications so this is no longer needed.
1729       */
1730      @Deprecated
1731      public static final String EXTRA_ALLOW_REPLACE
1732              = "android.intent.extra.ALLOW_REPLACE";
1733  
1734      /**
1735       * Used as a boolean extra field with {@link #ACTION_INSTALL_PACKAGE} or
1736       * {@link #ACTION_UNINSTALL_PACKAGE}.  Specifies that the installer UI should
1737       * return to the application the result code of the install/uninstall.  The returned result
1738       * code will be {@link android.app.Activity#RESULT_OK} on success or
1739       * {@link android.app.Activity#RESULT_FIRST_USER} on failure.
1740       */
1741      public static final String EXTRA_RETURN_RESULT
1742              = "android.intent.extra.RETURN_RESULT";
1743  
1744      /**
1745       * Package manager install result code.  @hide because result codes are not
1746       * yet ready to be exposed.
1747       */
1748      public static final String EXTRA_INSTALL_RESULT
1749              = "android.intent.extra.INSTALL_RESULT";
1750  
1751      /**
1752       * Activity Action: Launch application uninstaller.
1753       * <p>
1754       * Input: The data must be a package: URI whose scheme specific part is
1755       * the package name of the current installed package to be uninstalled.
1756       * You can optionally supply {@link #EXTRA_RETURN_RESULT}.
1757       * <p>
1758       * Output: If {@link #EXTRA_RETURN_RESULT}, returns whether the install
1759       * succeeded.
1760       * <p>
1761       * Requires {@link android.Manifest.permission#REQUEST_DELETE_PACKAGES}
1762       * since {@link Build.VERSION_CODES#P}.
1763       *
1764       * @deprecated Use {@link android.content.pm.PackageInstaller#uninstall(String, IntentSender)}
1765       *             instead
1766       */
1767      @Deprecated
1768      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1769      public static final String ACTION_UNINSTALL_PACKAGE = "android.intent.action.UNINSTALL_PACKAGE";
1770  
1771      /**
1772       * Specify whether the package should be uninstalled for all users.
1773       * @hide because these should not be part of normal application flow.
1774       */
1775      public static final String EXTRA_UNINSTALL_ALL_USERS
1776              = "android.intent.extra.UNINSTALL_ALL_USERS";
1777  
1778      /**
1779       * A string that associates with a metadata entry, indicating the last run version of the
1780       * platform that was setup.
1781       *
1782       * @see #ACTION_UPGRADE_SETUP
1783       *
1784       * @hide
1785       */
1786      @SystemApi
1787      public static final String METADATA_SETUP_VERSION = "android.SETUP_VERSION";
1788  
1789      /**
1790       * Activity action: Launch UI to manage the permissions of an app.
1791       * <p>
1792       * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permissions
1793       * will be managed by the launched UI.
1794       * </p>
1795       * <p>
1796       * Output: Nothing.
1797       * </p>
1798       *
1799       * @see #EXTRA_PACKAGE_NAME
1800       *
1801       * @hide
1802       */
1803      @SystemApi
1804      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1805      public static final String ACTION_MANAGE_APP_PERMISSIONS =
1806              "android.intent.action.MANAGE_APP_PERMISSIONS";
1807  
1808      /**
1809       * Activity action: Launch UI to manage a specific permissions of an app.
1810       * <p>
1811       * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose permission
1812       * will be managed by the launched UI.
1813       * </p>
1814       * <p>
1815       * Input: {@link #EXTRA_PERMISSION_NAME} specifies the (individual) permission
1816       * that should be managed by the launched UI.
1817       * </p>
1818       * <p>
1819       * <li> {@link #EXTRA_USER} specifies the UserHandle of the user that owns the app.
1820       * </p>
1821       * <p>
1822       * Output: Nothing.
1823       * </p>
1824       *
1825       * @see #EXTRA_PACKAGE_NAME
1826       * @see #EXTRA_PERMISSION_NAME
1827       * @see #EXTRA_USER
1828       *
1829       * @hide
1830       */
1831      @SystemApi
1832      @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
1833      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1834      public static final String ACTION_MANAGE_APP_PERMISSION =
1835              "android.intent.action.MANAGE_APP_PERMISSION";
1836  
1837      /**
1838       * Activity action: Launch UI to manage permissions.
1839       * <p>
1840       * Input: Nothing.
1841       * </p>
1842       * <p>
1843       * Output: Nothing.
1844       * </p>
1845       *
1846       * @hide
1847       */
1848      @SystemApi
1849      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1850      public static final String ACTION_MANAGE_PERMISSIONS =
1851              "android.intent.action.MANAGE_PERMISSIONS";
1852  
1853      /**
1854       * Activity action: Launch UI to review permissions for an app.
1855       * The system uses this intent if permission review for apps not
1856       * supporting the new runtime permissions model is enabled. In
1857       * this mode a permission review is required before any of the
1858       * app components can run.
1859       * <p>
1860       * Input: {@link #EXTRA_PACKAGE_NAME} specifies the package whose
1861       * permissions will be reviewed (mandatory).
1862       * </p>
1863       * <p>
1864       * Input: {@link #EXTRA_INTENT} specifies a pending intent to
1865       * be fired after the permission review (optional).
1866       * </p>
1867       * <p>
1868       * Input: {@link #EXTRA_REMOTE_CALLBACK} specifies a callback to
1869       * be invoked after the permission review (optional).
1870       * </p>
1871       * <p>
1872       * Input: {@link #EXTRA_RESULT_NEEDED} specifies whether the intent
1873       * passed via {@link #EXTRA_INTENT} needs a result (optional).
1874       * </p>
1875       * <p>
1876       * Output: Nothing.
1877       * </p>
1878       *
1879       * @see #EXTRA_PACKAGE_NAME
1880       * @see #EXTRA_INTENT
1881       * @see #EXTRA_REMOTE_CALLBACK
1882       * @see #EXTRA_RESULT_NEEDED
1883       *
1884       * @hide
1885       */
1886      @SystemApi
1887      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1888      public static final String ACTION_REVIEW_PERMISSIONS =
1889              "android.intent.action.REVIEW_PERMISSIONS";
1890  
1891      /**
1892       * Activity action: Launch UI to show information about the usage
1893       * of a given permission. This action would be handled by apps that
1894       * want to show details about how and why given permission is being
1895       * used.
1896       * <p>
1897       * <strong>Important:</strong>You must protect the activity that handles
1898       * this action with the {@link android.Manifest.permission#START_VIEW_PERMISSION_USAGE
1899       *  START_VIEW_PERMISSION_USAGE} permission to ensure that only the
1900       * system can launch this activity. The system will not launch
1901       * activities that are not properly protected.
1902       *
1903       * <p>
1904       * Input: {@code android.intent.extra.PERMISSION_NAME} specifies the permission
1905       * for which the launched UI would be targeted.
1906       * </p>
1907       * <p>
1908       * Output: Nothing.
1909       * </p>
1910       */
1911      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1912      @RequiresPermission(android.Manifest.permission.START_VIEW_PERMISSION_USAGE)
1913      public static final String ACTION_VIEW_PERMISSION_USAGE =
1914              "android.intent.action.VIEW_PERMISSION_USAGE";
1915  
1916      /**
1917       * Activity action: Launch UI to manage a default app.
1918       * <p>
1919       * Input: {@link #EXTRA_ROLE_NAME} specifies the role of the default app which will be managed
1920       * by the launched UI.
1921       * </p>
1922       * <p>
1923       * Output: Nothing.
1924       * </p>
1925       *
1926       * @hide
1927       */
1928      @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
1929      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1930      @SystemApi
1931      public static final String ACTION_MANAGE_DEFAULT_APP =
1932              "android.intent.action.MANAGE_DEFAULT_APP";
1933  
1934      /**
1935       * Intent extra: A role name.
1936       * <p>
1937       * Type: String
1938       * </p>
1939       *
1940       * @see android.app.role.RoleManager
1941       *
1942       * @hide
1943       */
1944      @SystemApi
1945      @TestApi
1946      public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME";
1947  
1948      /**
1949       * Activity action: Launch UI to manage special app accesses.
1950       * <p>
1951       * Input: Nothing.
1952       * </p>
1953       * <p>
1954       * Output: Nothing.
1955       * </p>
1956       *
1957       * @hide
1958       */
1959      @RequiresPermission(android.Manifest.permission.MANAGE_ROLE_HOLDERS)
1960      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
1961      @SystemApi
1962      public static final String ACTION_MANAGE_SPECIAL_APP_ACCESSES =
1963              "android.intent.action.MANAGE_SPECIAL_APP_ACCESSES";
1964  
1965      /**
1966       * Intent extra: A callback for reporting remote result as a bundle.
1967       * <p>
1968       * Type: IRemoteCallback
1969       * </p>
1970       *
1971       * @hide
1972       */
1973      @SystemApi
1974      public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK";
1975  
1976      /**
1977       * Intent extra: An app package name.
1978       * <p>
1979       * Type: String
1980       * </p>
1981       *
1982       */
1983      public static final String EXTRA_PACKAGE_NAME = "android.intent.extra.PACKAGE_NAME";
1984  
1985      /**
1986       * Intent extra: A {@link Bundle} of extras for a package being suspended. Will be sent as an
1987       * extra with {@link #ACTION_MY_PACKAGE_SUSPENDED}.
1988       *
1989       * <p>The contents of this {@link Bundle} are a contract between the suspended app and the
1990       * suspending app, i.e. any app with the permission {@code android.permission.SUSPEND_APPS}.
1991       * This is meant to enable the suspended app to better handle the state of being suspended.
1992       *
1993       * @see #ACTION_MY_PACKAGE_SUSPENDED
1994       * @see #ACTION_MY_PACKAGE_UNSUSPENDED
1995       * @see PackageManager#isPackageSuspended()
1996       * @see PackageManager#getSuspendedPackageAppExtras()
1997       */
1998      public static final String EXTRA_SUSPENDED_PACKAGE_EXTRAS = "android.intent.extra.SUSPENDED_PACKAGE_EXTRAS";
1999  
2000      /**
2001       * Intent extra: An app split name.
2002       * <p>
2003       * Type: String
2004       * </p>
2005       */
2006      public static final String EXTRA_SPLIT_NAME = "android.intent.extra.SPLIT_NAME";
2007  
2008      /**
2009       * Intent extra: A {@link ComponentName} value.
2010       * <p>
2011       * Type: String
2012       * </p>
2013       */
2014      public static final String EXTRA_COMPONENT_NAME = "android.intent.extra.COMPONENT_NAME";
2015  
2016      /**
2017       * Intent extra: An extra for specifying whether a result is needed.
2018       * <p>
2019       * Type: boolean
2020       * </p>
2021       *
2022       * @hide
2023       */
2024      @SystemApi
2025      public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED";
2026  
2027      /**
2028       * Intent extra: A {@link Bundle} of extras supplied for the launcher when any packages on
2029       * device are suspended. Will be sent with {@link #ACTION_PACKAGES_SUSPENDED}.
2030       *
2031       * @see PackageManager#isPackageSuspended()
2032       * @see #ACTION_PACKAGES_SUSPENDED
2033       *
2034       * @hide
2035       */
2036      public static final String EXTRA_LAUNCHER_EXTRAS = "android.intent.extra.LAUNCHER_EXTRAS";
2037  
2038      /**
2039       * Intent extra: ID of the shortcut used to send the share intent. Will be sent with
2040       * {@link #ACTION_SEND}.
2041       *
2042       * @see ShortcutInfo#getId()
2043       *
2044       * <p>
2045       * Type: String
2046       * </p>
2047       */
2048      public static final String EXTRA_SHORTCUT_ID = "android.intent.extra.shortcut.ID";
2049  
2050      /**
2051       * Activity action: Launch UI to manage which apps have a given permission.
2052       * <p>
2053       * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission group
2054       * which will be managed by the launched UI.
2055       * </p>
2056       * <p>
2057       * Output: Nothing.
2058       * </p>
2059       *
2060       * @see #EXTRA_PERMISSION_NAME
2061       *
2062       * @hide
2063       */
2064      @SystemApi
2065      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2066      public static final String ACTION_MANAGE_PERMISSION_APPS =
2067              "android.intent.action.MANAGE_PERMISSION_APPS";
2068  
2069      /**
2070       * Intent extra: The name of a permission.
2071       * <p>
2072       * Type: String
2073       * </p>
2074       *
2075       * @hide
2076       */
2077      @SystemApi
2078      public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME";
2079  
2080      /**
2081       * Intent extra: The name of a permission group.
2082       * <p>
2083       * Type: String
2084       * </p>
2085       *
2086       * @hide
2087       */
2088      @SystemApi
2089      public static final String EXTRA_PERMISSION_GROUP_NAME =
2090              "android.intent.extra.PERMISSION_GROUP_NAME";
2091  
2092      /**
2093       * Intent extra: The number of milliseconds.
2094       * <p>
2095       * Type: long
2096       * </p>
2097       */
2098      public static final String EXTRA_DURATION_MILLIS =
2099              "android.intent.extra.DURATION_MILLIS";
2100  
2101      /**
2102       * Activity action: Launch UI to review app uses of permissions.
2103       * <p>
2104       * Input: {@link #EXTRA_PERMISSION_NAME} specifies the permission name
2105       * that will be displayed by the launched UI.  Do not pass both this and
2106       * {@link #EXTRA_PERMISSION_GROUP_NAME} .
2107       * </p>
2108       * <p>
2109       * Input: {@link #EXTRA_PERMISSION_GROUP_NAME} specifies the permission group name
2110       * that will be displayed by the launched UI.  Do not pass both this and
2111       * {@link #EXTRA_PERMISSION_NAME}.
2112       * </p>
2113       * <p>
2114       * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2115       * activity to show (optional).  Must be non-negative.
2116       * </p>
2117       * <p>
2118       * Output: Nothing.
2119       * </p>
2120       * <p class="note">
2121       * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2122       * </p>
2123       *
2124       * @see #EXTRA_PERMISSION_NAME
2125       * @see #EXTRA_PERMISSION_GROUP_NAME
2126       * @see #EXTRA_DURATION_MILLIS
2127       *
2128       * @hide
2129       */
2130      @SystemApi
2131      @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2132      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2133      public static final String ACTION_REVIEW_PERMISSION_USAGE =
2134              "android.intent.action.REVIEW_PERMISSION_USAGE";
2135  
2136      /**
2137       * Activity action: Launch UI to review ongoing app uses of permissions.
2138       * <p>
2139       * Input: {@link #EXTRA_DURATION_MILLIS} specifies the minimum number of milliseconds of recent
2140       * activity to show (optional).  Must be non-negative.
2141       * </p>
2142       * <p>
2143       * Output: Nothing.
2144       * </p>
2145       * <p class="note">
2146       * This requires {@link android.Manifest.permission#GRANT_RUNTIME_PERMISSIONS} permission.
2147       * </p>
2148       *
2149       * @see #EXTRA_DURATION_MILLIS
2150       *
2151       * @hide
2152       */
2153      @SystemApi
2154      @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS)
2155      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2156      public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE =
2157              "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE";
2158  
2159      /**
2160       * Activity action: Launch UI to review running accessibility services.
2161       * <p>
2162       * Input: Nothing.
2163       * </p>
2164       * <p>
2165       * Output: Nothing.
2166       * </p>
2167       *
2168       * @hide
2169       */
2170      @SystemApi
2171      @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES)
2172      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2173      public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES =
2174              "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES";
2175  
2176      // ---------------------------------------------------------------------
2177      // ---------------------------------------------------------------------
2178      // Standard intent broadcast actions (see action variable).
2179  
2180      /**
2181       * Broadcast Action: Sent when the device goes to sleep and becomes non-interactive.
2182       * <p>
2183       * For historical reasons, the name of this broadcast action refers to the power
2184       * state of the screen but it is actually sent in response to changes in the
2185       * overall interactive state of the device.
2186       * </p><p>
2187       * This broadcast is sent when the device becomes non-interactive which may have
2188       * nothing to do with the screen turning off.  To determine the
2189       * actual state of the screen, use {@link android.view.Display#getState}.
2190       * </p><p>
2191       * See {@link android.os.PowerManager#isInteractive} for details.
2192       * </p>
2193       * You <em>cannot</em> receive this through components declared in
2194       * manifests, only by explicitly registering for it with
2195       * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2196       * Context.registerReceiver()}.
2197       *
2198       * <p class="note">This is a protected intent that can only be sent
2199       * by the system.
2200       */
2201      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2202      public static final String ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
2203  
2204      /**
2205       * Broadcast Action: Sent when the device wakes up and becomes interactive.
2206       * <p>
2207       * For historical reasons, the name of this broadcast action refers to the power
2208       * state of the screen but it is actually sent in response to changes in the
2209       * overall interactive state of the device.
2210       * </p><p>
2211       * This broadcast is sent when the device becomes interactive which may have
2212       * nothing to do with the screen turning on.  To determine the
2213       * actual state of the screen, use {@link android.view.Display#getState}.
2214       * </p><p>
2215       * See {@link android.os.PowerManager#isInteractive} for details.
2216       * </p>
2217       * You <em>cannot</em> receive this through components declared in
2218       * manifests, only by explicitly registering for it with
2219       * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2220       * Context.registerReceiver()}.
2221       *
2222       * <p class="note">This is a protected intent that can only be sent
2223       * by the system.
2224       */
2225      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2226      public static final String ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
2227  
2228      /**
2229       * Broadcast Action: Sent after the system stops dreaming.
2230       *
2231       * <p class="note">This is a protected intent that can only be sent by the system.
2232       * It is only sent to registered receivers.</p>
2233       */
2234      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2235      public static final String ACTION_DREAMING_STOPPED = "android.intent.action.DREAMING_STOPPED";
2236  
2237      /**
2238       * Broadcast Action: Sent after the system starts dreaming.
2239       *
2240       * <p class="note">This is a protected intent that can only be sent by the system.
2241       * It is only sent to registered receivers.</p>
2242       */
2243      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2244      public static final String ACTION_DREAMING_STARTED = "android.intent.action.DREAMING_STARTED";
2245  
2246      /**
2247       * Broadcast Action: Sent when the user is present after device wakes up (e.g when the
2248       * keyguard is gone).
2249       *
2250       * <p class="note">This is a protected intent that can only be sent
2251       * by the system.
2252       */
2253      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2254      public static final String ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
2255  
2256      /**
2257       * Broadcast Action: The current time has changed.  Sent every
2258       * minute.  You <em>cannot</em> receive this through components declared
2259       * in manifests, only by explicitly registering for it with
2260       * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2261       * Context.registerReceiver()}.
2262       *
2263       * <p class="note">This is a protected intent that can only be sent
2264       * by the system.
2265       */
2266      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2267      public static final String ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
2268      /**
2269       * Broadcast Action: The time was set.
2270       */
2271      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2272      public static final String ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
2273      /**
2274       * Broadcast Action: The date has changed.
2275       */
2276      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2277      public static final String ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
2278      /**
2279       * Broadcast Action: The timezone has changed. The intent will have the following extra values:</p>
2280       * <ul>
2281       *   <li><em>time-zone</em> - The java.util.TimeZone.getID() value identifying the new time zone.</li>
2282       * </ul>
2283       *
2284       * <p class="note">This is a protected intent that can only be sent
2285       * by the system.
2286       */
2287      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2288      public static final String ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
2289      /**
2290       * Clear DNS Cache Action: This is broadcast when networks have changed and old
2291       * DNS entries should be tossed.
2292       * @hide
2293       */
2294      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2295      public static final String ACTION_CLEAR_DNS_CACHE = "android.intent.action.CLEAR_DNS_CACHE";
2296      /**
2297       * Alarm Changed Action: This is broadcast when the AlarmClock
2298       * application's alarm is set or unset.  It is used by the
2299       * AlarmClock application and the StatusBar service.
2300       * @hide
2301       */
2302      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2303      @UnsupportedAppUsage
2304      public static final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED";
2305  
2306      /**
2307       * Broadcast Action: This is broadcast once, after the user has finished
2308       * booting, but while still in the "locked" state. It can be used to perform
2309       * application-specific initialization, such as installing alarms. You must
2310       * hold the {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED}
2311       * permission in order to receive this broadcast.
2312       * <p>
2313       * This broadcast is sent immediately at boot by all devices (regardless of
2314       * direct boot support) running {@link android.os.Build.VERSION_CODES#N} or
2315       * higher. Upon receipt of this broadcast, the user is still locked and only
2316       * device-protected storage can be accessed safely. If you want to access
2317       * credential-protected storage, you need to wait for the user to be
2318       * unlocked (typically by entering their lock pattern or PIN for the first
2319       * time), after which the {@link #ACTION_USER_UNLOCKED} and
2320       * {@link #ACTION_BOOT_COMPLETED} broadcasts are sent.
2321       * <p>
2322       * To receive this broadcast, your receiver component must be marked as
2323       * being {@link ComponentInfo#directBootAware}.
2324       * <p class="note">
2325       * This is a protected intent that can only be sent by the system.
2326       *
2327       * @see Context#createDeviceProtectedStorageContext()
2328       */
2329      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2330      public static final String ACTION_LOCKED_BOOT_COMPLETED = "android.intent.action.LOCKED_BOOT_COMPLETED";
2331  
2332      /**
2333       * Broadcast Action: This is broadcast once, after the user has finished
2334       * booting. It can be used to perform application-specific initialization,
2335       * such as installing alarms. You must hold the
2336       * {@link android.Manifest.permission#RECEIVE_BOOT_COMPLETED} permission in
2337       * order to receive this broadcast.
2338       * <p>
2339       * This broadcast is sent at boot by all devices (both with and without
2340       * direct boot support). Upon receipt of this broadcast, the user is
2341       * unlocked and both device-protected and credential-protected storage can
2342       * accessed safely.
2343       * <p>
2344       * If you need to run while the user is still locked (before they've entered
2345       * their lock pattern or PIN for the first time), you can listen for the
2346       * {@link #ACTION_LOCKED_BOOT_COMPLETED} broadcast.
2347       * <p class="note">
2348       * This is a protected intent that can only be sent by the system.
2349       */
2350      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2351      @BroadcastBehavior(includeBackground = true)
2352      public static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
2353  
2354      /**
2355       * Broadcast Action: This is broadcast when a user action should request a
2356       * temporary system dialog to dismiss.  Some examples of temporary system
2357       * dialogs are the notification window-shade and the recent tasks dialog.
2358       */
2359      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2360      public static final String ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
2361      /**
2362       * Broadcast Action: Trigger the download and eventual installation
2363       * of a package.
2364       * <p>Input: {@link #getData} is the URI of the package file to download.
2365       *
2366       * <p class="note">This is a protected intent that can only be sent
2367       * by the system.
2368       *
2369       * @deprecated This constant has never been used.
2370       */
2371      @Deprecated
2372      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2373      public static final String ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
2374      /**
2375       * Broadcast Action: A new application package has been installed on the
2376       * device. The data contains the name of the package.  Note that the
2377       * newly installed package does <em>not</em> receive this broadcast.
2378       * <p>May include the following extras:
2379       * <ul>
2380       * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2381       * <li> {@link #EXTRA_REPLACING} is set to true if this is following
2382       * an {@link #ACTION_PACKAGE_REMOVED} broadcast for the same package.
2383       * </ul>
2384       *
2385       * <p class="note">This is a protected intent that can only be sent
2386       * by the system.
2387       */
2388      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2389      public static final String ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
2390      /**
2391       * Broadcast Action: A new version of an application package has been
2392       * installed, replacing an existing version that was previously installed.
2393       * The data contains the name of the package.
2394       * <p>May include the following extras:
2395       * <ul>
2396       * <li> {@link #EXTRA_UID} containing the integer uid assigned to the new package.
2397       * </ul>
2398       *
2399       * <p class="note">This is a protected intent that can only be sent
2400       * by the system.
2401       */
2402      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2403      public static final String ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
2404      /**
2405       * Broadcast Action: A new version of your application has been installed
2406       * over an existing one.  This is only sent to the application that was
2407       * replaced.  It does not contain any additional data; to receive it, just
2408       * use an intent filter for this action.
2409       *
2410       * <p class="note">This is a protected intent that can only be sent
2411       * by the system.
2412       */
2413      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2414      public static final String ACTION_MY_PACKAGE_REPLACED = "android.intent.action.MY_PACKAGE_REPLACED";
2415      /**
2416       * Broadcast Action: An existing application package has been removed from
2417       * the device.  The data contains the name of the package.  The package
2418       * that is being removed does <em>not</em> receive this Intent.
2419       * <ul>
2420       * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2421       * to the package.
2422       * <li> {@link #EXTRA_DATA_REMOVED} is set to true if the entire
2423       * application -- data and code -- is being removed.
2424       * <li> {@link #EXTRA_REPLACING} is set to true if this will be followed
2425       * by an {@link #ACTION_PACKAGE_ADDED} broadcast for the same package.
2426       * </ul>
2427       *
2428       * <p class="note">This is a protected intent that can only be sent
2429       * by the system.
2430       */
2431      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2432      public static final String ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
2433      /**
2434       * Broadcast Action: An existing application package has been completely
2435       * removed from the device.  The data contains the name of the package.
2436       * This is like {@link #ACTION_PACKAGE_REMOVED}, but only set when
2437       * {@link #EXTRA_DATA_REMOVED} is true and
2438       * {@link #EXTRA_REPLACING} is false of that broadcast.
2439       *
2440       * <ul>
2441       * <li> {@link #EXTRA_UID} containing the integer uid previously assigned
2442       * to the package.
2443       * </ul>
2444       *
2445       * <p class="note">This is a protected intent that can only be sent
2446       * by the system.
2447       */
2448      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2449      public static final String ACTION_PACKAGE_FULLY_REMOVED
2450              = "android.intent.action.PACKAGE_FULLY_REMOVED";
2451      /**
2452       * Broadcast Action: An existing application package has been changed (for
2453       * example, a component has been enabled or disabled).  The data contains
2454       * the name of the package.
2455       * <ul>
2456       * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2457       * <li> {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST} containing the class name
2458       * of the changed components (or the package name itself).
2459       * <li> {@link #EXTRA_DONT_KILL_APP} containing boolean field to override the
2460       * default action of restarting the application.
2461       * </ul>
2462       *
2463       * <p class="note">This is a protected intent that can only be sent
2464       * by the system.
2465       */
2466      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2467      public static final String ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
2468      /**
2469       * Broadcast Action: Sent to the system rollback manager when a package
2470       * needs to have rollback enabled.
2471       * <p class="note">
2472       * This is a protected intent that can only be sent by the system.
2473       * </p>
2474       *
2475       * @hide This broadcast is used internally by the system.
2476       */
2477      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2478      public static final String ACTION_PACKAGE_ENABLE_ROLLBACK =
2479              "android.intent.action.PACKAGE_ENABLE_ROLLBACK";
2480      /**
2481       * Broadcast Action: Sent to the system rollback manager when the rollback for a certain
2482       * package needs to be cancelled.
2483       *
2484       * <p class="note">This intent is sent by PackageManagerService to notify RollbackManager
2485       * that enabling a specific rollback has timed out.
2486       *
2487       * @hide
2488       */
2489      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2490      public static final String ACTION_CANCEL_ENABLE_ROLLBACK =
2491              "android.intent.action.CANCEL_ENABLE_ROLLBACK";
2492      /**
2493       * Broadcast Action: A rollback has been committed.
2494       *
2495       * <p class="note">This is a protected intent that can only be sent
2496       * by the system. The receiver must hold MANAGE_ROLLBACK permission.
2497       *
2498       * @hide
2499       */
2500      @SystemApi @TestApi
2501      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2502      public static final String ACTION_ROLLBACK_COMMITTED =
2503              "android.intent.action.ROLLBACK_COMMITTED";
2504      /**
2505       * @hide
2506       * Broadcast Action: Ask system services if there is any reason to
2507       * restart the given package.  The data contains the name of the
2508       * package.
2509       * <ul>
2510       * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2511       * <li> {@link #EXTRA_PACKAGES} String array of all packages to check.
2512       * </ul>
2513       *
2514       * <p class="note">This is a protected intent that can only be sent
2515       * by the system.
2516       */
2517      @SystemApi
2518      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2519      public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART";
2520      /**
2521       * Broadcast Action: The user has restarted a package, and all of its
2522       * processes have been killed.  All runtime state
2523       * associated with it (processes, alarms, notifications, etc) should
2524       * be removed.  Note that the restarted package does <em>not</em>
2525       * receive this broadcast.
2526       * The data contains the name of the package.
2527       * <ul>
2528       * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package.
2529       * </ul>
2530       *
2531       * <p class="note">This is a protected intent that can only be sent
2532       * by the system.
2533       */
2534      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2535      public static final String ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
2536      /**
2537       * Broadcast Action: The user has cleared the data of a package.  This should
2538       * be preceded by {@link #ACTION_PACKAGE_RESTARTED}, after which all of
2539       * its persistent data is erased and this broadcast sent.
2540       * Note that the cleared package does <em>not</em>
2541       * receive this broadcast. The data contains the name of the package.
2542       * <ul>
2543       * <li> {@link #EXTRA_UID} containing the integer uid assigned to the package. If the
2544       *      package whose data was cleared is an uninstalled instant app, then the UID
2545       *      will be -1. The platform keeps some meta-data associated with instant apps
2546       *      after they are uninstalled.
2547       * <li> {@link #EXTRA_PACKAGE_NAME} containing the package name only if the cleared
2548       *      data was for an instant app.
2549       * </ul>
2550       *
2551       * <p class="note">This is a protected intent that can only be sent
2552       * by the system.
2553       */
2554      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2555      public static final String ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
2556      /**
2557       * Broadcast Action: Packages have been suspended.
2558       * <p>Includes the following extras:
2559       * <ul>
2560       * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been suspended
2561       * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been suspended
2562       * </ul>
2563       *
2564       * <p class="note">This is a protected intent that can only be sent
2565       * by the system. It is only sent to registered receivers.
2566       */
2567      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2568      public static final String ACTION_PACKAGES_SUSPENDED = "android.intent.action.PACKAGES_SUSPENDED";
2569      /**
2570       * Broadcast Action: Packages have been unsuspended.
2571       * <p>Includes the following extras:
2572       * <ul>
2573       * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been unsuspended
2574       * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been unsuspended
2575       * </ul>
2576       *
2577       * <p class="note">This is a protected intent that can only be sent
2578       * by the system. It is only sent to registered receivers.
2579       */
2580      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2581      public static final String ACTION_PACKAGES_UNSUSPENDED = "android.intent.action.PACKAGES_UNSUSPENDED";
2582  
2583      /**
2584       * Broadcast Action: Distracting packages have been changed.
2585       * <p>Includes the following extras:
2586       * <ul>
2587       * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages which have been changed.
2588       * <li> {@link #EXTRA_CHANGED_UID_LIST} is the set of uids which have been changed.
2589       * <li> {@link #EXTRA_DISTRACTION_RESTRICTIONS} the new restrictions set on these packages.
2590       * </ul>
2591       *
2592       * <p class="note">This is a protected intent that can only be sent
2593       * by the system. It is only sent to registered receivers.
2594       *
2595       * @see PackageManager#setDistractingPackageRestrictions(String[], int)
2596       * @hide
2597       */
2598      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2599      public static final String ACTION_DISTRACTING_PACKAGES_CHANGED =
2600              "android.intent.action.DISTRACTING_PACKAGES_CHANGED";
2601  
2602      /**
2603       * Broadcast Action: Sent to a package that has been suspended by the system. This is sent
2604       * whenever a package is put into a suspended state or any of its app extras change while in the
2605       * suspended state.
2606       * <p> Optionally includes the following extras:
2607       * <ul>
2608       *     <li> {@link #EXTRA_SUSPENDED_PACKAGE_EXTRAS} which is a {@link Bundle} which will contain
2609       *     useful information for the app being suspended.
2610       * </ul>
2611       * <p class="note">This is a protected intent that can only be sent
2612       * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2613       * the manifest.</em>
2614       *
2615       * @see #ACTION_MY_PACKAGE_UNSUSPENDED
2616       * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2617       * @see PackageManager#isPackageSuspended()
2618       * @see PackageManager#getSuspendedPackageAppExtras()
2619       */
2620      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2621      public static final String ACTION_MY_PACKAGE_SUSPENDED = "android.intent.action.MY_PACKAGE_SUSPENDED";
2622  
2623      /**
2624       * Activity Action: Started to show more details about why an application was suspended.
2625       *
2626       * <p>Whenever the system detects an activity launch for a suspended app, this action can
2627       * be used to show more details about the reason for suspension.
2628       *
2629       * <p>Apps holding {@link android.Manifest.permission#SUSPEND_APPS} must declare an activity
2630       * handling this intent and protect it with
2631       * {@link android.Manifest.permission#SEND_SHOW_SUSPENDED_APP_DETAILS}.
2632       *
2633       * <p>Includes an extra {@link #EXTRA_PACKAGE_NAME} which is the name of the suspended package.
2634       *
2635       * <p class="note">This is a protected intent that can only be sent
2636       * by the system.
2637       *
2638       * @see PackageManager#setPackagesSuspended(String[], boolean, PersistableBundle,
2639       * PersistableBundle, String)
2640       * @see PackageManager#isPackageSuspended()
2641       * @see #ACTION_PACKAGES_SUSPENDED
2642       *
2643       * @hide
2644       */
2645      @SystemApi
2646      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
2647      public static final String ACTION_SHOW_SUSPENDED_APP_DETAILS =
2648              "android.intent.action.SHOW_SUSPENDED_APP_DETAILS";
2649  
2650      /**
2651       * Broadcast Action: Sent to a package that has been unsuspended.
2652       *
2653       * <p class="note">This is a protected intent that can only be sent
2654       * by the system. <em>This will be delivered to {@link BroadcastReceiver} components declared in
2655       * the manifest.</em>
2656       *
2657       * @see #ACTION_MY_PACKAGE_SUSPENDED
2658       * @see #EXTRA_SUSPENDED_PACKAGE_EXTRAS
2659       * @see PackageManager#isPackageSuspended()
2660       * @see PackageManager#getSuspendedPackageAppExtras()
2661       */
2662      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2663      public static final String ACTION_MY_PACKAGE_UNSUSPENDED = "android.intent.action.MY_PACKAGE_UNSUSPENDED";
2664  
2665      /**
2666       * Broadcast Action: A user ID has been removed from the system.  The user
2667       * ID number is stored in the extra data under {@link #EXTRA_UID}.
2668       *
2669       * <p class="note">This is a protected intent that can only be sent
2670       * by the system.
2671       */
2672      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2673      public static final String ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
2674  
2675      /**
2676       * Broadcast Action: Sent to the installer package of an application when
2677       * that application is first launched (that is the first time it is moved
2678       * out of the stopped state).  The data contains the name of the package.
2679       *
2680       * <p class="note">This is a protected intent that can only be sent
2681       * by the system.
2682       */
2683      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2684      public static final String ACTION_PACKAGE_FIRST_LAUNCH = "android.intent.action.PACKAGE_FIRST_LAUNCH";
2685  
2686      /**
2687       * Broadcast Action: Sent to the system package verifier when a package
2688       * needs to be verified. The data contains the package URI.
2689       * <p class="note">
2690       * This is a protected intent that can only be sent by the system.
2691       * </p>
2692       */
2693      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2694      public static final String ACTION_PACKAGE_NEEDS_VERIFICATION = "android.intent.action.PACKAGE_NEEDS_VERIFICATION";
2695  
2696      /**
2697       * Broadcast Action: Sent to the system package verifier when a package is
2698       * verified. The data contains the package URI.
2699       * <p class="note">
2700       * This is a protected intent that can only be sent by the system.
2701       */
2702      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2703      public static final String ACTION_PACKAGE_VERIFIED = "android.intent.action.PACKAGE_VERIFIED";
2704  
2705      /**
2706       * Broadcast Action: Sent to the system intent filter verifier when an
2707       * intent filter needs to be verified. The data contains the filter data
2708       * hosts to be verified against.
2709       * <p class="note">
2710       * This is a protected intent that can only be sent by the system.
2711       * </p>
2712       *
2713       * @hide
2714       */
2715      @SystemApi
2716      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2717      public static final String ACTION_INTENT_FILTER_NEEDS_VERIFICATION = "android.intent.action.INTENT_FILTER_NEEDS_VERIFICATION";
2718  
2719      /**
2720       * Broadcast Action: Resources for a set of packages (which were
2721       * previously unavailable) are currently
2722       * available since the media on which they exist is available.
2723       * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2724       * list of packages whose availability changed.
2725       * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2726       * list of uids of packages whose availability changed.
2727       * Note that the
2728       * packages in this list do <em>not</em> receive this broadcast.
2729       * The specified set of packages are now available on the system.
2730       * <p>Includes the following extras:
2731       * <ul>
2732       * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2733       * whose resources(were previously unavailable) are currently available.
2734       * {@link #EXTRA_CHANGED_UID_LIST} is the set of uids of the
2735       * packages whose resources(were previously unavailable)
2736       * are  currently available.
2737       * </ul>
2738       *
2739       * <p class="note">This is a protected intent that can only be sent
2740       * by the system.
2741       */
2742      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2743      public static final String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE =
2744          "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE";
2745  
2746      /**
2747       * Broadcast Action: Resources for a set of packages are currently
2748       * unavailable since the media on which they exist is unavailable.
2749       * The extra data {@link #EXTRA_CHANGED_PACKAGE_LIST} contains a
2750       * list of packages whose availability changed.
2751       * The extra data {@link #EXTRA_CHANGED_UID_LIST} contains a
2752       * list of uids of packages whose availability changed.
2753       * The specified set of packages can no longer be
2754       * launched and are practically unavailable on the system.
2755       * <p>Inclues the following extras:
2756       * <ul>
2757       * <li> {@link #EXTRA_CHANGED_PACKAGE_LIST} is the set of packages
2758       * whose resources are no longer available.
2759       * {@link #EXTRA_CHANGED_UID_LIST} is the set of packages
2760       * whose resources are no longer available.
2761       * </ul>
2762       *
2763       * <p class="note">This is a protected intent that can only be sent
2764       * by the system.
2765       */
2766      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2767      public static final String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE =
2768          "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE";
2769  
2770      /**
2771       * Broadcast Action: preferred activities have changed *explicitly*.
2772       *
2773       * <p>Note there are cases where a preferred activity is invalidated *implicitly*, e.g.
2774       * when an app is installed or uninstalled, but in such cases this broadcast will *not*
2775       * be sent.
2776       *
2777       * {@link #EXTRA_USER_HANDLE} contains the user ID in question.
2778       *
2779       * @hide
2780       */
2781      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2782      public static final String ACTION_PREFERRED_ACTIVITY_CHANGED =
2783              "android.intent.action.ACTION_PREFERRED_ACTIVITY_CHANGED";
2784  
2785  
2786      /**
2787       * Broadcast Action:  The current system wallpaper has changed.  See
2788       * {@link android.app.WallpaperManager} for retrieving the new wallpaper.
2789       * This should <em>only</em> be used to determine when the wallpaper
2790       * has changed to show the new wallpaper to the user.  You should certainly
2791       * never, in response to this, change the wallpaper or other attributes of
2792       * it such as the suggested size.  That would be crazy, right?  You'd cause
2793       * all kinds of loops, especially if other apps are doing similar things,
2794       * right?  Of course.  So please don't do this.
2795       *
2796       * @deprecated Modern applications should use
2797       * {@link android.view.WindowManager.LayoutParams#FLAG_SHOW_WALLPAPER
2798       * WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER} to have the wallpaper
2799       * shown behind their UI, rather than watching for this broadcast and
2800       * rendering the wallpaper on their own.
2801       */
2802      @Deprecated @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2803      public static final String ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
2804      /**
2805       * Broadcast Action: The current device {@link android.content.res.Configuration}
2806       * (orientation, locale, etc) has changed.  When such a change happens, the
2807       * UIs (view hierarchy) will need to be rebuilt based on this new
2808       * information; for the most part, applications don't need to worry about
2809       * this, because the system will take care of stopping and restarting the
2810       * application to make sure it sees the new changes.  Some system code that
2811       * can not be restarted will need to watch for this action and handle it
2812       * appropriately.
2813       *
2814       * <p class="note">
2815       * You <em>cannot</em> receive this through components declared
2816       * in manifests, only by explicitly registering for it with
2817       * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2818       * Context.registerReceiver()}.
2819       *
2820       * <p class="note">This is a protected intent that can only be sent
2821       * by the system.
2822       *
2823       * @see android.content.res.Configuration
2824       */
2825      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2826      public static final String ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
2827  
2828      /**
2829       * Broadcast Action: The current device {@link android.content.res.Configuration} has changed
2830       * such that the device may be eligible for the installation of additional configuration splits.
2831       * Configuration properties that can trigger this broadcast include locale and display density.
2832       *
2833       * <p class="note">
2834       * Unlike {@link #ACTION_CONFIGURATION_CHANGED}, you <em>can</em> receive this through
2835       * components declared in manifests. However, the receiver <em>must</em> hold the
2836       * {@link android.Manifest.permission#INSTALL_PACKAGES} permission.
2837       *
2838       * <p class="note">
2839       * This is a protected intent that can only be sent by the system.
2840       *
2841       * @hide
2842       */
2843      @SystemApi
2844      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2845      public static final String ACTION_SPLIT_CONFIGURATION_CHANGED =
2846              "android.intent.action.SPLIT_CONFIGURATION_CHANGED";
2847      /**
2848       * Broadcast Action: The current device's locale has changed.
2849       *
2850       * <p class="note">This is a protected intent that can only be sent
2851       * by the system.
2852       */
2853      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2854      public static final String ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
2855      /**
2856       * Broadcast Action:  This is a <em>sticky broadcast</em> containing the
2857       * charging state, level, and other information about the battery.
2858       * See {@link android.os.BatteryManager} for documentation on the
2859       * contents of the Intent.
2860       *
2861       * <p class="note">
2862       * You <em>cannot</em> receive this through components declared
2863       * in manifests, only by explicitly registering for it with
2864       * {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2865       * Context.registerReceiver()}.  See {@link #ACTION_BATTERY_LOW},
2866       * {@link #ACTION_BATTERY_OKAY}, {@link #ACTION_POWER_CONNECTED},
2867       * and {@link #ACTION_POWER_DISCONNECTED} for distinct battery-related
2868       * broadcasts that are sent and can be received through manifest
2869       * receivers.
2870       *
2871       * <p class="note">This is a protected intent that can only be sent
2872       * by the system.
2873       */
2874      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2875      public static final String ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
2876  
2877  
2878      /**
2879       * Broadcast Action: Sent when the current battery level changes.
2880       *
2881       * It has {@link android.os.BatteryManager#EXTRA_EVENTS} that carries a list of {@link Bundle}
2882       * instances representing individual battery level changes with associated
2883       * extras from {@link #ACTION_BATTERY_CHANGED}.
2884       *
2885       * <p class="note">
2886       * This broadcast requires {@link android.Manifest.permission#BATTERY_STATS} permission.
2887       *
2888       * @hide
2889       */
2890      @SystemApi
2891      public static final String ACTION_BATTERY_LEVEL_CHANGED =
2892              "android.intent.action.BATTERY_LEVEL_CHANGED";
2893      /**
2894       * Broadcast Action:  Indicates low battery condition on the device.
2895       * This broadcast corresponds to the "Low battery warning" system dialog.
2896       *
2897       * <p class="note">This is a protected intent that can only be sent
2898       * by the system.
2899       */
2900      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2901      public static final String ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
2902      /**
2903       * Broadcast Action:  Indicates the battery is now okay after being low.
2904       * This will be sent after {@link #ACTION_BATTERY_LOW} once the battery has
2905       * gone back up to an okay state.
2906       *
2907       * <p class="note">This is a protected intent that can only be sent
2908       * by the system.
2909       */
2910      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2911      public static final String ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
2912      /**
2913       * Broadcast Action:  External power has been connected to the device.
2914       * This is intended for applications that wish to register specifically to this notification.
2915       * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2916       * stay active to receive this notification.  This action can be used to implement actions
2917       * that wait until power is available to trigger.
2918       *
2919       * <p class="note">This is a protected intent that can only be sent
2920       * by the system.
2921       */
2922      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2923      public static final String ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
2924      /**
2925       * Broadcast Action:  External power has been removed from the device.
2926       * This is intended for applications that wish to register specifically to this notification.
2927       * Unlike ACTION_BATTERY_CHANGED, applications will be woken for this and so do not have to
2928       * stay active to receive this notification.  This action can be used to implement actions
2929       * that wait until power is available to trigger.
2930       *
2931       * <p class="note">This is a protected intent that can only be sent
2932       * by the system.
2933       */
2934      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2935      public static final String ACTION_POWER_DISCONNECTED =
2936              "android.intent.action.ACTION_POWER_DISCONNECTED";
2937      /**
2938       * Broadcast Action:  Device is shutting down.
2939       * This is broadcast when the device is being shut down (completely turned
2940       * off, not sleeping).  Once the broadcast is complete, the final shutdown
2941       * will proceed and all unsaved data lost.  Apps will not normally need
2942       * to handle this, since the foreground activity will be paused as well.
2943       * <p>As of {@link Build.VERSION_CODES#P} this broadcast is only sent to receivers registered
2944       * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
2945       * Context.registerReceiver}.
2946       *
2947       * <p class="note">This is a protected intent that can only be sent
2948       * by the system.
2949       * <p>May include the following extras:
2950       * <ul>
2951       * <li> {@link #EXTRA_SHUTDOWN_USERSPACE_ONLY} a boolean that is set to true if this
2952       * shutdown is only for userspace processes.  If not set, assumed to be false.
2953       * </ul>
2954       */
2955      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2956      public static final String ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
2957      /**
2958       * Activity Action:  Start this activity to request system shutdown.
2959       * The optional boolean extra field {@link #EXTRA_KEY_CONFIRM} can be set to true
2960       * to request confirmation from the user before shutting down. The optional boolean
2961       * extra field {@link #EXTRA_USER_REQUESTED_SHUTDOWN} can be set to true to
2962       * indicate that the shutdown is requested by the user.
2963       *
2964       * <p class="note">This is a protected intent that can only be sent
2965       * by the system.
2966       *
2967       * {@hide}
2968       */
2969      public static final String ACTION_REQUEST_SHUTDOWN
2970              = "com.android.internal.intent.action.REQUEST_SHUTDOWN";
2971      /**
2972       * Broadcast Action: A sticky broadcast that indicates low storage space
2973       * condition on the device
2974       * <p class="note">
2975       * This is a protected intent that can only be sent by the system.
2976       *
2977       * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2978       *             or above, this broadcast will no longer be delivered to any
2979       *             {@link BroadcastReceiver} defined in your manifest. Instead,
2980       *             apps are strongly encouraged to use the improved
2981       *             {@link Context#getCacheDir()} behavior so the system can
2982       *             automatically free up storage when needed.
2983       */
2984      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
2985      @Deprecated
2986      public static final String ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
2987      /**
2988       * Broadcast Action: Indicates low storage space condition on the device no
2989       * longer exists
2990       * <p class="note">
2991       * This is a protected intent that can only be sent by the system.
2992       *
2993       * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
2994       *             or above, this broadcast will no longer be delivered to any
2995       *             {@link BroadcastReceiver} defined in your manifest. Instead,
2996       *             apps are strongly encouraged to use the improved
2997       *             {@link Context#getCacheDir()} behavior so the system can
2998       *             automatically free up storage when needed.
2999       */
3000      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3001      @Deprecated
3002      public static final String ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
3003      /**
3004       * Broadcast Action: A sticky broadcast that indicates a storage space full
3005       * condition on the device. This is intended for activities that want to be
3006       * able to fill the data partition completely, leaving only enough free
3007       * space to prevent system-wide SQLite failures.
3008       * <p class="note">
3009       * This is a protected intent that can only be sent by the system.
3010       *
3011       * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3012       *             or above, this broadcast will no longer be delivered to any
3013       *             {@link BroadcastReceiver} defined in your manifest. Instead,
3014       *             apps are strongly encouraged to use the improved
3015       *             {@link Context#getCacheDir()} behavior so the system can
3016       *             automatically free up storage when needed.
3017       * @hide
3018       */
3019      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3020      @Deprecated
3021      public static final String ACTION_DEVICE_STORAGE_FULL = "android.intent.action.DEVICE_STORAGE_FULL";
3022      /**
3023       * Broadcast Action: Indicates storage space full condition on the device no
3024       * longer exists.
3025       * <p class="note">
3026       * This is a protected intent that can only be sent by the system.
3027       *
3028       * @deprecated if your app targets {@link android.os.Build.VERSION_CODES#O}
3029       *             or above, this broadcast will no longer be delivered to any
3030       *             {@link BroadcastReceiver} defined in your manifest. Instead,
3031       *             apps are strongly encouraged to use the improved
3032       *             {@link Context#getCacheDir()} behavior so the system can
3033       *             automatically free up storage when needed.
3034       * @hide
3035       */
3036      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3037      @Deprecated
3038      public static final String ACTION_DEVICE_STORAGE_NOT_FULL = "android.intent.action.DEVICE_STORAGE_NOT_FULL";
3039      /**
3040       * Broadcast Action:  Indicates low memory condition notification acknowledged by user
3041       * and package management should be started.
3042       * This is triggered by the user from the ACTION_DEVICE_STORAGE_LOW
3043       * notification.
3044       */
3045      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3046      public static final String ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
3047      /**
3048       * Broadcast Action:  The device has entered USB Mass Storage mode.
3049       * This is used mainly for the USB Settings panel.
3050       * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3051       * when the SD card file system is mounted or unmounted
3052       * @deprecated replaced by android.os.storage.StorageEventListener
3053       */
3054      @Deprecated
3055      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3056      public static final String ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
3057  
3058      /**
3059       * Broadcast Action:  The device has exited USB Mass Storage mode.
3060       * This is used mainly for the USB Settings panel.
3061       * Apps should listen for ACTION_MEDIA_MOUNTED and ACTION_MEDIA_UNMOUNTED broadcasts to be notified
3062       * when the SD card file system is mounted or unmounted
3063       * @deprecated replaced by android.os.storage.StorageEventListener
3064       */
3065      @Deprecated
3066      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3067      public static final String ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
3068  
3069      /**
3070       * Broadcast Action:  External media has been removed.
3071       * The path to the mount point for the removed media is contained in the Intent.mData field.
3072       */
3073      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3074      public static final String ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
3075  
3076      /**
3077       * Broadcast Action:  External media is present, but not mounted at its mount point.
3078       * The path to the mount point for the unmounted media is contained in the Intent.mData field.
3079       */
3080      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3081      public static final String ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
3082  
3083      /**
3084       * Broadcast Action:  External media is present, and being disk-checked
3085       * The path to the mount point for the checking media is contained in the Intent.mData field.
3086       */
3087      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3088      public static final String ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
3089  
3090      /**
3091       * Broadcast Action:  External media is present, but is using an incompatible fs (or is blank)
3092       * The path to the mount point for the checking media is contained in the Intent.mData field.
3093       */
3094      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3095      public static final String ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
3096  
3097      /**
3098       * Broadcast Action:  External media is present and mounted at its mount point.
3099       * The path to the mount point for the mounted media is contained in the Intent.mData field.
3100       * The Intent contains an extra with name "read-only" and Boolean value to indicate if the
3101       * media was mounted read only.
3102       */
3103      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3104      public static final String ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
3105  
3106      /**
3107       * Broadcast Action:  External media is unmounted because it is being shared via USB mass storage.
3108       * The path to the mount point for the shared media is contained in the Intent.mData field.
3109       */
3110      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3111      public static final String ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
3112  
3113      /**
3114       * Broadcast Action:  External media is no longer being shared via USB mass storage.
3115       * The path to the mount point for the previously shared media is contained in the Intent.mData field.
3116       *
3117       * @hide
3118       */
3119      public static final String ACTION_MEDIA_UNSHARED = "android.intent.action.MEDIA_UNSHARED";
3120  
3121      /**
3122       * Broadcast Action:  External media was removed from SD card slot, but mount point was not unmounted.
3123       * The path to the mount point for the removed media is contained in the Intent.mData field.
3124       */
3125      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3126      public static final String ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
3127  
3128      /**
3129       * Broadcast Action:  External media is present but cannot be mounted.
3130       * The path to the mount point for the unmountable media is contained in the Intent.mData field.
3131       */
3132      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3133      public static final String ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
3134  
3135     /**
3136       * Broadcast Action:  User has expressed the desire to remove the external storage media.
3137       * Applications should close all files they have open within the mount point when they receive this intent.
3138       * The path to the mount point for the media to be ejected is contained in the Intent.mData field.
3139       */
3140      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3141      public static final String ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
3142  
3143      /**
3144       * Broadcast Action:  The media scanner has started scanning a directory.
3145       * The path to the directory being scanned is contained in the Intent.mData field.
3146       */
3147      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3148      public static final String ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
3149  
3150     /**
3151       * Broadcast Action:  The media scanner has finished scanning a directory.
3152       * The path to the scanned directory is contained in the Intent.mData field.
3153       */
3154      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3155      public static final String ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
3156  
3157      /**
3158       * Broadcast Action: Request the media scanner to scan a file and add it to
3159       * the media database.
3160       * <p>
3161       * The path to the file is contained in {@link Intent#getData()}.
3162       *
3163       * @deprecated Callers should migrate to inserting items directly into
3164       *             {@link MediaStore}, where they will be automatically scanned
3165       *             after each mutation.
3166       */
3167      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3168      @Deprecated
3169      public static final String ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
3170  
3171     /**
3172       * Broadcast Action:  The "Media Button" was pressed.  Includes a single
3173       * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3174       * caused the broadcast.
3175       */
3176      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3177      public static final String ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
3178  
3179      /**
3180       * Broadcast Action:  The "Camera Button" was pressed.  Includes a single
3181       * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3182       * caused the broadcast.
3183       */
3184      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3185      public static final String ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
3186  
3187      // *** NOTE: @todo(*) The following really should go into a more domain-specific
3188      // location; they are not general-purpose actions.
3189  
3190      /**
3191       * Broadcast Action: A GTalk connection has been established.
3192       */
3193      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3194      public static final String ACTION_GTALK_SERVICE_CONNECTED =
3195              "android.intent.action.GTALK_CONNECTED";
3196  
3197      /**
3198       * Broadcast Action: A GTalk connection has been disconnected.
3199       */
3200      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3201      public static final String ACTION_GTALK_SERVICE_DISCONNECTED =
3202              "android.intent.action.GTALK_DISCONNECTED";
3203  
3204      /**
3205       * Broadcast Action: An input method has been changed.
3206       */
3207      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3208      public static final String ACTION_INPUT_METHOD_CHANGED =
3209              "android.intent.action.INPUT_METHOD_CHANGED";
3210  
3211      /**
3212       * <p>Broadcast Action: The user has switched the phone into or out of Airplane Mode. One or
3213       * more radios have been turned off or on. The intent will have the following extra value:</p>
3214       * <ul>
3215       *   <li><em>state</em> - A boolean value indicating whether Airplane Mode is on. If true,
3216       *   then cell radio and possibly other radios such as bluetooth or WiFi may have also been
3217       *   turned off</li>
3218       * </ul>
3219       *
3220       * <p class="note">This is a protected intent that can only be sent by the system.</p>
3221       */
3222      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3223      public static final String ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
3224  
3225      /**
3226       * Broadcast Action: Some content providers have parts of their namespace
3227       * where they publish new events or items that the user may be especially
3228       * interested in. For these things, they may broadcast this action when the
3229       * set of interesting items change.
3230       *
3231       * For example, GmailProvider sends this notification when the set of unread
3232       * mail in the inbox changes.
3233       *
3234       * <p>The data of the intent identifies which part of which provider
3235       * changed. When queried through the content resolver, the data URI will
3236       * return the data set in question.
3237       *
3238       * <p>The intent will have the following extra values:
3239       * <ul>
3240       *   <li><em>count</em> - The number of items in the data set. This is the
3241       *       same as the number of items in the cursor returned by querying the
3242       *       data URI. </li>
3243       * </ul>
3244       *
3245       * This intent will be sent at boot (if the count is non-zero) and when the
3246       * data set changes. It is possible for the data set to change without the
3247       * count changing (for example, if a new unread message arrives in the same
3248       * sync operation in which a message is archived). The phone should still
3249       * ring/vibrate/etc as normal in this case.
3250       */
3251      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3252      public static final String ACTION_PROVIDER_CHANGED =
3253              "android.intent.action.PROVIDER_CHANGED";
3254  
3255      /**
3256       * Broadcast Action: Wired Headset plugged in or unplugged.
3257       *
3258       * Same as {@link android.media.AudioManager#ACTION_HEADSET_PLUG}, to be consulted for value
3259       *   and documentation.
3260       * <p>If the minimum SDK version of your application is
3261       * {@link android.os.Build.VERSION_CODES#LOLLIPOP}, it is recommended to refer
3262       * to the <code>AudioManager</code> constant in your receiver registration code instead.
3263       */
3264      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3265      public static final String ACTION_HEADSET_PLUG = android.media.AudioManager.ACTION_HEADSET_PLUG;
3266  
3267      /**
3268       * <p>Broadcast Action: The user has switched on advanced settings in the settings app:</p>
3269       * <ul>
3270       *   <li><em>state</em> - A boolean value indicating whether the settings is on or off.</li>
3271       * </ul>
3272       *
3273       * <p class="note">This is a protected intent that can only be sent
3274       * by the system.
3275       *
3276       * @hide
3277       */
3278      //@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3279      public static final String ACTION_ADVANCED_SETTINGS_CHANGED
3280              = "android.intent.action.ADVANCED_SETTINGS";
3281  
3282      /**
3283       *  Broadcast Action: Sent after application restrictions are changed.
3284       *
3285       * <p class="note">This is a protected intent that can only be sent
3286       * by the system.</p>
3287       */
3288      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3289      public static final String ACTION_APPLICATION_RESTRICTIONS_CHANGED =
3290              "android.intent.action.APPLICATION_RESTRICTIONS_CHANGED";
3291  
3292      /**
3293       * Broadcast Action: An outgoing call is about to be placed.
3294       *
3295       * <p>The Intent will have the following extra value:</p>
3296       * <ul>
3297       *   <li><em>{@link android.content.Intent#EXTRA_PHONE_NUMBER}</em> -
3298       *       the phone number originally intended to be dialed.</li>
3299       * </ul>
3300       * <p>Once the broadcast is finished, the resultData is used as the actual
3301       * number to call.  If  <code>null</code>, no call will be placed.</p>
3302       * <p>It is perfectly acceptable for multiple receivers to process the
3303       * outgoing call in turn: for example, a parental control application
3304       * might verify that the user is authorized to place the call at that
3305       * time, then a number-rewriting application might add an area code if
3306       * one was not specified.</p>
3307       * <p>For consistency, any receiver whose purpose is to prohibit phone
3308       * calls should have a priority of 0, to ensure it will see the final
3309       * phone number to be dialed.
3310       * Any receiver whose purpose is to rewrite phone numbers to be called
3311       * should have a positive priority.
3312       * Negative priorities are reserved for the system for this broadcast;
3313       * using them may cause problems.</p>
3314       * <p>Any BroadcastReceiver receiving this Intent <em>must not</em>
3315       * abort the broadcast.</p>
3316       * <p>Emergency calls cannot be intercepted using this mechanism, and
3317       * other calls cannot be modified to call emergency numbers using this
3318       * mechanism.
3319       * <p>Some apps (such as VoIP apps) may want to redirect the outgoing
3320       * call to use their own service instead. Those apps should first prevent
3321       * the call from being placed by setting resultData to <code>null</code>
3322       * and then start their own app to make the call.
3323       * <p>You must hold the
3324       * {@link android.Manifest.permission#PROCESS_OUTGOING_CALLS}
3325       * permission to receive this Intent.</p>
3326       *
3327       * <p class="note">This is a protected intent that can only be sent
3328       * by the system.
3329       *
3330       * <p class="note">If the user has chosen a {@link android.telecom.CallRedirectionService} to
3331       * handle redirection of outgoing calls, this intent will NOT be sent as an ordered broadcast.
3332       * This means that attempts to re-write the outgoing call by other apps using this intent will
3333       * be ignored.
3334       * </p>
3335       *
3336       * @deprecated Apps that redirect outgoing calls should use the
3337       * {@link android.telecom.CallRedirectionService} API.  Apps that perform call screening
3338       * should use the {@link android.telecom.CallScreeningService} API.
3339       */
3340      @Deprecated
3341      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3342      public static final String ACTION_NEW_OUTGOING_CALL =
3343              "android.intent.action.NEW_OUTGOING_CALL";
3344  
3345      /**
3346       * Broadcast Action: Have the device reboot.  This is only for use by
3347       * system code.
3348       *
3349       * <p class="note">This is a protected intent that can only be sent
3350       * by the system.
3351       */
3352      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3353      public static final String ACTION_REBOOT =
3354              "android.intent.action.REBOOT";
3355  
3356      /**
3357       * Broadcast Action:  A sticky broadcast for changes in the physical
3358       * docking state of the device.
3359       *
3360       * <p>The intent will have the following extra values:
3361       * <ul>
3362       *   <li><em>{@link #EXTRA_DOCK_STATE}</em> - the current dock
3363       *       state, indicating which dock the device is physically in.</li>
3364       * </ul>
3365       * <p>This is intended for monitoring the current physical dock state.
3366       * See {@link android.app.UiModeManager} for the normal API dealing with
3367       * dock mode changes.
3368       */
3369      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3370      public static final String ACTION_DOCK_EVENT =
3371              "android.intent.action.DOCK_EVENT";
3372  
3373      /**
3374       * Broadcast Action: A broadcast when idle maintenance can be started.
3375       * This means that the user is not interacting with the device and is
3376       * not expected to do so soon. Typical use of the idle maintenance is
3377       * to perform somehow expensive tasks that can be postponed at a moment
3378       * when they will not degrade user experience.
3379       * <p>
3380       * <p class="note">In order to keep the device responsive in case of an
3381       * unexpected user interaction, implementations of a maintenance task
3382       * should be interruptible. In such a scenario a broadcast with action
3383       * {@link #ACTION_IDLE_MAINTENANCE_END} will be sent. In other words, you
3384       * should not do the maintenance work in
3385       * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather start a
3386       * maintenance service by {@link Context#startService(Intent)}. Also
3387       * you should hold a wake lock while your maintenance service is running
3388       * to prevent the device going to sleep.
3389       * </p>
3390       * <p>
3391       * <p class="note">This is a protected intent that can only be sent by
3392       * the system.
3393       * </p>
3394       *
3395       * @see #ACTION_IDLE_MAINTENANCE_END
3396       *
3397       * @hide
3398       */
3399      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3400      public static final String ACTION_IDLE_MAINTENANCE_START =
3401              "android.intent.action.ACTION_IDLE_MAINTENANCE_START";
3402  
3403      /**
3404       * Broadcast Action:  A broadcast when idle maintenance should be stopped.
3405       * This means that the user was not interacting with the device as a result
3406       * of which a broadcast with action {@link #ACTION_IDLE_MAINTENANCE_START}
3407       * was sent and now the user started interacting with the device. Typical
3408       * use of the idle maintenance is to perform somehow expensive tasks that
3409       * can be postponed at a moment when they will not degrade user experience.
3410       * <p>
3411       * <p class="note">In order to keep the device responsive in case of an
3412       * unexpected user interaction, implementations of a maintenance task
3413       * should be interruptible. Hence, on receiving a broadcast with this
3414       * action, the maintenance task should be interrupted as soon as possible.
3415       * In other words, you should not do the maintenance work in
3416       * {@link BroadcastReceiver#onReceive(Context, Intent)}, rather stop the
3417       * maintenance service that was started on receiving of
3418       * {@link #ACTION_IDLE_MAINTENANCE_START}.Also you should release the wake
3419       * lock you acquired when your maintenance service started.
3420       * </p>
3421       * <p class="note">This is a protected intent that can only be sent
3422       * by the system.
3423       *
3424       * @see #ACTION_IDLE_MAINTENANCE_START
3425       *
3426       * @hide
3427       */
3428      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3429      public static final String ACTION_IDLE_MAINTENANCE_END =
3430              "android.intent.action.ACTION_IDLE_MAINTENANCE_END";
3431  
3432      /**
3433       * Broadcast Action: a remote intent is to be broadcasted.
3434       *
3435       * A remote intent is used for remote RPC between devices. The remote intent
3436       * is serialized and sent from one device to another device. The receiving
3437       * device parses the remote intent and broadcasts it. Note that anyone can
3438       * broadcast a remote intent. However, if the intent receiver of the remote intent
3439       * does not trust intent broadcasts from arbitrary intent senders, it should require
3440       * the sender to hold certain permissions so only trusted sender's broadcast will be
3441       * let through.
3442       * @hide
3443       */
3444      public static final String ACTION_REMOTE_INTENT =
3445              "com.google.android.c2dm.intent.RECEIVE";
3446  
3447      /**
3448       * Broadcast Action: This is broadcast once when the user is booting after a
3449       * system update. It can be used to perform cleanup or upgrades after a
3450       * system update.
3451       * <p>
3452       * This broadcast is sent after the {@link #ACTION_LOCKED_BOOT_COMPLETED}
3453       * broadcast but before the {@link #ACTION_BOOT_COMPLETED} broadcast. It's
3454       * only sent when the {@link Build#FINGERPRINT} has changed, and it's only
3455       * sent to receivers in the system image.
3456       *
3457       * @hide
3458       */
3459      @SystemApi
3460      public static final String ACTION_PRE_BOOT_COMPLETED =
3461              "android.intent.action.PRE_BOOT_COMPLETED";
3462  
3463      /**
3464       * Broadcast to a specific application to query any supported restrictions to impose
3465       * on restricted users. The broadcast intent contains an extra
3466       * {@link #EXTRA_RESTRICTIONS_BUNDLE} with the currently persisted
3467       * restrictions as a Bundle of key/value pairs. The value types can be Boolean, String or
3468       * String[] depending on the restriction type.<p/>
3469       * The response should contain an extra {@link #EXTRA_RESTRICTIONS_LIST},
3470       * which is of type <code>ArrayList&lt;RestrictionEntry&gt;</code>. It can also
3471       * contain an extra {@link #EXTRA_RESTRICTIONS_INTENT}, which is of type <code>Intent</code>.
3472       * The activity specified by that intent will be launched for a result which must contain
3473       * one of the extras {@link #EXTRA_RESTRICTIONS_LIST} or {@link #EXTRA_RESTRICTIONS_BUNDLE}.
3474       * The keys and values of the returned restrictions will be persisted.
3475       * @see RestrictionEntry
3476       */
3477      public static final String ACTION_GET_RESTRICTION_ENTRIES =
3478              "android.intent.action.GET_RESTRICTION_ENTRIES";
3479  
3480      /**
3481       * Sent the first time a user is starting, to allow system apps to
3482       * perform one time initialization.  (This will not be seen by third
3483       * party applications because a newly initialized user does not have any
3484       * third party applications installed for it.)  This is sent early in
3485       * starting the user, around the time the home app is started, before
3486       * {@link #ACTION_BOOT_COMPLETED} is sent.  This is sent as a foreground
3487       * broadcast, since it is part of a visible user interaction; be as quick
3488       * as possible when handling it.
3489       */
3490      public static final String ACTION_USER_INITIALIZE =
3491              "android.intent.action.USER_INITIALIZE";
3492  
3493      /**
3494       * Sent when a user switch is happening, causing the process's user to be
3495       * brought to the foreground.  This is only sent to receivers registered
3496       * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3497       * Context.registerReceiver}.  It is sent to the user that is going to the
3498       * foreground.  This is sent as a foreground
3499       * broadcast, since it is part of a visible user interaction; be as quick
3500       * as possible when handling it.
3501       */
3502      public static final String ACTION_USER_FOREGROUND =
3503              "android.intent.action.USER_FOREGROUND";
3504  
3505      /**
3506       * Sent when a user switch is happening, causing the process's user to be
3507       * sent to the background.  This is only sent to receivers registered
3508       * through {@link Context#registerReceiver(BroadcastReceiver, IntentFilter)
3509       * Context.registerReceiver}.  It is sent to the user that is going to the
3510       * background.  This is sent as a foreground
3511       * broadcast, since it is part of a visible user interaction; be as quick
3512       * as possible when handling it.
3513       */
3514      public static final String ACTION_USER_BACKGROUND =
3515              "android.intent.action.USER_BACKGROUND";
3516  
3517      /**
3518       * Broadcast sent to the system when a user is added. Carries an extra
3519       * EXTRA_USER_HANDLE that has the userHandle of the new user.  It is sent to
3520       * all running users.  You must hold
3521       * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3522       * @hide
3523       */
3524      @SystemApi
3525      public static final String ACTION_USER_ADDED =
3526              "android.intent.action.USER_ADDED";
3527  
3528      /**
3529       * Broadcast sent by the system when a user is started. Carries an extra
3530       * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only sent to
3531       * registered receivers, not manifest receivers.  It is sent to the user
3532       * that has been started.  This is sent as a foreground
3533       * broadcast, since it is part of a visible user interaction; be as quick
3534       * as possible when handling it.
3535       * @hide
3536       */
3537      public static final String ACTION_USER_STARTED =
3538              "android.intent.action.USER_STARTED";
3539  
3540      /**
3541       * Broadcast sent when a user is in the process of starting.  Carries an extra
3542       * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only
3543       * sent to registered receivers, not manifest receivers.  It is sent to all
3544       * users (including the one that is being started).  You must hold
3545       * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3546       * this broadcast.  This is sent as a background broadcast, since
3547       * its result is not part of the primary UX flow; to safely keep track of
3548       * started/stopped state of a user you can use this in conjunction with
3549       * {@link #ACTION_USER_STOPPING}.  It is <b>not</b> generally safe to use with
3550       * other user state broadcasts since those are foreground broadcasts so can
3551       * execute in a different order.
3552       * @hide
3553       */
3554      public static final String ACTION_USER_STARTING =
3555              "android.intent.action.USER_STARTING";
3556  
3557      /**
3558       * Broadcast sent when a user is going to be stopped.  Carries an extra
3559       * EXTRA_USER_HANDLE that has the userHandle of the user.  This is only
3560       * sent to registered receivers, not manifest receivers.  It is sent to all
3561       * users (including the one that is being stopped).  You must hold
3562       * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} to receive
3563       * this broadcast.  The user will not stop until all receivers have
3564       * handled the broadcast.  This is sent as a background broadcast, since
3565       * its result is not part of the primary UX flow; to safely keep track of
3566       * started/stopped state of a user you can use this in conjunction with
3567       * {@link #ACTION_USER_STARTING}.  It is <b>not</b> generally safe to use with
3568       * other user state broadcasts since those are foreground broadcasts so can
3569       * execute in a different order.
3570       * @hide
3571       */
3572      public static final String ACTION_USER_STOPPING =
3573              "android.intent.action.USER_STOPPING";
3574  
3575      /**
3576       * Broadcast sent to the system when a user is stopped. Carries an extra
3577       * EXTRA_USER_HANDLE that has the userHandle of the user.  This is similar to
3578       * {@link #ACTION_PACKAGE_RESTARTED}, but for an entire user instead of a
3579       * specific package.  This is only sent to registered receivers, not manifest
3580       * receivers.  It is sent to all running users <em>except</em> the one that
3581       * has just been stopped (which is no longer running).
3582       * @hide
3583       */
3584      public static final String ACTION_USER_STOPPED =
3585              "android.intent.action.USER_STOPPED";
3586  
3587      /**
3588       * Broadcast sent to the system when a user is removed. Carries an extra EXTRA_USER_HANDLE that has
3589       * the userHandle of the user.  It is sent to all running users except the
3590       * one that has been removed. The user will not be completely removed until all receivers have
3591       * handled the broadcast. You must hold
3592       * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3593       * @hide
3594       */
3595      @SystemApi
3596      public static final String ACTION_USER_REMOVED =
3597              "android.intent.action.USER_REMOVED";
3598  
3599      /**
3600       * Broadcast sent to the system when the user switches. Carries an extra EXTRA_USER_HANDLE that has
3601       * the userHandle of the user to become the current one. This is only sent to
3602       * registered receivers, not manifest receivers.  It is sent to all running users.
3603       * You must hold
3604       * {@link android.Manifest.permission#MANAGE_USERS} to receive this broadcast.
3605       * @hide
3606       */
3607      @UnsupportedAppUsage
3608      public static final String ACTION_USER_SWITCHED =
3609              "android.intent.action.USER_SWITCHED";
3610  
3611      /**
3612       * Broadcast Action: Sent when the credential-encrypted private storage has
3613       * become unlocked for the target user. This is only sent to registered
3614       * receivers, not manifest receivers.
3615       */
3616      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3617      public static final String ACTION_USER_UNLOCKED = "android.intent.action.USER_UNLOCKED";
3618  
3619      /**
3620       * Broadcast sent to the system when a user's information changes. Carries an extra
3621       * {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
3622       * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
3623       * @hide
3624       */
3625      public static final String ACTION_USER_INFO_CHANGED =
3626              "android.intent.action.USER_INFO_CHANGED";
3627  
3628      /**
3629       * Broadcast sent to the primary user when an associated managed profile is added (the profile
3630       * was created and is ready to be used). Carries an extra {@link #EXTRA_USER} that specifies
3631       * the UserHandle of the profile that was added. Only applications (for example Launchers)
3632       * that need to display merged content across both primary and managed profiles need to
3633       * worry about this broadcast. This is only sent to registered receivers,
3634       * not manifest receivers.
3635       */
3636      public static final String ACTION_MANAGED_PROFILE_ADDED =
3637              "android.intent.action.MANAGED_PROFILE_ADDED";
3638  
3639      /**
3640       * Broadcast sent to the primary user when an associated managed profile is removed. Carries an
3641       * extra {@link #EXTRA_USER} that specifies the UserHandle of the profile that was removed.
3642       * Only applications (for example Launchers) that need to display merged content across both
3643       * primary and managed profiles need to worry about this broadcast. This is only sent to
3644       * registered receivers, not manifest receivers.
3645       */
3646      public static final String ACTION_MANAGED_PROFILE_REMOVED =
3647              "android.intent.action.MANAGED_PROFILE_REMOVED";
3648  
3649      /**
3650       * Broadcast sent to the primary user when the credential-encrypted private storage for
3651       * an associated managed profile is unlocked. Carries an extra {@link #EXTRA_USER} that
3652       * specifies the UserHandle of the profile that was unlocked. Only applications (for example
3653       * Launchers) that need to display merged content across both primary and managed profiles
3654       * need to worry about this broadcast. This is only sent to registered receivers,
3655       * not manifest receivers.
3656       */
3657      public static final String ACTION_MANAGED_PROFILE_UNLOCKED =
3658              "android.intent.action.MANAGED_PROFILE_UNLOCKED";
3659  
3660      /**
3661       * Broadcast sent to the primary user when an associated managed profile has become available.
3662       * Currently this includes when the user disables quiet mode for the profile. Carries an extra
3663       * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3664       * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3665       * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3666       */
3667      public static final String ACTION_MANAGED_PROFILE_AVAILABLE =
3668              "android.intent.action.MANAGED_PROFILE_AVAILABLE";
3669  
3670      /**
3671       * Broadcast sent to the primary user when an associated managed profile has become unavailable.
3672       * Currently this includes when the user enables quiet mode for the profile. Carries an extra
3673       * {@link #EXTRA_USER} that specifies the UserHandle of the profile. When quiet mode is changed,
3674       * this broadcast will carry a boolean extra {@link #EXTRA_QUIET_MODE} indicating the new state
3675       * of quiet mode. This is only sent to registered receivers, not manifest receivers.
3676       */
3677      public static final String ACTION_MANAGED_PROFILE_UNAVAILABLE =
3678              "android.intent.action.MANAGED_PROFILE_UNAVAILABLE";
3679  
3680      /**
3681       * Broadcast sent to the system user when the 'device locked' state changes for any user.
3682       * Carries an extra {@link #EXTRA_USER_HANDLE} that specifies the ID of the user for which
3683       * the device was locked or unlocked.
3684       *
3685       * This is only sent to registered receivers.
3686       *
3687       * @hide
3688       */
3689      public static final String ACTION_DEVICE_LOCKED_CHANGED =
3690              "android.intent.action.DEVICE_LOCKED_CHANGED";
3691  
3692      /**
3693       * Sent when the user taps on the clock widget in the system's "quick settings" area.
3694       */
3695      public static final String ACTION_QUICK_CLOCK =
3696              "android.intent.action.QUICK_CLOCK";
3697  
3698      /**
3699       * Activity Action: Shows the brightness setting dialog.
3700       * @hide
3701       */
3702      public static final String ACTION_SHOW_BRIGHTNESS_DIALOG =
3703              "com.android.intent.action.SHOW_BRIGHTNESS_DIALOG";
3704  
3705      /**
3706       * Broadcast Action:  A global button was pressed.  Includes a single
3707       * extra field, {@link #EXTRA_KEY_EVENT}, containing the key event that
3708       * caused the broadcast.
3709       * @hide
3710       */
3711      @SystemApi
3712      public static final String ACTION_GLOBAL_BUTTON = "android.intent.action.GLOBAL_BUTTON";
3713  
3714      /**
3715       * Broadcast Action: Sent when media resource is granted.
3716       * <p>
3717       * {@link #EXTRA_PACKAGES} specifies the packages on the process holding the media resource
3718       * granted.
3719       * </p>
3720       * <p class="note">
3721       * This is a protected intent that can only be sent by the system.
3722       * </p>
3723       * <p class="note">
3724       * This requires {@link android.Manifest.permission#RECEIVE_MEDIA_RESOURCE_USAGE} permission.
3725       * </p>
3726       *
3727       * @hide
3728       */
3729      public static final String ACTION_MEDIA_RESOURCE_GRANTED =
3730              "android.intent.action.MEDIA_RESOURCE_GRANTED";
3731  
3732      /**
3733       * Broadcast Action: An overlay package has changed. The data contains the
3734       * name of the overlay package which has changed. This is broadcast on all
3735       * changes to the OverlayInfo returned by {@link
3736       * android.content.om.IOverlayManager#getOverlayInfo(String, int)}. The
3737       * most common change is a state change that will change whether the
3738       * overlay is enabled or not.
3739       * @hide
3740       */
3741      public static final String ACTION_OVERLAY_CHANGED = "android.intent.action.OVERLAY_CHANGED";
3742  
3743      /**
3744       * Activity Action: Allow the user to select and return one or more existing
3745       * documents. When invoked, the system will display the various
3746       * {@link DocumentsProvider} instances installed on the device, letting the
3747       * user interactively navigate through them. These documents include local
3748       * media, such as photos and video, and documents provided by installed
3749       * cloud storage providers.
3750       * <p>
3751       * Each document is represented as a {@code content://} URI backed by a
3752       * {@link DocumentsProvider}, which can be opened as a stream with
3753       * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3754       * {@link android.provider.DocumentsContract.Document} metadata.
3755       * <p>
3756       * All selected documents are returned to the calling application with
3757       * persistable read and write permission grants. If you want to maintain
3758       * access to the documents across device reboots, you need to explicitly
3759       * take the persistable permissions using
3760       * {@link ContentResolver#takePersistableUriPermission(Uri, int)}.
3761       * <p>
3762       * Callers must indicate the acceptable document MIME types through
3763       * {@link #setType(String)}. For example, to select photos, use
3764       * {@code image/*}. If multiple disjoint MIME types are acceptable, define
3765       * them in {@link #EXTRA_MIME_TYPES} and {@link #setType(String)} to
3766       * {@literal *}/*.
3767       * <p>
3768       * If the caller can handle multiple returned items (the user performing
3769       * multiple selection), then you can specify {@link #EXTRA_ALLOW_MULTIPLE}
3770       * to indicate this.
3771       * <p>
3772       * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3773       * URIs that can be opened with
3774       * {@link ContentResolver#openFileDescriptor(Uri, String)}.
3775       * <p>
3776       * Callers can set a document URI through
3777       * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3778       * location of documents navigator. System will do its best to launch the
3779       * navigator in the specified document if it's a folder, or the folder that
3780       * contains the specified document if not.
3781       * <p>
3782       * Output: The URI of the item that was picked, returned in
3783       * {@link #getData()}. This must be a {@code content://} URI so that any
3784       * receiver can access it. If multiple documents were selected, they are
3785       * returned in {@link #getClipData()}.
3786       *
3787       * @see DocumentsContract
3788       * @see #ACTION_OPEN_DOCUMENT_TREE
3789       * @see #ACTION_CREATE_DOCUMENT
3790       * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
3791       */
3792      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3793      public static final String ACTION_OPEN_DOCUMENT = "android.intent.action.OPEN_DOCUMENT";
3794  
3795      /**
3796       * Activity Action: Allow the user to create a new document. When invoked,
3797       * the system will display the various {@link DocumentsProvider} instances
3798       * installed on the device, letting the user navigate through them. The
3799       * returned document may be a newly created document with no content, or it
3800       * may be an existing document with the requested MIME type.
3801       * <p>
3802       * Each document is represented as a {@code content://} URI backed by a
3803       * {@link DocumentsProvider}, which can be opened as a stream with
3804       * {@link ContentResolver#openFileDescriptor(Uri, String)}, or queried for
3805       * {@link android.provider.DocumentsContract.Document} metadata.
3806       * <p>
3807       * Callers must indicate the concrete MIME type of the document being
3808       * created by setting {@link #setType(String)}. This MIME type cannot be
3809       * changed after the document is created.
3810       * <p>
3811       * Callers can provide an initial display name through {@link #EXTRA_TITLE},
3812       * but the user may change this value before creating the file.
3813       * <p>
3814       * Callers must include {@link #CATEGORY_OPENABLE} in the Intent to obtain
3815       * URIs that can be opened with
3816       * {@link ContentResolver#openFileDescriptor(Uri, String)}.
3817       * <p>
3818       * Callers can set a document URI through
3819       * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3820       * location of documents navigator. System will do its best to launch the
3821       * navigator in the specified document if it's a folder, or the folder that
3822       * contains the specified document if not.
3823       * <p>
3824       * Output: The URI of the item that was created. This must be a
3825       * {@code content://} URI so that any receiver can access it.
3826       *
3827       * @see DocumentsContract
3828       * @see #ACTION_OPEN_DOCUMENT
3829       * @see #ACTION_OPEN_DOCUMENT_TREE
3830       * @see #FLAG_GRANT_PERSISTABLE_URI_PERMISSION
3831       */
3832      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3833      public static final String ACTION_CREATE_DOCUMENT = "android.intent.action.CREATE_DOCUMENT";
3834  
3835      /**
3836       * Activity Action: Allow the user to pick a directory subtree. When
3837       * invoked, the system will display the various {@link DocumentsProvider}
3838       * instances installed on the device, letting the user navigate through
3839       * them. Apps can fully manage documents within the returned directory.
3840       * <p>
3841       * To gain access to descendant (child, grandchild, etc) documents, use
3842       * {@link DocumentsContract#buildDocumentUriUsingTree(Uri, String)} and
3843       * {@link DocumentsContract#buildChildDocumentsUriUsingTree(Uri, String)}
3844       * with the returned URI.
3845       * <p>
3846       * Callers can set a document URI through
3847       * {@link DocumentsContract#EXTRA_INITIAL_URI} to indicate the initial
3848       * location of documents navigator. System will do its best to launch the
3849       * navigator in the specified document if it's a folder, or the folder that
3850       * contains the specified document if not.
3851       * <p>
3852       * Output: The URI representing the selected directory tree.
3853       *
3854       * @see DocumentsContract
3855       */
3856      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3857      public static final String
3858              ACTION_OPEN_DOCUMENT_TREE = "android.intent.action.OPEN_DOCUMENT_TREE";
3859  
3860  
3861      /**
3862       * Activity Action: Perform text translation.
3863       * <p>
3864       * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to translate.
3865       * <p>
3866       * Output: nothing.
3867       */
3868      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3869      public static final String ACTION_TRANSLATE = "android.intent.action.TRANSLATE";
3870  
3871      /**
3872       * Activity Action: Define the meaning of the selected word(s).
3873       * <p>
3874       * Input: {@link #EXTRA_TEXT getCharSequence(EXTRA_TEXT)} is the text to define.
3875       * <p>
3876       * Output: nothing.
3877       */
3878      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3879      public static final String ACTION_DEFINE = "android.intent.action.DEFINE";
3880  
3881      /**
3882       * Broadcast Action: List of dynamic sensor is changed due to new sensor being connected or
3883       * exisiting sensor being disconnected.
3884       *
3885       * <p class="note">This is a protected intent that can only be sent by the system.</p>
3886       *
3887       * {@hide}
3888       */
3889      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3890      public static final String
3891              ACTION_DYNAMIC_SENSOR_CHANGED = "android.intent.action.DYNAMIC_SENSOR_CHANGED";
3892  
3893      /**
3894       * Deprecated - use ACTION_FACTORY_RESET instead.
3895       * @hide
3896       * @removed
3897       */
3898      @Deprecated
3899      @SystemApi
3900      public static final String ACTION_MASTER_CLEAR = "android.intent.action.MASTER_CLEAR";
3901  
3902      /**
3903       * Broadcast intent sent by the RecoverySystem to inform listeners that a master clear (wipe)
3904       * is about to be performed.
3905       * @hide
3906       */
3907      @SystemApi
3908      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3909      public static final String ACTION_MASTER_CLEAR_NOTIFICATION
3910              = "android.intent.action.MASTER_CLEAR_NOTIFICATION";
3911  
3912      /**
3913       * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3914       * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3915       *
3916       * <p>Deprecated - use {@link #EXTRA_FORCE_FACTORY_RESET} instead.
3917       *
3918       * @hide
3919       */
3920      @Deprecated
3921      public static final String EXTRA_FORCE_MASTER_CLEAR =
3922              "android.intent.extra.FORCE_MASTER_CLEAR";
3923  
3924      /**
3925       * A broadcast action to trigger a factory reset.
3926       *
3927       * <p>The sender must hold the {@link android.Manifest.permission#MASTER_CLEAR} permission. The
3928       * reason for the factory reset should be specified as {@link #EXTRA_REASON}.
3929       *
3930       * <p>Not for use by third-party applications.
3931       *
3932       * @see #EXTRA_FORCE_FACTORY_RESET
3933       *
3934       * {@hide}
3935       */
3936      @SystemApi
3937      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
3938      public static final String ACTION_FACTORY_RESET = "android.intent.action.FACTORY_RESET";
3939  
3940      /**
3941       * Boolean intent extra to be used with {@link #ACTION_MASTER_CLEAR} in order to force a factory
3942       * reset even if {@link android.os.UserManager#DISALLOW_FACTORY_RESET} is set.
3943       *
3944       * <p>Not for use by third-party applications.
3945       *
3946       * @hide
3947       */
3948      @SystemApi
3949      public static final String EXTRA_FORCE_FACTORY_RESET =
3950              "android.intent.extra.FORCE_FACTORY_RESET";
3951  
3952      /**
3953       * Broadcast action: report that a settings element is being restored from backup. The intent
3954       * contains four extras: EXTRA_SETTING_NAME is a string naming the restored setting,
3955       * EXTRA_SETTING_NEW_VALUE is the value being restored, EXTRA_SETTING_PREVIOUS_VALUE
3956       * is the value of that settings entry prior to the restore operation, and
3957       * EXTRA_SETTING_RESTORED_FROM_SDK_INT is the version of the SDK that the setting has been
3958       * restored from (corresponds to {@link android.os.Build.VERSION#SDK_INT}). The first three
3959       * values are represented as strings, the fourth one as int.
3960       *
3961       * <p>This broadcast is sent only for settings provider entries known to require special handling
3962       * around restore time.  These entries are found in the BROADCAST_ON_RESTORE table within
3963       * the provider's backup agent implementation.
3964       *
3965       * @see #EXTRA_SETTING_NAME
3966       * @see #EXTRA_SETTING_PREVIOUS_VALUE
3967       * @see #EXTRA_SETTING_NEW_VALUE
3968       * @see #EXTRA_SETTING_RESTORED_FROM_SDK_INT
3969       * {@hide}
3970       */
3971      public static final String ACTION_SETTING_RESTORED = "android.os.action.SETTING_RESTORED";
3972  
3973      /** {@hide} */
3974      public static final String EXTRA_SETTING_NAME = "setting_name";
3975      /** {@hide} */
3976      public static final String EXTRA_SETTING_PREVIOUS_VALUE = "previous_value";
3977      /** {@hide} */
3978      public static final String EXTRA_SETTING_NEW_VALUE = "new_value";
3979      /** {@hide} */
3980      public static final String EXTRA_SETTING_RESTORED_FROM_SDK_INT = "restored_from_sdk_int";
3981  
3982      /**
3983       * Activity Action: Process a piece of text.
3984       * <p>Input: {@link #EXTRA_PROCESS_TEXT} contains the text to be processed.
3985       * {@link #EXTRA_PROCESS_TEXT_READONLY} states if the resulting text will be read-only.</p>
3986       * <p>Output: {@link #EXTRA_PROCESS_TEXT} contains the processed text.</p>
3987       */
3988      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
3989      public static final String ACTION_PROCESS_TEXT = "android.intent.action.PROCESS_TEXT";
3990  
3991      /**
3992       * Broadcast Action: The sim card state has changed.
3993       * For more details see TelephonyIntents.ACTION_SIM_STATE_CHANGED. This is here
3994       * because TelephonyIntents is an internal class.
3995       * @hide
3996       * @deprecated Use {@link #ACTION_SIM_CARD_STATE_CHANGED} or
3997       * {@link #ACTION_SIM_APPLICATION_STATE_CHANGED}
3998       */
3999      @Deprecated
4000      @SystemApi
4001      @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
4002      public static final String ACTION_SIM_STATE_CHANGED = "android.intent.action.SIM_STATE_CHANGED";
4003  
4004      /**
4005       * Broadcast Action: indicate that the phone service state has changed.
4006       * The intent will have the following extra values:</p>
4007       * <p>
4008       * @see #EXTRA_VOICE_REG_STATE
4009       * @see #EXTRA_DATA_REG_STATE
4010       * @see #EXTRA_VOICE_ROAMING_TYPE
4011       * @see #EXTRA_DATA_ROAMING_TYPE
4012       * @see #EXTRA_OPERATOR_ALPHA_LONG
4013       * @see #EXTRA_OPERATOR_ALPHA_SHORT
4014       * @see #EXTRA_OPERATOR_NUMERIC
4015       * @see #EXTRA_DATA_OPERATOR_ALPHA_LONG
4016       * @see #EXTRA_DATA_OPERATOR_ALPHA_SHORT
4017       * @see #EXTRA_DATA_OPERATOR_NUMERIC
4018       * @see #EXTRA_MANUAL
4019       * @see #EXTRA_VOICE_RADIO_TECH
4020       * @see #EXTRA_DATA_RADIO_TECH
4021       * @see #EXTRA_CSS_INDICATOR
4022       * @see #EXTRA_NETWORK_ID
4023       * @see #EXTRA_SYSTEM_ID
4024       * @see #EXTRA_CDMA_ROAMING_INDICATOR
4025       * @see #EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR
4026       * @see #EXTRA_EMERGENCY_ONLY
4027       * @see #EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION
4028       * @see #EXTRA_IS_USING_CARRIER_AGGREGATION
4029       * @see #EXTRA_LTE_EARFCN_RSRP_BOOST
4030       *
4031       * <p class="note">
4032       * Requires the READ_PHONE_STATE permission.
4033       *
4034       * <p class="note">This is a protected intent that can only be sent by the system.
4035       * @hide
4036       * @removed
4037       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable} and the helper
4038       * functions {@code ServiceStateTable.getUriForSubscriptionIdAndField} and
4039       * {@code ServiceStateTable.getUriForSubscriptionId} to subscribe to changes to the ServiceState
4040       * for a given subscription id and field with a ContentObserver or using JobScheduler.
4041       */
4042      @Deprecated
4043      @SystemApi
4044      @SdkConstant(SdkConstant.SdkConstantType.BROADCAST_INTENT_ACTION)
4045      public static final String ACTION_SERVICE_STATE = "android.intent.action.SERVICE_STATE";
4046  
4047      /**
4048       * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates voice registration
4049       * state.
4050       * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4051       * @see android.telephony.ServiceState#STATE_IN_SERVICE
4052       * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4053       * @see android.telephony.ServiceState#STATE_POWER_OFF
4054       * @hide
4055       * @removed
4056       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_REG_STATE}.
4057       */
4058      @Deprecated
4059      @SystemApi
4060      public static final String EXTRA_VOICE_REG_STATE = "voiceRegState";
4061  
4062      /**
4063       * An int extra used with {@link #ACTION_SERVICE_STATE} which indicates data registration state.
4064       * @see android.telephony.ServiceState#STATE_EMERGENCY_ONLY
4065       * @see android.telephony.ServiceState#STATE_IN_SERVICE
4066       * @see android.telephony.ServiceState#STATE_OUT_OF_SERVICE
4067       * @see android.telephony.ServiceState#STATE_POWER_OFF
4068       * @hide
4069       * @removed
4070       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_REG_STATE}.
4071       */
4072      @Deprecated
4073      @SystemApi
4074      public static final String EXTRA_DATA_REG_STATE = "dataRegState";
4075  
4076      /**
4077       * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the voice roaming
4078       * type.
4079       * @hide
4080       * @removed
4081       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_ROAMING_TYPE}.
4082       */
4083      @Deprecated
4084      @SystemApi
4085      public static final String EXTRA_VOICE_ROAMING_TYPE = "voiceRoamingType";
4086  
4087      /**
4088       * An integer extra used with {@link #ACTION_SERVICE_STATE} which indicates the data roaming
4089       * type.
4090       * @hide
4091       * @removed
4092       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_ROAMING_TYPE}.
4093       */
4094      @Deprecated
4095      @SystemApi
4096      public static final String EXTRA_DATA_ROAMING_TYPE = "dataRoamingType";
4097  
4098      /**
4099       * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4100       * registered voice operator name in long alphanumeric format.
4101       * {@code null} if the operator name is not known or unregistered.
4102       * @hide
4103       * @removed
4104       * @deprecated Use
4105       * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_LONG}.
4106       */
4107      @Deprecated
4108      @SystemApi
4109      public static final String EXTRA_OPERATOR_ALPHA_LONG = "operator-alpha-long";
4110  
4111      /**
4112       * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4113       * registered voice operator name in short alphanumeric format.
4114       * {@code null} if the operator name is not known or unregistered.
4115       * @hide
4116       * @removed
4117       * @deprecated Use
4118       * {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_ALPHA_SHORT}.
4119       */
4120      @Deprecated
4121      @SystemApi
4122      public static final String EXTRA_OPERATOR_ALPHA_SHORT = "operator-alpha-short";
4123  
4124      /**
4125       * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4126       * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the mobile
4127       * network.
4128       * @hide
4129       * @removed
4130       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#VOICE_OPERATOR_NUMERIC}.
4131       */
4132      @Deprecated
4133      @SystemApi
4134      public static final String EXTRA_OPERATOR_NUMERIC = "operator-numeric";
4135  
4136      /**
4137       * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4138       * registered data operator name in long alphanumeric format.
4139       * {@code null} if the operator name is not known or unregistered.
4140       * @hide
4141       * @removed
4142       * @deprecated Use
4143       * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_LONG}.
4144       */
4145      @Deprecated
4146      @SystemApi
4147      public static final String EXTRA_DATA_OPERATOR_ALPHA_LONG = "data-operator-alpha-long";
4148  
4149      /**
4150       * A string extra used with {@link #ACTION_SERVICE_STATE} which represents the current
4151       * registered data operator name in short alphanumeric format.
4152       * {@code null} if the operator name is not known or unregistered.
4153       * @hide
4154       * @removed
4155       * @deprecated Use
4156       * {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_ALPHA_SHORT}.
4157       */
4158      @Deprecated
4159      @SystemApi
4160      public static final String EXTRA_DATA_OPERATOR_ALPHA_SHORT = "data-operator-alpha-short";
4161  
4162      /**
4163       * A string extra used with {@link #ACTION_SERVICE_STATE} containing the MCC
4164       * (Mobile Country Code, 3 digits) and MNC (Mobile Network code, 2-3 digits) for the
4165       * data operator.
4166       * @hide
4167       * @removed
4168       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#DATA_OPERATOR_NUMERIC}.
4169       */
4170      @Deprecated
4171      @SystemApi
4172      public static final String EXTRA_DATA_OPERATOR_NUMERIC = "data-operator-numeric";
4173  
4174      /**
4175       * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether the current
4176       * network selection mode is manual.
4177       * Will be {@code true} if manual mode, {@code false} if automatic mode.
4178       * @hide
4179       * @removed
4180       * @deprecated Use
4181       * {@link android.provider.Telephony.ServiceStateTable#IS_MANUAL_NETWORK_SELECTION}.
4182       */
4183      @Deprecated
4184      @SystemApi
4185      public static final String EXTRA_MANUAL = "manual";
4186  
4187      /**
4188       * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current voice
4189       * radio technology.
4190       * @hide
4191       * @removed
4192       * @deprecated Use
4193       * {@link android.provider.Telephony.ServiceStateTable#RIL_VOICE_RADIO_TECHNOLOGY}.
4194       */
4195      @Deprecated
4196      @SystemApi
4197      public static final String EXTRA_VOICE_RADIO_TECH = "radioTechnology";
4198  
4199      /**
4200       * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the current data
4201       * radio technology.
4202       * @hide
4203       * @removed
4204       * @deprecated Use
4205       * {@link android.provider.Telephony.ServiceStateTable#RIL_DATA_RADIO_TECHNOLOGY}.
4206       */
4207      @Deprecated
4208      @SystemApi
4209      public static final String EXTRA_DATA_RADIO_TECH = "dataRadioTechnology";
4210  
4211      /**
4212       * A boolean extra used with {@link #ACTION_SERVICE_STATE} which represents concurrent service
4213       * support on CDMA network.
4214       * Will be {@code true} if support, {@code false} otherwise.
4215       * @hide
4216       * @removed
4217       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CSS_INDICATOR}.
4218       */
4219      @Deprecated
4220      @SystemApi
4221      public static final String EXTRA_CSS_INDICATOR = "cssIndicator";
4222  
4223      /**
4224       * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA network
4225       * id. {@code Integer.MAX_VALUE} if unknown.
4226       * @hide
4227       * @removed
4228       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#NETWORK_ID}.
4229       */
4230      @Deprecated
4231      @SystemApi
4232      public static final String EXTRA_NETWORK_ID = "networkId";
4233  
4234      /**
4235       * An integer extra used with {@link #ACTION_SERVICE_STATE} which represents the CDMA system id.
4236       * {@code Integer.MAX_VALUE} if unknown.
4237       * @hide
4238       * @removed
4239       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#SYSTEM_ID}.
4240       */
4241      @Deprecated
4242      @SystemApi
4243      public static final String EXTRA_SYSTEM_ID = "systemId";
4244  
4245      /**
4246       * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the TSB-58 roaming
4247       * indicator if registered on a CDMA or EVDO system or {@code -1} if not.
4248       * @hide
4249       * @removed
4250       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#CDMA_ROAMING_INDICATOR}.
4251       */
4252      @Deprecated
4253      @SystemApi
4254      public static final String EXTRA_CDMA_ROAMING_INDICATOR = "cdmaRoamingIndicator";
4255  
4256      /**
4257       * An integer extra used with {@link #ACTION_SERVICE_STATE} represents the default roaming
4258       * indicator from the PRL if registered on a CDMA or EVDO system {@code -1} if not.
4259       * @hide
4260       * @removed
4261       * @deprecated Use
4262       * {@link android.provider.Telephony.ServiceStateTable#CDMA_DEFAULT_ROAMING_INDICATOR}.
4263       */
4264      @Deprecated
4265      @SystemApi
4266      public static final String EXTRA_CDMA_DEFAULT_ROAMING_INDICATOR = "cdmaDefaultRoamingIndicator";
4267  
4268      /**
4269       * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if under emergency
4270       * only mode.
4271       * {@code true} if in emergency only mode, {@code false} otherwise.
4272       * @hide
4273       * @removed
4274       * @deprecated Use {@link android.provider.Telephony.ServiceStateTable#IS_EMERGENCY_ONLY}.
4275       */
4276      @Deprecated
4277      @SystemApi
4278      public static final String EXTRA_EMERGENCY_ONLY = "emergencyOnly";
4279  
4280      /**
4281       * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates whether data network
4282       * registration state is roaming.
4283       * {@code true} if registration indicates roaming, {@code false} otherwise
4284       * @hide
4285       * @removed
4286       * @deprecated Use
4287       * {@link android.provider.Telephony.ServiceStateTable#IS_DATA_ROAMING_FROM_REGISTRATION}.
4288       */
4289      @Deprecated
4290      @SystemApi
4291      public static final String EXTRA_IS_DATA_ROAMING_FROM_REGISTRATION =
4292              "isDataRoamingFromRegistration";
4293  
4294      /**
4295       * A boolean extra used with {@link #ACTION_SERVICE_STATE} which indicates if carrier
4296       * aggregation is in use.
4297       * {@code true} if carrier aggregation is in use, {@code false} otherwise.
4298       * @hide
4299       * @removed
4300       * @deprecated Use
4301       * {@link android.provider.Telephony.ServiceStateTable#IS_USING_CARRIER_AGGREGATION}.
4302       */
4303      @Deprecated
4304      @SystemApi
4305      public static final String EXTRA_IS_USING_CARRIER_AGGREGATION = "isUsingCarrierAggregation";
4306  
4307      /**
4308       * An integer extra used with {@link #ACTION_SERVICE_STATE} representing the offset which
4309       * is reduced from the rsrp threshold while calculating signal strength level.
4310       * @hide
4311       * @removed
4312       */
4313      @Deprecated
4314      @SystemApi
4315      public static final String EXTRA_LTE_EARFCN_RSRP_BOOST = "LteEarfcnRsrpBoost";
4316  
4317      /**
4318       * An parcelable extra used with {@link #ACTION_SERVICE_STATE} representing the service state.
4319       * @hide
4320       */
4321      public static final String EXTRA_SERVICE_STATE = "android.intent.extra.SERVICE_STATE";
4322  
4323      /**
4324       * The name of the extra used to define the text to be processed, as a
4325       * CharSequence. Note that this may be a styled CharSequence, so you must use
4326       * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to retrieve it.
4327       */
4328      public static final String EXTRA_PROCESS_TEXT = "android.intent.extra.PROCESS_TEXT";
4329      /**
4330       * The name of the boolean extra used to define if the processed text will be used as read-only.
4331       */
4332      public static final String EXTRA_PROCESS_TEXT_READONLY =
4333              "android.intent.extra.PROCESS_TEXT_READONLY";
4334  
4335      /**
4336       * Broadcast action: reports when a new thermal event has been reached. When the device
4337       * is reaching its maximum temperatue, the thermal level reported
4338       * {@hide}
4339       */
4340      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4341      public static final String ACTION_THERMAL_EVENT = "android.intent.action.THERMAL_EVENT";
4342  
4343      /** {@hide} */
4344      public static final String EXTRA_THERMAL_STATE = "android.intent.extra.THERMAL_STATE";
4345  
4346      /**
4347       * Thermal state when the device is normal. This state is sent in the
4348       * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4349       * {@hide}
4350       */
4351      public static final int EXTRA_THERMAL_STATE_NORMAL = 0;
4352  
4353      /**
4354       * Thermal state where the device is approaching its maximum threshold. This state is sent in
4355       * the {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4356       * {@hide}
4357       */
4358      public static final int EXTRA_THERMAL_STATE_WARNING = 1;
4359  
4360      /**
4361       * Thermal state where the device has reached its maximum threshold. This state is sent in the
4362       * {@link #ACTION_THERMAL_EVENT} broadcast as {@link #EXTRA_THERMAL_STATE}.
4363       * {@hide}
4364       */
4365      public static final int EXTRA_THERMAL_STATE_EXCEEDED = 2;
4366  
4367      /**
4368       * Broadcast Action: Indicates the dock in idle state while device is docked.
4369       *
4370       * <p class="note">This is a protected intent that can only be sent
4371       * by the system.
4372       *
4373       * @hide
4374       */
4375      public static final String ACTION_DOCK_IDLE = "android.intent.action.DOCK_IDLE";
4376  
4377      /**
4378       * Broadcast Action: Indicates the dock in active state while device is docked.
4379       *
4380       * <p class="note">This is a protected intent that can only be sent
4381       * by the system.
4382       *
4383       * @hide
4384       */
4385      public static final String ACTION_DOCK_ACTIVE = "android.intent.action.DOCK_ACTIVE";
4386  
4387      /**
4388       * Broadcast Action: Indicates that a new device customization has been
4389       * downloaded and applied (packages installed, runtime resource overlays
4390       * enabled, xml files copied, ...), and that it is time for components that
4391       * need to for example clear their caches to do so now.
4392       *
4393       * @hide
4394       */
4395      @SystemApi
4396      public static final String ACTION_DEVICE_CUSTOMIZATION_READY =
4397              "android.intent.action.DEVICE_CUSTOMIZATION_READY";
4398  
4399  
4400      /**
4401       * Activity Action: Display an activity state associated with an unique {@link LocusId}.
4402       *
4403       * <p>For example, a chat app could use the context to resume a conversation between 2 users.
4404       *
4405       * <p>Input: {@link #EXTRA_LOCUS_ID} specifies the unique identifier of the locus in the
4406       * app domain. Should be stable across reboots and backup / restore.
4407       * <p>Output: nothing.
4408       */
4409      @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
4410      public static final String ACTION_VIEW_LOCUS = "android.intent.action.VIEW_LOCUS";
4411  
4412      // ---------------------------------------------------------------------
4413      // ---------------------------------------------------------------------
4414      // Standard intent categories (see addCategory()).
4415  
4416      /**
4417       * Set if the activity should be an option for the default action
4418       * (center press) to perform on a piece of data.  Setting this will
4419       * hide from the user any activities without it set when performing an
4420       * action on some data.  Note that this is normally -not- set in the
4421       * Intent when initiating an action -- it is for use in intent filters
4422       * specified in packages.
4423       */
4424      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4425      public static final String CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
4426      /**
4427       * Activities that can be safely invoked from a browser must support this
4428       * category.  For example, if the user is viewing a web page or an e-mail
4429       * and clicks on a link in the text, the Intent generated execute that
4430       * link will require the BROWSABLE category, so that only activities
4431       * supporting this category will be considered as possible actions.  By
4432       * supporting this category, you are promising that there is nothing
4433       * damaging (without user intervention) that can happen by invoking any
4434       * matching Intent.
4435       */
4436      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4437      public static final String CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
4438      /**
4439       * Categories for activities that can participate in voice interaction.
4440       * An activity that supports this category must be prepared to run with
4441       * no UI shown at all (though in some case it may have a UI shown), and
4442       * rely on {@link android.app.VoiceInteractor} to interact with the user.
4443       */
4444      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4445      public static final String CATEGORY_VOICE = "android.intent.category.VOICE";
4446      /**
4447       * Set if the activity should be considered as an alternative action to
4448       * the data the user is currently viewing.  See also
4449       * {@link #CATEGORY_SELECTED_ALTERNATIVE} for an alternative action that
4450       * applies to the selection in a list of items.
4451       *
4452       * <p>Supporting this category means that you would like your activity to be
4453       * displayed in the set of alternative things the user can do, usually as
4454       * part of the current activity's options menu.  You will usually want to
4455       * include a specific label in the &lt;intent-filter&gt; of this action
4456       * describing to the user what it does.
4457       *
4458       * <p>The action of IntentFilter with this category is important in that it
4459       * describes the specific action the target will perform.  This generally
4460       * should not be a generic action (such as {@link #ACTION_VIEW}, but rather
4461       * a specific name such as "com.android.camera.action.CROP.  Only one
4462       * alternative of any particular action will be shown to the user, so using
4463       * a specific action like this makes sure that your alternative will be
4464       * displayed while also allowing other applications to provide their own
4465       * overrides of that particular action.
4466       */
4467      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4468      public static final String CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
4469      /**
4470       * Set if the activity should be considered as an alternative selection
4471       * action to the data the user has currently selected.  This is like
4472       * {@link #CATEGORY_ALTERNATIVE}, but is used in activities showing a list
4473       * of items from which the user can select, giving them alternatives to the
4474       * default action that will be performed on it.
4475       */
4476      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4477      public static final String CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
4478      /**
4479       * Intended to be used as a tab inside of a containing TabActivity.
4480       */
4481      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4482      public static final String CATEGORY_TAB = "android.intent.category.TAB";
4483      /**
4484       * Should be displayed in the top-level launcher.
4485       */
4486      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4487      public static final String CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
4488      /**
4489       * Indicates an activity optimized for Leanback mode, and that should
4490       * be displayed in the Leanback launcher.
4491       */
4492      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4493      public static final String CATEGORY_LEANBACK_LAUNCHER = "android.intent.category.LEANBACK_LAUNCHER";
4494      /**
4495       * Indicates the preferred entry-point activity when an application is launched from a Car
4496       * launcher. If not present, Car launcher can optionally use {@link #CATEGORY_LAUNCHER} as a
4497       * fallback, or exclude the application entirely.
4498       * @hide
4499       */
4500      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4501      public static final String CATEGORY_CAR_LAUNCHER = "android.intent.category.CAR_LAUNCHER";
4502      /**
4503       * Indicates a Leanback settings activity to be displayed in the Leanback launcher.
4504       * @hide
4505       */
4506      @SystemApi
4507      public static final String CATEGORY_LEANBACK_SETTINGS = "android.intent.category.LEANBACK_SETTINGS";
4508      /**
4509       * Provides information about the package it is in; typically used if
4510       * a package does not contain a {@link #CATEGORY_LAUNCHER} to provide
4511       * a front-door to the user without having to be shown in the all apps list.
4512       */
4513      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4514      public static final String CATEGORY_INFO = "android.intent.category.INFO";
4515      /**
4516       * This is the home activity, that is the first activity that is displayed
4517       * when the device boots.
4518       */
4519      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4520      public static final String CATEGORY_HOME = "android.intent.category.HOME";
4521      /**
4522       * This is the home activity that is displayed when the device is finished setting up and ready
4523       * for use.
4524       * @hide
4525       */
4526      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4527      public static final String CATEGORY_HOME_MAIN = "android.intent.category.HOME_MAIN";
4528      /**
4529       * The home activity shown on secondary displays that support showing home activities.
4530       */
4531      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4532      public static final String CATEGORY_SECONDARY_HOME = "android.intent.category.SECONDARY_HOME";
4533      /**
4534       * This is the setup wizard activity, that is the first activity that is displayed
4535       * when the user sets up the device for the first time.
4536       * @hide
4537       */
4538      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4539      public static final String CATEGORY_SETUP_WIZARD = "android.intent.category.SETUP_WIZARD";
4540      /**
4541       * This is the home activity, that is the activity that serves as the launcher app
4542       * from there the user can start other apps. Often components with lower/higher
4543       * priority intent filters handle the home intent, for example SetupWizard, to
4544       * setup the device and we need to be able to distinguish the home app from these
4545       * setup helpers.
4546       * @hide
4547       */
4548      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4549      public static final String CATEGORY_LAUNCHER_APP = "android.intent.category.LAUNCHER_APP";
4550      /**
4551       * This activity is a preference panel.
4552       */
4553      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4554      public static final String CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
4555      /**
4556       * This activity is a development preference panel.
4557       */
4558      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4559      public static final String CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
4560      /**
4561       * Capable of running inside a parent activity container.
4562       */
4563      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4564      public static final String CATEGORY_EMBED = "android.intent.category.EMBED";
4565      /**
4566       * This activity allows the user to browse and download new applications.
4567       */
4568      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4569      public static final String CATEGORY_APP_MARKET = "android.intent.category.APP_MARKET";
4570      /**
4571       * This activity may be exercised by the monkey or other automated test tools.
4572       */
4573      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4574      public static final String CATEGORY_MONKEY = "android.intent.category.MONKEY";
4575      /**
4576       * To be used as a test (not part of the normal user experience).
4577       */
4578      public static final String CATEGORY_TEST = "android.intent.category.TEST";
4579      /**
4580       * To be used as a unit test (run through the Test Harness).
4581       */
4582      public static final String CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
4583      /**
4584       * To be used as a sample code example (not part of the normal user
4585       * experience).
4586       */
4587      public static final String CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
4588  
4589      /**
4590       * Used to indicate that an intent only wants URIs that can be opened with
4591       * {@link ContentResolver#openFileDescriptor(Uri, String)}. Openable URIs
4592       * must support at least the columns defined in {@link OpenableColumns} when
4593       * queried.
4594       *
4595       * @see #ACTION_GET_CONTENT
4596       * @see #ACTION_OPEN_DOCUMENT
4597       * @see #ACTION_CREATE_DOCUMENT
4598       */
4599      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4600      public static final String CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
4601  
4602      /**
4603       * Used to indicate that an intent filter can accept files which are not necessarily
4604       * openable by {@link ContentResolver#openFileDescriptor(Uri, String)}, but
4605       * at least streamable via
4606       * {@link ContentResolver#openTypedAssetFileDescriptor(Uri, String, Bundle)}
4607       * using one of the stream types exposed via
4608       * {@link ContentResolver#getStreamTypes(Uri, String)}.
4609       *
4610       * @see #ACTION_SEND
4611       * @see #ACTION_SEND_MULTIPLE
4612       */
4613      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4614      public static final String CATEGORY_TYPED_OPENABLE  =
4615              "android.intent.category.TYPED_OPENABLE";
4616  
4617      /**
4618       * To be used as code under test for framework instrumentation tests.
4619       */
4620      public static final String CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST =
4621              "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
4622      /**
4623       * An activity to run when device is inserted into a car dock.
4624       * Used with {@link #ACTION_MAIN} to launch an activity.  For more
4625       * information, see {@link android.app.UiModeManager}.
4626       */
4627      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4628      public static final String CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
4629      /**
4630       * An activity to run when device is inserted into a car dock.
4631       * Used with {@link #ACTION_MAIN} to launch an activity.  For more
4632       * information, see {@link android.app.UiModeManager}.
4633       */
4634      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4635      public static final String CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
4636      /**
4637       * An activity to run when device is inserted into a analog (low end) dock.
4638       * Used with {@link #ACTION_MAIN} to launch an activity.  For more
4639       * information, see {@link android.app.UiModeManager}.
4640       */
4641      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4642      public static final String CATEGORY_LE_DESK_DOCK = "android.intent.category.LE_DESK_DOCK";
4643  
4644      /**
4645       * An activity to run when device is inserted into a digital (high end) dock.
4646       * Used with {@link #ACTION_MAIN} to launch an activity.  For more
4647       * information, see {@link android.app.UiModeManager}.
4648       */
4649      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4650      public static final String CATEGORY_HE_DESK_DOCK = "android.intent.category.HE_DESK_DOCK";
4651  
4652      /**
4653       * Used to indicate that the activity can be used in a car environment.
4654       */
4655      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4656      public static final String CATEGORY_CAR_MODE = "android.intent.category.CAR_MODE";
4657  
4658      /**
4659       * An activity to use for the launcher when the device is placed in a VR Headset viewer.
4660       * Used with {@link #ACTION_MAIN} to launch an activity.  For more
4661       * information, see {@link android.app.UiModeManager}.
4662       */
4663      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4664      public static final String CATEGORY_VR_HOME = "android.intent.category.VR_HOME";
4665      // ---------------------------------------------------------------------
4666      // ---------------------------------------------------------------------
4667      // Application launch intent categories (see addCategory()).
4668  
4669      /**
4670       * Used with {@link #ACTION_MAIN} to launch the browser application.
4671       * The activity should be able to browse the Internet.
4672       * <p>NOTE: This should not be used as the primary key of an Intent,
4673       * since it will not result in the app launching with the correct
4674       * action and category.  Instead, use this with
4675       * {@link #makeMainSelectorActivity(String, String)} to generate a main
4676       * Intent with this category in the selector.</p>
4677       */
4678      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4679      public static final String CATEGORY_APP_BROWSER = "android.intent.category.APP_BROWSER";
4680  
4681      /**
4682       * Used with {@link #ACTION_MAIN} to launch the calculator application.
4683       * The activity should be able to perform standard arithmetic operations.
4684       * <p>NOTE: This should not be used as the primary key of an Intent,
4685       * since it will not result in the app launching with the correct
4686       * action and category.  Instead, use this with
4687       * {@link #makeMainSelectorActivity(String, String)} to generate a main
4688       * Intent with this category in the selector.</p>
4689       */
4690      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4691      public static final String CATEGORY_APP_CALCULATOR = "android.intent.category.APP_CALCULATOR";
4692  
4693      /**
4694       * Used with {@link #ACTION_MAIN} to launch the calendar application.
4695       * The activity should be able to view and manipulate calendar entries.
4696       * <p>NOTE: This should not be used as the primary key of an Intent,
4697       * since it will not result in the app launching with the correct
4698       * action and category.  Instead, use this with
4699       * {@link #makeMainSelectorActivity(String, String)} to generate a main
4700       * Intent with this category in the selector.</p>
4701       */
4702      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4703      public static final String CATEGORY_APP_CALENDAR = "android.intent.category.APP_CALENDAR";
4704  
4705      /**
4706       * Used with {@link #ACTION_MAIN} to launch the contacts application.
4707       * The activity should be able to view and manipulate address book entries.
4708       * <p>NOTE: This should not be used as the primary key of an Intent,
4709       * since it will not result in the app launching with the correct
4710       * action and category.  Instead, use this with
4711       * {@link #makeMainSelectorActivity(String, String)} to generate a main
4712       * Intent with this category in the selector.</p>
4713       */
4714      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4715      public static final String CATEGORY_APP_CONTACTS = "android.intent.category.APP_CONTACTS";
4716  
4717      /**
4718       * Used with {@link #ACTION_MAIN} to launch the email application.
4719       * The activity should be able to send and receive email.
4720       * <p>NOTE: This should not be used as the primary key of an Intent,
4721       * since it will not result in the app launching with the correct
4722       * action and category.  Instead, use this with
4723       * {@link #makeMainSelectorActivity(String, String)} to generate a main
4724       * Intent with this category in the selector.</p>
4725       */
4726      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4727      public static final String CATEGORY_APP_EMAIL = "android.intent.category.APP_EMAIL";
4728  
4729      /**
4730       * Used with {@link #ACTION_MAIN} to launch the gallery application.
4731       * The activity should be able to view and manipulate image and video files
4732       * stored on the device.
4733       * <p>NOTE: This should not be used as the primary key of an Intent,
4734       * since it will not result in the app launching with the correct
4735       * action and category.  Instead, use this with
4736       * {@link #makeMainSelectorActivity(String, String)} to generate a main
4737       * Intent with this category in the selector.</p>
4738       */
4739      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4740      public static final String CATEGORY_APP_GALLERY = "android.intent.category.APP_GALLERY";
4741  
4742      /**
4743       * Used with {@link #ACTION_MAIN} to launch the maps application.
4744       * The activity should be able to show the user's current location and surroundings.
4745       * <p>NOTE: This should not be used as the primary key of an Intent,
4746       * since it will not result in the app launching with the correct
4747       * action and category.  Instead, use this with
4748       * {@link #makeMainSelectorActivity(String, String)} to generate a main
4749       * Intent with this category in the selector.</p>
4750       */
4751      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4752      public static final String CATEGORY_APP_MAPS = "android.intent.category.APP_MAPS";
4753  
4754      /**
4755       * Used with {@link #ACTION_MAIN} to launch the messaging application.
4756       * The activity should be able to send and receive text messages.
4757       * <p>NOTE: This should not be used as the primary key of an Intent,
4758       * since it will not result in the app launching with the correct
4759       * action and category.  Instead, use this with
4760       * {@link #makeMainSelectorActivity(String, String)} to generate a main
4761       * Intent with this category in the selector.</p>
4762       */
4763      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4764      public static final String CATEGORY_APP_MESSAGING = "android.intent.category.APP_MESSAGING";
4765  
4766      /**
4767       * Used with {@link #ACTION_MAIN} to launch the music application.
4768       * The activity should be able to play, browse, or manipulate music files
4769       * stored on the device.
4770       * <p>NOTE: This should not be used as the primary key of an Intent,
4771       * since it will not result in the app launching with the correct
4772       * action and category.  Instead, use this with
4773       * {@link #makeMainSelectorActivity(String, String)} to generate a main
4774       * Intent with this category in the selector.</p>
4775       */
4776      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4777      public static final String CATEGORY_APP_MUSIC = "android.intent.category.APP_MUSIC";
4778  
4779      /**
4780       * Used with {@link #ACTION_MAIN} to launch the files application.
4781       * The activity should be able to browse and manage files stored on the device.
4782       * <p>NOTE: This should not be used as the primary key of an Intent,
4783       * since it will not result in the app launching with the correct
4784       * action and category.  Instead, use this with
4785       * {@link #makeMainSelectorActivity(String, String)} to generate a main
4786       * Intent with this category in the selector.</p>
4787       */
4788      @SdkConstant(SdkConstantType.INTENT_CATEGORY)
4789      public static final String CATEGORY_APP_FILES = "android.intent.category.APP_FILES";
4790  
4791      // ---------------------------------------------------------------------
4792      // ---------------------------------------------------------------------
4793      // Standard extra data keys.
4794  
4795      /**
4796       * The initial data to place in a newly created record.  Use with
4797       * {@link #ACTION_INSERT}.  The data here is a Map containing the same
4798       * fields as would be given to the underlying ContentProvider.insert()
4799       * call.
4800       */
4801      public static final String EXTRA_TEMPLATE = "android.intent.extra.TEMPLATE";
4802  
4803      /**
4804       * A constant CharSequence that is associated with the Intent, used with
4805       * {@link #ACTION_SEND} to supply the literal data to be sent.  Note that
4806       * this may be a styled CharSequence, so you must use
4807       * {@link Bundle#getCharSequence(String) Bundle.getCharSequence()} to
4808       * retrieve it.
4809       */
4810      public static final String EXTRA_TEXT = "android.intent.extra.TEXT";
4811  
4812      /**
4813       * A constant String that is associated with the Intent, used with
4814       * {@link #ACTION_SEND} to supply an alternative to {@link #EXTRA_TEXT}
4815       * as HTML formatted text.  Note that you <em>must</em> also supply
4816       * {@link #EXTRA_TEXT}.
4817       */
4818      public static final String EXTRA_HTML_TEXT = "android.intent.extra.HTML_TEXT";
4819  
4820      /**
4821       * A content: URI holding a stream of data associated with the Intent,
4822       * used with {@link #ACTION_SEND} to supply the data being sent.
4823       */
4824      public static final String EXTRA_STREAM = "android.intent.extra.STREAM";
4825  
4826      /**
4827       * A String[] holding e-mail addresses that should be delivered to.
4828       */
4829      public static final String EXTRA_EMAIL       = "android.intent.extra.EMAIL";
4830  
4831      /**
4832       * A String[] holding e-mail addresses that should be carbon copied.
4833       */
4834      public static final String EXTRA_CC       = "android.intent.extra.CC";
4835  
4836      /**
4837       * A String[] holding e-mail addresses that should be blind carbon copied.
4838       */
4839      public static final String EXTRA_BCC      = "android.intent.extra.BCC";
4840  
4841      /**
4842       * A constant string holding the desired subject line of a message.
4843       */
4844      public static final String EXTRA_SUBJECT  = "android.intent.extra.SUBJECT";
4845  
4846      /**
4847       * An Intent describing the choices you would like shown with
4848       * {@link #ACTION_PICK_ACTIVITY} or {@link #ACTION_CHOOSER}.
4849       */
4850      public static final String EXTRA_INTENT = "android.intent.extra.INTENT";
4851  
4852      /**
4853       * An int representing the user id to be used.
4854       *
4855       * @hide
4856       */
4857      public static final String EXTRA_USER_ID = "android.intent.extra.USER_ID";
4858  
4859      /**
4860       * An int representing the task id to be retrieved. This is used when a launch from recents is
4861       * intercepted by another action such as credentials confirmation to remember which task should
4862       * be resumed when complete.
4863       *
4864       * @hide
4865       */
4866      public static final String EXTRA_TASK_ID = "android.intent.extra.TASK_ID";
4867  
4868      /**
4869       * An Intent[] describing additional, alternate choices you would like shown with
4870       * {@link #ACTION_CHOOSER}.
4871       *
4872       * <p>An app may be capable of providing several different payload types to complete a
4873       * user's intended action. For example, an app invoking {@link #ACTION_SEND} to share photos
4874       * with another app may use EXTRA_ALTERNATE_INTENTS to have the chooser transparently offer
4875       * several different supported sending mechanisms for sharing, such as the actual "image/*"
4876       * photo data or a hosted link where the photos can be viewed.</p>
4877       *
4878       * <p>The intent present in {@link #EXTRA_INTENT} will be treated as the
4879       * first/primary/preferred intent in the set. Additional intents specified in
4880       * this extra are ordered; by default intents that appear earlier in the array will be
4881       * preferred over intents that appear later in the array as matches for the same
4882       * target component. To alter this preference, a calling app may also supply
4883       * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER}.</p>
4884       */
4885      public static final String EXTRA_ALTERNATE_INTENTS = "android.intent.extra.ALTERNATE_INTENTS";
4886  
4887      /**
4888       * A {@link ComponentName ComponentName[]} describing components that should be filtered out
4889       * and omitted from a list of components presented to the user.
4890       *
4891       * <p>When used with {@link #ACTION_CHOOSER}, the chooser will omit any of the components
4892       * in this array if it otherwise would have shown them. Useful for omitting specific targets
4893       * from your own package or other apps from your organization if the idea of sending to those
4894       * targets would be redundant with other app functionality. Filtered components will not
4895       * be able to present targets from an associated <code>ChooserTargetService</code>.</p>
4896       */
4897      public static final String EXTRA_EXCLUDE_COMPONENTS
4898              = "android.intent.extra.EXCLUDE_COMPONENTS";
4899  
4900      /**
4901       * A {@link android.service.chooser.ChooserTarget ChooserTarget[]} for {@link #ACTION_CHOOSER}
4902       * describing additional high-priority deep-link targets for the chooser to present to the user.
4903       *
4904       * <p>Targets provided in this way will be presented inline with all other targets provided
4905       * by services from other apps. They will be prioritized before other service targets, but
4906       * after those targets provided by sources that the user has manually pinned to the front.</p>
4907       *
4908       * @see #ACTION_CHOOSER
4909       */
4910      public static final String EXTRA_CHOOSER_TARGETS = "android.intent.extra.CHOOSER_TARGETS";
4911  
4912      /**
4913       * An {@link IntentSender} for an Activity that will be invoked when the user makes a selection
4914       * from the chooser activity presented by {@link #ACTION_CHOOSER}.
4915       *
4916       * <p>An app preparing an action for another app to complete may wish to allow the user to
4917       * disambiguate between several options for completing the action based on the chosen target
4918       * or otherwise refine the action before it is invoked.
4919       * </p>
4920       *
4921       * <p>When sent, this IntentSender may be filled in with the following extras:</p>
4922       * <ul>
4923       *     <li>{@link #EXTRA_INTENT} The first intent that matched the user's chosen target</li>
4924       *     <li>{@link #EXTRA_ALTERNATE_INTENTS} Any additional intents that also matched the user's
4925       *     chosen target beyond the first</li>
4926       *     <li>{@link #EXTRA_RESULT_RECEIVER} A {@link ResultReceiver} that the refinement activity
4927       *     should fill in and send once the disambiguation is complete</li>
4928       * </ul>
4929       */
4930      public static final String EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER
4931              = "android.intent.extra.CHOOSER_REFINEMENT_INTENT_SENDER";
4932  
4933      /**
4934       * An {@code ArrayList} of {@code String} annotations describing content for
4935       * {@link #ACTION_CHOOSER}.
4936       *
4937       * <p>If {@link #EXTRA_CONTENT_ANNOTATIONS} is present in an intent used to start a
4938       * {@link #ACTION_CHOOSER} activity, the first three annotations will be used to rank apps.</p>
4939       *
4940       * <p>Annotations should describe the major components or topics of the content. It is up to
4941       * apps initiating {@link #ACTION_CHOOSER} to learn and add annotations. Annotations should be
4942       * learned in advance, e.g., when creating or saving content, to avoid increasing latency to
4943       * start {@link #ACTION_CHOOSER}. Names of customized annotations should not contain the colon
4944       * character. Performance on customized annotations can suffer, if they are rarely used for
4945       * {@link #ACTION_CHOOSER} in the past 14 days. Therefore, it is recommended to use the
4946       * following annotations when applicable.</p>
4947       * <ul>
4948       *     <li>"product" represents that the topic of the content is mainly about products, e.g.,
4949       *     health & beauty, and office supplies.</li>
4950       *     <li>"emotion" represents that the topic of the content is mainly about emotions, e.g.,
4951       *     happy, and sad.</li>
4952       *     <li>"person" represents that the topic of the content is mainly about persons, e.g.,
4953       *     face, finger, standing, and walking.</li>
4954       *     <li>"child" represents that the topic of the content is mainly about children, e.g.,
4955       *     child, and baby.</li>
4956       *     <li>"selfie" represents that the topic of the content is mainly about selfies.</li>
4957       *     <li>"crowd" represents that the topic of the content is mainly about crowds.</li>
4958       *     <li>"party" represents that the topic of the content is mainly about parties.</li>
4959       *     <li>"animal" represent that the topic of the content is mainly about animals.</li>
4960       *     <li>"plant" represents that the topic of the content is mainly about plants, e.g.,
4961       *     flowers.</li>
4962       *     <li>"vacation" represents that the topic of the content is mainly about vacations.</li>
4963       *     <li>"fashion" represents that the topic of the content is mainly about fashion, e.g.
4964       *     sunglasses, jewelry, handbags and clothing.</li>
4965       *     <li>"material" represents that the topic of the content is mainly about materials, e.g.,
4966       *     paper, and silk.</li>
4967       *     <li>"vehicle" represents that the topic of the content is mainly about vehicles, like
4968       *     cars, and boats.</li>
4969       *     <li>"document" represents that the topic of the content is mainly about documents, e.g.
4970       *     posters.</li>
4971       *     <li>"design" represents that the topic of the content is mainly about design, e.g. arts
4972       *     and designs of houses.</li>
4973       *     <li>"holiday" represents that the topic of the content is mainly about holidays, e.g.,
4974       *     Christmas and Thanksgiving.</li>
4975       * </ul>
4976       */
4977      public static final String EXTRA_CONTENT_ANNOTATIONS
4978              = "android.intent.extra.CONTENT_ANNOTATIONS";
4979  
4980      /**
4981       * A {@link ResultReceiver} used to return data back to the sender.
4982       *
4983       * <p>Used to complete an app-specific
4984       * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER refinement} for {@link #ACTION_CHOOSER}.</p>
4985       *
4986       * <p>If {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} is present in the intent
4987       * used to start a {@link #ACTION_CHOOSER} activity this extra will be
4988       * {@link #fillIn(Intent, int) filled in} to that {@link IntentSender} and sent
4989       * when the user selects a target component from the chooser. It is up to the recipient
4990       * to send a result to this ResultReceiver to signal that disambiguation is complete
4991       * and that the chooser should invoke the user's choice.</p>
4992       *
4993       * <p>The disambiguator should provide a Bundle to the ResultReceiver with an intent
4994       * assigned to the key {@link #EXTRA_INTENT}. This supplied intent will be used by the chooser
4995       * to match and fill in the final Intent or ChooserTarget before starting it.
4996       * The supplied intent must {@link #filterEquals(Intent) match} one of the intents from
4997       * {@link #EXTRA_INTENT} or {@link #EXTRA_ALTERNATE_INTENTS} passed to
4998       * {@link #EXTRA_CHOOSER_REFINEMENT_INTENT_SENDER} to be accepted.</p>
4999       *
5000       * <p>The result code passed to the ResultReceiver should be
5001       * {@link android.app.Activity#RESULT_OK} if the refinement succeeded and the supplied intent's
5002       * target in the chooser should be started, or {@link android.app.Activity#RESULT_CANCELED} if
5003       * the chooser should finish without starting a target.</p>
5004       */
5005      public static final String EXTRA_RESULT_RECEIVER
5006              = "android.intent.extra.RESULT_RECEIVER";
5007  
5008      /**
5009       * A CharSequence dialog title to provide to the user when used with a
5010       * {@link #ACTION_CHOOSER}.
5011       */
5012      public static final String EXTRA_TITLE = "android.intent.extra.TITLE";
5013  
5014      /**
5015       * A Parcelable[] of {@link Intent} or
5016       * {@link android.content.pm.LabeledIntent} objects as set with
5017       * {@link #putExtra(String, Parcelable[])} of additional activities to place
5018       * a the front of the list of choices, when shown to the user with a
5019       * {@link #ACTION_CHOOSER}.
5020       */
5021      public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
5022  
5023      /**
5024       * A {@link IntentSender} to start after instant app installation success.
5025       * @hide
5026       */
5027      @SystemApi
5028      public static final String EXTRA_INSTANT_APP_SUCCESS =
5029              "android.intent.extra.INSTANT_APP_SUCCESS";
5030  
5031      /**
5032       * A {@link IntentSender} to start after instant app installation failure.
5033       * @hide
5034       */
5035      @SystemApi
5036      public static final String EXTRA_INSTANT_APP_FAILURE =
5037              "android.intent.extra.INSTANT_APP_FAILURE";
5038  
5039      /**
5040       * The host name that triggered an instant app resolution.
5041       * @hide
5042       */
5043      @SystemApi
5044      public static final String EXTRA_INSTANT_APP_HOSTNAME =
5045              "android.intent.extra.INSTANT_APP_HOSTNAME";
5046  
5047      /**
5048       * An opaque token to track instant app resolution.
5049       * @hide
5050       */
5051      @SystemApi
5052      public static final String EXTRA_INSTANT_APP_TOKEN =
5053              "android.intent.extra.INSTANT_APP_TOKEN";
5054  
5055      /**
5056       * The action that triggered an instant application resolution.
5057       * @hide
5058       */
5059      @SystemApi
5060      public static final String EXTRA_INSTANT_APP_ACTION = "android.intent.extra.INSTANT_APP_ACTION";
5061  
5062      /**
5063       * An array of {@link Bundle}s containing details about resolved instant apps..
5064       * @hide
5065       */
5066      @SystemApi
5067      public static final String EXTRA_INSTANT_APP_BUNDLES =
5068              "android.intent.extra.INSTANT_APP_BUNDLES";
5069  
5070      /**
5071       * A {@link Bundle} of metadata that describes the instant application that needs to be
5072       * installed. This data is populated from the response to
5073       * {@link android.content.pm.InstantAppResolveInfo#getExtras()} as provided by the registered
5074       * instant application resolver.
5075       * @hide
5076       */
5077      @SystemApi
5078      public static final String EXTRA_INSTANT_APP_EXTRAS =
5079              "android.intent.extra.INSTANT_APP_EXTRAS";
5080  
5081      /**
5082       * A boolean value indicating that the instant app resolver was unable to state with certainty
5083       * that it did or did not have an app for the sanitized {@link Intent} defined at
5084       * {@link #EXTRA_INTENT}.
5085       * @hide
5086       */
5087      @SystemApi
5088      public static final String EXTRA_UNKNOWN_INSTANT_APP =
5089              "android.intent.extra.UNKNOWN_INSTANT_APP";
5090  
5091      /**
5092       * The version code of the app to install components from.
5093       * @deprecated Use {@link #EXTRA_LONG_VERSION_CODE).
5094       * @hide
5095       */
5096      @Deprecated
5097      public static final String EXTRA_VERSION_CODE = "android.intent.extra.VERSION_CODE";
5098  
5099      /**
5100       * The version code of the app to install components from.
5101       * @hide
5102       */
5103      @SystemApi
5104      public static final String EXTRA_LONG_VERSION_CODE = "android.intent.extra.LONG_VERSION_CODE";
5105  
5106      /**
5107       * The app that triggered the instant app installation.
5108       * @hide
5109       */
5110      @SystemApi
5111      public static final String EXTRA_CALLING_PACKAGE
5112              = "android.intent.extra.CALLING_PACKAGE";
5113  
5114      /**
5115       * Optional calling app provided bundle containing additional launch information the
5116       * installer may use.
5117       * @hide
5118       */
5119      @SystemApi
5120      public static final String EXTRA_VERIFICATION_BUNDLE
5121              = "android.intent.extra.VERIFICATION_BUNDLE";
5122  
5123      /**
5124       * A Bundle forming a mapping of potential target package names to different extras Bundles
5125       * to add to the default intent extras in {@link #EXTRA_INTENT} when used with
5126       * {@link #ACTION_CHOOSER}. Each key should be a package name. The package need not
5127       * be currently installed on the device.
5128       *
5129       * <p>An application may choose to provide alternate extras for the case where a user
5130       * selects an activity from a predetermined set of target packages. If the activity
5131       * the user selects from the chooser belongs to a package with its package name as
5132       * a key in this bundle, the corresponding extras for that package will be merged with
5133       * the extras already present in the intent at {@link #EXTRA_INTENT}. If a replacement
5134       * extra has the same key as an extra already present in the intent it will overwrite
5135       * the extra from the intent.</p>
5136       *
5137       * <p><em>Examples:</em>
5138       * <ul>
5139       *     <li>An application may offer different {@link #EXTRA_TEXT} to an application
5140       *     when sharing with it via {@link #ACTION_SEND}, augmenting a link with additional query
5141       *     parameters for that target.</li>
5142       *     <li>An application may offer additional metadata for known targets of a given intent
5143       *     to pass along information only relevant to that target such as account or content
5144       *     identifiers already known to that application.</li>
5145       * </ul></p>
5146       */
5147      public static final String EXTRA_REPLACEMENT_EXTRAS =
5148              "android.intent.extra.REPLACEMENT_EXTRAS";
5149  
5150      /**
5151       * An {@link IntentSender} that will be notified if a user successfully chooses a target
5152       * component to handle an action in an {@link #ACTION_CHOOSER} activity. The IntentSender
5153       * will have the extra {@link #EXTRA_CHOSEN_COMPONENT} appended to it containing the
5154       * {@link ComponentName} of the chosen component.
5155       *
5156       * <p>In some situations this callback may never come, for example if the user abandons
5157       * the chooser, switches to another task or any number of other reasons. Apps should not
5158       * be written assuming that this callback will always occur.</p>
5159       */
5160      public static final String EXTRA_CHOSEN_COMPONENT_INTENT_SENDER =
5161              "android.intent.extra.CHOSEN_COMPONENT_INTENT_SENDER";
5162  
5163      /**
5164       * The {@link ComponentName} chosen by the user to complete an action.
5165       *
5166       * @see #EXTRA_CHOSEN_COMPONENT_INTENT_SENDER
5167       */
5168      public static final String EXTRA_CHOSEN_COMPONENT = "android.intent.extra.CHOSEN_COMPONENT";
5169  
5170      /**
5171       * A {@link android.view.KeyEvent} object containing the event that
5172       * triggered the creation of the Intent it is in.
5173       */
5174      public static final String EXTRA_KEY_EVENT = "android.intent.extra.KEY_EVENT";
5175  
5176      /**
5177       * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to request confirmation from the user
5178       * before shutting down.
5179       *
5180       * {@hide}
5181       */
5182      public static final String EXTRA_KEY_CONFIRM = "android.intent.extra.KEY_CONFIRM";
5183  
5184      /**
5185       * Set to true in {@link #ACTION_REQUEST_SHUTDOWN} to indicate that the shutdown is
5186       * requested by the user.
5187       *
5188       * {@hide}
5189       */
5190      public static final String EXTRA_USER_REQUESTED_SHUTDOWN =
5191              "android.intent.extra.USER_REQUESTED_SHUTDOWN";
5192  
5193      /**
5194       * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5195       * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} intents to override the default action
5196       * of restarting the application.
5197       */
5198      public static final String EXTRA_DONT_KILL_APP = "android.intent.extra.DONT_KILL_APP";
5199  
5200      /**
5201       * A String holding the phone number originally entered in
5202       * {@link android.content.Intent#ACTION_NEW_OUTGOING_CALL}, or the actual
5203       * number to call in a {@link android.content.Intent#ACTION_CALL}.
5204       */
5205      public static final String EXTRA_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";
5206  
5207      /**
5208       * Used as an int extra field in {@link android.content.Intent#ACTION_UID_REMOVED}
5209       * intents to supply the uid the package had been assigned.  Also an optional
5210       * extra in {@link android.content.Intent#ACTION_PACKAGE_REMOVED} or
5211       * {@link android.content.Intent#ACTION_PACKAGE_CHANGED} for the same
5212       * purpose.
5213       */
5214      public static final String EXTRA_UID = "android.intent.extra.UID";
5215  
5216      /**
5217       * @hide String array of package names.
5218       */
5219      @SystemApi
5220      public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES";
5221  
5222      /**
5223       * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5224       * intents to indicate whether this represents a full uninstall (removing
5225       * both the code and its data) or a partial uninstall (leaving its data,
5226       * implying that this is an update).
5227       */
5228      public static final String EXTRA_DATA_REMOVED = "android.intent.extra.DATA_REMOVED";
5229  
5230      /**
5231       * @hide
5232       * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5233       * intents to indicate that at this point the package has been removed for
5234       * all users on the device.
5235       */
5236      public static final String EXTRA_REMOVED_FOR_ALL_USERS
5237              = "android.intent.extra.REMOVED_FOR_ALL_USERS";
5238  
5239      /**
5240       * Used as a boolean extra field in {@link android.content.Intent#ACTION_PACKAGE_REMOVED}
5241       * intents to indicate that this is a replacement of the package, so this
5242       * broadcast will immediately be followed by an add broadcast for a
5243       * different version of the same package.
5244       */
5245      public static final String EXTRA_REPLACING = "android.intent.extra.REPLACING";
5246  
5247      /**
5248       * Used as an int extra field in {@link android.app.AlarmManager} intents
5249       * to tell the application being invoked how many pending alarms are being
5250       * delievered with the intent.  For one-shot alarms this will always be 1.
5251       * For recurring alarms, this might be greater than 1 if the device was
5252       * asleep or powered off at the time an earlier alarm would have been
5253       * delivered.
5254       */
5255      public static final String EXTRA_ALARM_COUNT = "android.intent.extra.ALARM_COUNT";
5256  
5257      /**
5258       * Used as an int extra field in {@link android.content.Intent#ACTION_DOCK_EVENT}
5259       * intents to request the dock state.  Possible values are
5260       * {@link android.content.Intent#EXTRA_DOCK_STATE_UNDOCKED},
5261       * {@link android.content.Intent#EXTRA_DOCK_STATE_DESK}, or
5262       * {@link android.content.Intent#EXTRA_DOCK_STATE_CAR}, or
5263       * {@link android.content.Intent#EXTRA_DOCK_STATE_LE_DESK}, or
5264       * {@link android.content.Intent#EXTRA_DOCK_STATE_HE_DESK}.
5265       */
5266      public static final String EXTRA_DOCK_STATE = "android.intent.extra.DOCK_STATE";
5267  
5268      /**
5269       * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5270       * to represent that the phone is not in any dock.
5271       */
5272      public static final int EXTRA_DOCK_STATE_UNDOCKED = 0;
5273  
5274      /**
5275       * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5276       * to represent that the phone is in a desk dock.
5277       */
5278      public static final int EXTRA_DOCK_STATE_DESK = 1;
5279  
5280      /**
5281       * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5282       * to represent that the phone is in a car dock.
5283       */
5284      public static final int EXTRA_DOCK_STATE_CAR = 2;
5285  
5286      /**
5287       * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5288       * to represent that the phone is in a analog (low end) dock.
5289       */
5290      public static final int EXTRA_DOCK_STATE_LE_DESK = 3;
5291  
5292      /**
5293       * Used as an int value for {@link android.content.Intent#EXTRA_DOCK_STATE}
5294       * to represent that the phone is in a digital (high end) dock.
5295       */
5296      public static final int EXTRA_DOCK_STATE_HE_DESK = 4;
5297  
5298      /**
5299       * Boolean that can be supplied as meta-data with a dock activity, to
5300       * indicate that the dock should take over the home key when it is active.
5301       */
5302      public static final String METADATA_DOCK_HOME = "android.dock_home";
5303  
5304      /**
5305       * Used as a parcelable extra field in {@link #ACTION_APP_ERROR}, containing
5306       * the bug report.
5307       */
5308      public static final String EXTRA_BUG_REPORT = "android.intent.extra.BUG_REPORT";
5309  
5310      /**
5311       * Used in the extra field in the remote intent. It's astring token passed with the
5312       * remote intent.
5313       */
5314      public static final String EXTRA_REMOTE_INTENT_TOKEN =
5315              "android.intent.extra.remote_intent_token";
5316  
5317      /**
5318       * @deprecated See {@link #EXTRA_CHANGED_COMPONENT_NAME_LIST}; this field
5319       * will contain only the first name in the list.
5320       */
5321      @Deprecated public static final String EXTRA_CHANGED_COMPONENT_NAME =
5322              "android.intent.extra.changed_component_name";
5323  
5324      /**
5325       * This field is part of {@link android.content.Intent#ACTION_PACKAGE_CHANGED},
5326       * and contains a string array of all of the components that have changed.  If
5327       * the state of the overall package has changed, then it will contain an entry
5328       * with the package name itself.
5329       */
5330      public static final String EXTRA_CHANGED_COMPONENT_NAME_LIST =
5331              "android.intent.extra.changed_component_name_list";
5332  
5333      /**
5334       * This field is part of
5335       * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5336       * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE},
5337       * {@link android.content.Intent#ACTION_PACKAGES_SUSPENDED},
5338       * {@link android.content.Intent#ACTION_PACKAGES_UNSUSPENDED}
5339       * and contains a string array of all of the components that have changed.
5340       */
5341      public static final String EXTRA_CHANGED_PACKAGE_LIST =
5342              "android.intent.extra.changed_package_list";
5343  
5344      /**
5345       * This field is part of
5346       * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_AVAILABLE},
5347       * {@link android.content.Intent#ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE}
5348       * and contains an integer array of uids of all of the components
5349       * that have changed.
5350       */
5351      public static final String EXTRA_CHANGED_UID_LIST =
5352              "android.intent.extra.changed_uid_list";
5353  
5354      /**
5355       * An integer denoting a bitwise combination of restrictions set on distracting packages via
5356       * {@link PackageManager#setDistractingPackageRestrictions(String[], int)}
5357       *
5358       * @hide
5359       * @see PackageManager.DistractionRestriction
5360       * @see PackageManager#setDistractingPackageRestrictions(String[], int)
5361       */
5362      public static final String EXTRA_DISTRACTION_RESTRICTIONS =
5363              "android.intent.extra.distraction_restrictions";
5364  
5365      /**
5366       * @hide
5367       * Magic extra system code can use when binding, to give a label for
5368       * who it is that has bound to a service.  This is an integer giving
5369       * a framework string resource that can be displayed to the user.
5370       */
5371      public static final String EXTRA_CLIENT_LABEL =
5372              "android.intent.extra.client_label";
5373  
5374      /**
5375       * @hide
5376       * Magic extra system code can use when binding, to give a PendingIntent object
5377       * that can be launched for the user to disable the system's use of this
5378       * service.
5379       */
5380      public static final String EXTRA_CLIENT_INTENT =
5381              "android.intent.extra.client_intent";
5382  
5383      /**
5384       * Extra used to indicate that an intent should only return data that is on
5385       * the local device. This is a boolean extra; the default is false. If true,
5386       * an implementation should only allow the user to select data that is
5387       * already on the device, not requiring it be downloaded from a remote
5388       * service when opened.
5389       *
5390       * @see #ACTION_GET_CONTENT
5391       * @see #ACTION_OPEN_DOCUMENT
5392       * @see #ACTION_OPEN_DOCUMENT_TREE
5393       * @see #ACTION_CREATE_DOCUMENT
5394       */
5395      public static final String EXTRA_LOCAL_ONLY =
5396              "android.intent.extra.LOCAL_ONLY";
5397  
5398      /**
5399       * Extra used to indicate that an intent can allow the user to select and
5400       * return multiple items. This is a boolean extra; the default is false. If
5401       * true, an implementation is allowed to present the user with a UI where
5402       * they can pick multiple items that are all returned to the caller. When
5403       * this happens, they should be returned as the {@link #getClipData()} part
5404       * of the result Intent.
5405       *
5406       * @see #ACTION_GET_CONTENT
5407       * @see #ACTION_OPEN_DOCUMENT
5408       */
5409      public static final String EXTRA_ALLOW_MULTIPLE =
5410              "android.intent.extra.ALLOW_MULTIPLE";
5411  
5412      /**
5413       * The integer userHandle carried with broadcast intents related to addition, removal and
5414       * switching of users and managed profiles - {@link #ACTION_USER_ADDED},
5415       * {@link #ACTION_USER_REMOVED} and {@link #ACTION_USER_SWITCHED}.
5416       *
5417       * @hide
5418       */
5419      public static final String EXTRA_USER_HANDLE =
5420              "android.intent.extra.user_handle";
5421  
5422      /**
5423       * The UserHandle carried with intents.
5424       */
5425      public static final String EXTRA_USER =
5426              "android.intent.extra.USER";
5427  
5428      /**
5429       * Extra used in the response from a BroadcastReceiver that handles
5430       * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is
5431       * <code>ArrayList&lt;RestrictionEntry&gt;</code>.
5432       */
5433      public static final String EXTRA_RESTRICTIONS_LIST = "android.intent.extra.restrictions_list";
5434  
5435      /**
5436       * Extra sent in the intent to the BroadcastReceiver that handles
5437       * {@link #ACTION_GET_RESTRICTION_ENTRIES}. The type of the extra is a Bundle containing
5438       * the restrictions as key/value pairs.
5439       */
5440      public static final String EXTRA_RESTRICTIONS_BUNDLE =
5441              "android.intent.extra.restrictions_bundle";
5442  
5443      /**
5444       * Extra used in the response from a BroadcastReceiver that handles
5445       * {@link #ACTION_GET_RESTRICTION_ENTRIES}.
5446       */
5447      public static final String EXTRA_RESTRICTIONS_INTENT =
5448              "android.intent.extra.restrictions_intent";
5449  
5450      /**
5451       * Extra used to communicate a set of acceptable MIME types. The type of the
5452       * extra is {@code String[]}. Values may be a combination of concrete MIME
5453       * types (such as "image/png") and/or partial MIME types (such as
5454       * "audio/*").
5455       *
5456       * @see #ACTION_GET_CONTENT
5457       * @see #ACTION_OPEN_DOCUMENT
5458       */
5459      public static final String EXTRA_MIME_TYPES = "android.intent.extra.MIME_TYPES";
5460  
5461      /**
5462       * Optional extra for {@link #ACTION_SHUTDOWN} that allows the sender to qualify that
5463       * this shutdown is only for the user space of the system, not a complete shutdown.
5464       * When this is true, hardware devices can use this information to determine that
5465       * they shouldn't do a complete shutdown of their device since this is not a
5466       * complete shutdown down to the kernel, but only user space restarting.
5467       * The default if not supplied is false.
5468       */
5469      public static final String EXTRA_SHUTDOWN_USERSPACE_ONLY
5470              = "android.intent.extra.SHUTDOWN_USERSPACE_ONLY";
5471  
5472      /**
5473       * Optional int extra for {@link #ACTION_TIME_CHANGED} that indicates the
5474       * user has set their time format preference. See {@link #EXTRA_TIME_PREF_VALUE_USE_12_HOUR},
5475       * {@link #EXTRA_TIME_PREF_VALUE_USE_24_HOUR} and
5476       * {@link #EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT}. The value must not be negative.
5477       *
5478       * @hide for internal use only.
5479       */
5480      public static final String EXTRA_TIME_PREF_24_HOUR_FORMAT =
5481              "android.intent.extra.TIME_PREF_24_HOUR_FORMAT";
5482      /** @hide */
5483      public static final int EXTRA_TIME_PREF_VALUE_USE_12_HOUR = 0;
5484      /** @hide */
5485      public static final int EXTRA_TIME_PREF_VALUE_USE_24_HOUR = 1;
5486      /** @hide */
5487      public static final int EXTRA_TIME_PREF_VALUE_USE_LOCALE_DEFAULT = 2;
5488  
5489      /**
5490       * Intent extra: the reason that the operation associated with this intent is being performed.
5491       *
5492       * <p>Type: String
5493       * @hide
5494       */
5495      @SystemApi
5496      public static final String EXTRA_REASON = "android.intent.extra.REASON";
5497  
5498      /**
5499       * {@hide}
5500       * This extra will be send together with {@link #ACTION_FACTORY_RESET}
5501       */
5502      public static final String EXTRA_WIPE_EXTERNAL_STORAGE = "android.intent.extra.WIPE_EXTERNAL_STORAGE";
5503  
5504      /**
5505       * {@hide}
5506       * This extra will be set to true when the user choose to wipe the data on eSIM during factory
5507       * reset for the device with eSIM. This extra will be sent together with
5508       * {@link #ACTION_FACTORY_RESET}
5509       */
5510      public static final String EXTRA_WIPE_ESIMS = "com.android.internal.intent.extra.WIPE_ESIMS";
5511  
5512      /**
5513       * Optional {@link android.app.PendingIntent} extra used to deliver the result of the SIM
5514       * activation request.
5515       * TODO: Add information about the structure and response data used with the pending intent.
5516       * @hide
5517       */
5518      public static final String EXTRA_SIM_ACTIVATION_RESPONSE =
5519              "android.intent.extra.SIM_ACTIVATION_RESPONSE";
5520  
5521      /**
5522       * Optional index with semantics depending on the intent action.
5523       *
5524       * <p>The value must be an integer greater or equal to 0.
5525       * @see #ACTION_QUICK_VIEW
5526       */
5527      public static final String EXTRA_INDEX = "android.intent.extra.INDEX";
5528  
5529      /**
5530       * Tells the quick viewer to show additional UI actions suitable for the passed Uris,
5531       * such as opening in other apps, sharing, opening, editing, printing, deleting,
5532       * casting, etc.
5533       *
5534       * <p>The value is boolean. By default false.
5535       * @see #ACTION_QUICK_VIEW
5536       * @removed
5537       */
5538      @Deprecated
5539      public static final String EXTRA_QUICK_VIEW_ADVANCED =
5540              "android.intent.extra.QUICK_VIEW_ADVANCED";
5541  
5542      /**
5543       * An optional extra of {@code String[]} indicating which quick view features should be made
5544       * available to the user in the quick view UI while handing a
5545       * {@link Intent#ACTION_QUICK_VIEW} intent.
5546       * <li>Enumeration of features here is not meant to restrict capabilities of the quick viewer.
5547       * Quick viewer can implement features not listed below.
5548       * <li>Features included at this time are: {@link QuickViewConstants#FEATURE_VIEW},
5549       * {@link QuickViewConstants#FEATURE_EDIT}, {@link QuickViewConstants#FEATURE_DELETE},
5550       * {@link QuickViewConstants#FEATURE_DOWNLOAD}, {@link QuickViewConstants#FEATURE_SEND},
5551       * {@link QuickViewConstants#FEATURE_PRINT}.
5552       * <p>
5553       * Requirements:
5554       * <li>Quick viewer shouldn't show a feature if the feature is absent in
5555       * {@link #EXTRA_QUICK_VIEW_FEATURES}.
5556       * <li>When {@link #EXTRA_QUICK_VIEW_FEATURES} is not present, quick viewer should follow
5557       * internal policies.
5558       * <li>Presence of an feature in {@link #EXTRA_QUICK_VIEW_FEATURES}, does not constitute a
5559       * requirement that the feature be shown. Quick viewer may, according to its own policies,
5560       * disable or hide features.
5561       *
5562       * @see #ACTION_QUICK_VIEW
5563       */
5564      public static final String EXTRA_QUICK_VIEW_FEATURES =
5565              "android.intent.extra.QUICK_VIEW_FEATURES";
5566  
5567      /**
5568       * Optional boolean extra indicating whether quiet mode has been switched on or off.
5569       * When a profile goes into quiet mode, all apps in the profile are killed and the
5570       * profile user is stopped. Widgets originating from the profile are masked, and app
5571       * launcher icons are grayed out.
5572       */
5573      public static final String EXTRA_QUIET_MODE = "android.intent.extra.QUIET_MODE";
5574  
5575      /**
5576       * Optional CharSequence extra to provide a search query.
5577       * The format of this query is dependent on the receiving application.
5578       *
5579       * <p>Applicable to {@link Intent} with actions:
5580       * <ul>
5581       *      <li>{@link Intent#ACTION_GET_CONTENT}</li>
5582       *      <li>{@link Intent#ACTION_OPEN_DOCUMENT}</li>
5583       * </ul>
5584       */
5585      public static final String EXTRA_CONTENT_QUERY = "android.intent.extra.CONTENT_QUERY";
5586  
5587      /**
5588       * Used as an int extra field in {@link #ACTION_MEDIA_RESOURCE_GRANTED}
5589       * intents to specify the resource type granted. Possible values are
5590       * {@link #EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC} or
5591       * {@link #EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC}.
5592       *
5593       * @hide
5594       */
5595      public static final String EXTRA_MEDIA_RESOURCE_TYPE =
5596              "android.intent.extra.MEDIA_RESOURCE_TYPE";
5597  
5598      /**
5599       * Used as a boolean extra field in {@link #ACTION_CHOOSER} intents to specify
5600       * whether to show the chooser or not when there is only one application available
5601       * to choose from.
5602       */
5603      public static final String EXTRA_AUTO_LAUNCH_SINGLE_CHOICE =
5604              "android.intent.extra.AUTO_LAUNCH_SINGLE_CHOICE";
5605  
5606      /**
5607       * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
5608       * to represent that a video codec is allowed to use.
5609       *
5610       * @hide
5611       */
5612      public static final int EXTRA_MEDIA_RESOURCE_TYPE_VIDEO_CODEC = 0;
5613  
5614      /**
5615       * Used as an int value for {@link #EXTRA_MEDIA_RESOURCE_TYPE}
5616       * to represent that a audio codec is allowed to use.
5617       *
5618       * @hide
5619       */
5620      public static final int EXTRA_MEDIA_RESOURCE_TYPE_AUDIO_CODEC = 1;
5621  
5622      /**
5623       * Intent extra: ID of the context used on {@link #ACTION_VIEW_LOCUS}.
5624       *
5625       * <p>
5626       * Type: {@link LocusId}
5627       * </p>
5628       */
5629      public static final String EXTRA_LOCUS_ID = "android.intent.extra.LOCUS_ID";
5630  
5631      // ---------------------------------------------------------------------
5632      // ---------------------------------------------------------------------
5633      // Intent flags (see mFlags variable).
5634  
5635      /** @hide */
5636      @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
5637              FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION,
5638              FLAG_GRANT_PERSISTABLE_URI_PERMISSION, FLAG_GRANT_PREFIX_URI_PERMISSION })
5639      @Retention(RetentionPolicy.SOURCE)
5640      public @interface GrantUriMode {}
5641  
5642      /** @hide */
5643      @IntDef(flag = true, prefix = { "FLAG_GRANT_" }, value = {
5644              FLAG_GRANT_READ_URI_PERMISSION, FLAG_GRANT_WRITE_URI_PERMISSION })
5645      @Retention(RetentionPolicy.SOURCE)
5646      public @interface AccessUriMode {}
5647  
5648      /**
5649       * Test if given mode flags specify an access mode, which must be at least
5650       * read and/or write.
5651       *
5652       * @hide
5653       */
isAccessUriMode(int modeFlags)5654      public static boolean isAccessUriMode(int modeFlags) {
5655          return (modeFlags & (Intent.FLAG_GRANT_READ_URI_PERMISSION
5656                  | Intent.FLAG_GRANT_WRITE_URI_PERMISSION)) != 0;
5657      }
5658  
5659      /** @hide */
5660      @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5661              FLAG_GRANT_READ_URI_PERMISSION,
5662              FLAG_GRANT_WRITE_URI_PERMISSION,
5663              FLAG_FROM_BACKGROUND,
5664              FLAG_DEBUG_LOG_RESOLUTION,
5665              FLAG_EXCLUDE_STOPPED_PACKAGES,
5666              FLAG_INCLUDE_STOPPED_PACKAGES,
5667              FLAG_GRANT_PERSISTABLE_URI_PERMISSION,
5668              FLAG_GRANT_PREFIX_URI_PERMISSION,
5669              FLAG_DEBUG_TRIAGED_MISSING,
5670              FLAG_IGNORE_EPHEMERAL,
5671              FLAG_ACTIVITY_MATCH_EXTERNAL,
5672              FLAG_ACTIVITY_NO_HISTORY,
5673              FLAG_ACTIVITY_SINGLE_TOP,
5674              FLAG_ACTIVITY_NEW_TASK,
5675              FLAG_ACTIVITY_MULTIPLE_TASK,
5676              FLAG_ACTIVITY_CLEAR_TOP,
5677              FLAG_ACTIVITY_FORWARD_RESULT,
5678              FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5679              FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5680              FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5681              FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5682              FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5683              FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5684              FLAG_ACTIVITY_NEW_DOCUMENT,
5685              FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5686              FLAG_ACTIVITY_NO_USER_ACTION,
5687              FLAG_ACTIVITY_REORDER_TO_FRONT,
5688              FLAG_ACTIVITY_NO_ANIMATION,
5689              FLAG_ACTIVITY_CLEAR_TASK,
5690              FLAG_ACTIVITY_TASK_ON_HOME,
5691              FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5692              FLAG_ACTIVITY_LAUNCH_ADJACENT,
5693              FLAG_RECEIVER_REGISTERED_ONLY,
5694              FLAG_RECEIVER_REPLACE_PENDING,
5695              FLAG_RECEIVER_FOREGROUND,
5696              FLAG_RECEIVER_NO_ABORT,
5697              FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5698              FLAG_RECEIVER_BOOT_UPGRADE,
5699              FLAG_RECEIVER_INCLUDE_BACKGROUND,
5700              FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5701              FLAG_RECEIVER_FROM_SHELL,
5702              FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5703              FLAG_RECEIVER_OFFLOAD,
5704      })
5705      @Retention(RetentionPolicy.SOURCE)
5706      public @interface Flags {}
5707  
5708      /** @hide */
5709      @IntDef(flag = true, prefix = { "FLAG_" }, value = {
5710              FLAG_FROM_BACKGROUND,
5711              FLAG_DEBUG_LOG_RESOLUTION,
5712              FLAG_EXCLUDE_STOPPED_PACKAGES,
5713              FLAG_INCLUDE_STOPPED_PACKAGES,
5714              FLAG_DEBUG_TRIAGED_MISSING,
5715              FLAG_IGNORE_EPHEMERAL,
5716              FLAG_ACTIVITY_MATCH_EXTERNAL,
5717              FLAG_ACTIVITY_NO_HISTORY,
5718              FLAG_ACTIVITY_SINGLE_TOP,
5719              FLAG_ACTIVITY_NEW_TASK,
5720              FLAG_ACTIVITY_MULTIPLE_TASK,
5721              FLAG_ACTIVITY_CLEAR_TOP,
5722              FLAG_ACTIVITY_FORWARD_RESULT,
5723              FLAG_ACTIVITY_PREVIOUS_IS_TOP,
5724              FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
5725              FLAG_ACTIVITY_BROUGHT_TO_FRONT,
5726              FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
5727              FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
5728              FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5729              FLAG_ACTIVITY_NEW_DOCUMENT,
5730              FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
5731              FLAG_ACTIVITY_NO_USER_ACTION,
5732              FLAG_ACTIVITY_REORDER_TO_FRONT,
5733              FLAG_ACTIVITY_NO_ANIMATION,
5734              FLAG_ACTIVITY_CLEAR_TASK,
5735              FLAG_ACTIVITY_TASK_ON_HOME,
5736              FLAG_ACTIVITY_RETAIN_IN_RECENTS,
5737              FLAG_ACTIVITY_LAUNCH_ADJACENT,
5738              FLAG_RECEIVER_REGISTERED_ONLY,
5739              FLAG_RECEIVER_REPLACE_PENDING,
5740              FLAG_RECEIVER_FOREGROUND,
5741              FLAG_RECEIVER_NO_ABORT,
5742              FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
5743              FLAG_RECEIVER_BOOT_UPGRADE,
5744              FLAG_RECEIVER_INCLUDE_BACKGROUND,
5745              FLAG_RECEIVER_EXCLUDE_BACKGROUND,
5746              FLAG_RECEIVER_FROM_SHELL,
5747              FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
5748              FLAG_RECEIVER_OFFLOAD,
5749      })
5750      @Retention(RetentionPolicy.SOURCE)
5751      public @interface MutableFlags {}
5752  
5753      /**
5754       * If set, the recipient of this Intent will be granted permission to
5755       * perform read operations on the URI in the Intent's data and any URIs
5756       * specified in its ClipData.  When applying to an Intent's ClipData,
5757       * all URIs as well as recursive traversals through data or other ClipData
5758       * in Intent items will be granted; only the grant flags of the top-level
5759       * Intent are used.
5760       */
5761      public static final int FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
5762      /**
5763       * If set, the recipient of this Intent will be granted permission to
5764       * perform write operations on the URI in the Intent's data and any URIs
5765       * specified in its ClipData.  When applying to an Intent's ClipData,
5766       * all URIs as well as recursive traversals through data or other ClipData
5767       * in Intent items will be granted; only the grant flags of the top-level
5768       * Intent are used.
5769       */
5770      public static final int FLAG_GRANT_WRITE_URI_PERMISSION = 0x00000002;
5771      /**
5772       * Can be set by the caller to indicate that this Intent is coming from
5773       * a background operation, not from direct user interaction.
5774       */
5775      public static final int FLAG_FROM_BACKGROUND = 0x00000004;
5776      /**
5777       * A flag you can enable for debugging: when set, log messages will be
5778       * printed during the resolution of this intent to show you what has
5779       * been found to create the final resolved list.
5780       */
5781      public static final int FLAG_DEBUG_LOG_RESOLUTION = 0x00000008;
5782      /**
5783       * If set, this intent will not match any components in packages that
5784       * are currently stopped.  If this is not set, then the default behavior
5785       * is to include such applications in the result.
5786       */
5787      public static final int FLAG_EXCLUDE_STOPPED_PACKAGES = 0x00000010;
5788      /**
5789       * If set, this intent will always match any components in packages that
5790       * are currently stopped.  This is the default behavior when
5791       * {@link #FLAG_EXCLUDE_STOPPED_PACKAGES} is not set.  If both of these
5792       * flags are set, this one wins (it allows overriding of exclude for
5793       * places where the framework may automatically set the exclude flag).
5794       */
5795      public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 0x00000020;
5796  
5797      /**
5798       * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5799       * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant can be
5800       * persisted across device reboots until explicitly revoked with
5801       * {@link Context#revokeUriPermission(Uri, int)}. This flag only offers the
5802       * grant for possible persisting; the receiving application must call
5803       * {@link ContentResolver#takePersistableUriPermission(Uri, int)} to
5804       * actually persist.
5805       *
5806       * @see ContentResolver#takePersistableUriPermission(Uri, int)
5807       * @see ContentResolver#releasePersistableUriPermission(Uri, int)
5808       * @see ContentResolver#getPersistedUriPermissions()
5809       * @see ContentResolver#getOutgoingPersistedUriPermissions()
5810       */
5811      public static final int FLAG_GRANT_PERSISTABLE_URI_PERMISSION = 0x00000040;
5812  
5813      /**
5814       * When combined with {@link #FLAG_GRANT_READ_URI_PERMISSION} and/or
5815       * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, the URI permission grant
5816       * applies to any URI that is a prefix match against the original granted
5817       * URI. (Without this flag, the URI must match exactly for access to be
5818       * granted.) Another URI is considered a prefix match only when scheme,
5819       * authority, and all path segments defined by the prefix are an exact
5820       * match.
5821       */
5822      public static final int FLAG_GRANT_PREFIX_URI_PERMISSION = 0x00000080;
5823  
5824      /**
5825       * Flag used to automatically match intents based on their Direct Boot
5826       * awareness and the current user state.
5827       * <p>
5828       * Since the default behavior is to automatically apply the current user
5829       * state, this is effectively a sentinel value that doesn't change the
5830       * output of any queries based on its presence or absence.
5831       * <p>
5832       * Instead, this value can be useful in conjunction with
5833       * {@link android.os.StrictMode.VmPolicy.Builder#detectImplicitDirectBoot()}
5834       * to detect when a caller is relying on implicit automatic matching,
5835       * instead of confirming the explicit behavior they want.
5836       */
5837      public static final int FLAG_DIRECT_BOOT_AUTO = 0x00000100;
5838  
5839      /** {@hide} */
5840      @Deprecated
5841      public static final int FLAG_DEBUG_TRIAGED_MISSING = FLAG_DIRECT_BOOT_AUTO;
5842  
5843      /**
5844       * Internal flag used to indicate ephemeral applications should not be
5845       * considered when resolving the intent.
5846       *
5847       * @hide
5848       */
5849      public static final int FLAG_IGNORE_EPHEMERAL = 0x00000200;
5850  
5851      /**
5852       * If set, the new activity is not kept in the history stack.  As soon as
5853       * the user navigates away from it, the activity is finished.  This may also
5854       * be set with the {@link android.R.styleable#AndroidManifestActivity_noHistory
5855       * noHistory} attribute.
5856       *
5857       * <p>If set, {@link android.app.Activity#onActivityResult onActivityResult()}
5858       * is never invoked when the current activity starts a new activity which
5859       * sets a result and finishes.
5860       */
5861      public static final int FLAG_ACTIVITY_NO_HISTORY = 0x40000000;
5862      /**
5863       * If set, the activity will not be launched if it is already running
5864       * at the top of the history stack.
5865       */
5866      public static final int FLAG_ACTIVITY_SINGLE_TOP = 0x20000000;
5867      /**
5868       * If set, this activity will become the start of a new task on this
5869       * history stack.  A task (from the activity that started it to the
5870       * next task activity) defines an atomic group of activities that the
5871       * user can move to.  Tasks can be moved to the foreground and background;
5872       * all of the activities inside of a particular task always remain in
5873       * the same order.  See
5874       * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5875       * Stack</a> for more information about tasks.
5876       *
5877       * <p>This flag is generally used by activities that want
5878       * to present a "launcher" style behavior: they give the user a list of
5879       * separate things that can be done, which otherwise run completely
5880       * independently of the activity launching them.
5881       *
5882       * <p>When using this flag, if a task is already running for the activity
5883       * you are now starting, then a new activity will not be started; instead,
5884       * the current task will simply be brought to the front of the screen with
5885       * the state it was last in.  See {@link #FLAG_ACTIVITY_MULTIPLE_TASK} for a flag
5886       * to disable this behavior.
5887       *
5888       * <p>This flag can not be used when the caller is requesting a result from
5889       * the activity being launched.
5890       */
5891      public static final int FLAG_ACTIVITY_NEW_TASK = 0x10000000;
5892      /**
5893       * This flag is used to create a new task and launch an activity into it.
5894       * This flag is always paired with either {@link #FLAG_ACTIVITY_NEW_DOCUMENT}
5895       * or {@link #FLAG_ACTIVITY_NEW_TASK}. In both cases these flags alone would
5896       * search through existing tasks for ones matching this Intent. Only if no such
5897       * task is found would a new task be created. When paired with
5898       * FLAG_ACTIVITY_MULTIPLE_TASK both of these behaviors are modified to skip
5899       * the search for a matching task and unconditionally start a new task.
5900       *
5901       * <strong>When used with {@link #FLAG_ACTIVITY_NEW_TASK} do not use this
5902       * flag unless you are implementing your own
5903       * top-level application launcher.</strong>  Used in conjunction with
5904       * {@link #FLAG_ACTIVITY_NEW_TASK} to disable the
5905       * behavior of bringing an existing task to the foreground.  When set,
5906       * a new task is <em>always</em> started to host the Activity for the
5907       * Intent, regardless of whether there is already an existing task running
5908       * the same thing.
5909       *
5910       * <p><strong>Because the default system does not include graphical task management,
5911       * you should not use this flag unless you provide some way for a user to
5912       * return back to the tasks you have launched.</strong>
5913       *
5914       * See {@link #FLAG_ACTIVITY_NEW_DOCUMENT} for details of this flag's use for
5915       * creating new document tasks.
5916       *
5917       * <p>This flag is ignored if one of {@link #FLAG_ACTIVITY_NEW_TASK} or
5918       * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} is not also set.
5919       *
5920       * <p>See
5921       * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5922       * Stack</a> for more information about tasks.
5923       *
5924       * @see #FLAG_ACTIVITY_NEW_DOCUMENT
5925       * @see #FLAG_ACTIVITY_NEW_TASK
5926       */
5927      public static final int FLAG_ACTIVITY_MULTIPLE_TASK = 0x08000000;
5928      /**
5929       * If set, and the activity being launched is already running in the
5930       * current task, then instead of launching a new instance of that activity,
5931       * all of the other activities on top of it will be closed and this Intent
5932       * will be delivered to the (now on top) old activity as a new Intent.
5933       *
5934       * <p>For example, consider a task consisting of the activities: A, B, C, D.
5935       * If D calls startActivity() with an Intent that resolves to the component
5936       * of activity B, then C and D will be finished and B receive the given
5937       * Intent, resulting in the stack now being: A, B.
5938       *
5939       * <p>The currently running instance of activity B in the above example will
5940       * either receive the new intent you are starting here in its
5941       * onNewIntent() method, or be itself finished and restarted with the
5942       * new intent.  If it has declared its launch mode to be "multiple" (the
5943       * default) and you have not set {@link #FLAG_ACTIVITY_SINGLE_TOP} in
5944       * the same intent, then it will be finished and re-created; for all other
5945       * launch modes or if {@link #FLAG_ACTIVITY_SINGLE_TOP} is set then this
5946       * Intent will be delivered to the current instance's onNewIntent().
5947       *
5948       * <p>This launch mode can also be used to good effect in conjunction with
5949       * {@link #FLAG_ACTIVITY_NEW_TASK}: if used to start the root activity
5950       * of a task, it will bring any currently running instance of that task
5951       * to the foreground, and then clear it to its root state.  This is
5952       * especially useful, for example, when launching an activity from the
5953       * notification manager.
5954       *
5955       * <p>See
5956       * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
5957       * Stack</a> for more information about tasks.
5958       */
5959      public static final int FLAG_ACTIVITY_CLEAR_TOP = 0x04000000;
5960      /**
5961       * If set and this intent is being used to launch a new activity from an
5962       * existing one, then the reply target of the existing activity will be
5963       * transferred to the new activity.  This way, the new activity can call
5964       * {@link android.app.Activity#setResult} and have that result sent back to
5965       * the reply target of the original activity.
5966       */
5967      public static final int FLAG_ACTIVITY_FORWARD_RESULT = 0x02000000;
5968      /**
5969       * If set and this intent is being used to launch a new activity from an
5970       * existing one, the current activity will not be counted as the top
5971       * activity for deciding whether the new intent should be delivered to
5972       * the top instead of starting a new one.  The previous activity will
5973       * be used as the top, with the assumption being that the current activity
5974       * will finish itself immediately.
5975       */
5976      public static final int FLAG_ACTIVITY_PREVIOUS_IS_TOP = 0x01000000;
5977      /**
5978       * If set, the new activity is not kept in the list of recently launched
5979       * activities.
5980       */
5981      public static final int FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS = 0x00800000;
5982      /**
5983       * This flag is not normally set by application code, but set for you by
5984       * the system as described in the
5985       * {@link android.R.styleable#AndroidManifestActivity_launchMode
5986       * launchMode} documentation for the singleTask mode.
5987       */
5988      public static final int FLAG_ACTIVITY_BROUGHT_TO_FRONT = 0x00400000;
5989      /**
5990       * If set, and this activity is either being started in a new task or
5991       * bringing to the top an existing task, then it will be launched as
5992       * the front door of the task.  This will result in the application of
5993       * any affinities needed to have that task in the proper state (either
5994       * moving activities to or from it), or simply resetting that task to
5995       * its initial state if needed.
5996       */
5997      public static final int FLAG_ACTIVITY_RESET_TASK_IF_NEEDED = 0x00200000;
5998      /**
5999       * This flag is not normally set by application code, but set for you by
6000       * the system if this activity is being launched from history
6001       * (longpress home key).
6002       */
6003      public static final int FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY = 0x00100000;
6004      /**
6005       * @deprecated As of API 21 this performs identically to
6006       * {@link #FLAG_ACTIVITY_NEW_DOCUMENT} which should be used instead of this.
6007       */
6008      @Deprecated
6009      public static final int FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET = 0x00080000;
6010      /**
6011       * This flag is used to open a document into a new task rooted at the activity launched
6012       * by this Intent. Through the use of this flag, or its equivalent attribute,
6013       * {@link android.R.attr#documentLaunchMode} multiple instances of the same activity
6014       * containing different documents will appear in the recent tasks list.
6015       *
6016       * <p>The use of the activity attribute form of this,
6017       * {@link android.R.attr#documentLaunchMode}, is
6018       * preferred over the Intent flag described here. The attribute form allows the
6019       * Activity to specify multiple document behavior for all launchers of the Activity
6020       * whereas using this flag requires each Intent that launches the Activity to specify it.
6021       *
6022       * <p>Note that the default semantics of this flag w.r.t. whether the recents entry for
6023       * it is kept after the activity is finished is different than the use of
6024       * {@link #FLAG_ACTIVITY_NEW_TASK} and {@link android.R.attr#documentLaunchMode} -- if
6025       * this flag is being used to create a new recents entry, then by default that entry
6026       * will be removed once the activity is finished.  You can modify this behavior with
6027       * {@link #FLAG_ACTIVITY_RETAIN_IN_RECENTS}.
6028       *
6029       * <p>FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with {@link
6030       * #FLAG_ACTIVITY_MULTIPLE_TASK}. When used alone it is the
6031       * equivalent of the Activity manifest specifying {@link
6032       * android.R.attr#documentLaunchMode}="intoExisting". When used with
6033       * FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying
6034       * {@link android.R.attr#documentLaunchMode}="always".
6035       *
6036       * Refer to {@link android.R.attr#documentLaunchMode} for more information.
6037       *
6038       * @see android.R.attr#documentLaunchMode
6039       * @see #FLAG_ACTIVITY_MULTIPLE_TASK
6040       */
6041      public static final int FLAG_ACTIVITY_NEW_DOCUMENT = FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
6042      /**
6043       * If set, this flag will prevent the normal {@link android.app.Activity#onUserLeaveHint}
6044       * callback from occurring on the current frontmost activity before it is
6045       * paused as the newly-started activity is brought to the front.
6046       *
6047       * <p>Typically, an activity can rely on that callback to indicate that an
6048       * explicit user action has caused their activity to be moved out of the
6049       * foreground. The callback marks an appropriate point in the activity's
6050       * lifecycle for it to dismiss any notifications that it intends to display
6051       * "until the user has seen them," such as a blinking LED.
6052       *
6053       * <p>If an activity is ever started via any non-user-driven events such as
6054       * phone-call receipt or an alarm handler, this flag should be passed to {@link
6055       * Context#startActivity Context.startActivity}, ensuring that the pausing
6056       * activity does not think the user has acknowledged its notification.
6057       */
6058      public static final int FLAG_ACTIVITY_NO_USER_ACTION = 0x00040000;
6059      /**
6060       * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6061       * this flag will cause the launched activity to be brought to the front of its
6062       * task's history stack if it is already running.
6063       *
6064       * <p>For example, consider a task consisting of four activities: A, B, C, D.
6065       * If D calls startActivity() with an Intent that resolves to the component
6066       * of activity B, then B will be brought to the front of the history stack,
6067       * with this resulting order:  A, C, D, B.
6068       *
6069       * This flag will be ignored if {@link #FLAG_ACTIVITY_CLEAR_TOP} is also
6070       * specified.
6071       */
6072      public static final int FLAG_ACTIVITY_REORDER_TO_FRONT = 0X00020000;
6073      /**
6074       * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6075       * this flag will prevent the system from applying an activity transition
6076       * animation to go to the next activity state.  This doesn't mean an
6077       * animation will never run -- if another activity change happens that doesn't
6078       * specify this flag before the activity started here is displayed, then
6079       * that transition will be used.  This flag can be put to good use
6080       * when you are going to do a series of activity operations but the
6081       * animation seen by the user shouldn't be driven by the first activity
6082       * change but rather a later one.
6083       */
6084      public static final int FLAG_ACTIVITY_NO_ANIMATION = 0X00010000;
6085      /**
6086       * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6087       * this flag will cause any existing task that would be associated with the
6088       * activity to be cleared before the activity is started.  That is, the activity
6089       * becomes the new root of an otherwise empty task, and any old activities
6090       * are finished.  This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6091       */
6092      public static final int FLAG_ACTIVITY_CLEAR_TASK = 0X00008000;
6093      /**
6094       * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6095       * this flag will cause a newly launching task to be placed on top of the current
6096       * home activity task (if there is one).  That is, pressing back from the task
6097       * will always return the user to home even if that was not the last activity they
6098       * saw.   This can only be used in conjunction with {@link #FLAG_ACTIVITY_NEW_TASK}.
6099       */
6100      public static final int FLAG_ACTIVITY_TASK_ON_HOME = 0X00004000;
6101      /**
6102       * By default a document created by {@link #FLAG_ACTIVITY_NEW_DOCUMENT} will
6103       * have its entry in recent tasks removed when the user closes it (with back
6104       * or however else it may finish()). If you would like to instead allow the
6105       * document to be kept in recents so that it can be re-launched, you can use
6106       * this flag. When set and the task's activity is finished, the recents
6107       * entry will remain in the interface for the user to re-launch it, like a
6108       * recents entry for a top-level application.
6109       * <p>
6110       * The receiving activity can override this request with
6111       * {@link android.R.attr#autoRemoveFromRecents} or by explcitly calling
6112       * {@link android.app.Activity#finishAndRemoveTask()
6113       * Activity.finishAndRemoveTask()}.
6114       */
6115      public static final int FLAG_ACTIVITY_RETAIN_IN_RECENTS = 0x00002000;
6116  
6117      /**
6118       * This flag is only used in split-screen multi-window mode. The new activity will be displayed
6119       * adjacent to the one launching it. This can only be used in conjunction with
6120       * {@link #FLAG_ACTIVITY_NEW_TASK}. Also, setting {@link #FLAG_ACTIVITY_MULTIPLE_TASK} is
6121       * required if you want a new instance of an existing activity to be created.
6122       */
6123      public static final int FLAG_ACTIVITY_LAUNCH_ADJACENT = 0x00001000;
6124  
6125  
6126      /**
6127       * If set in an Intent passed to {@link Context#startActivity Context.startActivity()},
6128       * this flag will attempt to launch an instant app if no full app on the device can already
6129       * handle the intent.
6130       * <p>
6131       * When attempting to resolve instant apps externally, the following {@link Intent} properties
6132       * are supported:
6133       * <ul>
6134       *     <li>{@link Intent#setAction(String)}</li>
6135       *     <li>{@link Intent#addCategory(String)}</li>
6136       *     <li>{@link Intent#setData(Uri)}</li>
6137       *     <li>{@link Intent#setType(String)}</li>
6138       *     <li>{@link Intent#setPackage(String)}</li>
6139       *     <li>{@link Intent#addFlags(int)}</li>
6140       * </ul>
6141       * <p>
6142       * In the case that no instant app can be found, the installer will be launched to notify the
6143       * user that the intent could not be resolved. On devices that do not support instant apps,
6144       * the flag will be ignored.
6145       */
6146      public static final int FLAG_ACTIVITY_MATCH_EXTERNAL = 0x00000800;
6147  
6148      /**
6149       * If set, when sending a broadcast only registered receivers will be
6150       * called -- no BroadcastReceiver components will be launched.
6151       */
6152      public static final int FLAG_RECEIVER_REGISTERED_ONLY = 0x40000000;
6153      /**
6154       * If set, when sending a broadcast the new broadcast will replace
6155       * any existing pending broadcast that matches it.  Matching is defined
6156       * by {@link Intent#filterEquals(Intent) Intent.filterEquals} returning
6157       * true for the intents of the two broadcasts.  When a match is found,
6158       * the new broadcast (and receivers associated with it) will replace the
6159       * existing one in the pending broadcast list, remaining at the same
6160       * position in the list.
6161       *
6162       * <p>This flag is most typically used with sticky broadcasts, which
6163       * only care about delivering the most recent values of the broadcast
6164       * to their receivers.
6165       */
6166      public static final int FLAG_RECEIVER_REPLACE_PENDING = 0x20000000;
6167      /**
6168       * If set, when sending a broadcast the recipient is allowed to run at
6169       * foreground priority, with a shorter timeout interval.  During normal
6170       * broadcasts the receivers are not automatically hoisted out of the
6171       * background priority class.
6172       */
6173      public static final int FLAG_RECEIVER_FOREGROUND = 0x10000000;
6174      /**
6175       * If set, when sending a broadcast the recipient will be run on the offload queue.
6176       *
6177       * @hide
6178       */
6179      public static final int FLAG_RECEIVER_OFFLOAD = 0x80000000;
6180      /**
6181       * If this is an ordered broadcast, don't allow receivers to abort the broadcast.
6182       * They can still propagate results through to later receivers, but they can not prevent
6183       * later receivers from seeing the broadcast.
6184       */
6185      public static final int FLAG_RECEIVER_NO_ABORT = 0x08000000;
6186      /**
6187       * If set, when sending a broadcast <i>before boot has completed</i> only
6188       * registered receivers will be called -- no BroadcastReceiver components
6189       * will be launched.  Sticky intent state will be recorded properly even
6190       * if no receivers wind up being called.  If {@link #FLAG_RECEIVER_REGISTERED_ONLY}
6191       * is specified in the broadcast intent, this flag is unnecessary.
6192       *
6193       * <p>This flag is only for use by system sevices as a convenience to
6194       * avoid having to implement a more complex mechanism around detection
6195       * of boot completion.
6196       *
6197       * @hide
6198       */
6199      @UnsupportedAppUsage
6200      public static final int FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT = 0x04000000;
6201      /**
6202       * Set when this broadcast is for a boot upgrade, a special mode that
6203       * allows the broadcast to be sent before the system is ready and launches
6204       * the app process with no providers running in it.
6205       * @hide
6206       */
6207      public static final int FLAG_RECEIVER_BOOT_UPGRADE = 0x02000000;
6208      /**
6209       * If set, the broadcast will always go to manifest receivers in background (cached
6210       * or not running) apps, regardless of whether that would be done by default.  By
6211       * default they will only receive broadcasts if the broadcast has specified an
6212       * explicit component or package name.
6213       *
6214       * NOTE: dumpstate uses this flag numerically, so when its value is changed
6215       * the broadcast code there must also be changed to match.
6216       *
6217       * @hide
6218       */
6219      public static final int FLAG_RECEIVER_INCLUDE_BACKGROUND = 0x01000000;
6220      /**
6221       * If set, the broadcast will never go to manifest receivers in background (cached
6222       * or not running) apps, regardless of whether that would be done by default.  By
6223       * default they will receive broadcasts if the broadcast has specified an
6224       * explicit component or package name.
6225       * @hide
6226       */
6227      public static final int FLAG_RECEIVER_EXCLUDE_BACKGROUND = 0x00800000;
6228      /**
6229       * If set, this broadcast is being sent from the shell.
6230       * @hide
6231       */
6232      public static final int FLAG_RECEIVER_FROM_SHELL = 0x00400000;
6233  
6234      /**
6235       * If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps
6236       * will not receive broadcasts.
6237       *
6238       * <em>This flag has no effect when used by an Instant App.</em>
6239       */
6240      public static final int FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS = 0x00200000;
6241  
6242      /**
6243       * @hide Flags that can't be changed with PendingIntent.
6244       */
6245      public static final int IMMUTABLE_FLAGS = FLAG_GRANT_READ_URI_PERMISSION
6246              | FLAG_GRANT_WRITE_URI_PERMISSION | FLAG_GRANT_PERSISTABLE_URI_PERMISSION
6247              | FLAG_GRANT_PREFIX_URI_PERMISSION;
6248  
6249      // ---------------------------------------------------------------------
6250      // ---------------------------------------------------------------------
6251      // toUri() and parseUri() options.
6252  
6253      /** @hide */
6254      @IntDef(flag = true, prefix = { "URI_" }, value = {
6255              URI_ALLOW_UNSAFE,
6256              URI_ANDROID_APP_SCHEME,
6257              URI_INTENT_SCHEME,
6258      })
6259      @Retention(RetentionPolicy.SOURCE)
6260      public @interface UriFlags {}
6261  
6262      /**
6263       * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6264       * always has the "intent:" scheme.  This syntax can be used when you want
6265       * to later disambiguate between URIs that are intended to describe an
6266       * Intent vs. all others that should be treated as raw URIs.  When used
6267       * with {@link #parseUri}, any other scheme will result in a generic
6268       * VIEW action for that raw URI.
6269       */
6270      public static final int URI_INTENT_SCHEME = 1<<0;
6271  
6272      /**
6273       * Flag for use with {@link #toUri} and {@link #parseUri}: the URI string
6274       * always has the "android-app:" scheme.  This is a variation of
6275       * {@link #URI_INTENT_SCHEME} whose format is simpler for the case of an
6276       * http/https URI being delivered to a specific package name.  The format
6277       * is:
6278       *
6279       * <pre class="prettyprint">
6280       * android-app://{package_id}[/{scheme}[/{host}[/{path}]]][#Intent;{...}]</pre>
6281       *
6282       * <p>In this scheme, only the <code>package_id</code> is required.  If you include a host,
6283       * you must also include a scheme; including a path also requires both a host and a scheme.
6284       * The final #Intent; fragment can be used without a scheme, host, or path.
6285       * Note that this can not be
6286       * used with intents that have a {@link #setSelector}, since the base intent
6287       * will always have an explicit package name.</p>
6288       *
6289       * <p>Some examples of how this scheme maps to Intent objects:</p>
6290       * <table border="2" width="85%" align="center" frame="hsides" rules="rows">
6291       *     <colgroup align="left" />
6292       *     <colgroup align="left" />
6293       *     <thead>
6294       *     <tr><th>URI</th> <th>Intent</th></tr>
6295       *     </thead>
6296       *
6297       *     <tbody>
6298       *     <tr><td><code>android-app://com.example.app</code></td>
6299       *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6300       *             <tr><td>Action: </td><td>{@link #ACTION_MAIN}</td></tr>
6301       *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6302       *         </table></td>
6303       *     </tr>
6304       *     <tr><td><code>android-app://com.example.app/http/example.com</code></td>
6305       *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6306       *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6307       *             <tr><td>Data: </td><td><code>http://example.com/</code></td></tr>
6308       *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6309       *         </table></td>
6310       *     </tr>
6311       *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234</code></td>
6312       *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6313       *             <tr><td>Action: </td><td>{@link #ACTION_VIEW}</td></tr>
6314       *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6315       *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6316       *         </table></td>
6317       *     </tr>
6318       *     <tr><td><code>android-app://com.example.app/<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6319       *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6320       *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6321       *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6322       *         </table></td>
6323       *     </tr>
6324       *     <tr><td><code>android-app://com.example.app/http/example.com/foo?1234<br />#Intent;action=com.example.MY_ACTION;end</code></td>
6325       *         <td><table style="margin:0;border:0;cellpadding:0;cellspacing:0">
6326       *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6327       *             <tr><td>Data: </td><td><code>http://example.com/foo?1234</code></td></tr>
6328       *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6329       *         </table></td>
6330       *     </tr>
6331       *     <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>
6332       *         <td><table border="" style="margin:0" >
6333       *             <tr><td>Action: </td><td><code>com.example.MY_ACTION</code></td></tr>
6334       *             <tr><td>Package: </td><td><code>com.example.app</code></td></tr>
6335       *             <tr><td>Extras: </td><td><code>some_int=(int)100<br />some_str=(String)hello</code></td></tr>
6336       *         </table></td>
6337       *     </tr>
6338       *     </tbody>
6339       * </table>
6340       */
6341      public static final int URI_ANDROID_APP_SCHEME = 1<<1;
6342  
6343      /**
6344       * Flag for use with {@link #toUri} and {@link #parseUri}: allow parsing
6345       * of unsafe information.  In particular, the flags {@link #FLAG_GRANT_READ_URI_PERMISSION},
6346       * {@link #FLAG_GRANT_WRITE_URI_PERMISSION}, {@link #FLAG_GRANT_PERSISTABLE_URI_PERMISSION},
6347       * and {@link #FLAG_GRANT_PREFIX_URI_PERMISSION} flags can not be set, so that the
6348       * generated Intent can not cause unexpected data access to happen.
6349       *
6350       * <p>If you do not trust the source of the URI being parsed, you should still do further
6351       * processing to protect yourself from it.  In particular, when using it to start an
6352       * activity you should usually add in {@link #CATEGORY_BROWSABLE} to limit the activities
6353       * that can handle it.</p>
6354       */
6355      public static final int URI_ALLOW_UNSAFE = 1<<2;
6356  
6357      // ---------------------------------------------------------------------
6358  
6359      private String mAction;
6360      private Uri mData;
6361      private String mType;
6362      private String mIdentifier;
6363      private String mPackage;
6364      private ComponentName mComponent;
6365      private int mFlags;
6366      private ArraySet<String> mCategories;
6367      @UnsupportedAppUsage
6368      private Bundle mExtras;
6369      private Rect mSourceBounds;
6370      private Intent mSelector;
6371      private ClipData mClipData;
6372      private int mContentUserHint = UserHandle.USER_CURRENT;
6373      /** Token to track instant app launches. Local only; do not copy cross-process. */
6374      private String mLaunchToken;
6375  
6376      // ---------------------------------------------------------------------
6377  
6378      private static final int COPY_MODE_ALL = 0;
6379      private static final int COPY_MODE_FILTER = 1;
6380      private static final int COPY_MODE_HISTORY = 2;
6381  
6382      /** @hide */
6383      @IntDef(prefix = { "COPY_MODE_" }, value = {
6384              COPY_MODE_ALL,
6385              COPY_MODE_FILTER,
6386              COPY_MODE_HISTORY
6387      })
6388      @Retention(RetentionPolicy.SOURCE)
6389      public @interface CopyMode {}
6390  
6391      /**
6392       * Create an empty intent.
6393       */
Intent()6394      public Intent() {
6395      }
6396  
6397      /**
6398       * Copy constructor.
6399       */
Intent(Intent o)6400      public Intent(Intent o) {
6401          this(o, COPY_MODE_ALL);
6402      }
6403  
Intent(Intent o, @CopyMode int copyMode)6404      private Intent(Intent o, @CopyMode int copyMode) {
6405          this.mAction = o.mAction;
6406          this.mData = o.mData;
6407          this.mType = o.mType;
6408          this.mIdentifier = o.mIdentifier;
6409          this.mPackage = o.mPackage;
6410          this.mComponent = o.mComponent;
6411  
6412          if (o.mCategories != null) {
6413              this.mCategories = new ArraySet<>(o.mCategories);
6414          }
6415  
6416          if (copyMode != COPY_MODE_FILTER) {
6417              this.mFlags = o.mFlags;
6418              this.mContentUserHint = o.mContentUserHint;
6419              this.mLaunchToken = o.mLaunchToken;
6420              if (o.mSourceBounds != null) {
6421                  this.mSourceBounds = new Rect(o.mSourceBounds);
6422              }
6423              if (o.mSelector != null) {
6424                  this.mSelector = new Intent(o.mSelector);
6425              }
6426  
6427              if (copyMode != COPY_MODE_HISTORY) {
6428                  if (o.mExtras != null) {
6429                      this.mExtras = new Bundle(o.mExtras);
6430                  }
6431                  if (o.mClipData != null) {
6432                      this.mClipData = new ClipData(o.mClipData);
6433                  }
6434              } else {
6435                  if (o.mExtras != null && !o.mExtras.maybeIsEmpty()) {
6436                      this.mExtras = Bundle.STRIPPED;
6437                  }
6438  
6439                  // Also set "stripped" clip data when we ever log mClipData in the (broadcast)
6440                  // history.
6441              }
6442          }
6443      }
6444  
6445      @Override
clone()6446      public Object clone() {
6447          return new Intent(this);
6448      }
6449  
6450      /**
6451       * Make a clone of only the parts of the Intent that are relevant for
6452       * filter matching: the action, data, type, component, and categories.
6453       */
cloneFilter()6454      public @NonNull Intent cloneFilter() {
6455          return new Intent(this, COPY_MODE_FILTER);
6456      }
6457  
6458      /**
6459       * Create an intent with a given action.  All other fields (data, type,
6460       * class) are null.  Note that the action <em>must</em> be in a
6461       * namespace because Intents are used globally in the system -- for
6462       * example the system VIEW action is android.intent.action.VIEW; an
6463       * application's custom action would be something like
6464       * com.google.app.myapp.CUSTOM_ACTION.
6465       *
6466       * @param action The Intent action, such as ACTION_VIEW.
6467       */
Intent(String action)6468      public Intent(String action) {
6469          setAction(action);
6470      }
6471  
6472      /**
6473       * Create an intent with a given action and for a given data url.  Note
6474       * that the action <em>must</em> be in a namespace because Intents are
6475       * used globally in the system -- for example the system VIEW action is
6476       * android.intent.action.VIEW; an application's custom action would be
6477       * something like com.google.app.myapp.CUSTOM_ACTION.
6478       *
6479       * <p><em>Note: scheme and host name matching in the Android framework is
6480       * case-sensitive, unlike the formal RFC.  As a result,
6481       * you should always ensure that you write your Uri with these elements
6482       * using lower case letters, and normalize any Uris you receive from
6483       * outside of Android to ensure the scheme and host is lower case.</em></p>
6484       *
6485       * @param action The Intent action, such as ACTION_VIEW.
6486       * @param uri The Intent data URI.
6487       */
Intent(String action, Uri uri)6488      public Intent(String action, Uri uri) {
6489          setAction(action);
6490          mData = uri;
6491      }
6492  
6493      /**
6494       * Create an intent for a specific component.  All other fields (action, data,
6495       * type, class) are null, though they can be modified later with explicit
6496       * calls.  This provides a convenient way to create an intent that is
6497       * intended to execute a hard-coded class name, rather than relying on the
6498       * system to find an appropriate class for you; see {@link #setComponent}
6499       * for more information on the repercussions of this.
6500       *
6501       * @param packageContext A Context of the application package implementing
6502       * this class.
6503       * @param cls The component class that is to be used for the intent.
6504       *
6505       * @see #setClass
6506       * @see #setComponent
6507       * @see #Intent(String, android.net.Uri , Context, Class)
6508       */
Intent(Context packageContext, Class<?> cls)6509      public Intent(Context packageContext, Class<?> cls) {
6510          mComponent = new ComponentName(packageContext, cls);
6511      }
6512  
6513      /**
6514       * Create an intent for a specific component with a specified action and data.
6515       * This is equivalent to using {@link #Intent(String, android.net.Uri)} to
6516       * construct the Intent and then calling {@link #setClass} to set its
6517       * class.
6518       *
6519       * <p><em>Note: scheme and host name matching in the Android framework is
6520       * case-sensitive, unlike the formal RFC.  As a result,
6521       * you should always ensure that you write your Uri with these elements
6522       * using lower case letters, and normalize any Uris you receive from
6523       * outside of Android to ensure the scheme and host is lower case.</em></p>
6524       *
6525       * @param action The Intent action, such as ACTION_VIEW.
6526       * @param uri The Intent data URI.
6527       * @param packageContext A Context of the application package implementing
6528       * this class.
6529       * @param cls The component class that is to be used for the intent.
6530       *
6531       * @see #Intent(String, android.net.Uri)
6532       * @see #Intent(Context, Class)
6533       * @see #setClass
6534       * @see #setComponent
6535       */
Intent(String action, Uri uri, Context packageContext, Class<?> cls)6536      public Intent(String action, Uri uri,
6537              Context packageContext, Class<?> cls) {
6538          setAction(action);
6539          mData = uri;
6540          mComponent = new ComponentName(packageContext, cls);
6541      }
6542  
6543      /**
6544       * Create an intent to launch the main (root) activity of a task.  This
6545       * is the Intent that is started when the application's is launched from
6546       * Home.  For anything else that wants to launch an application in the
6547       * same way, it is important that they use an Intent structured the same
6548       * way, and can use this function to ensure this is the case.
6549       *
6550       * <p>The returned Intent has the given Activity component as its explicit
6551       * component, {@link #ACTION_MAIN} as its action, and includes the
6552       * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
6553       * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6554       * to do that through {@link #addFlags(int)} on the returned Intent.
6555       *
6556       * @param mainActivity The main activity component that this Intent will
6557       * launch.
6558       * @return Returns a newly created Intent that can be used to launch the
6559       * activity as a main application entry.
6560       *
6561       * @see #setClass
6562       * @see #setComponent
6563       */
makeMainActivity(ComponentName mainActivity)6564      public static Intent makeMainActivity(ComponentName mainActivity) {
6565          Intent intent = new Intent(ACTION_MAIN);
6566          intent.setComponent(mainActivity);
6567          intent.addCategory(CATEGORY_LAUNCHER);
6568          return intent;
6569      }
6570  
6571      /**
6572       * Make an Intent for the main activity of an application, without
6573       * specifying a specific activity to run but giving a selector to find
6574       * the activity.  This results in a final Intent that is structured
6575       * the same as when the application is launched from
6576       * Home.  For anything else that wants to launch an application in the
6577       * same way, it is important that they use an Intent structured the same
6578       * way, and can use this function to ensure this is the case.
6579       *
6580       * <p>The returned Intent has {@link #ACTION_MAIN} as its action, and includes the
6581       * category {@link #CATEGORY_LAUNCHER}.  This does <em>not</em> have
6582       * {@link #FLAG_ACTIVITY_NEW_TASK} set, though typically you will want
6583       * to do that through {@link #addFlags(int)} on the returned Intent.
6584       *
6585       * @param selectorAction The action name of the Intent's selector.
6586       * @param selectorCategory The name of a category to add to the Intent's
6587       * selector.
6588       * @return Returns a newly created Intent that can be used to launch the
6589       * activity as a main application entry.
6590       *
6591       * @see #setSelector(Intent)
6592       */
makeMainSelectorActivity(String selectorAction, String selectorCategory)6593      public static Intent makeMainSelectorActivity(String selectorAction,
6594              String selectorCategory) {
6595          Intent intent = new Intent(ACTION_MAIN);
6596          intent.addCategory(CATEGORY_LAUNCHER);
6597          Intent selector = new Intent();
6598          selector.setAction(selectorAction);
6599          selector.addCategory(selectorCategory);
6600          intent.setSelector(selector);
6601          return intent;
6602      }
6603  
6604      /**
6605       * Make an Intent that can be used to re-launch an application's task
6606       * in its base state.  This is like {@link #makeMainActivity(ComponentName)},
6607       * but also sets the flags {@link #FLAG_ACTIVITY_NEW_TASK} and
6608       * {@link #FLAG_ACTIVITY_CLEAR_TASK}.
6609       *
6610       * @param mainActivity The activity component that is the root of the
6611       * task; this is the activity that has been published in the application's
6612       * manifest as the main launcher icon.
6613       *
6614       * @return Returns a newly created Intent that can be used to relaunch the
6615       * activity's task in its root state.
6616       */
makeRestartActivityTask(ComponentName mainActivity)6617      public static Intent makeRestartActivityTask(ComponentName mainActivity) {
6618          Intent intent = makeMainActivity(mainActivity);
6619          intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
6620                  | Intent.FLAG_ACTIVITY_CLEAR_TASK);
6621          return intent;
6622      }
6623  
6624      /**
6625       * Call {@link #parseUri} with 0 flags.
6626       * @deprecated Use {@link #parseUri} instead.
6627       */
6628      @Deprecated
getIntent(String uri)6629      public static Intent getIntent(String uri) throws URISyntaxException {
6630          return parseUri(uri, 0);
6631      }
6632  
6633      /**
6634       * Create an intent from a URI.  This URI may encode the action,
6635       * category, and other intent fields, if it was returned by
6636       * {@link #toUri}.  If the Intent was not generate by toUri(), its data
6637       * will be the entire URI and its action will be ACTION_VIEW.
6638       *
6639       * <p>The URI given here must not be relative -- that is, it must include
6640       * the scheme and full path.
6641       *
6642       * @param uri The URI to turn into an Intent.
6643       * @param flags Additional processing flags.
6644       *
6645       * @return Intent The newly created Intent object.
6646       *
6647       * @throws URISyntaxException Throws URISyntaxError if the basic URI syntax
6648       * it bad (as parsed by the Uri class) or the Intent data within the
6649       * URI is invalid.
6650       *
6651       * @see #toUri
6652       */
parseUri(String uri, @UriFlags int flags)6653      public static Intent parseUri(String uri, @UriFlags int flags) throws URISyntaxException {
6654          int i = 0;
6655          try {
6656              final boolean androidApp = uri.startsWith("android-app:");
6657  
6658              // Validate intent scheme if requested.
6659              if ((flags&(URI_INTENT_SCHEME|URI_ANDROID_APP_SCHEME)) != 0) {
6660                  if (!uri.startsWith("intent:") && !androidApp) {
6661                      Intent intent = new Intent(ACTION_VIEW);
6662                      try {
6663                          intent.setData(Uri.parse(uri));
6664                      } catch (IllegalArgumentException e) {
6665                          throw new URISyntaxException(uri, e.getMessage());
6666                      }
6667                      return intent;
6668                  }
6669              }
6670  
6671              i = uri.lastIndexOf("#");
6672              // simple case
6673              if (i == -1) {
6674                  if (!androidApp) {
6675                      return new Intent(ACTION_VIEW, Uri.parse(uri));
6676                  }
6677  
6678              // old format Intent URI
6679              } else if (!uri.startsWith("#Intent;", i)) {
6680                  if (!androidApp) {
6681                      return getIntentOld(uri, flags);
6682                  } else {
6683                      i = -1;
6684                  }
6685              }
6686  
6687              // new format
6688              Intent intent = new Intent(ACTION_VIEW);
6689              Intent baseIntent = intent;
6690              boolean explicitAction = false;
6691              boolean inSelector = false;
6692  
6693              // fetch data part, if present
6694              String scheme = null;
6695              String data;
6696              if (i >= 0) {
6697                  data = uri.substring(0, i);
6698                  i += 8; // length of "#Intent;"
6699              } else {
6700                  data = uri;
6701              }
6702  
6703              // loop over contents of Intent, all name=value;
6704              while (i >= 0 && !uri.startsWith("end", i)) {
6705                  int eq = uri.indexOf('=', i);
6706                  if (eq < 0) eq = i-1;
6707                  int semi = uri.indexOf(';', i);
6708                  String value = eq < semi ? Uri.decode(uri.substring(eq + 1, semi)) : "";
6709  
6710                  // action
6711                  if (uri.startsWith("action=", i)) {
6712                      intent.setAction(value);
6713                      if (!inSelector) {
6714                          explicitAction = true;
6715                      }
6716                  }
6717  
6718                  // categories
6719                  else if (uri.startsWith("category=", i)) {
6720                      intent.addCategory(value);
6721                  }
6722  
6723                  // type
6724                  else if (uri.startsWith("type=", i)) {
6725                      intent.mType = value;
6726                  }
6727  
6728                  // identifier
6729                  else if (uri.startsWith("identifier=", i)) {
6730                      intent.mIdentifier = value;
6731                  }
6732  
6733                  // launch flags
6734                  else if (uri.startsWith("launchFlags=", i)) {
6735                      intent.mFlags = Integer.decode(value).intValue();
6736                      if ((flags& URI_ALLOW_UNSAFE) == 0) {
6737                          intent.mFlags &= ~IMMUTABLE_FLAGS;
6738                      }
6739                  }
6740  
6741                  // package
6742                  else if (uri.startsWith("package=", i)) {
6743                      intent.mPackage = value;
6744                  }
6745  
6746                  // component
6747                  else if (uri.startsWith("component=", i)) {
6748                      intent.mComponent = ComponentName.unflattenFromString(value);
6749                  }
6750  
6751                  // scheme
6752                  else if (uri.startsWith("scheme=", i)) {
6753                      if (inSelector) {
6754                          intent.mData = Uri.parse(value + ":");
6755                      } else {
6756                          scheme = value;
6757                      }
6758                  }
6759  
6760                  // source bounds
6761                  else if (uri.startsWith("sourceBounds=", i)) {
6762                      intent.mSourceBounds = Rect.unflattenFromString(value);
6763                  }
6764  
6765                  // selector
6766                  else if (semi == (i+3) && uri.startsWith("SEL", i)) {
6767                      intent = new Intent();
6768                      inSelector = true;
6769                  }
6770  
6771                  // extra
6772                  else {
6773                      String key = Uri.decode(uri.substring(i + 2, eq));
6774                      // create Bundle if it doesn't already exist
6775                      if (intent.mExtras == null) intent.mExtras = new Bundle();
6776                      Bundle b = intent.mExtras;
6777                      // add EXTRA
6778                      if      (uri.startsWith("S.", i)) b.putString(key, value);
6779                      else if (uri.startsWith("B.", i)) b.putBoolean(key, Boolean.parseBoolean(value));
6780                      else if (uri.startsWith("b.", i)) b.putByte(key, Byte.parseByte(value));
6781                      else if (uri.startsWith("c.", i)) b.putChar(key, value.charAt(0));
6782                      else if (uri.startsWith("d.", i)) b.putDouble(key, Double.parseDouble(value));
6783                      else if (uri.startsWith("f.", i)) b.putFloat(key, Float.parseFloat(value));
6784                      else if (uri.startsWith("i.", i)) b.putInt(key, Integer.parseInt(value));
6785                      else if (uri.startsWith("l.", i)) b.putLong(key, Long.parseLong(value));
6786                      else if (uri.startsWith("s.", i)) b.putShort(key, Short.parseShort(value));
6787                      else throw new URISyntaxException(uri, "unknown EXTRA type", i);
6788                  }
6789  
6790                  // move to the next item
6791                  i = semi + 1;
6792              }
6793  
6794              if (inSelector) {
6795                  // The Intent had a selector; fix it up.
6796                  if (baseIntent.mPackage == null) {
6797                      baseIntent.setSelector(intent);
6798                  }
6799                  intent = baseIntent;
6800              }
6801  
6802              if (data != null) {
6803                  if (data.startsWith("intent:")) {
6804                      data = data.substring(7);
6805                      if (scheme != null) {
6806                          data = scheme + ':' + data;
6807                      }
6808                  } else if (data.startsWith("android-app:")) {
6809                      if (data.charAt(12) == '/' && data.charAt(13) == '/') {
6810                          // Correctly formed android-app, first part is package name.
6811                          int end = data.indexOf('/', 14);
6812                          if (end < 0) {
6813                              // All we have is a package name.
6814                              intent.mPackage = data.substring(14);
6815                              if (!explicitAction) {
6816                                  intent.setAction(ACTION_MAIN);
6817                              }
6818                              data = "";
6819                          } else {
6820                              // Target the Intent at the given package name always.
6821                              String authority = null;
6822                              intent.mPackage = data.substring(14, end);
6823                              int newEnd;
6824                              if ((end+1) < data.length()) {
6825                                  if ((newEnd=data.indexOf('/', end+1)) >= 0) {
6826                                      // Found a scheme, remember it.
6827                                      scheme = data.substring(end+1, newEnd);
6828                                      end = newEnd;
6829                                      if (end < data.length() && (newEnd=data.indexOf('/', end+1)) >= 0) {
6830                                          // Found a authority, remember it.
6831                                          authority = data.substring(end+1, newEnd);
6832                                          end = newEnd;
6833                                      }
6834                                  } else {
6835                                      // All we have is a scheme.
6836                                      scheme = data.substring(end+1);
6837                                  }
6838                              }
6839                              if (scheme == null) {
6840                                  // If there was no scheme, then this just targets the package.
6841                                  if (!explicitAction) {
6842                                      intent.setAction(ACTION_MAIN);
6843                                  }
6844                                  data = "";
6845                              } else if (authority == null) {
6846                                  data = scheme + ":";
6847                              } else {
6848                                  data = scheme + "://" + authority + data.substring(end);
6849                              }
6850                          }
6851                      } else {
6852                          data = "";
6853                      }
6854                  }
6855  
6856                  if (data.length() > 0) {
6857                      try {
6858                          intent.mData = Uri.parse(data);
6859                      } catch (IllegalArgumentException e) {
6860                          throw new URISyntaxException(uri, e.getMessage());
6861                      }
6862                  }
6863              }
6864  
6865              return intent;
6866  
6867          } catch (IndexOutOfBoundsException e) {
6868              throw new URISyntaxException(uri, "illegal Intent URI format", i);
6869          }
6870      }
6871  
6872      public static Intent getIntentOld(String uri) throws URISyntaxException {
6873          return getIntentOld(uri, 0);
6874      }
6875  
6876      private static Intent getIntentOld(String uri, int flags) throws URISyntaxException {
6877          Intent intent;
6878  
6879          int i = uri.lastIndexOf('#');
6880          if (i >= 0) {
6881              String action = null;
6882              final int intentFragmentStart = i;
6883              boolean isIntentFragment = false;
6884  
6885              i++;
6886  
6887              if (uri.regionMatches(i, "action(", 0, 7)) {
6888                  isIntentFragment = true;
6889                  i += 7;
6890                  int j = uri.indexOf(')', i);
6891                  action = uri.substring(i, j);
6892                  i = j + 1;
6893              }
6894  
6895              intent = new Intent(action);
6896  
6897              if (uri.regionMatches(i, "categories(", 0, 11)) {
6898                  isIntentFragment = true;
6899                  i += 11;
6900                  int j = uri.indexOf(')', i);
6901                  while (i < j) {
6902                      int sep = uri.indexOf('!', i);
6903                      if (sep < 0 || sep > j) sep = j;
6904                      if (i < sep) {
6905                          intent.addCategory(uri.substring(i, sep));
6906                      }
6907                      i = sep + 1;
6908                  }
6909                  i = j + 1;
6910              }
6911  
6912              if (uri.regionMatches(i, "type(", 0, 5)) {
6913                  isIntentFragment = true;
6914                  i += 5;
6915                  int j = uri.indexOf(')', i);
6916                  intent.mType = uri.substring(i, j);
6917                  i = j + 1;
6918              }
6919  
6920              if (uri.regionMatches(i, "launchFlags(", 0, 12)) {
6921                  isIntentFragment = true;
6922                  i += 12;
6923                  int j = uri.indexOf(')', i);
6924                  intent.mFlags = Integer.decode(uri.substring(i, j)).intValue();
6925                  if ((flags& URI_ALLOW_UNSAFE) == 0) {
6926                      intent.mFlags &= ~IMMUTABLE_FLAGS;
6927                  }
6928                  i = j + 1;
6929              }
6930  
6931              if (uri.regionMatches(i, "component(", 0, 10)) {
6932                  isIntentFragment = true;
6933                  i += 10;
6934                  int j = uri.indexOf(')', i);
6935                  int sep = uri.indexOf('!', i);
6936                  if (sep >= 0 && sep < j) {
6937                      String pkg = uri.substring(i, sep);
6938                      String cls = uri.substring(sep + 1, j);
6939                      intent.mComponent = new ComponentName(pkg, cls);
6940                  }
6941                  i = j + 1;
6942              }
6943  
6944              if (uri.regionMatches(i, "extras(", 0, 7)) {
6945                  isIntentFragment = true;
6946                  i += 7;
6947  
6948                  final int closeParen = uri.indexOf(')', i);
6949                  if (closeParen == -1) throw new URISyntaxException(uri,
6950                          "EXTRA missing trailing ')'", i);
6951  
6952                  while (i < closeParen) {
6953                      // fetch the key value
6954                      int j = uri.indexOf('=', i);
6955                      if (j <= i + 1 || i >= closeParen) {
6956                          throw new URISyntaxException(uri, "EXTRA missing '='", i);
6957                      }
6958                      char type = uri.charAt(i);
6959                      i++;
6960                      String key = uri.substring(i, j);
6961                      i = j + 1;
6962  
6963                      // get type-value
6964                      j = uri.indexOf('!', i);
6965                      if (j == -1 || j >= closeParen) j = closeParen;
6966                      if (i >= j) throw new URISyntaxException(uri, "EXTRA missing '!'", i);
6967                      String value = uri.substring(i, j);
6968                      i = j;
6969  
6970                      // create Bundle if it doesn't already exist
6971                      if (intent.mExtras == null) intent.mExtras = new Bundle();
6972  
6973                      // add item to bundle
6974                      try {
6975                          switch (type) {
6976                              case 'S':
6977                                  intent.mExtras.putString(key, Uri.decode(value));
6978                                  break;
6979                              case 'B':
6980                                  intent.mExtras.putBoolean(key, Boolean.parseBoolean(value));
6981                                  break;
6982                              case 'b':
6983                                  intent.mExtras.putByte(key, Byte.parseByte(value));
6984                                  break;
6985                              case 'c':
6986                                  intent.mExtras.putChar(key, Uri.decode(value).charAt(0));
6987                                  break;
6988                              case 'd':
6989                                  intent.mExtras.putDouble(key, Double.parseDouble(value));
6990                                  break;
6991                              case 'f':
6992                                  intent.mExtras.putFloat(key, Float.parseFloat(value));
6993                                  break;
6994                              case 'i':
6995                                  intent.mExtras.putInt(key, Integer.parseInt(value));
6996                                  break;
6997                              case 'l':
6998                                  intent.mExtras.putLong(key, Long.parseLong(value));
6999                                  break;
7000                              case 's':
7001                                  intent.mExtras.putShort(key, Short.parseShort(value));
7002                                  break;
7003                              default:
7004                                  throw new URISyntaxException(uri, "EXTRA has unknown type", i);
7005                          }
7006                      } catch (NumberFormatException e) {
7007                          throw new URISyntaxException(uri, "EXTRA value can't be parsed", i);
7008                      }
7009  
7010                      char ch = uri.charAt(i);
7011                      if (ch == ')') break;
7012                      if (ch != '!') throw new URISyntaxException(uri, "EXTRA missing '!'", i);
7013                      i++;
7014                  }
7015              }
7016  
7017              if (isIntentFragment) {
7018                  intent.mData = Uri.parse(uri.substring(0, intentFragmentStart));
7019              } else {
7020                  intent.mData = Uri.parse(uri);
7021              }
7022  
7023              if (intent.mAction == null) {
7024                  // By default, if no action is specified, then use VIEW.
7025                  intent.mAction = ACTION_VIEW;
7026              }
7027  
7028          } else {
7029              intent = new Intent(ACTION_VIEW, Uri.parse(uri));
7030          }
7031  
7032          return intent;
7033      }
7034  
7035      /** @hide */
7036      public interface CommandOptionHandler {
7037          boolean handleOption(String opt, ShellCommand cmd);
7038      }
7039  
7040      /** @hide */
7041      @UnsupportedAppUsage
parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)7042      public static Intent parseCommandArgs(ShellCommand cmd, CommandOptionHandler optionHandler)
7043              throws URISyntaxException {
7044          Intent intent = new Intent();
7045          Intent baseIntent = intent;
7046          boolean hasIntentInfo = false;
7047  
7048          Uri data = null;
7049          String type = null;
7050  
7051          String opt;
7052          while ((opt=cmd.getNextOption()) != null) {
7053              switch (opt) {
7054                  case "-a":
7055                      intent.setAction(cmd.getNextArgRequired());
7056                      if (intent == baseIntent) {
7057                          hasIntentInfo = true;
7058                      }
7059                      break;
7060                  case "-d":
7061                      data = Uri.parse(cmd.getNextArgRequired());
7062                      if (intent == baseIntent) {
7063                          hasIntentInfo = true;
7064                      }
7065                      break;
7066                  case "-t":
7067                      type = cmd.getNextArgRequired();
7068                      if (intent == baseIntent) {
7069                          hasIntentInfo = true;
7070                      }
7071                      break;
7072                  case "-i":
7073                      intent.setIdentifier(cmd.getNextArgRequired());
7074                      if (intent == baseIntent) {
7075                          hasIntentInfo = true;
7076                      }
7077                      break;
7078                  case "-c":
7079                      intent.addCategory(cmd.getNextArgRequired());
7080                      if (intent == baseIntent) {
7081                          hasIntentInfo = true;
7082                      }
7083                      break;
7084                  case "-e":
7085                  case "--es": {
7086                      String key = cmd.getNextArgRequired();
7087                      String value = cmd.getNextArgRequired();
7088                      intent.putExtra(key, value);
7089                  }
7090                  break;
7091                  case "--esn": {
7092                      String key = cmd.getNextArgRequired();
7093                      intent.putExtra(key, (String) null);
7094                  }
7095                  break;
7096                  case "--ei": {
7097                      String key = cmd.getNextArgRequired();
7098                      String value = cmd.getNextArgRequired();
7099                      intent.putExtra(key, Integer.decode(value));
7100                  }
7101                  break;
7102                  case "--eu": {
7103                      String key = cmd.getNextArgRequired();
7104                      String value = cmd.getNextArgRequired();
7105                      intent.putExtra(key, Uri.parse(value));
7106                  }
7107                  break;
7108                  case "--ecn": {
7109                      String key = cmd.getNextArgRequired();
7110                      String value = cmd.getNextArgRequired();
7111                      ComponentName cn = ComponentName.unflattenFromString(value);
7112                      if (cn == null)
7113                          throw new IllegalArgumentException("Bad component name: " + value);
7114                      intent.putExtra(key, cn);
7115                  }
7116                  break;
7117                  case "--eia": {
7118                      String key = cmd.getNextArgRequired();
7119                      String value = cmd.getNextArgRequired();
7120                      String[] strings = value.split(",");
7121                      int[] list = new int[strings.length];
7122                      for (int i = 0; i < strings.length; i++) {
7123                          list[i] = Integer.decode(strings[i]);
7124                      }
7125                      intent.putExtra(key, list);
7126                  }
7127                  break;
7128                  case "--eial": {
7129                      String key = cmd.getNextArgRequired();
7130                      String value = cmd.getNextArgRequired();
7131                      String[] strings = value.split(",");
7132                      ArrayList<Integer> list = new ArrayList<>(strings.length);
7133                      for (int i = 0; i < strings.length; i++) {
7134                          list.add(Integer.decode(strings[i]));
7135                      }
7136                      intent.putExtra(key, list);
7137                  }
7138                  break;
7139                  case "--el": {
7140                      String key = cmd.getNextArgRequired();
7141                      String value = cmd.getNextArgRequired();
7142                      intent.putExtra(key, Long.valueOf(value));
7143                  }
7144                  break;
7145                  case "--ela": {
7146                      String key = cmd.getNextArgRequired();
7147                      String value = cmd.getNextArgRequired();
7148                      String[] strings = value.split(",");
7149                      long[] list = new long[strings.length];
7150                      for (int i = 0; i < strings.length; i++) {
7151                          list[i] = Long.valueOf(strings[i]);
7152                      }
7153                      intent.putExtra(key, list);
7154                      hasIntentInfo = true;
7155                  }
7156                  break;
7157                  case "--elal": {
7158                      String key = cmd.getNextArgRequired();
7159                      String value = cmd.getNextArgRequired();
7160                      String[] strings = value.split(",");
7161                      ArrayList<Long> list = new ArrayList<>(strings.length);
7162                      for (int i = 0; i < strings.length; i++) {
7163                          list.add(Long.valueOf(strings[i]));
7164                      }
7165                      intent.putExtra(key, list);
7166                      hasIntentInfo = true;
7167                  }
7168                  break;
7169                  case "--ef": {
7170                      String key = cmd.getNextArgRequired();
7171                      String value = cmd.getNextArgRequired();
7172                      intent.putExtra(key, Float.valueOf(value));
7173                      hasIntentInfo = true;
7174                  }
7175                  break;
7176                  case "--efa": {
7177                      String key = cmd.getNextArgRequired();
7178                      String value = cmd.getNextArgRequired();
7179                      String[] strings = value.split(",");
7180                      float[] list = new float[strings.length];
7181                      for (int i = 0; i < strings.length; i++) {
7182                          list[i] = Float.valueOf(strings[i]);
7183                      }
7184                      intent.putExtra(key, list);
7185                      hasIntentInfo = true;
7186                  }
7187                  break;
7188                  case "--efal": {
7189                      String key = cmd.getNextArgRequired();
7190                      String value = cmd.getNextArgRequired();
7191                      String[] strings = value.split(",");
7192                      ArrayList<Float> list = new ArrayList<>(strings.length);
7193                      for (int i = 0; i < strings.length; i++) {
7194                          list.add(Float.valueOf(strings[i]));
7195                      }
7196                      intent.putExtra(key, list);
7197                      hasIntentInfo = true;
7198                  }
7199                  break;
7200                  case "--esa": {
7201                      String key = cmd.getNextArgRequired();
7202                      String value = cmd.getNextArgRequired();
7203                      // Split on commas unless they are preceeded by an escape.
7204                      // The escape character must be escaped for the string and
7205                      // again for the regex, thus four escape characters become one.
7206                      String[] strings = value.split("(?<!\\\\),");
7207                      intent.putExtra(key, strings);
7208                      hasIntentInfo = true;
7209                  }
7210                  break;
7211                  case "--esal": {
7212                      String key = cmd.getNextArgRequired();
7213                      String value = cmd.getNextArgRequired();
7214                      // Split on commas unless they are preceeded by an escape.
7215                      // The escape character must be escaped for the string and
7216                      // again for the regex, thus four escape characters become one.
7217                      String[] strings = value.split("(?<!\\\\),");
7218                      ArrayList<String> list = new ArrayList<>(strings.length);
7219                      for (int i = 0; i < strings.length; i++) {
7220                          list.add(strings[i]);
7221                      }
7222                      intent.putExtra(key, list);
7223                      hasIntentInfo = true;
7224                  }
7225                  break;
7226                  case "--ez": {
7227                      String key = cmd.getNextArgRequired();
7228                      String value = cmd.getNextArgRequired().toLowerCase();
7229                      // Boolean.valueOf() results in false for anything that is not "true", which is
7230                      // error-prone in shell commands
7231                      boolean arg;
7232                      if ("true".equals(value) || "t".equals(value)) {
7233                          arg = true;
7234                      } else if ("false".equals(value) || "f".equals(value)) {
7235                          arg = false;
7236                      } else {
7237                          try {
7238                              arg = Integer.decode(value) != 0;
7239                          } catch (NumberFormatException ex) {
7240                              throw new IllegalArgumentException("Invalid boolean value: " + value);
7241                          }
7242                      }
7243  
7244                      intent.putExtra(key, arg);
7245                  }
7246                  break;
7247                  case "-n": {
7248                      String str = cmd.getNextArgRequired();
7249                      ComponentName cn = ComponentName.unflattenFromString(str);
7250                      if (cn == null)
7251                          throw new IllegalArgumentException("Bad component name: " + str);
7252                      intent.setComponent(cn);
7253                      if (intent == baseIntent) {
7254                          hasIntentInfo = true;
7255                      }
7256                  }
7257                  break;
7258                  case "-p": {
7259                      String str = cmd.getNextArgRequired();
7260                      intent.setPackage(str);
7261                      if (intent == baseIntent) {
7262                          hasIntentInfo = true;
7263                      }
7264                  }
7265                  break;
7266                  case "-f":
7267                      String str = cmd.getNextArgRequired();
7268                      intent.setFlags(Integer.decode(str).intValue());
7269                      break;
7270                  case "--grant-read-uri-permission":
7271                      intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
7272                      break;
7273                  case "--grant-write-uri-permission":
7274                      intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
7275                      break;
7276                  case "--grant-persistable-uri-permission":
7277                      intent.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
7278                      break;
7279                  case "--grant-prefix-uri-permission":
7280                      intent.addFlags(Intent.FLAG_GRANT_PREFIX_URI_PERMISSION);
7281                      break;
7282                  case "--exclude-stopped-packages":
7283                      intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
7284                      break;
7285                  case "--include-stopped-packages":
7286                      intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
7287                      break;
7288                  case "--debug-log-resolution":
7289                      intent.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION);
7290                      break;
7291                  case "--activity-brought-to-front":
7292                      intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
7293                      break;
7294                  case "--activity-clear-top":
7295                      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
7296                      break;
7297                  case "--activity-clear-when-task-reset":
7298                      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
7299                      break;
7300                  case "--activity-exclude-from-recents":
7301                      intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
7302                      break;
7303                  case "--activity-launched-from-history":
7304                      intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY);
7305                      break;
7306                  case "--activity-multiple-task":
7307                      intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
7308                      break;
7309                  case "--activity-no-animation":
7310                      intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
7311                      break;
7312                  case "--activity-no-history":
7313                      intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
7314                      break;
7315                  case "--activity-no-user-action":
7316                      intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
7317                      break;
7318                  case "--activity-previous-is-top":
7319                      intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
7320                      break;
7321                  case "--activity-reorder-to-front":
7322                      intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
7323                      break;
7324                  case "--activity-reset-task-if-needed":
7325                      intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
7326                      break;
7327                  case "--activity-single-top":
7328                      intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
7329                      break;
7330                  case "--activity-clear-task":
7331                      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
7332                      break;
7333                  case "--activity-task-on-home":
7334                      intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
7335                      break;
7336                  case "--activity-match-external":
7337                      intent.addFlags(Intent.FLAG_ACTIVITY_MATCH_EXTERNAL);
7338                      break;
7339                  case "--receiver-registered-only":
7340                      intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
7341                      break;
7342                  case "--receiver-replace-pending":
7343                      intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
7344                      break;
7345                  case "--receiver-foreground":
7346                      intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
7347                      break;
7348                  case "--receiver-no-abort":
7349                      intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT);
7350                      break;
7351                  case "--receiver-include-background":
7352                      intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
7353                      break;
7354                  case "--selector":
7355                      intent.setDataAndType(data, type);
7356                      intent = new Intent();
7357                      break;
7358                  default:
7359                      if (optionHandler != null && optionHandler.handleOption(opt, cmd)) {
7360                          // Okay, caller handled this option.
7361                      } else {
7362                          throw new IllegalArgumentException("Unknown option: " + opt);
7363                      }
7364                      break;
7365              }
7366          }
7367          intent.setDataAndType(data, type);
7368  
7369          final boolean hasSelector = intent != baseIntent;
7370          if (hasSelector) {
7371              // A selector was specified; fix up.
7372              baseIntent.setSelector(intent);
7373              intent = baseIntent;
7374          }
7375  
7376          String arg = cmd.getNextArg();
7377          baseIntent = null;
7378          if (arg == null) {
7379              if (hasSelector) {
7380                  // If a selector has been specified, and no arguments
7381                  // have been supplied for the main Intent, then we can
7382                  // assume it is ACTION_MAIN CATEGORY_LAUNCHER; we don't
7383                  // need to have a component name specified yet, the
7384                  // selector will take care of that.
7385                  baseIntent = new Intent(Intent.ACTION_MAIN);
7386                  baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7387              }
7388          } else if (arg.indexOf(':') >= 0) {
7389              // The argument is a URI.  Fully parse it, and use that result
7390              // to fill in any data not specified so far.
7391              baseIntent = Intent.parseUri(arg, Intent.URI_INTENT_SCHEME
7392                      | Intent.URI_ANDROID_APP_SCHEME | Intent.URI_ALLOW_UNSAFE);
7393          } else if (arg.indexOf('/') >= 0) {
7394              // The argument is a component name.  Build an Intent to launch
7395              // it.
7396              baseIntent = new Intent(Intent.ACTION_MAIN);
7397              baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7398              baseIntent.setComponent(ComponentName.unflattenFromString(arg));
7399          } else {
7400              // Assume the argument is a package name.
7401              baseIntent = new Intent(Intent.ACTION_MAIN);
7402              baseIntent.addCategory(Intent.CATEGORY_LAUNCHER);
7403              baseIntent.setPackage(arg);
7404          }
7405          if (baseIntent != null) {
7406              Bundle extras = intent.getExtras();
7407              intent.replaceExtras((Bundle)null);
7408              Bundle uriExtras = baseIntent.getExtras();
7409              baseIntent.replaceExtras((Bundle)null);
7410              if (intent.getAction() != null && baseIntent.getCategories() != null) {
7411                  HashSet<String> cats = new HashSet<String>(baseIntent.getCategories());
7412                  for (String c : cats) {
7413                      baseIntent.removeCategory(c);
7414                  }
7415              }
7416              intent.fillIn(baseIntent, Intent.FILL_IN_COMPONENT | Intent.FILL_IN_SELECTOR);
7417              if (extras == null) {
7418                  extras = uriExtras;
7419              } else if (uriExtras != null) {
7420                  uriExtras.putAll(extras);
7421                  extras = uriExtras;
7422              }
7423              intent.replaceExtras(extras);
7424              hasIntentInfo = true;
7425          }
7426  
7427          if (!hasIntentInfo) throw new IllegalArgumentException("No intent supplied");
7428          return intent;
7429      }
7430  
7431      /** @hide */
7432      @UnsupportedAppUsage
printIntentArgsHelp(PrintWriter pw, String prefix)7433      public static void printIntentArgsHelp(PrintWriter pw, String prefix) {
7434          final String[] lines = new String[] {
7435                  "<INTENT> specifications include these flags and arguments:",
7436                  "    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-i <IDENTIFIER>]",
7437                  "    [-c <CATEGORY> [-c <CATEGORY>] ...]",
7438                  "    [-n <COMPONENT_NAME>]",
7439                  "    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
7440                  "    [--esn <EXTRA_KEY> ...]",
7441                  "    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
7442                  "    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]",
7443                  "    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]",
7444                  "    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]",
7445                  "    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]",
7446                  "    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]",
7447                  "    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7448                  "        (mutiple extras passed as Integer[])",
7449                  "    [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]",
7450                  "        (mutiple extras passed as List<Integer>)",
7451                  "    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7452                  "        (mutiple extras passed as Long[])",
7453                  "    [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]",
7454                  "        (mutiple extras passed as List<Long>)",
7455                  "    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7456                  "        (mutiple extras passed as Float[])",
7457                  "    [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]",
7458                  "        (mutiple extras passed as List<Float>)",
7459                  "    [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7460                  "        (mutiple extras passed as String[]; to embed a comma into a string,",
7461                  "         escape it using \"\\,\")",
7462                  "    [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]",
7463                  "        (mutiple extras passed as List<String>; to embed a comma into a string,",
7464                  "         escape it using \"\\,\")",
7465                  "    [-f <FLAG>]",
7466                  "    [--grant-read-uri-permission] [--grant-write-uri-permission]",
7467                  "    [--grant-persistable-uri-permission] [--grant-prefix-uri-permission]",
7468                  "    [--debug-log-resolution] [--exclude-stopped-packages]",
7469                  "    [--include-stopped-packages]",
7470                  "    [--activity-brought-to-front] [--activity-clear-top]",
7471                  "    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]",
7472                  "    [--activity-launched-from-history] [--activity-multiple-task]",
7473                  "    [--activity-no-animation] [--activity-no-history]",
7474                  "    [--activity-no-user-action] [--activity-previous-is-top]",
7475                  "    [--activity-reorder-to-front] [--activity-reset-task-if-needed]",
7476                  "    [--activity-single-top] [--activity-clear-task]",
7477                  "    [--activity-task-on-home] [--activity-match-external]",
7478                  "    [--receiver-registered-only] [--receiver-replace-pending]",
7479                  "    [--receiver-foreground] [--receiver-no-abort]",
7480                  "    [--receiver-include-background]",
7481                  "    [--selector]",
7482                  "    [<URI> | <PACKAGE> | <COMPONENT>]"
7483          };
7484          for (String line : lines) {
7485              pw.print(prefix);
7486              pw.println(line);
7487          }
7488      }
7489  
7490      /**
7491       * Retrieve the general action to be performed, such as
7492       * {@link #ACTION_VIEW}.  The action describes the general way the rest of
7493       * the information in the intent should be interpreted -- most importantly,
7494       * what to do with the data returned by {@link #getData}.
7495       *
7496       * @return The action of this intent or null if none is specified.
7497       *
7498       * @see #setAction
7499       */
getAction()7500      public @Nullable String getAction() {
7501          return mAction;
7502      }
7503  
7504      /**
7505       * Retrieve data this intent is operating on.  This URI specifies the name
7506       * of the data; often it uses the content: scheme, specifying data in a
7507       * content provider.  Other schemes may be handled by specific activities,
7508       * such as http: by the web browser.
7509       *
7510       * @return The URI of the data this intent is targeting or null.
7511       *
7512       * @see #getScheme
7513       * @see #setData
7514       */
getData()7515      public @Nullable Uri getData() {
7516          return mData;
7517      }
7518  
7519      /**
7520       * The same as {@link #getData()}, but returns the URI as an encoded
7521       * String.
7522       */
getDataString()7523      public @Nullable String getDataString() {
7524          return mData != null ? mData.toString() : null;
7525      }
7526  
7527      /**
7528       * Return the scheme portion of the intent's data.  If the data is null or
7529       * does not include a scheme, null is returned.  Otherwise, the scheme
7530       * prefix without the final ':' is returned, i.e. "http".
7531       *
7532       * <p>This is the same as calling getData().getScheme() (and checking for
7533       * null data).
7534       *
7535       * @return The scheme of this intent.
7536       *
7537       * @see #getData
7538       */
getScheme()7539      public @Nullable String getScheme() {
7540          return mData != null ? mData.getScheme() : null;
7541      }
7542  
7543      /**
7544       * Retrieve any explicit MIME type included in the intent.  This is usually
7545       * null, as the type is determined by the intent data.
7546       *
7547       * @return If a type was manually set, it is returned; else null is
7548       *         returned.
7549       *
7550       * @see #resolveType(ContentResolver)
7551       * @see #setType
7552       */
getType()7553      public @Nullable String getType() {
7554          return mType;
7555      }
7556  
7557      /**
7558       * Return the MIME data type of this intent.  If the type field is
7559       * explicitly set, that is simply returned.  Otherwise, if the data is set,
7560       * the type of that data is returned.  If neither fields are set, a null is
7561       * returned.
7562       *
7563       * @return The MIME type of this intent.
7564       *
7565       * @see #getType
7566       * @see #resolveType(ContentResolver)
7567       */
resolveType(@onNull Context context)7568      public @Nullable String resolveType(@NonNull Context context) {
7569          return resolveType(context.getContentResolver());
7570      }
7571  
7572      /**
7573       * Return the MIME data type of this intent.  If the type field is
7574       * explicitly set, that is simply returned.  Otherwise, if the data is set,
7575       * the type of that data is returned.  If neither fields are set, a null is
7576       * returned.
7577       *
7578       * @param resolver A ContentResolver that can be used to determine the MIME
7579       *                 type of the intent's data.
7580       *
7581       * @return The MIME type of this intent.
7582       *
7583       * @see #getType
7584       * @see #resolveType(Context)
7585       */
resolveType(@onNull ContentResolver resolver)7586      public @Nullable String resolveType(@NonNull ContentResolver resolver) {
7587          if (mType != null) {
7588              return mType;
7589          }
7590          if (mData != null) {
7591              if ("content".equals(mData.getScheme())) {
7592                  return resolver.getType(mData);
7593              }
7594          }
7595          return null;
7596      }
7597  
7598      /**
7599       * Return the MIME data type of this intent, only if it will be needed for
7600       * intent resolution.  This is not generally useful for application code;
7601       * it is used by the frameworks for communicating with back-end system
7602       * services.
7603       *
7604       * @param resolver A ContentResolver that can be used to determine the MIME
7605       *                 type of the intent's data.
7606       *
7607       * @return The MIME type of this intent, or null if it is unknown or not
7608       *         needed.
7609       */
resolveTypeIfNeeded(@onNull ContentResolver resolver)7610      public @Nullable String resolveTypeIfNeeded(@NonNull ContentResolver resolver) {
7611          if (mComponent != null) {
7612              return mType;
7613          }
7614          return resolveType(resolver);
7615      }
7616  
7617      /**
7618       * Retrieve the identifier for this Intent.  If non-null, this is an arbitrary identity
7619       * of the Intent to distinguish it from other Intents.
7620       *
7621       * @return The identifier of this intent or null if none is specified.
7622       *
7623       * @see #setIdentifier
7624       */
getIdentifier()7625      public @Nullable String getIdentifier() {
7626          return mIdentifier;
7627      }
7628  
7629      /**
7630       * Check if a category exists in the intent.
7631       *
7632       * @param category The category to check.
7633       *
7634       * @return boolean True if the intent contains the category, else false.
7635       *
7636       * @see #getCategories
7637       * @see #addCategory
7638       */
hasCategory(String category)7639      public boolean hasCategory(String category) {
7640          return mCategories != null && mCategories.contains(category);
7641      }
7642  
7643      /**
7644       * Return the set of all categories in the intent.  If there are no categories,
7645       * returns NULL.
7646       *
7647       * @return The set of categories you can examine.  Do not modify!
7648       *
7649       * @see #hasCategory
7650       * @see #addCategory
7651       */
getCategories()7652      public Set<String> getCategories() {
7653          return mCategories;
7654      }
7655  
7656      /**
7657       * Return the specific selector associated with this Intent.  If there is
7658       * none, returns null.  See {@link #setSelector} for more information.
7659       *
7660       * @see #setSelector
7661       */
getSelector()7662      public @Nullable Intent getSelector() {
7663          return mSelector;
7664      }
7665  
7666      /**
7667       * Return the {@link ClipData} associated with this Intent.  If there is
7668       * none, returns null.  See {@link #setClipData} for more information.
7669       *
7670       * @see #setClipData
7671       */
getClipData()7672      public @Nullable ClipData getClipData() {
7673          return mClipData;
7674      }
7675  
7676      /** @hide */
getContentUserHint()7677      public int getContentUserHint() {
7678          return mContentUserHint;
7679      }
7680  
7681      /** @hide */
getLaunchToken()7682      public String getLaunchToken() {
7683          return mLaunchToken;
7684      }
7685  
7686      /** @hide */
setLaunchToken(String launchToken)7687      public void setLaunchToken(String launchToken) {
7688          mLaunchToken = launchToken;
7689      }
7690  
7691      /**
7692       * Sets the ClassLoader that will be used when unmarshalling
7693       * any Parcelable values from the extras of this Intent.
7694       *
7695       * @param loader a ClassLoader, or null to use the default loader
7696       * at the time of unmarshalling.
7697       */
setExtrasClassLoader(@ullable ClassLoader loader)7698      public void setExtrasClassLoader(@Nullable ClassLoader loader) {
7699          if (mExtras != null) {
7700              mExtras.setClassLoader(loader);
7701          }
7702      }
7703  
7704      /**
7705       * Returns true if an extra value is associated with the given name.
7706       * @param name the extra's name
7707       * @return true if the given extra is present.
7708       */
hasExtra(String name)7709      public boolean hasExtra(String name) {
7710          return mExtras != null && mExtras.containsKey(name);
7711      }
7712  
7713      /**
7714       * Returns true if the Intent's extras contain a parcelled file descriptor.
7715       * @return true if the Intent contains a parcelled file descriptor.
7716       */
hasFileDescriptors()7717      public boolean hasFileDescriptors() {
7718          return mExtras != null && mExtras.hasFileDescriptors();
7719      }
7720  
7721      /** {@hide} */
7722      @UnsupportedAppUsage
setAllowFds(boolean allowFds)7723      public void setAllowFds(boolean allowFds) {
7724          if (mExtras != null) {
7725              mExtras.setAllowFds(allowFds);
7726          }
7727      }
7728  
7729      /** {@hide} */
setDefusable(boolean defusable)7730      public void setDefusable(boolean defusable) {
7731          if (mExtras != null) {
7732              mExtras.setDefusable(defusable);
7733          }
7734      }
7735  
7736      /**
7737       * Retrieve extended data from the intent.
7738       *
7739       * @param name The name of the desired item.
7740       *
7741       * @return the value of an item previously added with putExtra(),
7742       * or null if none was found.
7743       *
7744       * @deprecated
7745       * @hide
7746       */
7747      @Deprecated
7748      @UnsupportedAppUsage
getExtra(String name)7749      public Object getExtra(String name) {
7750          return getExtra(name, null);
7751      }
7752  
7753      /**
7754       * Retrieve extended data from the intent.
7755       *
7756       * @param name The name of the desired item.
7757       * @param defaultValue the value to be returned if no value of the desired
7758       * type is stored with the given name.
7759       *
7760       * @return the value of an item previously added with putExtra(),
7761       * or the default value if none was found.
7762       *
7763       * @see #putExtra(String, boolean)
7764       */
getBooleanExtra(String name, boolean defaultValue)7765      public boolean getBooleanExtra(String name, boolean defaultValue) {
7766          return mExtras == null ? defaultValue :
7767              mExtras.getBoolean(name, defaultValue);
7768      }
7769  
7770      /**
7771       * Retrieve extended data from the intent.
7772       *
7773       * @param name The name of the desired item.
7774       * @param defaultValue the value to be returned if no value of the desired
7775       * type is stored with the given name.
7776       *
7777       * @return the value of an item previously added with putExtra(),
7778       * or the default value if none was found.
7779       *
7780       * @see #putExtra(String, byte)
7781       */
getByteExtra(String name, byte defaultValue)7782      public byte getByteExtra(String name, byte defaultValue) {
7783          return mExtras == null ? defaultValue :
7784              mExtras.getByte(name, defaultValue);
7785      }
7786  
7787      /**
7788       * Retrieve extended data from the intent.
7789       *
7790       * @param name The name of the desired item.
7791       * @param defaultValue the value to be returned if no value of the desired
7792       * type is stored with the given name.
7793       *
7794       * @return the value of an item previously added with putExtra(),
7795       * or the default value if none was found.
7796       *
7797       * @see #putExtra(String, short)
7798       */
getShortExtra(String name, short defaultValue)7799      public short getShortExtra(String name, short defaultValue) {
7800          return mExtras == null ? defaultValue :
7801              mExtras.getShort(name, defaultValue);
7802      }
7803  
7804      /**
7805       * Retrieve extended data from the intent.
7806       *
7807       * @param name The name of the desired item.
7808       * @param defaultValue the value to be returned if no value of the desired
7809       * type is stored with the given name.
7810       *
7811       * @return the value of an item previously added with putExtra(),
7812       * or the default value if none was found.
7813       *
7814       * @see #putExtra(String, char)
7815       */
getCharExtra(String name, char defaultValue)7816      public char getCharExtra(String name, char defaultValue) {
7817          return mExtras == null ? defaultValue :
7818              mExtras.getChar(name, defaultValue);
7819      }
7820  
7821      /**
7822       * Retrieve extended data from the intent.
7823       *
7824       * @param name The name of the desired item.
7825       * @param defaultValue the value to be returned if no value of the desired
7826       * type is stored with the given name.
7827       *
7828       * @return the value of an item previously added with putExtra(),
7829       * or the default value if none was found.
7830       *
7831       * @see #putExtra(String, int)
7832       */
getIntExtra(String name, int defaultValue)7833      public int getIntExtra(String name, int defaultValue) {
7834          return mExtras == null ? defaultValue :
7835              mExtras.getInt(name, defaultValue);
7836      }
7837  
7838      /**
7839       * Retrieve extended data from the intent.
7840       *
7841       * @param name The name of the desired item.
7842       * @param defaultValue the value to be returned if no value of the desired
7843       * type is stored with the given name.
7844       *
7845       * @return the value of an item previously added with putExtra(),
7846       * or the default value if none was found.
7847       *
7848       * @see #putExtra(String, long)
7849       */
getLongExtra(String name, long defaultValue)7850      public long getLongExtra(String name, long defaultValue) {
7851          return mExtras == null ? defaultValue :
7852              mExtras.getLong(name, defaultValue);
7853      }
7854  
7855      /**
7856       * Retrieve extended data from the intent.
7857       *
7858       * @param name The name of the desired item.
7859       * @param defaultValue the value to be returned if no value of the desired
7860       * type is stored with the given name.
7861       *
7862       * @return the value of an item previously added with putExtra(),
7863       * or the default value if no such item is present
7864       *
7865       * @see #putExtra(String, float)
7866       */
getFloatExtra(String name, float defaultValue)7867      public float getFloatExtra(String name, float defaultValue) {
7868          return mExtras == null ? defaultValue :
7869              mExtras.getFloat(name, defaultValue);
7870      }
7871  
7872      /**
7873       * Retrieve extended data from the intent.
7874       *
7875       * @param name The name of the desired item.
7876       * @param defaultValue the value to be returned if no value of the desired
7877       * type is stored with the given name.
7878       *
7879       * @return the value of an item previously added with putExtra(),
7880       * or the default value if none was found.
7881       *
7882       * @see #putExtra(String, double)
7883       */
getDoubleExtra(String name, double defaultValue)7884      public double getDoubleExtra(String name, double defaultValue) {
7885          return mExtras == null ? defaultValue :
7886              mExtras.getDouble(name, defaultValue);
7887      }
7888  
7889      /**
7890       * Retrieve extended data from the intent.
7891       *
7892       * @param name The name of the desired item.
7893       *
7894       * @return the value of an item previously added with putExtra(),
7895       * or null if no String value was found.
7896       *
7897       * @see #putExtra(String, String)
7898       */
getStringExtra(String name)7899      public @Nullable String getStringExtra(String name) {
7900          return mExtras == null ? null : mExtras.getString(name);
7901      }
7902  
7903      /**
7904       * Retrieve extended data from the intent.
7905       *
7906       * @param name The name of the desired item.
7907       *
7908       * @return the value of an item previously added with putExtra(),
7909       * or null if no CharSequence value was found.
7910       *
7911       * @see #putExtra(String, CharSequence)
7912       */
getCharSequenceExtra(String name)7913      public @Nullable CharSequence getCharSequenceExtra(String name) {
7914          return mExtras == null ? null : mExtras.getCharSequence(name);
7915      }
7916  
7917      /**
7918       * Retrieve extended data from the intent.
7919       *
7920       * @param name The name of the desired item.
7921       *
7922       * @return the value of an item previously added with putExtra(),
7923       * or null if no Parcelable value was found.
7924       *
7925       * @see #putExtra(String, Parcelable)
7926       */
getParcelableExtra(String name)7927      public @Nullable <T extends Parcelable> T getParcelableExtra(String name) {
7928          return mExtras == null ? null : mExtras.<T>getParcelable(name);
7929      }
7930  
7931      /**
7932       * Retrieve extended data from the intent.
7933       *
7934       * @param name The name of the desired item.
7935       *
7936       * @return the value of an item previously added with putExtra(),
7937       * or null if no Parcelable[] value was found.
7938       *
7939       * @see #putExtra(String, Parcelable[])
7940       */
getParcelableArrayExtra(String name)7941      public @Nullable Parcelable[] getParcelableArrayExtra(String name) {
7942          return mExtras == null ? null : mExtras.getParcelableArray(name);
7943      }
7944  
7945      /**
7946       * Retrieve extended data from the intent.
7947       *
7948       * @param name The name of the desired item.
7949       *
7950       * @return the value of an item previously added with
7951       * putParcelableArrayListExtra(), or null if no
7952       * ArrayList<Parcelable> value was found.
7953       *
7954       * @see #putParcelableArrayListExtra(String, ArrayList)
7955       */
getParcelableArrayListExtra(String name)7956      public @Nullable <T extends Parcelable> ArrayList<T> getParcelableArrayListExtra(String name) {
7957          return mExtras == null ? null : mExtras.<T>getParcelableArrayList(name);
7958      }
7959  
7960      /**
7961       * Retrieve extended data from the intent.
7962       *
7963       * @param name The name of the desired item.
7964       *
7965       * @return the value of an item previously added with putExtra(),
7966       * or null if no Serializable value was found.
7967       *
7968       * @see #putExtra(String, Serializable)
7969       */
getSerializableExtra(String name)7970      public @Nullable Serializable getSerializableExtra(String name) {
7971          return mExtras == null ? null : mExtras.getSerializable(name);
7972      }
7973  
7974      /**
7975       * Retrieve extended data from the intent.
7976       *
7977       * @param name The name of the desired item.
7978       *
7979       * @return the value of an item previously added with
7980       * putIntegerArrayListExtra(), or null if no
7981       * ArrayList<Integer> value was found.
7982       *
7983       * @see #putIntegerArrayListExtra(String, ArrayList)
7984       */
getIntegerArrayListExtra(String name)7985      public @Nullable ArrayList<Integer> getIntegerArrayListExtra(String name) {
7986          return mExtras == null ? null : mExtras.getIntegerArrayList(name);
7987      }
7988  
7989      /**
7990       * Retrieve extended data from the intent.
7991       *
7992       * @param name The name of the desired item.
7993       *
7994       * @return the value of an item previously added with
7995       * putStringArrayListExtra(), or null if no
7996       * ArrayList<String> value was found.
7997       *
7998       * @see #putStringArrayListExtra(String, ArrayList)
7999       */
getStringArrayListExtra(String name)8000      public @Nullable ArrayList<String> getStringArrayListExtra(String name) {
8001          return mExtras == null ? null : mExtras.getStringArrayList(name);
8002      }
8003  
8004      /**
8005       * Retrieve extended data from the intent.
8006       *
8007       * @param name The name of the desired item.
8008       *
8009       * @return the value of an item previously added with
8010       * putCharSequenceArrayListExtra, or null if no
8011       * ArrayList<CharSequence> value was found.
8012       *
8013       * @see #putCharSequenceArrayListExtra(String, ArrayList)
8014       */
getCharSequenceArrayListExtra(String name)8015      public @Nullable ArrayList<CharSequence> getCharSequenceArrayListExtra(String name) {
8016          return mExtras == null ? null : mExtras.getCharSequenceArrayList(name);
8017      }
8018  
8019      /**
8020       * Retrieve extended data from the intent.
8021       *
8022       * @param name The name of the desired item.
8023       *
8024       * @return the value of an item previously added with putExtra(),
8025       * or null if no boolean array value was found.
8026       *
8027       * @see #putExtra(String, boolean[])
8028       */
getBooleanArrayExtra(String name)8029      public @Nullable boolean[] getBooleanArrayExtra(String name) {
8030          return mExtras == null ? null : mExtras.getBooleanArray(name);
8031      }
8032  
8033      /**
8034       * Retrieve extended data from the intent.
8035       *
8036       * @param name The name of the desired item.
8037       *
8038       * @return the value of an item previously added with putExtra(),
8039       * or null if no byte array value was found.
8040       *
8041       * @see #putExtra(String, byte[])
8042       */
getByteArrayExtra(String name)8043      public @Nullable byte[] getByteArrayExtra(String name) {
8044          return mExtras == null ? null : mExtras.getByteArray(name);
8045      }
8046  
8047      /**
8048       * Retrieve extended data from the intent.
8049       *
8050       * @param name The name of the desired item.
8051       *
8052       * @return the value of an item previously added with putExtra(),
8053       * or null if no short array value was found.
8054       *
8055       * @see #putExtra(String, short[])
8056       */
getShortArrayExtra(String name)8057      public @Nullable short[] getShortArrayExtra(String name) {
8058          return mExtras == null ? null : mExtras.getShortArray(name);
8059      }
8060  
8061      /**
8062       * Retrieve extended data from the intent.
8063       *
8064       * @param name The name of the desired item.
8065       *
8066       * @return the value of an item previously added with putExtra(),
8067       * or null if no char array value was found.
8068       *
8069       * @see #putExtra(String, char[])
8070       */
getCharArrayExtra(String name)8071      public @Nullable char[] getCharArrayExtra(String name) {
8072          return mExtras == null ? null : mExtras.getCharArray(name);
8073      }
8074  
8075      /**
8076       * Retrieve extended data from the intent.
8077       *
8078       * @param name The name of the desired item.
8079       *
8080       * @return the value of an item previously added with putExtra(),
8081       * or null if no int array value was found.
8082       *
8083       * @see #putExtra(String, int[])
8084       */
getIntArrayExtra(String name)8085      public @Nullable int[] getIntArrayExtra(String name) {
8086          return mExtras == null ? null : mExtras.getIntArray(name);
8087      }
8088  
8089      /**
8090       * Retrieve extended data from the intent.
8091       *
8092       * @param name The name of the desired item.
8093       *
8094       * @return the value of an item previously added with putExtra(),
8095       * or null if no long array value was found.
8096       *
8097       * @see #putExtra(String, long[])
8098       */
getLongArrayExtra(String name)8099      public @Nullable long[] getLongArrayExtra(String name) {
8100          return mExtras == null ? null : mExtras.getLongArray(name);
8101      }
8102  
8103      /**
8104       * Retrieve extended data from the intent.
8105       *
8106       * @param name The name of the desired item.
8107       *
8108       * @return the value of an item previously added with putExtra(),
8109       * or null if no float array value was found.
8110       *
8111       * @see #putExtra(String, float[])
8112       */
getFloatArrayExtra(String name)8113      public @Nullable float[] getFloatArrayExtra(String name) {
8114          return mExtras == null ? null : mExtras.getFloatArray(name);
8115      }
8116  
8117      /**
8118       * Retrieve extended data from the intent.
8119       *
8120       * @param name The name of the desired item.
8121       *
8122       * @return the value of an item previously added with putExtra(),
8123       * or null if no double array value was found.
8124       *
8125       * @see #putExtra(String, double[])
8126       */
getDoubleArrayExtra(String name)8127      public @Nullable double[] getDoubleArrayExtra(String name) {
8128          return mExtras == null ? null : mExtras.getDoubleArray(name);
8129      }
8130  
8131      /**
8132       * Retrieve extended data from the intent.
8133       *
8134       * @param name The name of the desired item.
8135       *
8136       * @return the value of an item previously added with putExtra(),
8137       * or null if no String array value was found.
8138       *
8139       * @see #putExtra(String, String[])
8140       */
getStringArrayExtra(String name)8141      public @Nullable String[] getStringArrayExtra(String name) {
8142          return mExtras == null ? null : mExtras.getStringArray(name);
8143      }
8144  
8145      /**
8146       * Retrieve extended data from the intent.
8147       *
8148       * @param name The name of the desired item.
8149       *
8150       * @return the value of an item previously added with putExtra(),
8151       * or null if no CharSequence array value was found.
8152       *
8153       * @see #putExtra(String, CharSequence[])
8154       */
getCharSequenceArrayExtra(String name)8155      public @Nullable CharSequence[] getCharSequenceArrayExtra(String name) {
8156          return mExtras == null ? null : mExtras.getCharSequenceArray(name);
8157      }
8158  
8159      /**
8160       * Retrieve extended data from the intent.
8161       *
8162       * @param name The name of the desired item.
8163       *
8164       * @return the value of an item previously added with putExtra(),
8165       * or null if no Bundle value was found.
8166       *
8167       * @see #putExtra(String, Bundle)
8168       */
getBundleExtra(String name)8169      public @Nullable Bundle getBundleExtra(String name) {
8170          return mExtras == null ? null : mExtras.getBundle(name);
8171      }
8172  
8173      /**
8174       * Retrieve extended data from the intent.
8175       *
8176       * @param name The name of the desired item.
8177       *
8178       * @return the value of an item previously added with putExtra(),
8179       * or null if no IBinder value was found.
8180       *
8181       * @see #putExtra(String, IBinder)
8182       *
8183       * @deprecated
8184       * @hide
8185       */
8186      @Deprecated
8187      @UnsupportedAppUsage
getIBinderExtra(String name)8188      public IBinder getIBinderExtra(String name) {
8189          return mExtras == null ? null : mExtras.getIBinder(name);
8190      }
8191  
8192      /**
8193       * Retrieve extended data from the intent.
8194       *
8195       * @param name The name of the desired item.
8196       * @param defaultValue The default value to return in case no item is
8197       * associated with the key 'name'
8198       *
8199       * @return the value of an item previously added with putExtra(),
8200       * or defaultValue if none was found.
8201       *
8202       * @see #putExtra
8203       *
8204       * @deprecated
8205       * @hide
8206       */
8207      @Deprecated
8208      @UnsupportedAppUsage
getExtra(String name, Object defaultValue)8209      public Object getExtra(String name, Object defaultValue) {
8210          Object result = defaultValue;
8211          if (mExtras != null) {
8212              Object result2 = mExtras.get(name);
8213              if (result2 != null) {
8214                  result = result2;
8215              }
8216          }
8217  
8218          return result;
8219      }
8220  
8221      /**
8222       * Retrieves a map of extended data from the intent.
8223       *
8224       * @return the map of all extras previously added with putExtra(),
8225       * or null if none have been added.
8226       */
getExtras()8227      public @Nullable Bundle getExtras() {
8228          return (mExtras != null)
8229                  ? new Bundle(mExtras)
8230                  : null;
8231      }
8232  
8233      /**
8234       * Filter extras to only basic types.
8235       * @hide
8236       */
removeUnsafeExtras()8237      public void removeUnsafeExtras() {
8238          if (mExtras != null) {
8239              mExtras = mExtras.filterValues();
8240          }
8241      }
8242  
8243      /**
8244       * @return Whether {@link #maybeStripForHistory} will return an lightened intent or
8245       * return itself as-is.
8246       * @hide
8247       */
canStripForHistory()8248      public boolean canStripForHistory() {
8249          return ((mExtras != null) && mExtras.isParcelled()) || (mClipData != null);
8250      }
8251  
8252      /**
8253       * Call it when the system needs to keep an intent for logging purposes to remove fields
8254       * that are not needed for logging.
8255       * @hide
8256       */
maybeStripForHistory()8257      public Intent maybeStripForHistory() {
8258          // TODO Scan and remove possibly heavy instances like Bitmaps from unparcelled extras?
8259  
8260          if (!canStripForHistory()) {
8261              return this;
8262          }
8263          return new Intent(this, COPY_MODE_HISTORY);
8264      }
8265  
8266      /**
8267       * Retrieve any special flags associated with this intent.  You will
8268       * normally just set them with {@link #setFlags} and let the system
8269       * take the appropriate action with them.
8270       *
8271       * @return The currently set flags.
8272       * @see #setFlags
8273       * @see #addFlags
8274       * @see #removeFlags
8275       */
getFlags()8276      public @Flags int getFlags() {
8277          return mFlags;
8278      }
8279  
8280      /** @hide */
8281      @UnsupportedAppUsage
isExcludingStopped()8282      public boolean isExcludingStopped() {
8283          return (mFlags&(FLAG_EXCLUDE_STOPPED_PACKAGES|FLAG_INCLUDE_STOPPED_PACKAGES))
8284                  == FLAG_EXCLUDE_STOPPED_PACKAGES;
8285      }
8286  
8287      /**
8288       * Retrieve the application package name this Intent is limited to.  When
8289       * resolving an Intent, if non-null this limits the resolution to only
8290       * components in the given application package.
8291       *
8292       * @return The name of the application package for the Intent.
8293       *
8294       * @see #resolveActivity
8295       * @see #setPackage
8296       */
getPackage()8297      public @Nullable String getPackage() {
8298          return mPackage;
8299      }
8300  
8301      /**
8302       * Retrieve the concrete component associated with the intent.  When receiving
8303       * an intent, this is the component that was found to best handle it (that is,
8304       * yourself) and will always be non-null; in all other cases it will be
8305       * null unless explicitly set.
8306       *
8307       * @return The name of the application component to handle the intent.
8308       *
8309       * @see #resolveActivity
8310       * @see #setComponent
8311       */
getComponent()8312      public @Nullable ComponentName getComponent() {
8313          return mComponent;
8314      }
8315  
8316      /**
8317       * Get the bounds of the sender of this intent, in screen coordinates.  This can be
8318       * used as a hint to the receiver for animations and the like.  Null means that there
8319       * is no source bounds.
8320       */
getSourceBounds()8321      public @Nullable Rect getSourceBounds() {
8322          return mSourceBounds;
8323      }
8324  
8325      /**
8326       * Return the Activity component that should be used to handle this intent.
8327       * The appropriate component is determined based on the information in the
8328       * intent, evaluated as follows:
8329       *
8330       * <p>If {@link #getComponent} returns an explicit class, that is returned
8331       * without any further consideration.
8332       *
8333       * <p>The activity must handle the {@link Intent#CATEGORY_DEFAULT} Intent
8334       * category to be considered.
8335       *
8336       * <p>If {@link #getAction} is non-NULL, the activity must handle this
8337       * action.
8338       *
8339       * <p>If {@link #resolveType} returns non-NULL, the activity must handle
8340       * this type.
8341       *
8342       * <p>If {@link #addCategory} has added any categories, the activity must
8343       * handle ALL of the categories specified.
8344       *
8345       * <p>If {@link #getPackage} is non-NULL, only activity components in
8346       * that application package will be considered.
8347       *
8348       * <p>If there are no activities that satisfy all of these conditions, a
8349       * null string is returned.
8350       *
8351       * <p>If multiple activities are found to satisfy the intent, the one with
8352       * the highest priority will be used.  If there are multiple activities
8353       * with the same priority, the system will either pick the best activity
8354       * based on user preference, or resolve to a system class that will allow
8355       * the user to pick an activity and forward from there.
8356       *
8357       * <p>This method is implemented simply by calling
8358       * {@link PackageManager#resolveActivity} with the "defaultOnly" parameter
8359       * true.</p>
8360       * <p> This API is called for you as part of starting an activity from an
8361       * intent.  You do not normally need to call it yourself.</p>
8362       *
8363       * @param pm The package manager with which to resolve the Intent.
8364       *
8365       * @return Name of the component implementing an activity that can
8366       *         display the intent.
8367       *
8368       * @see #setComponent
8369       * @see #getComponent
8370       * @see #resolveActivityInfo
8371       */
resolveActivity(@onNull PackageManager pm)8372      public ComponentName resolveActivity(@NonNull PackageManager pm) {
8373          if (mComponent != null) {
8374              return mComponent;
8375          }
8376  
8377          ResolveInfo info = pm.resolveActivity(
8378              this, PackageManager.MATCH_DEFAULT_ONLY);
8379          if (info != null) {
8380              return new ComponentName(
8381                      info.activityInfo.applicationInfo.packageName,
8382                      info.activityInfo.name);
8383          }
8384  
8385          return null;
8386      }
8387  
8388      /**
8389       * Resolve the Intent into an {@link ActivityInfo}
8390       * describing the activity that should execute the intent.  Resolution
8391       * follows the same rules as described for {@link #resolveActivity}, but
8392       * you get back the completely information about the resolved activity
8393       * instead of just its class name.
8394       *
8395       * @param pm The package manager with which to resolve the Intent.
8396       * @param flags Addition information to retrieve as per
8397       * {@link PackageManager#getActivityInfo(ComponentName, int)
8398       * PackageManager.getActivityInfo()}.
8399       *
8400       * @return PackageManager.ActivityInfo
8401       *
8402       * @see #resolveActivity
8403       */
resolveActivityInfo(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)8404      public ActivityInfo resolveActivityInfo(@NonNull PackageManager pm,
8405              @PackageManager.ComponentInfoFlags int flags) {
8406          ActivityInfo ai = null;
8407          if (mComponent != null) {
8408              try {
8409                  ai = pm.getActivityInfo(mComponent, flags);
8410              } catch (PackageManager.NameNotFoundException e) {
8411                  // ignore
8412              }
8413          } else {
8414              ResolveInfo info = pm.resolveActivity(
8415                  this, PackageManager.MATCH_DEFAULT_ONLY | flags);
8416              if (info != null) {
8417                  ai = info.activityInfo;
8418              }
8419          }
8420  
8421          return ai;
8422      }
8423  
8424      /**
8425       * Special function for use by the system to resolve service
8426       * intents to system apps.  Throws an exception if there are
8427       * multiple potential matches to the Intent.  Returns null if
8428       * there are no matches.
8429       * @hide
8430       */
8431      @UnsupportedAppUsage
resolveSystemService(@onNull PackageManager pm, @PackageManager.ComponentInfoFlags int flags)8432      public @Nullable ComponentName resolveSystemService(@NonNull PackageManager pm,
8433              @PackageManager.ComponentInfoFlags int flags) {
8434          if (mComponent != null) {
8435              return mComponent;
8436          }
8437  
8438          List<ResolveInfo> results = pm.queryIntentServices(this, flags);
8439          if (results == null) {
8440              return null;
8441          }
8442          ComponentName comp = null;
8443          for (int i=0; i<results.size(); i++) {
8444              ResolveInfo ri = results.get(i);
8445              if ((ri.serviceInfo.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
8446                  continue;
8447              }
8448              ComponentName foundComp = new ComponentName(ri.serviceInfo.applicationInfo.packageName,
8449                      ri.serviceInfo.name);
8450              if (comp != null) {
8451                  throw new IllegalStateException("Multiple system services handle " + this
8452                          + ": " + comp + ", " + foundComp);
8453              }
8454              comp = foundComp;
8455          }
8456          return comp;
8457      }
8458  
8459      /**
8460       * Set the general action to be performed.
8461       *
8462       * @param action An action name, such as ACTION_VIEW.  Application-specific
8463       *               actions should be prefixed with the vendor's package name.
8464       *
8465       * @return Returns the same Intent object, for chaining multiple calls
8466       * into a single statement.
8467       *
8468       * @see #getAction
8469       */
setAction(@ullable String action)8470      public @NonNull Intent setAction(@Nullable String action) {
8471          mAction = action != null ? action.intern() : null;
8472          return this;
8473      }
8474  
8475      /**
8476       * Set the data this intent is operating on.  This method automatically
8477       * clears any type that was previously set by {@link #setType} or
8478       * {@link #setTypeAndNormalize}.
8479       *
8480       * <p><em>Note: scheme matching in the Android framework is
8481       * case-sensitive, unlike the formal RFC. As a result,
8482       * you should always write your Uri with a lower case scheme,
8483       * or use {@link Uri#normalizeScheme} or
8484       * {@link #setDataAndNormalize}
8485       * to ensure that the scheme is converted to lower case.</em>
8486       *
8487       * @param data The Uri of the data this intent is now targeting.
8488       *
8489       * @return Returns the same Intent object, for chaining multiple calls
8490       * into a single statement.
8491       *
8492       * @see #getData
8493       * @see #setDataAndNormalize
8494       * @see android.net.Uri#normalizeScheme()
8495       */
setData(@ullable Uri data)8496      public @NonNull Intent setData(@Nullable Uri data) {
8497          mData = data;
8498          mType = null;
8499          return this;
8500      }
8501  
8502      /**
8503       * Normalize and set the data this intent is operating on.
8504       *
8505       * <p>This method automatically clears any type that was
8506       * previously set (for example, by {@link #setType}).
8507       *
8508       * <p>The data Uri is normalized using
8509       * {@link android.net.Uri#normalizeScheme} before it is set,
8510       * so really this is just a convenience method for
8511       * <pre>
8512       * setData(data.normalize())
8513       * </pre>
8514       *
8515       * @param data The Uri of the data this intent is now targeting.
8516       *
8517       * @return Returns the same Intent object, for chaining multiple calls
8518       * into a single statement.
8519       *
8520       * @see #getData
8521       * @see #setType
8522       * @see android.net.Uri#normalizeScheme
8523       */
setDataAndNormalize(@onNull Uri data)8524      public @NonNull Intent setDataAndNormalize(@NonNull Uri data) {
8525          return setData(data.normalizeScheme());
8526      }
8527  
8528      /**
8529       * Set an explicit MIME data type.
8530       *
8531       * <p>This is used to create intents that only specify a type and not data,
8532       * for example to indicate the type of data to return.
8533       *
8534       * <p>This method automatically clears any data that was
8535       * previously set (for example by {@link #setData}).
8536       *
8537       * <p><em>Note: MIME type matching in the Android framework is
8538       * case-sensitive, unlike formal RFC MIME types.  As a result,
8539       * you should always write your MIME types with lower case letters,
8540       * or use {@link #normalizeMimeType} or {@link #setTypeAndNormalize}
8541       * to ensure that it is converted to lower case.</em>
8542       *
8543       * @param type The MIME type of the data being handled by this intent.
8544       *
8545       * @return Returns the same Intent object, for chaining multiple calls
8546       * into a single statement.
8547       *
8548       * @see #getType
8549       * @see #setTypeAndNormalize
8550       * @see #setDataAndType
8551       * @see #normalizeMimeType
8552       */
setType(@ullable String type)8553      public @NonNull Intent setType(@Nullable String type) {
8554          mData = null;
8555          mType = type;
8556          return this;
8557      }
8558  
8559      /**
8560       * Normalize and set an explicit MIME data type.
8561       *
8562       * <p>This is used to create intents that only specify a type and not data,
8563       * for example to indicate the type of data to return.
8564       *
8565       * <p>This method automatically clears any data that was
8566       * previously set (for example by {@link #setData}).
8567       *
8568       * <p>The MIME type is normalized using
8569       * {@link #normalizeMimeType} before it is set,
8570       * so really this is just a convenience method for
8571       * <pre>
8572       * setType(Intent.normalizeMimeType(type))
8573       * </pre>
8574       *
8575       * @param type The MIME type of the data being handled by this intent.
8576       *
8577       * @return Returns the same Intent object, for chaining multiple calls
8578       * into a single statement.
8579       *
8580       * @see #getType
8581       * @see #setData
8582       * @see #normalizeMimeType
8583       */
setTypeAndNormalize(@ullable String type)8584      public @NonNull Intent setTypeAndNormalize(@Nullable String type) {
8585          return setType(normalizeMimeType(type));
8586      }
8587  
8588      /**
8589       * (Usually optional) Set the data for the intent along with an explicit
8590       * MIME data type.  This method should very rarely be used -- it allows you
8591       * to override the MIME type that would ordinarily be inferred from the
8592       * data with your own type given here.
8593       *
8594       * <p><em>Note: MIME type and Uri scheme matching in the
8595       * Android framework is case-sensitive, unlike the formal RFC definitions.
8596       * As a result, you should always write these elements with lower case letters,
8597       * or use {@link #normalizeMimeType} or {@link android.net.Uri#normalizeScheme} or
8598       * {@link #setDataAndTypeAndNormalize}
8599       * to ensure that they are converted to lower case.</em>
8600       *
8601       * @param data The Uri of the data this intent is now targeting.
8602       * @param type The MIME type of the data being handled by this intent.
8603       *
8604       * @return Returns the same Intent object, for chaining multiple calls
8605       * into a single statement.
8606       *
8607       * @see #setType
8608       * @see #setData
8609       * @see #normalizeMimeType
8610       * @see android.net.Uri#normalizeScheme
8611       * @see #setDataAndTypeAndNormalize
8612       */
setDataAndType(@ullable Uri data, @Nullable String type)8613      public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type) {
8614          mData = data;
8615          mType = type;
8616          return this;
8617      }
8618  
8619      /**
8620       * (Usually optional) Normalize and set both the data Uri and an explicit
8621       * MIME data type.  This method should very rarely be used -- it allows you
8622       * to override the MIME type that would ordinarily be inferred from the
8623       * data with your own type given here.
8624       *
8625       * <p>The data Uri and the MIME type are normalize using
8626       * {@link android.net.Uri#normalizeScheme} and {@link #normalizeMimeType}
8627       * before they are set, so really this is just a convenience method for
8628       * <pre>
8629       * setDataAndType(data.normalize(), Intent.normalizeMimeType(type))
8630       * </pre>
8631       *
8632       * @param data The Uri of the data this intent is now targeting.
8633       * @param type The MIME type of the data being handled by this intent.
8634       *
8635       * @return Returns the same Intent object, for chaining multiple calls
8636       * into a single statement.
8637       *
8638       * @see #setType
8639       * @see #setData
8640       * @see #setDataAndType
8641       * @see #normalizeMimeType
8642       * @see android.net.Uri#normalizeScheme
8643       */
setDataAndTypeAndNormalize(@onNull Uri data, @Nullable String type)8644      public @NonNull Intent setDataAndTypeAndNormalize(@NonNull Uri data, @Nullable String type) {
8645          return setDataAndType(data.normalizeScheme(), normalizeMimeType(type));
8646      }
8647  
8648      /**
8649       * Set an identifier for this Intent.  If set, this provides a unique identity for this Intent,
8650       * allowing it to be unique from other Intents that would otherwise look the same.  In
8651       * particular, this will be used by {@link #filterEquals(Intent)} to determine if two
8652       * Intents are the same as with other fields like {@link #setAction}.  However, unlike those
8653       * fields, the identifier is <em>never</em> used for matching against an {@link IntentFilter};
8654       * it is as if the identifier has not been set on the Intent.
8655       *
8656       * <p>This can be used, for example, to make this Intent unique from other Intents that
8657       * are otherwise the same, for use in creating a {@link android.app.PendingIntent}.  (Be aware
8658       * however that the receiver of the PendingIntent will see whatever you put in here.)  The
8659       * structure of this string is completely undefined by the platform, however if you are going
8660       * to be exposing identifier strings across different applications you may need to define
8661       * your own structure if there is no central party defining the contents of this field.</p>
8662       *
8663       * @param identifier The identifier for this Intent.  The contents of the string have no
8664       *                   meaning to the system, except whether they are exactly the same as
8665       *                   another identifier.
8666       *
8667       * @return Returns the same Intent object, for chaining multiple calls
8668       * into a single statement.
8669       *
8670       * @see #getIdentifier
8671       */
setIdentifier(@ullable String identifier)8672      public @NonNull Intent setIdentifier(@Nullable String identifier) {
8673          mIdentifier = identifier;
8674          return this;
8675      }
8676  
8677      /**
8678       * Add a new category to the intent.  Categories provide additional detail
8679       * about the action the intent performs.  When resolving an intent, only
8680       * activities that provide <em>all</em> of the requested categories will be
8681       * used.
8682       *
8683       * @param category The desired category.  This can be either one of the
8684       *               predefined Intent categories, or a custom category in your own
8685       *               namespace.
8686       *
8687       * @return Returns the same Intent object, for chaining multiple calls
8688       * into a single statement.
8689       *
8690       * @see #hasCategory
8691       * @see #removeCategory
8692       */
addCategory(String category)8693      public @NonNull Intent addCategory(String category) {
8694          if (mCategories == null) {
8695              mCategories = new ArraySet<String>();
8696          }
8697          mCategories.add(category.intern());
8698          return this;
8699      }
8700  
8701      /**
8702       * Remove a category from an intent.
8703       *
8704       * @param category The category to remove.
8705       *
8706       * @see #addCategory
8707       */
removeCategory(String category)8708      public void removeCategory(String category) {
8709          if (mCategories != null) {
8710              mCategories.remove(category);
8711              if (mCategories.size() == 0) {
8712                  mCategories = null;
8713              }
8714          }
8715      }
8716  
8717      /**
8718       * Set a selector for this Intent.  This is a modification to the kinds of
8719       * things the Intent will match.  If the selector is set, it will be used
8720       * when trying to find entities that can handle the Intent, instead of the
8721       * main contents of the Intent.  This allows you build an Intent containing
8722       * a generic protocol while targeting it more specifically.
8723       *
8724       * <p>An example of where this may be used is with things like
8725       * {@link #CATEGORY_APP_BROWSER}.  This category allows you to build an
8726       * Intent that will launch the Browser application.  However, the correct
8727       * main entry point of an application is actually {@link #ACTION_MAIN}
8728       * {@link #CATEGORY_LAUNCHER} with {@link #setComponent(ComponentName)}
8729       * used to specify the actual Activity to launch.  If you launch the browser
8730       * with something different, undesired behavior may happen if the user has
8731       * previously or later launches it the normal way, since they do not match.
8732       * Instead, you can build an Intent with the MAIN action (but no ComponentName
8733       * yet specified) and set a selector with {@link #ACTION_MAIN} and
8734       * {@link #CATEGORY_APP_BROWSER} to point it specifically to the browser activity.
8735       *
8736       * <p>Setting a selector does not impact the behavior of
8737       * {@link #filterEquals(Intent)} and {@link #filterHashCode()}.  This is part of the
8738       * desired behavior of a selector -- it does not impact the base meaning
8739       * of the Intent, just what kinds of things will be matched against it
8740       * when determining who can handle it.</p>
8741       *
8742       * <p>You can not use both a selector and {@link #setPackage(String)} on
8743       * the same base Intent.</p>
8744       *
8745       * @param selector The desired selector Intent; set to null to not use
8746       * a special selector.
8747       */
setSelector(@ullable Intent selector)8748      public void setSelector(@Nullable Intent selector) {
8749          if (selector == this) {
8750              throw new IllegalArgumentException(
8751                      "Intent being set as a selector of itself");
8752          }
8753          if (selector != null && mPackage != null) {
8754              throw new IllegalArgumentException(
8755                      "Can't set selector when package name is already set");
8756          }
8757          mSelector = selector;
8758      }
8759  
8760      /**
8761       * Set a {@link ClipData} associated with this Intent.  This replaces any
8762       * previously set ClipData.
8763       *
8764       * <p>The ClipData in an intent is not used for Intent matching or other
8765       * such operations.  Semantically it is like extras, used to transmit
8766       * additional data with the Intent.  The main feature of using this over
8767       * the extras for data is that {@link #FLAG_GRANT_READ_URI_PERMISSION}
8768       * and {@link #FLAG_GRANT_WRITE_URI_PERMISSION} will operate on any URI
8769       * items included in the clip data.  This is useful, in particular, if
8770       * you want to transmit an Intent containing multiple <code>content:</code>
8771       * URIs for which the recipient may not have global permission to access the
8772       * content provider.
8773       *
8774       * <p>If the ClipData contains items that are themselves Intents, any
8775       * grant flags in those Intents will be ignored.  Only the top-level flags
8776       * of the main Intent are respected, and will be applied to all Uri or
8777       * Intent items in the clip (or sub-items of the clip).
8778       *
8779       * <p>The MIME type, label, and icon in the ClipData object are not
8780       * directly used by Intent.  Applications should generally rely on the
8781       * MIME type of the Intent itself, not what it may find in the ClipData.
8782       * A common practice is to construct a ClipData for use with an Intent
8783       * with a MIME type of "*&#47;*".
8784       *
8785       * @param clip The new clip to set.  May be null to clear the current clip.
8786       */
setClipData(@ullable ClipData clip)8787      public void setClipData(@Nullable ClipData clip) {
8788          mClipData = clip;
8789      }
8790  
8791      /**
8792       * This is NOT a secure mechanism to identify the user who sent the intent.
8793       * When the intent is sent to a different user, it is used to fix uris by adding the userId
8794       * who sent the intent.
8795       * @hide
8796       */
prepareToLeaveUser(int userId)8797      public void prepareToLeaveUser(int userId) {
8798          // If mContentUserHint is not UserHandle.USER_CURRENT, the intent has already left a user.
8799          // We want mContentUserHint to refer to the original user, so don't do anything.
8800          if (mContentUserHint == UserHandle.USER_CURRENT) {
8801              mContentUserHint = userId;
8802          }
8803      }
8804  
8805      /**
8806       * Add extended data to the intent.  The name must include a package
8807       * prefix, for example the app com.android.contacts would use names
8808       * like "com.android.contacts.ShowAll".
8809       *
8810       * @param name The name of the extra data, with package prefix.
8811       * @param value The boolean data value.
8812       *
8813       * @return Returns the same Intent object, for chaining multiple calls
8814       * into a single statement.
8815       *
8816       * @see #putExtras
8817       * @see #removeExtra
8818       * @see #getBooleanExtra(String, boolean)
8819       */
putExtra(String name, boolean value)8820      public @NonNull Intent putExtra(String name, boolean value) {
8821          if (mExtras == null) {
8822              mExtras = new Bundle();
8823          }
8824          mExtras.putBoolean(name, value);
8825          return this;
8826      }
8827  
8828      /**
8829       * Add extended data to the intent.  The name must include a package
8830       * prefix, for example the app com.android.contacts would use names
8831       * like "com.android.contacts.ShowAll".
8832       *
8833       * @param name The name of the extra data, with package prefix.
8834       * @param value The byte data value.
8835       *
8836       * @return Returns the same Intent object, for chaining multiple calls
8837       * into a single statement.
8838       *
8839       * @see #putExtras
8840       * @see #removeExtra
8841       * @see #getByteExtra(String, byte)
8842       */
putExtra(String name, byte value)8843      public @NonNull Intent putExtra(String name, byte value) {
8844          if (mExtras == null) {
8845              mExtras = new Bundle();
8846          }
8847          mExtras.putByte(name, value);
8848          return this;
8849      }
8850  
8851      /**
8852       * Add extended data to the intent.  The name must include a package
8853       * prefix, for example the app com.android.contacts would use names
8854       * like "com.android.contacts.ShowAll".
8855       *
8856       * @param name The name of the extra data, with package prefix.
8857       * @param value The char data value.
8858       *
8859       * @return Returns the same Intent object, for chaining multiple calls
8860       * into a single statement.
8861       *
8862       * @see #putExtras
8863       * @see #removeExtra
8864       * @see #getCharExtra(String, char)
8865       */
putExtra(String name, char value)8866      public @NonNull Intent putExtra(String name, char value) {
8867          if (mExtras == null) {
8868              mExtras = new Bundle();
8869          }
8870          mExtras.putChar(name, value);
8871          return this;
8872      }
8873  
8874      /**
8875       * Add extended data to the intent.  The name must include a package
8876       * prefix, for example the app com.android.contacts would use names
8877       * like "com.android.contacts.ShowAll".
8878       *
8879       * @param name The name of the extra data, with package prefix.
8880       * @param value The short data value.
8881       *
8882       * @return Returns the same Intent object, for chaining multiple calls
8883       * into a single statement.
8884       *
8885       * @see #putExtras
8886       * @see #removeExtra
8887       * @see #getShortExtra(String, short)
8888       */
putExtra(String name, short value)8889      public @NonNull Intent putExtra(String name, short value) {
8890          if (mExtras == null) {
8891              mExtras = new Bundle();
8892          }
8893          mExtras.putShort(name, value);
8894          return this;
8895      }
8896  
8897      /**
8898       * Add extended data to the intent.  The name must include a package
8899       * prefix, for example the app com.android.contacts would use names
8900       * like "com.android.contacts.ShowAll".
8901       *
8902       * @param name The name of the extra data, with package prefix.
8903       * @param value The integer data value.
8904       *
8905       * @return Returns the same Intent object, for chaining multiple calls
8906       * into a single statement.
8907       *
8908       * @see #putExtras
8909       * @see #removeExtra
8910       * @see #getIntExtra(String, int)
8911       */
putExtra(String name, int value)8912      public @NonNull Intent putExtra(String name, int value) {
8913          if (mExtras == null) {
8914              mExtras = new Bundle();
8915          }
8916          mExtras.putInt(name, value);
8917          return this;
8918      }
8919  
8920      /**
8921       * Add extended data to the intent.  The name must include a package
8922       * prefix, for example the app com.android.contacts would use names
8923       * like "com.android.contacts.ShowAll".
8924       *
8925       * @param name The name of the extra data, with package prefix.
8926       * @param value The long data value.
8927       *
8928       * @return Returns the same Intent object, for chaining multiple calls
8929       * into a single statement.
8930       *
8931       * @see #putExtras
8932       * @see #removeExtra
8933       * @see #getLongExtra(String, long)
8934       */
putExtra(String name, long value)8935      public @NonNull Intent putExtra(String name, long value) {
8936          if (mExtras == null) {
8937              mExtras = new Bundle();
8938          }
8939          mExtras.putLong(name, value);
8940          return this;
8941      }
8942  
8943      /**
8944       * Add extended data to the intent.  The name must include a package
8945       * prefix, for example the app com.android.contacts would use names
8946       * like "com.android.contacts.ShowAll".
8947       *
8948       * @param name The name of the extra data, with package prefix.
8949       * @param value The float data value.
8950       *
8951       * @return Returns the same Intent object, for chaining multiple calls
8952       * into a single statement.
8953       *
8954       * @see #putExtras
8955       * @see #removeExtra
8956       * @see #getFloatExtra(String, float)
8957       */
putExtra(String name, float value)8958      public @NonNull Intent putExtra(String name, float value) {
8959          if (mExtras == null) {
8960              mExtras = new Bundle();
8961          }
8962          mExtras.putFloat(name, value);
8963          return this;
8964      }
8965  
8966      /**
8967       * Add extended data to the intent.  The name must include a package
8968       * prefix, for example the app com.android.contacts would use names
8969       * like "com.android.contacts.ShowAll".
8970       *
8971       * @param name The name of the extra data, with package prefix.
8972       * @param value The double data value.
8973       *
8974       * @return Returns the same Intent object, for chaining multiple calls
8975       * into a single statement.
8976       *
8977       * @see #putExtras
8978       * @see #removeExtra
8979       * @see #getDoubleExtra(String, double)
8980       */
putExtra(String name, double value)8981      public @NonNull Intent putExtra(String name, double value) {
8982          if (mExtras == null) {
8983              mExtras = new Bundle();
8984          }
8985          mExtras.putDouble(name, value);
8986          return this;
8987      }
8988  
8989      /**
8990       * Add extended data to the intent.  The name must include a package
8991       * prefix, for example the app com.android.contacts would use names
8992       * like "com.android.contacts.ShowAll".
8993       *
8994       * @param name The name of the extra data, with package prefix.
8995       * @param value The String data value.
8996       *
8997       * @return Returns the same Intent object, for chaining multiple calls
8998       * into a single statement.
8999       *
9000       * @see #putExtras
9001       * @see #removeExtra
9002       * @see #getStringExtra(String)
9003       */
putExtra(String name, @Nullable String value)9004      public @NonNull Intent putExtra(String name, @Nullable String value) {
9005          if (mExtras == null) {
9006              mExtras = new Bundle();
9007          }
9008          mExtras.putString(name, value);
9009          return this;
9010      }
9011  
9012      /**
9013       * Add extended data to the intent.  The name must include a package
9014       * prefix, for example the app com.android.contacts would use names
9015       * like "com.android.contacts.ShowAll".
9016       *
9017       * @param name The name of the extra data, with package prefix.
9018       * @param value The CharSequence data value.
9019       *
9020       * @return Returns the same Intent object, for chaining multiple calls
9021       * into a single statement.
9022       *
9023       * @see #putExtras
9024       * @see #removeExtra
9025       * @see #getCharSequenceExtra(String)
9026       */
putExtra(String name, @Nullable CharSequence value)9027      public @NonNull Intent putExtra(String name, @Nullable CharSequence value) {
9028          if (mExtras == null) {
9029              mExtras = new Bundle();
9030          }
9031          mExtras.putCharSequence(name, value);
9032          return this;
9033      }
9034  
9035      /**
9036       * Add extended data to the intent.  The name must include a package
9037       * prefix, for example the app com.android.contacts would use names
9038       * like "com.android.contacts.ShowAll".
9039       *
9040       * @param name The name of the extra data, with package prefix.
9041       * @param value The Parcelable data value.
9042       *
9043       * @return Returns the same Intent object, for chaining multiple calls
9044       * into a single statement.
9045       *
9046       * @see #putExtras
9047       * @see #removeExtra
9048       * @see #getParcelableExtra(String)
9049       */
putExtra(String name, @Nullable Parcelable value)9050      public @NonNull Intent putExtra(String name, @Nullable Parcelable value) {
9051          if (mExtras == null) {
9052              mExtras = new Bundle();
9053          }
9054          mExtras.putParcelable(name, value);
9055          return this;
9056      }
9057  
9058      /**
9059       * Add extended data to the intent.  The name must include a package
9060       * prefix, for example the app com.android.contacts would use names
9061       * like "com.android.contacts.ShowAll".
9062       *
9063       * @param name The name of the extra data, with package prefix.
9064       * @param value The Parcelable[] data value.
9065       *
9066       * @return Returns the same Intent object, for chaining multiple calls
9067       * into a single statement.
9068       *
9069       * @see #putExtras
9070       * @see #removeExtra
9071       * @see #getParcelableArrayExtra(String)
9072       */
putExtra(String name, @Nullable Parcelable[] value)9073      public @NonNull Intent putExtra(String name, @Nullable Parcelable[] value) {
9074          if (mExtras == null) {
9075              mExtras = new Bundle();
9076          }
9077          mExtras.putParcelableArray(name, value);
9078          return this;
9079      }
9080  
9081      /**
9082       * Add extended data to the intent.  The name must include a package
9083       * prefix, for example the app com.android.contacts would use names
9084       * like "com.android.contacts.ShowAll".
9085       *
9086       * @param name The name of the extra data, with package prefix.
9087       * @param value The ArrayList<Parcelable> data value.
9088       *
9089       * @return Returns the same Intent object, for chaining multiple calls
9090       * into a single statement.
9091       *
9092       * @see #putExtras
9093       * @see #removeExtra
9094       * @see #getParcelableArrayListExtra(String)
9095       */
putParcelableArrayListExtra(String name, @Nullable ArrayList<? extends Parcelable> value)9096      public @NonNull Intent putParcelableArrayListExtra(String name,
9097              @Nullable ArrayList<? extends Parcelable> value) {
9098          if (mExtras == null) {
9099              mExtras = new Bundle();
9100          }
9101          mExtras.putParcelableArrayList(name, value);
9102          return this;
9103      }
9104  
9105      /**
9106       * Add extended data to the intent.  The name must include a package
9107       * prefix, for example the app com.android.contacts would use names
9108       * like "com.android.contacts.ShowAll".
9109       *
9110       * @param name The name of the extra data, with package prefix.
9111       * @param value The ArrayList<Integer> data value.
9112       *
9113       * @return Returns the same Intent object, for chaining multiple calls
9114       * into a single statement.
9115       *
9116       * @see #putExtras
9117       * @see #removeExtra
9118       * @see #getIntegerArrayListExtra(String)
9119       */
putIntegerArrayListExtra(String name, @Nullable ArrayList<Integer> value)9120      public @NonNull Intent putIntegerArrayListExtra(String name,
9121              @Nullable ArrayList<Integer> value) {
9122          if (mExtras == null) {
9123              mExtras = new Bundle();
9124          }
9125          mExtras.putIntegerArrayList(name, value);
9126          return this;
9127      }
9128  
9129      /**
9130       * Add extended data to the intent.  The name must include a package
9131       * prefix, for example the app com.android.contacts would use names
9132       * like "com.android.contacts.ShowAll".
9133       *
9134       * @param name The name of the extra data, with package prefix.
9135       * @param value The ArrayList<String> data value.
9136       *
9137       * @return Returns the same Intent object, for chaining multiple calls
9138       * into a single statement.
9139       *
9140       * @see #putExtras
9141       * @see #removeExtra
9142       * @see #getStringArrayListExtra(String)
9143       */
putStringArrayListExtra(String name, @Nullable ArrayList<String> value)9144      public @NonNull Intent putStringArrayListExtra(String name, @Nullable ArrayList<String> value) {
9145          if (mExtras == null) {
9146              mExtras = new Bundle();
9147          }
9148          mExtras.putStringArrayList(name, value);
9149          return this;
9150      }
9151  
9152      /**
9153       * Add extended data to the intent.  The name must include a package
9154       * prefix, for example the app com.android.contacts would use names
9155       * like "com.android.contacts.ShowAll".
9156       *
9157       * @param name The name of the extra data, with package prefix.
9158       * @param value The ArrayList<CharSequence> data value.
9159       *
9160       * @return Returns the same Intent object, for chaining multiple calls
9161       * into a single statement.
9162       *
9163       * @see #putExtras
9164       * @see #removeExtra
9165       * @see #getCharSequenceArrayListExtra(String)
9166       */
putCharSequenceArrayListExtra(String name, @Nullable ArrayList<CharSequence> value)9167      public @NonNull Intent putCharSequenceArrayListExtra(String name,
9168              @Nullable ArrayList<CharSequence> value) {
9169          if (mExtras == null) {
9170              mExtras = new Bundle();
9171          }
9172          mExtras.putCharSequenceArrayList(name, value);
9173          return this;
9174      }
9175  
9176      /**
9177       * Add extended data to the intent.  The name must include a package
9178       * prefix, for example the app com.android.contacts would use names
9179       * like "com.android.contacts.ShowAll".
9180       *
9181       * @param name The name of the extra data, with package prefix.
9182       * @param value The Serializable data value.
9183       *
9184       * @return Returns the same Intent object, for chaining multiple calls
9185       * into a single statement.
9186       *
9187       * @see #putExtras
9188       * @see #removeExtra
9189       * @see #getSerializableExtra(String)
9190       */
putExtra(String name, @Nullable Serializable value)9191      public @NonNull Intent putExtra(String name, @Nullable Serializable value) {
9192          if (mExtras == null) {
9193              mExtras = new Bundle();
9194          }
9195          mExtras.putSerializable(name, value);
9196          return this;
9197      }
9198  
9199      /**
9200       * Add extended data to the intent.  The name must include a package
9201       * prefix, for example the app com.android.contacts would use names
9202       * like "com.android.contacts.ShowAll".
9203       *
9204       * @param name The name of the extra data, with package prefix.
9205       * @param value The boolean array data value.
9206       *
9207       * @return Returns the same Intent object, for chaining multiple calls
9208       * into a single statement.
9209       *
9210       * @see #putExtras
9211       * @see #removeExtra
9212       * @see #getBooleanArrayExtra(String)
9213       */
putExtra(String name, @Nullable boolean[] value)9214      public @NonNull Intent putExtra(String name, @Nullable boolean[] value) {
9215          if (mExtras == null) {
9216              mExtras = new Bundle();
9217          }
9218          mExtras.putBooleanArray(name, value);
9219          return this;
9220      }
9221  
9222      /**
9223       * Add extended data to the intent.  The name must include a package
9224       * prefix, for example the app com.android.contacts would use names
9225       * like "com.android.contacts.ShowAll".
9226       *
9227       * @param name The name of the extra data, with package prefix.
9228       * @param value The byte array data value.
9229       *
9230       * @return Returns the same Intent object, for chaining multiple calls
9231       * into a single statement.
9232       *
9233       * @see #putExtras
9234       * @see #removeExtra
9235       * @see #getByteArrayExtra(String)
9236       */
putExtra(String name, @Nullable byte[] value)9237      public @NonNull Intent putExtra(String name, @Nullable byte[] value) {
9238          if (mExtras == null) {
9239              mExtras = new Bundle();
9240          }
9241          mExtras.putByteArray(name, value);
9242          return this;
9243      }
9244  
9245      /**
9246       * Add extended data to the intent.  The name must include a package
9247       * prefix, for example the app com.android.contacts would use names
9248       * like "com.android.contacts.ShowAll".
9249       *
9250       * @param name The name of the extra data, with package prefix.
9251       * @param value The short array data value.
9252       *
9253       * @return Returns the same Intent object, for chaining multiple calls
9254       * into a single statement.
9255       *
9256       * @see #putExtras
9257       * @see #removeExtra
9258       * @see #getShortArrayExtra(String)
9259       */
putExtra(String name, @Nullable short[] value)9260      public @NonNull Intent putExtra(String name, @Nullable short[] value) {
9261          if (mExtras == null) {
9262              mExtras = new Bundle();
9263          }
9264          mExtras.putShortArray(name, value);
9265          return this;
9266      }
9267  
9268      /**
9269       * Add extended data to the intent.  The name must include a package
9270       * prefix, for example the app com.android.contacts would use names
9271       * like "com.android.contacts.ShowAll".
9272       *
9273       * @param name The name of the extra data, with package prefix.
9274       * @param value The char array data value.
9275       *
9276       * @return Returns the same Intent object, for chaining multiple calls
9277       * into a single statement.
9278       *
9279       * @see #putExtras
9280       * @see #removeExtra
9281       * @see #getCharArrayExtra(String)
9282       */
putExtra(String name, @Nullable char[] value)9283      public @NonNull Intent putExtra(String name, @Nullable char[] value) {
9284          if (mExtras == null) {
9285              mExtras = new Bundle();
9286          }
9287          mExtras.putCharArray(name, value);
9288          return this;
9289      }
9290  
9291      /**
9292       * Add extended data to the intent.  The name must include a package
9293       * prefix, for example the app com.android.contacts would use names
9294       * like "com.android.contacts.ShowAll".
9295       *
9296       * @param name The name of the extra data, with package prefix.
9297       * @param value The int array data value.
9298       *
9299       * @return Returns the same Intent object, for chaining multiple calls
9300       * into a single statement.
9301       *
9302       * @see #putExtras
9303       * @see #removeExtra
9304       * @see #getIntArrayExtra(String)
9305       */
putExtra(String name, @Nullable int[] value)9306      public @NonNull Intent putExtra(String name, @Nullable int[] value) {
9307          if (mExtras == null) {
9308              mExtras = new Bundle();
9309          }
9310          mExtras.putIntArray(name, value);
9311          return this;
9312      }
9313  
9314      /**
9315       * Add extended data to the intent.  The name must include a package
9316       * prefix, for example the app com.android.contacts would use names
9317       * like "com.android.contacts.ShowAll".
9318       *
9319       * @param name The name of the extra data, with package prefix.
9320       * @param value The byte array data value.
9321       *
9322       * @return Returns the same Intent object, for chaining multiple calls
9323       * into a single statement.
9324       *
9325       * @see #putExtras
9326       * @see #removeExtra
9327       * @see #getLongArrayExtra(String)
9328       */
putExtra(String name, @Nullable long[] value)9329      public @NonNull Intent putExtra(String name, @Nullable long[] value) {
9330          if (mExtras == null) {
9331              mExtras = new Bundle();
9332          }
9333          mExtras.putLongArray(name, value);
9334          return this;
9335      }
9336  
9337      /**
9338       * Add extended data to the intent.  The name must include a package
9339       * prefix, for example the app com.android.contacts would use names
9340       * like "com.android.contacts.ShowAll".
9341       *
9342       * @param name The name of the extra data, with package prefix.
9343       * @param value The float array data value.
9344       *
9345       * @return Returns the same Intent object, for chaining multiple calls
9346       * into a single statement.
9347       *
9348       * @see #putExtras
9349       * @see #removeExtra
9350       * @see #getFloatArrayExtra(String)
9351       */
putExtra(String name, @Nullable float[] value)9352      public @NonNull Intent putExtra(String name, @Nullable float[] value) {
9353          if (mExtras == null) {
9354              mExtras = new Bundle();
9355          }
9356          mExtras.putFloatArray(name, value);
9357          return this;
9358      }
9359  
9360      /**
9361       * Add extended data to the intent.  The name must include a package
9362       * prefix, for example the app com.android.contacts would use names
9363       * like "com.android.contacts.ShowAll".
9364       *
9365       * @param name The name of the extra data, with package prefix.
9366       * @param value The double array data value.
9367       *
9368       * @return Returns the same Intent object, for chaining multiple calls
9369       * into a single statement.
9370       *
9371       * @see #putExtras
9372       * @see #removeExtra
9373       * @see #getDoubleArrayExtra(String)
9374       */
putExtra(String name, @Nullable double[] value)9375      public @NonNull Intent putExtra(String name, @Nullable double[] value) {
9376          if (mExtras == null) {
9377              mExtras = new Bundle();
9378          }
9379          mExtras.putDoubleArray(name, value);
9380          return this;
9381      }
9382  
9383      /**
9384       * Add extended data to the intent.  The name must include a package
9385       * prefix, for example the app com.android.contacts would use names
9386       * like "com.android.contacts.ShowAll".
9387       *
9388       * @param name The name of the extra data, with package prefix.
9389       * @param value The String array data value.
9390       *
9391       * @return Returns the same Intent object, for chaining multiple calls
9392       * into a single statement.
9393       *
9394       * @see #putExtras
9395       * @see #removeExtra
9396       * @see #getStringArrayExtra(String)
9397       */
putExtra(String name, @Nullable String[] value)9398      public @NonNull Intent putExtra(String name, @Nullable String[] value) {
9399          if (mExtras == null) {
9400              mExtras = new Bundle();
9401          }
9402          mExtras.putStringArray(name, value);
9403          return this;
9404      }
9405  
9406      /**
9407       * Add extended data to the intent.  The name must include a package
9408       * prefix, for example the app com.android.contacts would use names
9409       * like "com.android.contacts.ShowAll".
9410       *
9411       * @param name The name of the extra data, with package prefix.
9412       * @param value The CharSequence array data value.
9413       *
9414       * @return Returns the same Intent object, for chaining multiple calls
9415       * into a single statement.
9416       *
9417       * @see #putExtras
9418       * @see #removeExtra
9419       * @see #getCharSequenceArrayExtra(String)
9420       */
putExtra(String name, @Nullable CharSequence[] value)9421      public @NonNull Intent putExtra(String name, @Nullable CharSequence[] value) {
9422          if (mExtras == null) {
9423              mExtras = new Bundle();
9424          }
9425          mExtras.putCharSequenceArray(name, value);
9426          return this;
9427      }
9428  
9429      /**
9430       * Add extended data to the intent.  The name must include a package
9431       * prefix, for example the app com.android.contacts would use names
9432       * like "com.android.contacts.ShowAll".
9433       *
9434       * @param name The name of the extra data, with package prefix.
9435       * @param value The Bundle data value.
9436       *
9437       * @return Returns the same Intent object, for chaining multiple calls
9438       * into a single statement.
9439       *
9440       * @see #putExtras
9441       * @see #removeExtra
9442       * @see #getBundleExtra(String)
9443       */
putExtra(String name, @Nullable Bundle value)9444      public @NonNull Intent putExtra(String name, @Nullable Bundle value) {
9445          if (mExtras == null) {
9446              mExtras = new Bundle();
9447          }
9448          mExtras.putBundle(name, value);
9449          return this;
9450      }
9451  
9452      /**
9453       * Add extended data to the intent.  The name must include a package
9454       * prefix, for example the app com.android.contacts would use names
9455       * like "com.android.contacts.ShowAll".
9456       *
9457       * @param name The name of the extra data, with package prefix.
9458       * @param value The IBinder data value.
9459       *
9460       * @return Returns the same Intent object, for chaining multiple calls
9461       * into a single statement.
9462       *
9463       * @see #putExtras
9464       * @see #removeExtra
9465       * @see #getIBinderExtra(String)
9466       *
9467       * @deprecated
9468       * @hide
9469       */
9470      @Deprecated
9471      @UnsupportedAppUsage
putExtra(String name, IBinder value)9472      public @NonNull Intent putExtra(String name, IBinder value) {
9473          if (mExtras == null) {
9474              mExtras = new Bundle();
9475          }
9476          mExtras.putIBinder(name, value);
9477          return this;
9478      }
9479  
9480      /**
9481       * Copy all extras in 'src' in to this intent.
9482       *
9483       * @param src Contains the extras to copy.
9484       *
9485       * @see #putExtra
9486       */
putExtras(@onNull Intent src)9487      public @NonNull Intent putExtras(@NonNull Intent src) {
9488          if (src.mExtras != null) {
9489              if (mExtras == null) {
9490                  mExtras = new Bundle(src.mExtras);
9491              } else {
9492                  mExtras.putAll(src.mExtras);
9493              }
9494          }
9495          return this;
9496      }
9497  
9498      /**
9499       * Add a set of extended data to the intent.  The keys must include a package
9500       * prefix, for example the app com.android.contacts would use names
9501       * like "com.android.contacts.ShowAll".
9502       *
9503       * @param extras The Bundle of extras to add to this intent.
9504       *
9505       * @see #putExtra
9506       * @see #removeExtra
9507       */
putExtras(@onNull Bundle extras)9508      public @NonNull Intent putExtras(@NonNull Bundle extras) {
9509          if (mExtras == null) {
9510              mExtras = new Bundle();
9511          }
9512          mExtras.putAll(extras);
9513          return this;
9514      }
9515  
9516      /**
9517       * Completely replace the extras in the Intent with the extras in the
9518       * given Intent.
9519       *
9520       * @param src The exact extras contained in this Intent are copied
9521       * into the target intent, replacing any that were previously there.
9522       */
replaceExtras(@onNull Intent src)9523      public @NonNull Intent replaceExtras(@NonNull Intent src) {
9524          mExtras = src.mExtras != null ? new Bundle(src.mExtras) : null;
9525          return this;
9526      }
9527  
9528      /**
9529       * Completely replace the extras in the Intent with the given Bundle of
9530       * extras.
9531       *
9532       * @param extras The new set of extras in the Intent, or null to erase
9533       * all extras.
9534       */
replaceExtras(@ullable Bundle extras)9535      public @NonNull Intent replaceExtras(@Nullable Bundle extras) {
9536          mExtras = extras != null ? new Bundle(extras) : null;
9537          return this;
9538      }
9539  
9540      /**
9541       * Remove extended data from the intent.
9542       *
9543       * @see #putExtra
9544       */
removeExtra(String name)9545      public void removeExtra(String name) {
9546          if (mExtras != null) {
9547              mExtras.remove(name);
9548              if (mExtras.size() == 0) {
9549                  mExtras = null;
9550              }
9551          }
9552      }
9553  
9554      /**
9555       * Set special flags controlling how this intent is handled.  Most values
9556       * here depend on the type of component being executed by the Intent,
9557       * specifically the FLAG_ACTIVITY_* flags are all for use with
9558       * {@link Context#startActivity Context.startActivity()} and the
9559       * FLAG_RECEIVER_* flags are all for use with
9560       * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
9561       *
9562       * <p>See the
9563       * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
9564       * Stack</a> documentation for important information on how some of these options impact
9565       * the behavior of your application.
9566       *
9567       * @param flags The desired flags.
9568       * @return Returns the same Intent object, for chaining multiple calls
9569       * into a single statement.
9570       * @see #getFlags
9571       * @see #addFlags
9572       * @see #removeFlags
9573       */
setFlags(@lags int flags)9574      public @NonNull Intent setFlags(@Flags int flags) {
9575          mFlags = flags;
9576          return this;
9577      }
9578  
9579      /**
9580       * Add additional flags to the intent (or with existing flags value).
9581       *
9582       * @param flags The new flags to set.
9583       * @return Returns the same Intent object, for chaining multiple calls into
9584       *         a single statement.
9585       * @see #setFlags
9586       * @see #getFlags
9587       * @see #removeFlags
9588       */
addFlags(@lags int flags)9589      public @NonNull Intent addFlags(@Flags int flags) {
9590          mFlags |= flags;
9591          return this;
9592      }
9593  
9594      /**
9595       * Remove these flags from the intent.
9596       *
9597       * @param flags The flags to remove.
9598       * @see #setFlags
9599       * @see #getFlags
9600       * @see #addFlags
9601       */
removeFlags(@lags int flags)9602      public void removeFlags(@Flags int flags) {
9603          mFlags &= ~flags;
9604      }
9605  
9606      /**
9607       * (Usually optional) Set an explicit application package name that limits
9608       * the components this Intent will resolve to.  If left to the default
9609       * value of null, all components in all applications will considered.
9610       * If non-null, the Intent can only match the components in the given
9611       * application package.
9612       *
9613       * @param packageName The name of the application package to handle the
9614       * intent, or null to allow any application package.
9615       *
9616       * @return Returns the same Intent object, for chaining multiple calls
9617       * into a single statement.
9618       *
9619       * @see #getPackage
9620       * @see #resolveActivity
9621       */
setPackage(@ullable String packageName)9622      public @NonNull Intent setPackage(@Nullable String packageName) {
9623          if (packageName != null && mSelector != null) {
9624              throw new IllegalArgumentException(
9625                      "Can't set package name when selector is already set");
9626          }
9627          mPackage = packageName;
9628          return this;
9629      }
9630  
9631      /**
9632       * (Usually optional) Explicitly set the component to handle the intent.
9633       * If left with the default value of null, the system will determine the
9634       * appropriate class to use based on the other fields (action, data,
9635       * type, categories) in the Intent.  If this class is defined, the
9636       * specified class will always be used regardless of the other fields.  You
9637       * should only set this value when you know you absolutely want a specific
9638       * class to be used; otherwise it is better to let the system find the
9639       * appropriate class so that you will respect the installed applications
9640       * and user preferences.
9641       *
9642       * @param component The name of the application component to handle the
9643       * intent, or null to let the system find one for you.
9644       *
9645       * @return Returns the same Intent object, for chaining multiple calls
9646       * into a single statement.
9647       *
9648       * @see #setClass
9649       * @see #setClassName(Context, String)
9650       * @see #setClassName(String, String)
9651       * @see #getComponent
9652       * @see #resolveActivity
9653       */
setComponent(@ullable ComponentName component)9654      public @NonNull Intent setComponent(@Nullable ComponentName component) {
9655          mComponent = component;
9656          return this;
9657      }
9658  
9659      /**
9660       * Convenience for calling {@link #setComponent} with an
9661       * explicit class name.
9662       *
9663       * @param packageContext A Context of the application package implementing
9664       * this class.
9665       * @param className The name of a class inside of the application package
9666       * that will be used as the component for this Intent.
9667       *
9668       * @return Returns the same Intent object, for chaining multiple calls
9669       * into a single statement.
9670       *
9671       * @see #setComponent
9672       * @see #setClass
9673       */
setClassName(@onNull Context packageContext, @NonNull String className)9674      public @NonNull Intent setClassName(@NonNull Context packageContext,
9675              @NonNull String className) {
9676          mComponent = new ComponentName(packageContext, className);
9677          return this;
9678      }
9679  
9680      /**
9681       * Convenience for calling {@link #setComponent} with an
9682       * explicit application package name and class name.
9683       *
9684       * @param packageName The name of the package implementing the desired
9685       * component.
9686       * @param className The name of a class inside of the application package
9687       * that will be used as the component for this Intent.
9688       *
9689       * @return Returns the same Intent object, for chaining multiple calls
9690       * into a single statement.
9691       *
9692       * @see #setComponent
9693       * @see #setClass
9694       */
setClassName(@onNull String packageName, @NonNull String className)9695      public @NonNull Intent setClassName(@NonNull String packageName, @NonNull String className) {
9696          mComponent = new ComponentName(packageName, className);
9697          return this;
9698      }
9699  
9700      /**
9701       * Convenience for calling {@link #setComponent(ComponentName)} with the
9702       * name returned by a {@link Class} object.
9703       *
9704       * @param packageContext A Context of the application package implementing
9705       * this class.
9706       * @param cls The class name to set, equivalent to
9707       *            <code>setClassName(context, cls.getName())</code>.
9708       *
9709       * @return Returns the same Intent object, for chaining multiple calls
9710       * into a single statement.
9711       *
9712       * @see #setComponent
9713       */
setClass(@onNull Context packageContext, @NonNull Class<?> cls)9714      public @NonNull Intent setClass(@NonNull Context packageContext, @NonNull Class<?> cls) {
9715          mComponent = new ComponentName(packageContext, cls);
9716          return this;
9717      }
9718  
9719      /**
9720       * Set the bounds of the sender of this intent, in screen coordinates.  This can be
9721       * used as a hint to the receiver for animations and the like.  Null means that there
9722       * is no source bounds.
9723       */
setSourceBounds(@ullable Rect r)9724      public void setSourceBounds(@Nullable Rect r) {
9725          if (r != null) {
9726              mSourceBounds = new Rect(r);
9727          } else {
9728              mSourceBounds = null;
9729          }
9730      }
9731  
9732      /** @hide */
9733      @IntDef(flag = true, prefix = { "FILL_IN_" }, value = {
9734              FILL_IN_ACTION,
9735              FILL_IN_DATA,
9736              FILL_IN_CATEGORIES,
9737              FILL_IN_COMPONENT,
9738              FILL_IN_PACKAGE,
9739              FILL_IN_SOURCE_BOUNDS,
9740              FILL_IN_SELECTOR,
9741              FILL_IN_CLIP_DATA
9742      })
9743      @Retention(RetentionPolicy.SOURCE)
9744      public @interface FillInFlags {}
9745  
9746      /**
9747       * Use with {@link #fillIn} to allow the current action value to be
9748       * overwritten, even if it is already set.
9749       */
9750      public static final int FILL_IN_ACTION = 1<<0;
9751  
9752      /**
9753       * Use with {@link #fillIn} to allow the current data or type value
9754       * overwritten, even if it is already set.
9755       */
9756      public static final int FILL_IN_DATA = 1<<1;
9757  
9758      /**
9759       * Use with {@link #fillIn} to allow the current categories to be
9760       * overwritten, even if they are already set.
9761       */
9762      public static final int FILL_IN_CATEGORIES = 1<<2;
9763  
9764      /**
9765       * Use with {@link #fillIn} to allow the current component value to be
9766       * overwritten, even if it is already set.
9767       */
9768      public static final int FILL_IN_COMPONENT = 1<<3;
9769  
9770      /**
9771       * Use with {@link #fillIn} to allow the current package value to be
9772       * overwritten, even if it is already set.
9773       */
9774      public static final int FILL_IN_PACKAGE = 1<<4;
9775  
9776      /**
9777       * Use with {@link #fillIn} to allow the current bounds rectangle to be
9778       * overwritten, even if it is already set.
9779       */
9780      public static final int FILL_IN_SOURCE_BOUNDS = 1<<5;
9781  
9782      /**
9783       * Use with {@link #fillIn} to allow the current selector to be
9784       * overwritten, even if it is already set.
9785       */
9786      public static final int FILL_IN_SELECTOR = 1<<6;
9787  
9788      /**
9789       * Use with {@link #fillIn} to allow the current ClipData to be
9790       * overwritten, even if it is already set.
9791       */
9792      public static final int FILL_IN_CLIP_DATA = 1<<7;
9793  
9794      /**
9795       * Use with {@link #fillIn} to allow the current identifier value to be
9796       * overwritten, even if it is already set.
9797       */
9798      public static final int FILL_IN_IDENTIFIER = 1<<8;
9799  
9800      /**
9801       * Copy the contents of <var>other</var> in to this object, but only
9802       * where fields are not defined by this object.  For purposes of a field
9803       * being defined, the following pieces of data in the Intent are
9804       * considered to be separate fields:
9805       *
9806       * <ul>
9807       * <li> action, as set by {@link #setAction}.
9808       * <li> data Uri and MIME type, as set by {@link #setData(Uri)},
9809       * {@link #setType(String)}, or {@link #setDataAndType(Uri, String)}.
9810       * <li> identifier, as set by {@link #setIdentifier}.
9811       * <li> categories, as set by {@link #addCategory}.
9812       * <li> package, as set by {@link #setPackage}.
9813       * <li> component, as set by {@link #setComponent(ComponentName)} or
9814       * related methods.
9815       * <li> source bounds, as set by {@link #setSourceBounds}.
9816       * <li> selector, as set by {@link #setSelector(Intent)}.
9817       * <li> clip data, as set by {@link #setClipData(ClipData)}.
9818       * <li> each top-level name in the associated extras.
9819       * </ul>
9820       *
9821       * <p>In addition, you can use the {@link #FILL_IN_ACTION},
9822       * {@link #FILL_IN_DATA}, {@link #FILL_IN_IDENTIFIER}, {@link #FILL_IN_CATEGORIES},
9823       * {@link #FILL_IN_PACKAGE}, {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9824       * {@link #FILL_IN_SELECTOR}, and {@link #FILL_IN_CLIP_DATA} to override
9825       * the restriction where the corresponding field will not be replaced if
9826       * it is already set.
9827       *
9828       * <p>Note: The component field will only be copied if {@link #FILL_IN_COMPONENT}
9829       * is explicitly specified.  The selector will only be copied if
9830       * {@link #FILL_IN_SELECTOR} is explicitly specified.
9831       *
9832       * <p>For example, consider Intent A with {data="foo", categories="bar"}
9833       * and Intent B with {action="gotit", data-type="some/thing",
9834       * categories="one","two"}.
9835       *
9836       * <p>Calling A.fillIn(B, Intent.FILL_IN_DATA) will result in A now
9837       * containing: {action="gotit", data-type="some/thing",
9838       * categories="bar"}.
9839       *
9840       * @param other Another Intent whose values are to be used to fill in
9841       * the current one.
9842       * @param flags Options to control which fields can be filled in.
9843       *
9844       * @return Returns a bit mask of {@link #FILL_IN_ACTION},
9845       * {@link #FILL_IN_DATA}, {@link #FILL_IN_CATEGORIES}, {@link #FILL_IN_PACKAGE},
9846       * {@link #FILL_IN_COMPONENT}, {@link #FILL_IN_SOURCE_BOUNDS},
9847       * {@link #FILL_IN_SELECTOR} and {@link #FILL_IN_CLIP_DATA} indicating which fields were
9848       * changed.
9849       */
9850      @FillInFlags
fillIn(@onNull Intent other, @FillInFlags int flags)9851      public int fillIn(@NonNull Intent other, @FillInFlags int flags) {
9852          int changes = 0;
9853          boolean mayHaveCopiedUris = false;
9854          if (other.mAction != null
9855                  && (mAction == null || (flags&FILL_IN_ACTION) != 0)) {
9856              mAction = other.mAction;
9857              changes |= FILL_IN_ACTION;
9858          }
9859          if ((other.mData != null || other.mType != null)
9860                  && ((mData == null && mType == null)
9861                          || (flags&FILL_IN_DATA) != 0)) {
9862              mData = other.mData;
9863              mType = other.mType;
9864              changes |= FILL_IN_DATA;
9865              mayHaveCopiedUris = true;
9866          }
9867          if (other.mIdentifier != null
9868                  && (mIdentifier == null || (flags&FILL_IN_IDENTIFIER) != 0)) {
9869              mIdentifier = other.mIdentifier;
9870              changes |= FILL_IN_IDENTIFIER;
9871          }
9872          if (other.mCategories != null
9873                  && (mCategories == null || (flags&FILL_IN_CATEGORIES) != 0)) {
9874              if (other.mCategories != null) {
9875                  mCategories = new ArraySet<String>(other.mCategories);
9876              }
9877              changes |= FILL_IN_CATEGORIES;
9878          }
9879          if (other.mPackage != null
9880                  && (mPackage == null || (flags&FILL_IN_PACKAGE) != 0)) {
9881              // Only do this if mSelector is not set.
9882              if (mSelector == null) {
9883                  mPackage = other.mPackage;
9884                  changes |= FILL_IN_PACKAGE;
9885              }
9886          }
9887          // Selector is special: it can only be set if explicitly allowed,
9888          // for the same reason as the component name.
9889          if (other.mSelector != null && (flags&FILL_IN_SELECTOR) != 0) {
9890              if (mPackage == null) {
9891                  mSelector = new Intent(other.mSelector);
9892                  mPackage = null;
9893                  changes |= FILL_IN_SELECTOR;
9894              }
9895          }
9896          if (other.mClipData != null
9897                  && (mClipData == null || (flags&FILL_IN_CLIP_DATA) != 0)) {
9898              mClipData = other.mClipData;
9899              changes |= FILL_IN_CLIP_DATA;
9900              mayHaveCopiedUris = true;
9901          }
9902          // Component is special: it can -only- be set if explicitly allowed,
9903          // since otherwise the sender could force the intent somewhere the
9904          // originator didn't intend.
9905          if (other.mComponent != null && (flags&FILL_IN_COMPONENT) != 0) {
9906              mComponent = other.mComponent;
9907              changes |= FILL_IN_COMPONENT;
9908          }
9909          mFlags |= other.mFlags;
9910          if (other.mSourceBounds != null
9911                  && (mSourceBounds == null || (flags&FILL_IN_SOURCE_BOUNDS) != 0)) {
9912              mSourceBounds = new Rect(other.mSourceBounds);
9913              changes |= FILL_IN_SOURCE_BOUNDS;
9914          }
9915          if (mExtras == null) {
9916              if (other.mExtras != null) {
9917                  mExtras = new Bundle(other.mExtras);
9918                  mayHaveCopiedUris = true;
9919              }
9920          } else if (other.mExtras != null) {
9921              try {
9922                  Bundle newb = new Bundle(other.mExtras);
9923                  newb.putAll(mExtras);
9924                  mExtras = newb;
9925                  mayHaveCopiedUris = true;
9926              } catch (RuntimeException e) {
9927                  // Modifying the extras can cause us to unparcel the contents
9928                  // of the bundle, and if we do this in the system process that
9929                  // may fail.  We really should handle this (i.e., the Bundle
9930                  // impl shouldn't be on top of a plain map), but for now just
9931                  // ignore it and keep the original contents. :(
9932                  Log.w(TAG, "Failure filling in extras", e);
9933              }
9934          }
9935          if (mayHaveCopiedUris && mContentUserHint == UserHandle.USER_CURRENT
9936                  && other.mContentUserHint != UserHandle.USER_CURRENT) {
9937              mContentUserHint = other.mContentUserHint;
9938          }
9939          return changes;
9940      }
9941  
9942      /**
9943       * Wrapper class holding an Intent and implementing comparisons on it for
9944       * the purpose of filtering.  The class implements its
9945       * {@link #equals equals()} and {@link #hashCode hashCode()} methods as
9946       * simple calls to {@link Intent#filterEquals(Intent)}  filterEquals()} and
9947       * {@link android.content.Intent#filterHashCode()}  filterHashCode()}
9948       * on the wrapped Intent.
9949       */
9950      public static final class FilterComparison {
9951          private final Intent mIntent;
9952          private final int mHashCode;
9953  
FilterComparison(Intent intent)9954          public FilterComparison(Intent intent) {
9955              mIntent = intent;
9956              mHashCode = intent.filterHashCode();
9957          }
9958  
9959          /**
9960           * Return the Intent that this FilterComparison represents.
9961           * @return Returns the Intent held by the FilterComparison.  Do
9962           * not modify!
9963           */
getIntent()9964          public Intent getIntent() {
9965              return mIntent;
9966          }
9967  
9968          @Override
equals(Object obj)9969          public boolean equals(Object obj) {
9970              if (obj instanceof FilterComparison) {
9971                  Intent other = ((FilterComparison)obj).mIntent;
9972                  return mIntent.filterEquals(other);
9973              }
9974              return false;
9975          }
9976  
9977          @Override
hashCode()9978          public int hashCode() {
9979              return mHashCode;
9980          }
9981      }
9982  
9983      /**
9984       * Determine if two intents are the same for the purposes of intent
9985       * resolution (filtering). That is, if their action, data, type, identity,
9986       * class, and categories are the same.  This does <em>not</em> compare
9987       * any extra data included in the intents.  Note that technically when actually
9988       * matching against an {@link IntentFilter} the identifier is ignored, while here
9989       * it is directly compared for equality like the other fields.
9990       *
9991       * @param other The other Intent to compare against.
9992       *
9993       * @return Returns true if action, data, type, class, and categories
9994       *         are the same.
9995       */
filterEquals(Intent other)9996      public boolean filterEquals(Intent other) {
9997          if (other == null) {
9998              return false;
9999          }
10000          if (!Objects.equals(this.mAction, other.mAction)) return false;
10001          if (!Objects.equals(this.mData, other.mData)) return false;
10002          if (!Objects.equals(this.mType, other.mType)) return false;
10003          if (!Objects.equals(this.mIdentifier, other.mIdentifier)) return false;
10004          if (!Objects.equals(this.mPackage, other.mPackage)) return false;
10005          if (!Objects.equals(this.mComponent, other.mComponent)) return false;
10006          if (!Objects.equals(this.mCategories, other.mCategories)) return false;
10007  
10008          return true;
10009      }
10010  
10011      /**
10012       * Generate hash code that matches semantics of filterEquals().
10013       *
10014       * @return Returns the hash value of the action, data, type, class, and
10015       *         categories.
10016       *
10017       * @see #filterEquals
10018       */
filterHashCode()10019      public int filterHashCode() {
10020          int code = 0;
10021          if (mAction != null) {
10022              code += mAction.hashCode();
10023          }
10024          if (mData != null) {
10025              code += mData.hashCode();
10026          }
10027          if (mType != null) {
10028              code += mType.hashCode();
10029          }
10030          if (mIdentifier != null) {
10031              code += mIdentifier.hashCode();
10032          }
10033          if (mPackage != null) {
10034              code += mPackage.hashCode();
10035          }
10036          if (mComponent != null) {
10037              code += mComponent.hashCode();
10038          }
10039          if (mCategories != null) {
10040              code += mCategories.hashCode();
10041          }
10042          return code;
10043      }
10044  
10045      @Override
toString()10046      public String toString() {
10047          StringBuilder b = new StringBuilder(128);
10048  
10049          b.append("Intent { ");
10050          toShortString(b, true, true, true, false);
10051          b.append(" }");
10052  
10053          return b.toString();
10054      }
10055  
10056      /** @hide */
10057      @UnsupportedAppUsage
toInsecureString()10058      public String toInsecureString() {
10059          StringBuilder b = new StringBuilder(128);
10060  
10061          b.append("Intent { ");
10062          toShortString(b, false, true, true, false);
10063          b.append(" }");
10064  
10065          return b.toString();
10066      }
10067  
10068      /** @hide */
toInsecureStringWithClip()10069      public String toInsecureStringWithClip() {
10070          StringBuilder b = new StringBuilder(128);
10071  
10072          b.append("Intent { ");
10073          toShortString(b, false, true, true, true);
10074          b.append(" }");
10075  
10076          return b.toString();
10077      }
10078  
10079      /** @hide */
toShortString(boolean secure, boolean comp, boolean extras, boolean clip)10080      public String toShortString(boolean secure, boolean comp, boolean extras, boolean clip) {
10081          StringBuilder b = new StringBuilder(128);
10082          toShortString(b, secure, comp, extras, clip);
10083          return b.toString();
10084      }
10085  
10086      /** @hide */
toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras, boolean clip)10087      public void toShortString(StringBuilder b, boolean secure, boolean comp, boolean extras,
10088              boolean clip) {
10089          boolean first = true;
10090          if (mAction != null) {
10091              b.append("act=").append(mAction);
10092              first = false;
10093          }
10094          if (mCategories != null) {
10095              if (!first) {
10096                  b.append(' ');
10097              }
10098              first = false;
10099              b.append("cat=[");
10100              for (int i=0; i<mCategories.size(); i++) {
10101                  if (i > 0) b.append(',');
10102                  b.append(mCategories.valueAt(i));
10103              }
10104              b.append("]");
10105          }
10106          if (mData != null) {
10107              if (!first) {
10108                  b.append(' ');
10109              }
10110              first = false;
10111              b.append("dat=");
10112              if (secure) {
10113                  b.append(mData.toSafeString());
10114              } else {
10115                  b.append(mData);
10116              }
10117          }
10118          if (mType != null) {
10119              if (!first) {
10120                  b.append(' ');
10121              }
10122              first = false;
10123              b.append("typ=").append(mType);
10124          }
10125          if (mIdentifier != null) {
10126              if (!first) {
10127                  b.append(' ');
10128              }
10129              first = false;
10130              b.append("id=").append(mIdentifier);
10131          }
10132          if (mFlags != 0) {
10133              if (!first) {
10134                  b.append(' ');
10135              }
10136              first = false;
10137              b.append("flg=0x").append(Integer.toHexString(mFlags));
10138          }
10139          if (mPackage != null) {
10140              if (!first) {
10141                  b.append(' ');
10142              }
10143              first = false;
10144              b.append("pkg=").append(mPackage);
10145          }
10146          if (comp && mComponent != null) {
10147              if (!first) {
10148                  b.append(' ');
10149              }
10150              first = false;
10151              b.append("cmp=").append(mComponent.flattenToShortString());
10152          }
10153          if (mSourceBounds != null) {
10154              if (!first) {
10155                  b.append(' ');
10156              }
10157              first = false;
10158              b.append("bnds=").append(mSourceBounds.toShortString());
10159          }
10160          if (mClipData != null) {
10161              if (!first) {
10162                  b.append(' ');
10163              }
10164              b.append("clip={");
10165              if (clip) {
10166                  mClipData.toShortString(b);
10167              } else {
10168                  if (mClipData.getDescription() != null) {
10169                      first = !mClipData.getDescription().toShortStringTypesOnly(b);
10170                  } else {
10171                      first = true;
10172                  }
10173                  mClipData.toShortStringShortItems(b, first);
10174              }
10175              first = false;
10176              b.append('}');
10177          }
10178          if (extras && mExtras != null) {
10179              if (!first) {
10180                  b.append(' ');
10181              }
10182              first = false;
10183              b.append("(has extras)");
10184          }
10185          if (mContentUserHint != UserHandle.USER_CURRENT) {
10186              if (!first) {
10187                  b.append(' ');
10188              }
10189              first = false;
10190              b.append("u=").append(mContentUserHint);
10191          }
10192          if (mSelector != null) {
10193              b.append(" sel=");
10194              mSelector.toShortString(b, secure, comp, extras, clip);
10195              b.append("}");
10196          }
10197      }
10198  
10199      /** @hide */
writeToProto(ProtoOutputStream proto, long fieldId)10200      public void writeToProto(ProtoOutputStream proto, long fieldId) {
10201          // Same input parameters that toString() gives to toShortString().
10202          writeToProto(proto, fieldId, true, true, true, false);
10203      }
10204  
10205      /** @hide */
writeToProto(ProtoOutputStream proto)10206      public void writeToProto(ProtoOutputStream proto) {
10207          // Same input parameters that toString() gives to toShortString().
10208          writeToProtoWithoutFieldId(proto, true, true, true, false);
10209      }
10210  
10211      /** @hide */
writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp, boolean extras, boolean clip)10212      public void writeToProto(ProtoOutputStream proto, long fieldId, boolean secure, boolean comp,
10213              boolean extras, boolean clip) {
10214          long token = proto.start(fieldId);
10215          writeToProtoWithoutFieldId(proto, secure, comp, extras, clip);
10216          proto.end(token);
10217      }
10218  
writeToProtoWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp, boolean extras, boolean clip)10219      private void writeToProtoWithoutFieldId(ProtoOutputStream proto, boolean secure, boolean comp,
10220              boolean extras, boolean clip) {
10221          if (mAction != null) {
10222              proto.write(IntentProto.ACTION, mAction);
10223          }
10224          if (mCategories != null)  {
10225              for (String category : mCategories) {
10226                  proto.write(IntentProto.CATEGORIES, category);
10227              }
10228          }
10229          if (mData != null) {
10230              proto.write(IntentProto.DATA, secure ? mData.toSafeString() : mData.toString());
10231          }
10232          if (mType != null) {
10233              proto.write(IntentProto.TYPE, mType);
10234          }
10235          if (mIdentifier != null) {
10236              proto.write(IntentProto.IDENTIFIER, mIdentifier);
10237          }
10238          if (mFlags != 0) {
10239              proto.write(IntentProto.FLAG, "0x" + Integer.toHexString(mFlags));
10240          }
10241          if (mPackage != null) {
10242              proto.write(IntentProto.PACKAGE, mPackage);
10243          }
10244          if (comp && mComponent != null) {
10245              mComponent.writeToProto(proto, IntentProto.COMPONENT);
10246          }
10247          if (mSourceBounds != null) {
10248              proto.write(IntentProto.SOURCE_BOUNDS, mSourceBounds.toShortString());
10249          }
10250          if (mClipData != null) {
10251              StringBuilder b = new StringBuilder();
10252              if (clip) {
10253                  mClipData.toShortString(b);
10254              } else {
10255                  mClipData.toShortStringShortItems(b, false);
10256              }
10257              proto.write(IntentProto.CLIP_DATA, b.toString());
10258          }
10259          if (extras && mExtras != null) {
10260              proto.write(IntentProto.EXTRAS, mExtras.toShortString());
10261          }
10262          if (mContentUserHint != 0) {
10263              proto.write(IntentProto.CONTENT_USER_HINT, mContentUserHint);
10264          }
10265          if (mSelector != null) {
10266              proto.write(IntentProto.SELECTOR, mSelector.toShortString(secure, comp, extras, clip));
10267          }
10268      }
10269  
10270      /**
10271       * Call {@link #toUri} with 0 flags.
10272       * @deprecated Use {@link #toUri} instead.
10273       */
10274      @Deprecated
toURI()10275      public String toURI() {
10276          return toUri(0);
10277      }
10278  
10279      /**
10280       * Convert this Intent into a String holding a URI representation of it.
10281       * The returned URI string has been properly URI encoded, so it can be
10282       * used with {@link Uri#parse Uri.parse(String)}.  The URI contains the
10283       * Intent's data as the base URI, with an additional fragment describing
10284       * the action, categories, type, flags, package, component, and extras.
10285       *
10286       * <p>You can convert the returned string back to an Intent with
10287       * {@link #getIntent}.
10288       *
10289       * @param flags Additional operating flags.
10290       *
10291       * @return Returns a URI encoding URI string describing the entire contents
10292       * of the Intent.
10293       */
toUri(@riFlags int flags)10294      public String toUri(@UriFlags int flags) {
10295          StringBuilder uri = new StringBuilder(128);
10296          if ((flags&URI_ANDROID_APP_SCHEME) != 0) {
10297              if (mPackage == null) {
10298                  throw new IllegalArgumentException(
10299                          "Intent must include an explicit package name to build an android-app: "
10300                          + this);
10301              }
10302              uri.append("android-app://");
10303              uri.append(mPackage);
10304              String scheme = null;
10305              if (mData != null) {
10306                  scheme = mData.getScheme();
10307                  if (scheme != null) {
10308                      uri.append('/');
10309                      uri.append(scheme);
10310                      String authority = mData.getEncodedAuthority();
10311                      if (authority != null) {
10312                          uri.append('/');
10313                          uri.append(authority);
10314                          String path = mData.getEncodedPath();
10315                          if (path != null) {
10316                              uri.append(path);
10317                          }
10318                          String queryParams = mData.getEncodedQuery();
10319                          if (queryParams != null) {
10320                              uri.append('?');
10321                              uri.append(queryParams);
10322                          }
10323                          String fragment = mData.getEncodedFragment();
10324                          if (fragment != null) {
10325                              uri.append('#');
10326                              uri.append(fragment);
10327                          }
10328                      }
10329                  }
10330              }
10331              toUriFragment(uri, null, scheme == null ? Intent.ACTION_MAIN : Intent.ACTION_VIEW,
10332                      mPackage, flags);
10333              return uri.toString();
10334          }
10335          String scheme = null;
10336          if (mData != null) {
10337              String data = mData.toString();
10338              if ((flags&URI_INTENT_SCHEME) != 0) {
10339                  final int N = data.length();
10340                  for (int i=0; i<N; i++) {
10341                      char c = data.charAt(i);
10342                      if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')
10343                              || (c >= '0' && c <= '9') || c == '.' || c == '-' || c == '+') {
10344                          continue;
10345                      }
10346                      if (c == ':' && i > 0) {
10347                          // Valid scheme.
10348                          scheme = data.substring(0, i);
10349                          uri.append("intent:");
10350                          data = data.substring(i+1);
10351                          break;
10352                      }
10353  
10354                      // No scheme.
10355                      break;
10356                  }
10357              }
10358              uri.append(data);
10359  
10360          } else if ((flags&URI_INTENT_SCHEME) != 0) {
10361              uri.append("intent:");
10362          }
10363  
10364          toUriFragment(uri, scheme, Intent.ACTION_VIEW, null, flags);
10365  
10366          return uri.toString();
10367      }
10368  
toUriFragment(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)10369      private void toUriFragment(StringBuilder uri, String scheme, String defAction,
10370              String defPackage, int flags) {
10371          StringBuilder frag = new StringBuilder(128);
10372  
10373          toUriInner(frag, scheme, defAction, defPackage, flags);
10374          if (mSelector != null) {
10375              frag.append("SEL;");
10376              // Note that for now we are not going to try to handle the
10377              // data part; not clear how to represent this as a URI, and
10378              // not much utility in it.
10379              mSelector.toUriInner(frag, mSelector.mData != null ? mSelector.mData.getScheme() : null,
10380                      null, null, flags);
10381          }
10382  
10383          if (frag.length() > 0) {
10384              uri.append("#Intent;");
10385              uri.append(frag);
10386              uri.append("end");
10387          }
10388      }
10389  
toUriInner(StringBuilder uri, String scheme, String defAction, String defPackage, int flags)10390      private void toUriInner(StringBuilder uri, String scheme, String defAction,
10391              String defPackage, int flags) {
10392          if (scheme != null) {
10393              uri.append("scheme=").append(scheme).append(';');
10394          }
10395          if (mAction != null && !mAction.equals(defAction)) {
10396              uri.append("action=").append(Uri.encode(mAction)).append(';');
10397          }
10398          if (mCategories != null) {
10399              for (int i=0; i<mCategories.size(); i++) {
10400                  uri.append("category=").append(Uri.encode(mCategories.valueAt(i))).append(';');
10401              }
10402          }
10403          if (mType != null) {
10404              uri.append("type=").append(Uri.encode(mType, "/")).append(';');
10405          }
10406          if (mIdentifier != null) {
10407              uri.append("identifier=").append(Uri.encode(mIdentifier, "/")).append(';');
10408          }
10409          if (mFlags != 0) {
10410              uri.append("launchFlags=0x").append(Integer.toHexString(mFlags)).append(';');
10411          }
10412          if (mPackage != null && !mPackage.equals(defPackage)) {
10413              uri.append("package=").append(Uri.encode(mPackage)).append(';');
10414          }
10415          if (mComponent != null) {
10416              uri.append("component=").append(Uri.encode(
10417                      mComponent.flattenToShortString(), "/")).append(';');
10418          }
10419          if (mSourceBounds != null) {
10420              uri.append("sourceBounds=")
10421                      .append(Uri.encode(mSourceBounds.flattenToString()))
10422                      .append(';');
10423          }
10424          if (mExtras != null) {
10425              for (String key : mExtras.keySet()) {
10426                  final Object value = mExtras.get(key);
10427                  char entryType =
10428                          value instanceof String    ? 'S' :
10429                          value instanceof Boolean   ? 'B' :
10430                          value instanceof Byte      ? 'b' :
10431                          value instanceof Character ? 'c' :
10432                          value instanceof Double    ? 'd' :
10433                          value instanceof Float     ? 'f' :
10434                          value instanceof Integer   ? 'i' :
10435                          value instanceof Long      ? 'l' :
10436                          value instanceof Short     ? 's' :
10437                          '\0';
10438  
10439                  if (entryType != '\0') {
10440                      uri.append(entryType);
10441                      uri.append('.');
10442                      uri.append(Uri.encode(key));
10443                      uri.append('=');
10444                      uri.append(Uri.encode(value.toString()));
10445                      uri.append(';');
10446                  }
10447              }
10448          }
10449      }
10450  
describeContents()10451      public int describeContents() {
10452          return (mExtras != null) ? mExtras.describeContents() : 0;
10453      }
10454  
writeToParcel(Parcel out, int flags)10455      public void writeToParcel(Parcel out, int flags) {
10456          out.writeString(mAction);
10457          Uri.writeToParcel(out, mData);
10458          out.writeString(mType);
10459          out.writeString(mIdentifier);
10460          out.writeInt(mFlags);
10461          out.writeString(mPackage);
10462          ComponentName.writeToParcel(mComponent, out);
10463  
10464          if (mSourceBounds != null) {
10465              out.writeInt(1);
10466              mSourceBounds.writeToParcel(out, flags);
10467          } else {
10468              out.writeInt(0);
10469          }
10470  
10471          if (mCategories != null) {
10472              final int N = mCategories.size();
10473              out.writeInt(N);
10474              for (int i=0; i<N; i++) {
10475                  out.writeString(mCategories.valueAt(i));
10476              }
10477          } else {
10478              out.writeInt(0);
10479          }
10480  
10481          if (mSelector != null) {
10482              out.writeInt(1);
10483              mSelector.writeToParcel(out, flags);
10484          } else {
10485              out.writeInt(0);
10486          }
10487  
10488          if (mClipData != null) {
10489              out.writeInt(1);
10490              mClipData.writeToParcel(out, flags);
10491          } else {
10492              out.writeInt(0);
10493          }
10494          out.writeInt(mContentUserHint);
10495          out.writeBundle(mExtras);
10496      }
10497  
10498      public static final @android.annotation.NonNull Parcelable.Creator<Intent> CREATOR
10499              = new Parcelable.Creator<Intent>() {
10500          public Intent createFromParcel(Parcel in) {
10501              return new Intent(in);
10502          }
10503          public Intent[] newArray(int size) {
10504              return new Intent[size];
10505          }
10506      };
10507  
10508      /** @hide */
Intent(Parcel in)10509      protected Intent(Parcel in) {
10510          readFromParcel(in);
10511      }
10512  
readFromParcel(Parcel in)10513      public void readFromParcel(Parcel in) {
10514          setAction(in.readString());
10515          mData = Uri.CREATOR.createFromParcel(in);
10516          mType = in.readString();
10517          mIdentifier = in.readString();
10518          mFlags = in.readInt();
10519          mPackage = in.readString();
10520          mComponent = ComponentName.readFromParcel(in);
10521  
10522          if (in.readInt() != 0) {
10523              mSourceBounds = Rect.CREATOR.createFromParcel(in);
10524          }
10525  
10526          int N = in.readInt();
10527          if (N > 0) {
10528              mCategories = new ArraySet<String>();
10529              int i;
10530              for (i=0; i<N; i++) {
10531                  mCategories.add(in.readString().intern());
10532              }
10533          } else {
10534              mCategories = null;
10535          }
10536  
10537          if (in.readInt() != 0) {
10538              mSelector = new Intent(in);
10539          }
10540  
10541          if (in.readInt() != 0) {
10542              mClipData = new ClipData(in);
10543          }
10544          mContentUserHint = in.readInt();
10545          mExtras = in.readBundle();
10546      }
10547  
10548      /**
10549       * Parses the "intent" element (and its children) from XML and instantiates
10550       * an Intent object.  The given XML parser should be located at the tag
10551       * where parsing should start (often named "intent"), from which the
10552       * basic action, data, type, and package and class name will be
10553       * retrieved.  The function will then parse in to any child elements,
10554       * looking for <category android:name="xxx"> tags to add categories and
10555       * <extra android:name="xxx" android:value="yyy"> to attach extra data
10556       * to the intent.
10557       *
10558       * @param resources The Resources to use when inflating resources.
10559       * @param parser The XML parser pointing at an "intent" tag.
10560       * @param attrs The AttributeSet interface for retrieving extended
10561       * attribute data at the current <var>parser</var> location.
10562       * @return An Intent object matching the XML data.
10563       * @throws XmlPullParserException If there was an XML parsing error.
10564       * @throws IOException If there was an I/O error.
10565       */
parseIntent(@onNull Resources resources, @NonNull XmlPullParser parser, AttributeSet attrs)10566      public static @NonNull Intent parseIntent(@NonNull Resources resources,
10567              @NonNull XmlPullParser parser, AttributeSet attrs)
10568              throws XmlPullParserException, IOException {
10569          Intent intent = new Intent();
10570  
10571          TypedArray sa = resources.obtainAttributes(attrs,
10572                  com.android.internal.R.styleable.Intent);
10573  
10574          intent.setAction(sa.getString(com.android.internal.R.styleable.Intent_action));
10575  
10576          String data = sa.getString(com.android.internal.R.styleable.Intent_data);
10577          String mimeType = sa.getString(com.android.internal.R.styleable.Intent_mimeType);
10578          intent.setDataAndType(data != null ? Uri.parse(data) : null, mimeType);
10579  
10580          intent.setIdentifier(sa.getString(com.android.internal.R.styleable.Intent_identifier));
10581  
10582          String packageName = sa.getString(com.android.internal.R.styleable.Intent_targetPackage);
10583          String className = sa.getString(com.android.internal.R.styleable.Intent_targetClass);
10584          if (packageName != null && className != null) {
10585              intent.setComponent(new ComponentName(packageName, className));
10586          }
10587  
10588          sa.recycle();
10589  
10590          int outerDepth = parser.getDepth();
10591          int type;
10592          while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
10593                 && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
10594              if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
10595                  continue;
10596              }
10597  
10598              String nodeName = parser.getName();
10599              if (nodeName.equals(TAG_CATEGORIES)) {
10600                  sa = resources.obtainAttributes(attrs,
10601                          com.android.internal.R.styleable.IntentCategory);
10602                  String cat = sa.getString(com.android.internal.R.styleable.IntentCategory_name);
10603                  sa.recycle();
10604  
10605                  if (cat != null) {
10606                      intent.addCategory(cat);
10607                  }
10608                  XmlUtils.skipCurrentTag(parser);
10609  
10610              } else if (nodeName.equals(TAG_EXTRA)) {
10611                  if (intent.mExtras == null) {
10612                      intent.mExtras = new Bundle();
10613                  }
10614                  resources.parseBundleExtra(TAG_EXTRA, attrs, intent.mExtras);
10615                  XmlUtils.skipCurrentTag(parser);
10616  
10617              } else {
10618                  XmlUtils.skipCurrentTag(parser);
10619              }
10620          }
10621  
10622          return intent;
10623      }
10624  
10625      /** @hide */
saveToXml(XmlSerializer out)10626      public void saveToXml(XmlSerializer out) throws IOException {
10627          if (mAction != null) {
10628              out.attribute(null, ATTR_ACTION, mAction);
10629          }
10630          if (mData != null) {
10631              out.attribute(null, ATTR_DATA, mData.toString());
10632          }
10633          if (mType != null) {
10634              out.attribute(null, ATTR_TYPE, mType);
10635          }
10636          if (mIdentifier != null) {
10637              out.attribute(null, ATTR_IDENTIFIER, mIdentifier);
10638          }
10639          if (mComponent != null) {
10640              out.attribute(null, ATTR_COMPONENT, mComponent.flattenToShortString());
10641          }
10642          out.attribute(null, ATTR_FLAGS, Integer.toHexString(getFlags()));
10643  
10644          if (mCategories != null) {
10645              out.startTag(null, TAG_CATEGORIES);
10646              for (int categoryNdx = mCategories.size() - 1; categoryNdx >= 0; --categoryNdx) {
10647                  out.attribute(null, ATTR_CATEGORY, mCategories.valueAt(categoryNdx));
10648              }
10649              out.endTag(null, TAG_CATEGORIES);
10650          }
10651      }
10652  
10653      /** @hide */
restoreFromXml(XmlPullParser in)10654      public static Intent restoreFromXml(XmlPullParser in) throws IOException,
10655              XmlPullParserException {
10656          Intent intent = new Intent();
10657          final int outerDepth = in.getDepth();
10658  
10659          int attrCount = in.getAttributeCount();
10660          for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10661              final String attrName = in.getAttributeName(attrNdx);
10662              final String attrValue = in.getAttributeValue(attrNdx);
10663              if (ATTR_ACTION.equals(attrName)) {
10664                  intent.setAction(attrValue);
10665              } else if (ATTR_DATA.equals(attrName)) {
10666                  intent.setData(Uri.parse(attrValue));
10667              } else if (ATTR_TYPE.equals(attrName)) {
10668                  intent.setType(attrValue);
10669              } else if (ATTR_IDENTIFIER.equals(attrName)) {
10670                  intent.setIdentifier(attrValue);
10671              } else if (ATTR_COMPONENT.equals(attrName)) {
10672                  intent.setComponent(ComponentName.unflattenFromString(attrValue));
10673              } else if (ATTR_FLAGS.equals(attrName)) {
10674                  intent.setFlags(Integer.parseInt(attrValue, 16));
10675              } else {
10676                  Log.e(TAG, "restoreFromXml: unknown attribute=" + attrName);
10677              }
10678          }
10679  
10680          int event;
10681          String name;
10682          while (((event = in.next()) != XmlPullParser.END_DOCUMENT) &&
10683                  (event != XmlPullParser.END_TAG || in.getDepth() < outerDepth)) {
10684              if (event == XmlPullParser.START_TAG) {
10685                  name = in.getName();
10686                  if (TAG_CATEGORIES.equals(name)) {
10687                      attrCount = in.getAttributeCount();
10688                      for (int attrNdx = attrCount - 1; attrNdx >= 0; --attrNdx) {
10689                          intent.addCategory(in.getAttributeValue(attrNdx));
10690                      }
10691                  } else {
10692                      Log.w(TAG, "restoreFromXml: unknown name=" + name);
10693                      XmlUtils.skipCurrentTag(in);
10694                  }
10695              }
10696          }
10697  
10698          return intent;
10699      }
10700  
10701      /**
10702       * Normalize a MIME data type.
10703       *
10704       * <p>A normalized MIME type has white-space trimmed,
10705       * content-type parameters removed, and is lower-case.
10706       * This aligns the type with Android best practices for
10707       * intent filtering.
10708       *
10709       * <p>For example, "text/plain; charset=utf-8" becomes "text/plain".
10710       * "text/x-vCard" becomes "text/x-vcard".
10711       *
10712       * <p>All MIME types received from outside Android (such as user input,
10713       * or external sources like Bluetooth, NFC, or the Internet) should
10714       * be normalized before they are used to create an Intent.
10715       *
10716       * @param type MIME data type to normalize
10717       * @return normalized MIME data type, or null if the input was null
10718       * @see #setType
10719       * @see #setTypeAndNormalize
10720       */
normalizeMimeType(@ullable String type)10721      public static @Nullable String normalizeMimeType(@Nullable String type) {
10722          if (type == null) {
10723              return null;
10724          }
10725  
10726          type = type.trim().toLowerCase(Locale.ROOT);
10727  
10728          final int semicolonIndex = type.indexOf(';');
10729          if (semicolonIndex != -1) {
10730              type = type.substring(0, semicolonIndex);
10731          }
10732          return type;
10733      }
10734  
10735      /**
10736       * Prepare this {@link Intent} to leave an app process.
10737       *
10738       * @hide
10739       */
10740      @UnsupportedAppUsage
prepareToLeaveProcess(Context context)10741      public void prepareToLeaveProcess(Context context) {
10742          final boolean leavingPackage = (mComponent == null)
10743                  || !Objects.equals(mComponent.getPackageName(), context.getPackageName());
10744          prepareToLeaveProcess(leavingPackage);
10745      }
10746  
10747      /**
10748       * Prepare this {@link Intent} to leave an app process.
10749       *
10750       * @hide
10751       */
prepareToLeaveProcess(boolean leavingPackage)10752      public void prepareToLeaveProcess(boolean leavingPackage) {
10753          setAllowFds(false);
10754  
10755          if (mSelector != null) {
10756              mSelector.prepareToLeaveProcess(leavingPackage);
10757          }
10758          if (mClipData != null) {
10759              mClipData.prepareToLeaveProcess(leavingPackage, getFlags());
10760          }
10761  
10762          if (mExtras != null && !mExtras.isParcelled()) {
10763              final Object intent = mExtras.get(Intent.EXTRA_INTENT);
10764              if (intent instanceof Intent) {
10765                  ((Intent) intent).prepareToLeaveProcess(leavingPackage);
10766              }
10767          }
10768  
10769          if (mAction != null && mData != null && StrictMode.vmFileUriExposureEnabled()
10770                  && leavingPackage) {
10771              switch (mAction) {
10772                  case ACTION_MEDIA_REMOVED:
10773                  case ACTION_MEDIA_UNMOUNTED:
10774                  case ACTION_MEDIA_CHECKING:
10775                  case ACTION_MEDIA_NOFS:
10776                  case ACTION_MEDIA_MOUNTED:
10777                  case ACTION_MEDIA_SHARED:
10778                  case ACTION_MEDIA_UNSHARED:
10779                  case ACTION_MEDIA_BAD_REMOVAL:
10780                  case ACTION_MEDIA_UNMOUNTABLE:
10781                  case ACTION_MEDIA_EJECT:
10782                  case ACTION_MEDIA_SCANNER_STARTED:
10783                  case ACTION_MEDIA_SCANNER_FINISHED:
10784                  case ACTION_MEDIA_SCANNER_SCAN_FILE:
10785                  case ACTION_PACKAGE_NEEDS_VERIFICATION:
10786                  case ACTION_PACKAGE_VERIFIED:
10787                  case ACTION_PACKAGE_ENABLE_ROLLBACK:
10788                      // Ignore legacy actions
10789                      break;
10790                  default:
10791                      mData.checkFileUriExposed("Intent.getData()");
10792              }
10793          }
10794  
10795          if (mAction != null && mData != null && StrictMode.vmContentUriWithoutPermissionEnabled()
10796                  && leavingPackage) {
10797              switch (mAction) {
10798                  case ACTION_PROVIDER_CHANGED:
10799                  case QuickContact.ACTION_QUICK_CONTACT:
10800                      // Ignore actions that don't need to grant
10801                      break;
10802                  default:
10803                      mData.checkContentUriWithoutPermission("Intent.getData()", getFlags());
10804              }
10805          }
10806  
10807          // Translate raw filesystem paths out of storage sandbox
10808          if (ACTION_MEDIA_SCANNER_SCAN_FILE.equals(mAction) && mData != null
10809                  && ContentResolver.SCHEME_FILE.equals(mData.getScheme()) && leavingPackage) {
10810              final StorageManager sm = AppGlobals.getInitialApplication()
10811                      .getSystemService(StorageManager.class);
10812              final File before = new File(mData.getPath());
10813              final File after = sm.translateAppToSystem(before,
10814                      android.os.Process.myPid(), android.os.Process.myUid());
10815              if (!Objects.equals(before, after)) {
10816                  Log.v(TAG, "Translated " + before + " to " + after);
10817                  mData = Uri.fromFile(after);
10818              }
10819          }
10820      }
10821  
10822      /**
10823       * @hide
10824       */
prepareToEnterProcess()10825      public void prepareToEnterProcess() {
10826          // We just entered destination process, so we should be able to read all
10827          // parcelables inside.
10828          setDefusable(true);
10829  
10830          if (mSelector != null) {
10831              mSelector.prepareToEnterProcess();
10832          }
10833          if (mClipData != null) {
10834              mClipData.prepareToEnterProcess();
10835          }
10836  
10837          if (mContentUserHint != UserHandle.USER_CURRENT) {
10838              if (UserHandle.getAppId(Process.myUid()) != Process.SYSTEM_UID) {
10839                  fixUris(mContentUserHint);
10840                  mContentUserHint = UserHandle.USER_CURRENT;
10841              }
10842          }
10843      }
10844  
10845      /** @hide */
hasWebURI()10846      public boolean hasWebURI() {
10847          if (getData() == null) {
10848              return false;
10849          }
10850          final String scheme = getScheme();
10851          if (TextUtils.isEmpty(scheme)) {
10852              return false;
10853          }
10854          return scheme.equals(IntentFilter.SCHEME_HTTP) || scheme.equals(IntentFilter.SCHEME_HTTPS);
10855      }
10856  
10857      /** @hide */
isWebIntent()10858      public boolean isWebIntent() {
10859          return ACTION_VIEW.equals(mAction)
10860                  && hasWebURI();
10861      }
10862  
10863      /**
10864       * @hide
10865       */
fixUris(int contentUserHint)10866       public void fixUris(int contentUserHint) {
10867          Uri data = getData();
10868          if (data != null) {
10869              mData = maybeAddUserId(data, contentUserHint);
10870          }
10871          if (mClipData != null) {
10872              mClipData.fixUris(contentUserHint);
10873          }
10874          String action = getAction();
10875          if (ACTION_SEND.equals(action)) {
10876              final Uri stream = getParcelableExtra(EXTRA_STREAM);
10877              if (stream != null) {
10878                  putExtra(EXTRA_STREAM, maybeAddUserId(stream, contentUserHint));
10879              }
10880          } else if (ACTION_SEND_MULTIPLE.equals(action)) {
10881              final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10882              if (streams != null) {
10883                  ArrayList<Uri> newStreams = new ArrayList<Uri>();
10884                  for (int i = 0; i < streams.size(); i++) {
10885                      newStreams.add(maybeAddUserId(streams.get(i), contentUserHint));
10886                  }
10887                  putParcelableArrayListExtra(EXTRA_STREAM, newStreams);
10888              }
10889          } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10890                  || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10891                  || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
10892              final Uri output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
10893              if (output != null) {
10894                  putExtra(MediaStore.EXTRA_OUTPUT, maybeAddUserId(output, contentUserHint));
10895              }
10896          }
10897       }
10898  
10899      /**
10900       * Migrate any {@link #EXTRA_STREAM} in {@link #ACTION_SEND} and
10901       * {@link #ACTION_SEND_MULTIPLE} to {@link ClipData}. Also inspects nested
10902       * intents in {@link #ACTION_CHOOSER}.
10903       *
10904       * @return Whether any contents were migrated.
10905       * @hide
10906       */
migrateExtraStreamToClipData()10907      public boolean migrateExtraStreamToClipData() {
10908          // Refuse to touch if extras already parcelled
10909          if (mExtras != null && mExtras.isParcelled()) return false;
10910  
10911          // Bail when someone already gave us ClipData
10912          if (getClipData() != null) return false;
10913  
10914          final String action = getAction();
10915          if (ACTION_CHOOSER.equals(action)) {
10916              // Inspect contained intents to see if we need to migrate extras. We
10917              // don't promote ClipData to the parent, since ChooserActivity will
10918              // already start the picked item as the caller, and we can't combine
10919              // the flags in a safe way.
10920  
10921              boolean migrated = false;
10922              try {
10923                  final Intent intent = getParcelableExtra(EXTRA_INTENT);
10924                  if (intent != null) {
10925                      migrated |= intent.migrateExtraStreamToClipData();
10926                  }
10927              } catch (ClassCastException e) {
10928              }
10929              try {
10930                  final Parcelable[] intents = getParcelableArrayExtra(EXTRA_INITIAL_INTENTS);
10931                  if (intents != null) {
10932                      for (int i = 0; i < intents.length; i++) {
10933                          final Intent intent = (Intent) intents[i];
10934                          if (intent != null) {
10935                              migrated |= intent.migrateExtraStreamToClipData();
10936                          }
10937                      }
10938                  }
10939              } catch (ClassCastException e) {
10940              }
10941              return migrated;
10942  
10943          } else if (ACTION_SEND.equals(action)) {
10944              try {
10945                  final Uri stream = getParcelableExtra(EXTRA_STREAM);
10946                  final CharSequence text = getCharSequenceExtra(EXTRA_TEXT);
10947                  final String htmlText = getStringExtra(EXTRA_HTML_TEXT);
10948                  if (stream != null || text != null || htmlText != null) {
10949                      final ClipData clipData = new ClipData(
10950                              null, new String[] { getType() },
10951                              new ClipData.Item(text, htmlText, null, stream));
10952                      setClipData(clipData);
10953                      addFlags(FLAG_GRANT_READ_URI_PERMISSION);
10954                      return true;
10955                  }
10956              } catch (ClassCastException e) {
10957              }
10958  
10959          } else if (ACTION_SEND_MULTIPLE.equals(action)) {
10960              try {
10961                  final ArrayList<Uri> streams = getParcelableArrayListExtra(EXTRA_STREAM);
10962                  final ArrayList<CharSequence> texts = getCharSequenceArrayListExtra(EXTRA_TEXT);
10963                  final ArrayList<String> htmlTexts = getStringArrayListExtra(EXTRA_HTML_TEXT);
10964                  int num = -1;
10965                  if (streams != null) {
10966                      num = streams.size();
10967                  }
10968                  if (texts != null) {
10969                      if (num >= 0 && num != texts.size()) {
10970                          // Wha...!  F- you.
10971                          return false;
10972                      }
10973                      num = texts.size();
10974                  }
10975                  if (htmlTexts != null) {
10976                      if (num >= 0 && num != htmlTexts.size()) {
10977                          // Wha...!  F- you.
10978                          return false;
10979                      }
10980                      num = htmlTexts.size();
10981                  }
10982                  if (num > 0) {
10983                      final ClipData clipData = new ClipData(
10984                              null, new String[] { getType() },
10985                              makeClipItem(streams, texts, htmlTexts, 0));
10986  
10987                      for (int i = 1; i < num; i++) {
10988                          clipData.addItem(makeClipItem(streams, texts, htmlTexts, i));
10989                      }
10990  
10991                      setClipData(clipData);
10992                      addFlags(FLAG_GRANT_READ_URI_PERMISSION);
10993                      return true;
10994                  }
10995              } catch (ClassCastException e) {
10996              }
10997          } else if (MediaStore.ACTION_IMAGE_CAPTURE.equals(action)
10998                  || MediaStore.ACTION_IMAGE_CAPTURE_SECURE.equals(action)
10999                  || MediaStore.ACTION_VIDEO_CAPTURE.equals(action)) {
11000              final Uri output;
11001              try {
11002                  output = getParcelableExtra(MediaStore.EXTRA_OUTPUT);
11003              } catch (ClassCastException e) {
11004                  return false;
11005              }
11006              if (output != null) {
11007                  setClipData(ClipData.newRawUri("", output));
11008                  addFlags(FLAG_GRANT_WRITE_URI_PERMISSION|FLAG_GRANT_READ_URI_PERMISSION);
11009                  return true;
11010              }
11011          }
11012  
11013          return false;
11014      }
11015  
11016      /**
11017       * Convert the dock state to a human readable format.
11018       * @hide
11019       */
dockStateToString(int dock)11020      public static String dockStateToString(int dock) {
11021          switch (dock) {
11022              case EXTRA_DOCK_STATE_HE_DESK:
11023                  return "EXTRA_DOCK_STATE_HE_DESK";
11024              case EXTRA_DOCK_STATE_LE_DESK:
11025                  return "EXTRA_DOCK_STATE_LE_DESK";
11026              case EXTRA_DOCK_STATE_CAR:
11027                  return "EXTRA_DOCK_STATE_CAR";
11028              case EXTRA_DOCK_STATE_DESK:
11029                  return "EXTRA_DOCK_STATE_DESK";
11030              case EXTRA_DOCK_STATE_UNDOCKED:
11031                  return "EXTRA_DOCK_STATE_UNDOCKED";
11032              default:
11033                  return Integer.toString(dock);
11034          }
11035      }
11036  
makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts, ArrayList<String> htmlTexts, int which)11037      private static ClipData.Item makeClipItem(ArrayList<Uri> streams, ArrayList<CharSequence> texts,
11038              ArrayList<String> htmlTexts, int which) {
11039          Uri uri = streams != null ? streams.get(which) : null;
11040          CharSequence text = texts != null ? texts.get(which) : null;
11041          String htmlText = htmlTexts != null ? htmlTexts.get(which) : null;
11042          return new ClipData.Item(text, htmlText, null, uri);
11043      }
11044  
11045      /** @hide */
isDocument()11046      public boolean isDocument() {
11047          return (mFlags & FLAG_ACTIVITY_NEW_DOCUMENT) == FLAG_ACTIVITY_NEW_DOCUMENT;
11048      }
11049  }
11050