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