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