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