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