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