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