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