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